forked from vaibhavviswanathan/CGoL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testbench_overall.sv.bak
53 lines (43 loc) · 1.19 KB
/
testbench_overall.sv.bak
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
module testbench_overall();
//initialize variables
logic ph1, ph2, reset;
logic [7:0] row, col, row_exp, col_exp;
logic [31:0] vectornum, errors;
logic [15:0] testvectors[500:0];
cgol dut(ph1, ph2, reset, row, col);
initial $readmemb("overall.tv", testvectors); //read in testvectors
initial vectornum = 0;
initial errors = 0;
// start with reset
initial begin
reset <= 1;
#10;
reset <= 0;
end
// initialize two phase clock
always begin
ph1 = 0; ph2 = 0;
#1; ph1 = 1;
#4; ph1 = 0;
#1; ph2 = 1;
#4; ph2 = 0;
end
// apply testvectors on ph1
always @(posedge ph1) begin
#1; {row_exp, col_exp} = testvectors[vectornum];
end
// compare expected to actual values on ph2
always @(posedge ph2) begin
if ((row !== row_exp)|(col !== col_exp))
begin
//$display("Error: inputs = %b; %b; %b; %b", row, row_exp, col, col_exp);
$display("outputs = %b (%b expected) and %b (%b expected)\n vectornum: %d", row, row_exp, col, col_exp, vectornum);
errors = errors + 1;
end
assign vectornum = vectornum + 1;
if (testvectors[vectornum] === 16'bx) begin
$display("Finished: %d vectors with %d errors", vectornum, errors);
$finish;
end
end
endmodule