Skip to content

Commit 3d93a35

Browse files
committed
init commit
0 parents  commit 3d93a35

File tree

11 files changed

+386
-0
lines changed

11 files changed

+386
-0
lines changed

.gitignore

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# gitignore template for Xilinx Vivado Design Suite
2+
# website: https://www.xilinx.com/support/download.html
3+
4+
# [home]
5+
*.jou
6+
*.log
7+
*.debug
8+
*.str
9+
*.zip
10+
*.tmp
11+
*.rst
12+
*.os
13+
*.js
14+
*.pb
15+
*.dcp
16+
*.hwdef
17+
*.vds
18+
*.veo
19+
*.wdf
20+
*.vdi
21+
*.dmp
22+
*.rpx
23+
*.rpt
24+
*_stub.v
25+
*_stub.vhdl
26+
*_funcsim.v
27+
*_funcsim.vhdl
28+
.project
29+
30+
# [dir]
31+
*.cache
32+
.metadata
33+
*.data
34+
*.ipdefs
35+
.Xil
36+
*.sdk
37+
*.hw
38+
*.ip_user_files
39+
40+
### IP synth
41+
*_synth_*
42+
43+
.jobs
44+
45+
### project synth
46+
*/*.runs/synth*/*.xml
47+
*/*.runs/synth*/*.txt
48+
*/*.runs/synth*/*.sh
49+
*/*.runs/synth*/*.tcl
50+
*/*.runs/synth*/*.bat
51+
*/*.runs/synth*/*.xdc
52+
!*/*.runs/synth*/*utilization*.rpt
53+
54+
*.runs/synth*/*.xml
55+
*.runs/synth*/*.txt
56+
*.runs/synth*/*.sh
57+
*.runs/synth*/*.tcl
58+
*.runs/synth*/*.bat
59+
*.runs/synth*/*.xdc
60+
!*.runs/synth*/*utilization*.rpt
61+
62+
### project impl
63+
*/*.runs/impl*/*.xml
64+
*/*.runs/impl*/*.html
65+
*/*.runs/impl*/*.txt
66+
*/*.runs/impl*/*.sh
67+
*/*.runs/impl*/*.tcl
68+
*/*.runs/impl*/*.bat
69+
!*/*.runs/impl*/*utilization*.rpt
70+
71+
*.runs/impl*/*.xml
72+
*.runs/impl*/*.html
73+
*.runs/impl*/*.txt
74+
*.runs/impl*/*.sh
75+
*.runs/impl*/*.tcl
76+
*.runs/impl*/*.bat
77+
!*.runs/impl*/*utilization*.rpt
78+
79+
### block design
80+
*/*/bd/*/hdl
81+
*/*/*/bd/*/hdl
82+
83+
*/*/bd/*/*.xdc
84+
*/*/*/bd/*/*.xdc
85+
86+
*/*/bd/*/ip/*/*.xdc
87+
*/*/*/bd/*/ip/*/*.xdc
88+
89+
*/*/bd/*/ip/*/*/
90+
*/*/*/bd/*/ip/*/*/
91+
92+
*/*/bd/*/ip/*/*.vhd
93+
*/*/*/bd/*/ip/*/*.vhd
94+
95+
*/*/bd/*/ip/*/*.xml
96+
*/*/*/bd/*/ip/*/*.xml
97+
98+
*.c
99+
*.h
100+
*.vho
101+
*.html
102+
*/*/bd/*/ip/*/*.tcl
103+
*/*/*/bd/*/ip/*/*.tcl
104+
hw_handoff
105+
ipshared

Manifest.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
modules = {
2+
"local" : [
3+
"modules",
4+
"top",
5+
],
6+
}

README.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Usage
2+
3+
## Dependencies
4+
5+
`hdlmake`, `make`, `vivado`, `python`
6+
7+
## Clone repository:
8+
```bash
9+
git clone --recurse-submodules https://github.com/RDSik/FPGA_transceiver.git
10+
cd FPGA_trasceiver
11+
# git clone --recurse-submodules https://github.com/RDSik/FPGA_transceiver.git
12+
# git submodule update --init
13+
```
14+
15+
## Requirements installation:
16+
```bash
17+
pip install six
18+
pip install hdlmake
19+
winget install GnuWin32.make # add to PATH system variable the Make bin folder: C:\Program Files (x86)\GnuWin32\bin
20+
```
21+
22+
## Build FPGA_trasceiver:
23+
```bash
24+
cd syn
25+
hdlmake
26+
make
27+
```
28+
29+
## Only create Vivado project
30+
```bash
31+
cd syn
32+
hdlmake
33+
make project
34+
```
35+
36+
## FPGA_trasceiver test
37+
38+
```bash
39+
cd sim
40+
hdlmake
41+
make
42+
vsim work.receiver_tb
43+
```

modules/Manifest.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
modules = {
2+
"local" : [
3+
"receiver",
4+
],
5+
}

modules/receiver/Manifest.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
files = [
2+
"receiver.v",
3+
]

modules/receiver/receiver.v

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
`timescale 1ns / 1ns
2+
//////////////////////////////////////////////////////////////////////////////////
3+
// Company:
4+
// Engineer:
5+
//
6+
// Create Date: 18.09.2023 20:41:16
7+
// Design Name:
8+
// Module Name: receiver
9+
// Project Name:
10+
// Target Devices:
11+
// Tool Versions:
12+
// Description:
13+
//
14+
// Dependencies:
15+
//
16+
// Revision:
17+
// Revision 0.01 - File Created
18+
// Additional Comments:
19+
//
20+
//////////////////////////////////////////////////////////////////////////////////
21+
22+
23+
module receiver #(
24+
parameter DATA_WIDTH = 9
25+
) (
26+
input clk,
27+
input arst, // asynchronous reset
28+
input in,
29+
output done,
30+
output [DATA_WIDTH-1:0] out
31+
);
32+
33+
parameter [3:0]
34+
START = 4'd0,
35+
D0 = 4'd1,
36+
D1 = 4'd2,
37+
D2 = 4'd3,
38+
D3 = 4'd4,
39+
D4 = 4'd5,
40+
D5 = 4'd6,
41+
D6 = 4'd7,
42+
D7 = 4'd8,
43+
D8 = 4'd9,
44+
STOP = 4'd10,
45+
DONE = 4'd11;
46+
47+
reg [3:0] state;
48+
reg [3:0] next_state;
49+
reg [DATA_WIDTH-1:0] data;
50+
51+
always @(*)
52+
begin
53+
case (state)
54+
START: begin
55+
if (in) // 1- start bit
56+
next_state = D0;
57+
else
58+
next_state = START;
59+
end
60+
D0: begin
61+
next_state = D1;
62+
data[0] = in;
63+
end
64+
D1: begin
65+
next_state = D2;
66+
data[1] = in;
67+
end
68+
D2: begin
69+
next_state = D3;
70+
data[2] = in;
71+
end
72+
D3: begin
73+
next_state = D4;
74+
data[3] = in;
75+
end
76+
D4: begin
77+
next_state = D5;
78+
data[4] = in;
79+
end
80+
D5: begin
81+
next_state = D6;
82+
data[5] = in;
83+
end
84+
D6: begin
85+
next_state = D7;
86+
data[6] = in;
87+
end
88+
D7: begin
89+
next_state = D8;
90+
data[7] = in;
91+
end
92+
D8: begin
93+
next_state = STOP;
94+
data[8] = (data[0]^data[1]^data[2]^data[3]^data[4]^data[5]^data[6]^data[7])^in; // parity bit
95+
end
96+
STOP: begin
97+
if (in && data[8]) // 1 - stop bit
98+
next_state = DONE;
99+
else
100+
next_state = START;
101+
end
102+
DONE: begin
103+
if (!in)
104+
next_state = START;
105+
else
106+
next_state = D0;
107+
end
108+
default: next_state = START;
109+
endcase
110+
end
111+
112+
always @(posedge clk or posedge arst)
113+
begin
114+
if (arst)
115+
state <= START;
116+
else
117+
state <= next_state;
118+
end
119+
120+
assign done = (state == DONE);
121+
assign out = done ? data : 9'd0;
122+
123+
endmodule

sim/Manifest.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
action = "simulation"
2+
sim_tool = "modelsim"
3+
sim_top = "receiver_tb"
4+
5+
modules = {
6+
"local" : [
7+
"../tb",
8+
"../",
9+
],
10+
}

syn/Manifest.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
target = "xilinx"
2+
3+
action = "synthesis"
4+
5+
syn_device = "xc7z020clg484-1"
6+
syn_package = ""
7+
syn_grade = "-3"
8+
syn_top = "receiver_top"
9+
syn_project = "receiver"
10+
syn_tool = "vivado"
11+
12+
files = [
13+
'receiver.xdc'
14+
]
15+
16+
modules = {
17+
"local" : [
18+
"../",
19+
],
20+
}

syn/receiver.xdc

Whitespace-only changes.

tb/receiver_tb.v

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
`timescale 1ns / 1ns
2+
//////////////////////////////////////////////////////////////////////////////////
3+
// Company:
4+
// Engineer:
5+
//
6+
// Create Date: 18.09.2023 21:45:38
7+
// Design Name:
8+
// Module Name: receiver_tb
9+
// Project Name:
10+
// Target Devices:
11+
// Tool Versions:
12+
// Description:
13+
//
14+
// Dependencies:
15+
//
16+
// Revision:
17+
// Revision 0.01 - File Created
18+
// Additional Comments:
19+
//
20+
//////////////////////////////////////////////////////////////////////////////////
21+
22+
23+
module receiver_tb();
24+
25+
reg clk;
26+
reg arst;
27+
reg in;
28+
29+
wire done;
30+
wire [8:0] out;
31+
wire [3:0] state;
32+
wire parity;
33+
34+
integer i;
35+
36+
receiver #(
37+
.DATA_WIDTH (9)
38+
) dut (
39+
.clk (clk),
40+
.arst (arst),
41+
.in (in),
42+
.done (done),
43+
.out (out)
44+
);
45+
46+
assign state = dut.state;
47+
assign parity = dut.data[8];
48+
49+
initial
50+
begin
51+
clk = 0;
52+
#5; arst = 1;
53+
#5; arst = 0;
54+
for (i = 0; i <= 127; i = i + 1)
55+
begin
56+
#5; in = $urandom_range(0,1);
57+
end
58+
end
59+
60+
always #5 clk = !clk;
61+
62+
initial
63+
$monitor("time=%g, clk=%b - in=%b - done=%b - out=%b", $time, clk, in, done, out);
64+
65+
initial
66+
#550 $stop;
67+
68+
endmodule

top/Manifest.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
files = [
2+
"receiver_top.v",
3+
]

0 commit comments

Comments
 (0)