-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_SerialTransmitter.v
199 lines (159 loc) · 3.2 KB
/
test_SerialTransmitter.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 21:46:09 06/15/2021
// Design Name:
// Module Name: test_SerialTransmitter
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module test_serial_transmitter ();
reg [7:0] data;
reg write;
wire serial_line;
reg clk = 0;
always #5 clk = !clk;
SerialTransmitter ut(
data,
write,
serial_line,
clk
);
initial begin
#5;
data <= 10;
write <= 1;
#10;
data <= 20;
write <= 1;
#10;
data <= 30;
write <= 1;
#10;
write <= 0;
#20;
end
endmodule
module test_FIFO();
reg [7:0] data_input = {0};
reg r = 0;
reg w = 0;
wire [7:0] data_out;
wire ff;
wire ee;
reg clk = 0;
always #5 clk = !clk;
FIFO ut(
data_input,
data_out,
ff,
ee,
r,
w,
clk
);
initial begin
#5;
data_input <= 8'hF0;
w <= 1;
#20;
data_input <= 8'h0F;
w <= 1;
#20;
w <= 0;
r <= 1;
#20;
#20;
end
endmodule
module test_Controller ();
wire data_available;
wire [8:0]data_output;
wire read_data;
reg data_fetched_by_transmitter = 0;
reg [7:0]data_input = {0};
reg no_data = 1;
reg clk = 0;
always #5 clk = !clk;
Controller ut(
data_available,
data_output,
read_data,
data_fetched_by_transmitter,
data_input,
no_data,
clk
);
initial
begin
#5;
#20;
data_input <= 8'hF0;
no_data <= 0;
#20;
no_data <= 1;
#20;
#100;
data_fetched_by_transmitter <= 1;
#20;
data_fetched_by_transmitter <= 0;
#20;
#100;
data_input <= 8'h01;
no_data <= 0;
#20;
no_data <= 1;
#20;
#100;
data_fetched_by_transmitter <= 1;
#20;
data_fetched_by_transmitter <= 0;
#20;
end
endmodule
module test_Transmitter();
reg [8:0] data = 9'b0;
reg data_available = 0;
reg clk = 0;
always #5 clk = !clk;
wire serial_line;
wire data_fetched;
Transmitter
#(
.DataLen(8)
)
ut
(
serial_line,
data_fetched,
data_available,
data,
clk
);
initial
begin
#5;
data <= 8'b00_1100_11;
data_available <= 1;
#20;
data_available <= 0;
#500;
#10;
data <= 8'h0F;
data_available <= 1;
#20;
data_available <= 0;
#10;
end
endmodule