-
Notifications
You must be signed in to change notification settings - Fork 18
/
fifo.v
63 lines (35 loc) · 1.2 KB
/
fifo.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
`define assert(signal, value) if ((signal) !== (value)) begin $display("ASSERTION FAILED in %m: signal != value"); $finish(1); end
`define POSEDGE #1 clk = 0; #1 clk = 0; #1 clk = 1; #1 clk = 1;
module test();
reg clk;
reg rst;
reg read_valid0;
wire read_ready0;
wire write_ready0;
reg write_valid0;
reg [31 : 0] in_data0;
wire [31 : 0] out_data0;
initial begin
#1 rst = 1;
`POSEDGE
#1 rst = 0;
#1 `assert(write_ready0, 1'd1)
#1 `assert(read_ready0, 1'd0)
#1 in_data0 = 1;
#1 write_valid0 = 1;
`POSEDGE
write_valid0 = 0;
#1 `assert(write_ready0, 1'd0)
#1 `assert(read_ready0, 1'd1)
`POSEDGE
read_valid0 = 1;
`POSEDGE
read_valid0 = 0;
$display("out_data0 = %d", out_data0);
#1 `assert(out_data0, 1)
#1 `assert(write_ready0, 1'd1)
#1 `assert(read_ready0, 1'd0)
#1 $display("Passed");
end // initial begin
fifo #(.WIDTH(32), .DEPTH(1)) in(.clk(clk), .rst(rst), .read_valid(read_valid0), .read_ready(read_ready0), .write_ready(write_ready0), .write_valid(write_valid0), .out_data(out_data0), .in_data(in_data0));
endmodule