-
Notifications
You must be signed in to change notification settings - Fork 13
/
uart_tx_tb.v
62 lines (55 loc) · 1.02 KB
/
uart_tx_tb.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
`timescale 1 ns / 100 ps
module uart_tx_tb ();
reg clock;
reg [7:0] read_data;
reg read_clock_enable;
reg reset; /* active low */
wire ready; /* ready to read new data */
wire tx;
wire uart_clock;
uart_tx #(.CLOCK_FREQ(2_400), .BAUD_RATE(1_200))
UART (
.reset(reset),
.clock(clock),
.read_data(read_data),
.read_clock_enable(read_clock_enable),
.tx(tx),
.ready(ready),
.uart_clock(uart_clock));
always
#2 clock = ~clock;
initial begin
#5000 $finish;
end
initial begin
$dumpfile ("uart_tx_tb.vcd");
$dumpvars (0, uart_tx_tb);
clock = 0;
reset = 0;
read_data = 8'hb7;
read_clock_enable = 1;
#10
if (ready == 'b1) begin
$display("ready in reset is high. Expected: low");
$stop;
end
#2
read_clock_enable = 0;
#20 reset = 1;
#2;
#2;
#2;
reset = 1;
#500;
if (ready == 'b0) begin
$display("ready after reset is low. Expected: high");
$stop;
end
#2;
read_clock_enable = 1;
@(negedge ready);
read_clock_enable = 0;
#2000;
$finish;
end
endmodule