-
Notifications
You must be signed in to change notification settings - Fork 18
/
cmp_gt_tb.v
139 lines (94 loc) · 2.85 KB
/
cmp_gt_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
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
`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] dbg_addr;
wire [31:0] dbg_data;
reg [4:0] dbg_wr_addr;
reg [31:0] dbg_wr_data;
reg dbg_wr_en;
wire [4:0] waddr;
wire [31:0] wdata;
wire [0:0] wen;
wire [4:0] raddr0;
wire [4:0] raddr1;
wire [31:0] rdata0;
wire [31:0] rdata1;
initial begin
#1 dbg_wr_addr = 0;
#1 dbg_wr_data = 198;
#1 dbg_wr_en = 1;
#1 clk = 0;
#1 clk = 1;
#1 rst = 1;
#1 dbg_wr_addr = 1;
#1 dbg_wr_data = 7;
#1 dbg_wr_en = 1;
#1 clk = 0;
#1 clk = 1;
#1 rst = 1;
#1 dbg_wr_en = 0;
#1 clk = 0;
#1 clk = 1;
#1 rst = 1;
#1 clk = 0;
#1 clk = 1;
#1 rst = 1;
#1 dbg_addr = 2;
#1 clk = 0;
#1 rst = 1;
#1 clk = 1;
// $display("dbg data = %d", dbg_data);
`assert(dbg_data, 32'hxxxxxxxx)
`assert(valid, 1'd0)
//$display("rdata = %d", rdata);
// $display("wen = %d", wen);
// $display("waddr = %d", waddr);
// $display("wdata = %d", wdata);
#1 rst = 0;
#1 clk = 0;
#1 clk = 1;
#1 clk = 0;
#1 clk = 1;
`assert(valid, 1'd0)
// #1 `assert(rdata0, 32'hxxxxxxxx)
#1 clk = 0;
#1 clk = 1;
// $display("dbg data = %d", dbg_data);
// $display("rdata = %d", rdata);
`assert(valid, 1'd0)
$display("dbg data = %d", dbg_data);
#1 clk = 0;
#1 clk = 1;
$display("dbg data = %d", dbg_data);
#1 clk = 0;
#1 clk = 1;
$display("dbg data = %d", dbg_data);
#1 clk = 0;
#1 clk = 1;
$display("dbg data = %d", dbg_data);
#1 clk = 0;
#1 clk = 1;
$display("dbg data = %d", dbg_data);
#1 `assert(dbg_data, 32'd10)
#1 `assert(valid, 1'd1)
#1 $display("Passed");
end
RAM2 mem(.clk(clk),
.rst(rst),
.raddr_0(raddr0),
.rdata_0(rdata0),
.raddr_1(raddr1),
.rdata_1(rdata1),
.debug_write_addr(dbg_wr_addr),
.debug_write_data(dbg_wr_data),
.debug_write_en(dbg_wr_en),
.debug_addr(dbg_addr),
.debug_data(dbg_data),
.wen(wen),
.wdata(wdata),
.waddr(waddr));
cmp_gt ss(.clk(clk), .rst(rst), .valid(valid), .ram_waddr_0(waddr), .ram_wdata_0(wdata), .ram_wen_0(wen), .ram_raddr_0(raddr0), .ram_rdata_0(rdata0), .ram_raddr_1(raddr1), .ram_rdata_1(rdata1));
endmodule