aboutsummaryrefslogtreecommitdiff
path: root/task1/tb_card7seg.sv
blob: 5d6886112c5d7e5bd824f36a4daa1ab8a88a03a6 (plain) (blame)
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
`define ACE	7'b0001000
`define TWO	7'b0100100
`define THREE	7'b0110000
`define FOUR	7'b0011001
`define FIVE	7'b0010010
`define SIX	7'b0000010
`define SEVEN	7'b1111000
`define EIGHT	7'b0000000
`define NINE	7'b0010000
`define TEN	7'b1000000
`define JACK	7'b1100001
`define QUEEN	7'b0011000
`define KING	7'b0001001
`define BLANK	7'b1111111

module tb_card7seg();
	logic err;
	logic [3:0] SW;
	logic [6:0] HEX0;

	card7seg DUT(SW, HEX0);

	task check;
		input logic [6:0] expected;

		if (HEX0 !== expected) begin
			err = 1;
			$display("FAILED: HEX is incorrect.",);
		end
	endtask: check


	initial begin
		err = 0;

		SW = 4'd0;
		#5;
		check(`BLANK);
		#5;

		SW = 4'd1;
		#5;
		check(`ACE);
		#5;

		SW = 4'd2;
		#5;
		check(`TWO);
		#5;

		SW = 4'd3;
		#5;
		check(`THREE);
		#5;

		SW = 4'd4;
		#5;
		check(`FOUR);
		#5;

		SW = 4'd5;
		#5;
		check(`FIVE);
		#5;

		SW = 4'd6;
		#5;
		check(`SIX);
		#5;

		SW = 4'd7;
		#5;
		check(`SEVEN);
		#5;

		SW = 4'd8;
		#5;
		check(`EIGHT);
		#5;

		SW = 4'd9;
		#5;
		check(`NINE);
		#5;

		SW = 4'd10;
		#5;
		check(`TEN);
		#5;

		SW = 4'd11;
		#5;
		check(`JACK);
		#5;

		SW = 4'd12;
		#5;
		check(`QUEEN);
		#5;

		SW = 4'd13;
		#5;
		check(`KING);
		#5;

		if (~err)
			$display("All tests passed.");

		#10;
		$stop;
	end
endmodule