-
Notifications
You must be signed in to change notification settings - Fork 18
/
single_store_tb.v
80 lines (56 loc) · 1.63 KB
/
single_store_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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
`define assert(signal, value) if ((signal) !== (value)) begin $display("ASSERTION FAILED in %m: signal != value"); $finish(1); end
module test();
reg clk;
reg rst;
wire valid;
// Depth 16, width 32 RAM
reg [4:0] raddr;
wire [4:0] waddr;
wire [31:0] wdata;
wire [0:0] wen;
reg [4:0] debug_addr;
wire [31:0] debug_data;
wire [31:0] rdata;
initial begin
#1 debug_addr = 0;
#1 clk = 0;
#1 rst = 1;
#1 clk = 1;
#1 raddr = 0;
// In global state 0
#1 `assert(debug_data, 32'hxxxxxxxx)
#1 `assert(valid, 1'd0)
#1 rst = 0;
#1 clk = 0;
#1 clk = 1;
// In global state 1
#1 `assert(debug_data, 32'hxxxxxxxx)
#1 `assert(valid, 1'd0)
#1 clk = 0;
#1 clk = 1;
// In global state 2
#1 `assert(debug_data, 32'hxxxxxxxx)
#1 `assert(valid, 1'd0)
#1 clk = 0;
#1 clk = 1;
// In global state 3, we should be done
#1 `assert(debug_data, 32'd5)
#1 `assert(valid, 1'd1)
#1 clk = 0;
#1 clk = 1;
// In global state 3, we should be done, but reads have a delay of one
#1 `assert(debug_data, 32'd5)
#1 `assert(valid, 1'd1)
#1 $display("Passed");
end
RAM mem(.clk(clk),
.rst(rst),
.raddr_0(raddr),
.rdata_0(rdata),
.wen_0(wen),
.wdata_0(wdata),
.waddr_0(waddr),
.debug_addr(debug_addr),
.debug_data(debug_data));
single_store ss(.clk(clk), .rst(rst), .valid(valid), .a_waddr_0(waddr), .a_wdata_0(wdata), .a_wen_0(wen));
endmodule