Add testbench for the seconds display
NOTE: This doesn't actually compile yet, but it should once changes to the seconds display are pushed
This commit is contained in:
parent
423f89a665
commit
da7d026d06
51
verification/seconds_display_tb.sv
Normal file
51
verification/seconds_display_tb.sv
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
module seconds_display_tb;
|
||||||
|
int errors = 0;
|
||||||
|
logic [5:0] seconds;
|
||||||
|
wire [6:0] display_tens;
|
||||||
|
wire [6:0] display_ones;
|
||||||
|
|
||||||
|
logic [6:0] expected_tens;
|
||||||
|
logic [6:0] expected_ones;
|
||||||
|
|
||||||
|
seconds_display Dut(.*);
|
||||||
|
initial begin
|
||||||
|
$display("Testing seconds_display");
|
||||||
|
for (seconds=0; seconds<60; seconds++) begin
|
||||||
|
expected_ones = encode_number(seconds % 10);
|
||||||
|
expected_tens = encode_number(seconds /10);
|
||||||
|
#1
|
||||||
|
if (display_ones !== expected_ones) begin
|
||||||
|
errors++;
|
||||||
|
$display("Failed ones test case, displayed = %b, expected = %b",
|
||||||
|
display_ones,
|
||||||
|
expected_ones);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if (display_tens !== expected_tens) begin
|
||||||
|
errors++;
|
||||||
|
$display("Failed tens test case, displayed = %b, expected = %b",
|
||||||
|
display_tens,
|
||||||
|
expected_tens);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if (errors == 0)
|
||||||
|
$display("All tests passing");
|
||||||
|
end
|
||||||
|
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
function automatic logic [6:0] encode_number(logic [5:0] num);
|
||||||
|
case (num)
|
||||||
|
0: return 7'b1111110;
|
||||||
|
1: return 7'b0000110;
|
||||||
|
2: return 7'b1101101;
|
||||||
|
3: return 7'b1111001;
|
||||||
|
4: return 7'b0110011;
|
||||||
|
5: return 7'b1011011;
|
||||||
|
6: return 7'b1011111;
|
||||||
|
7: return 7'b1110000;
|
||||||
|
8: return 7'b1111111;
|
||||||
|
9: return 7'b1111011;
|
||||||
|
endcase
|
||||||
|
endfunction
|
||||||
Loading…
x
Reference in New Issue
Block a user