forked from TimRudy/ice-chips-verilog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path7421-tb.v
115 lines (105 loc) · 2.19 KB
/
7421-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
// Test: Dual 4-input AND gate
module test;
`TBASSERT_METHOD(tbassert)
localparam BLOCKS = 1;
localparam WIDTH_IN = 4;
// DUT inputs
reg [BLOCKS*WIDTH_IN-1:0] A;
// DUT outputs
wire [BLOCKS-1:0] Y;
// DUT
ttl_7421 #(.BLOCKS(BLOCKS), .WIDTH_IN(WIDTH_IN), .DELAY_RISE(5), .DELAY_FALL(3)) dut(
.A_2D(A),
.Y(Y)
);
initial
begin
reg [BLOCKS-1:0] AInputs;
reg [BLOCKS-1:0] BInputs;
reg [BLOCKS-1:0] CInputs;
reg [BLOCKS-1:0] DInputs;
integer i;
$dumpfile("7421-tb.vcd");
$dumpvars;
// all zeroes -> 0
AInputs = 1'b0;
BInputs = AInputs;
CInputs = AInputs;
DInputs = AInputs;
A = {DInputs, CInputs, BInputs, AInputs};
#10
tbassert(Y == 1'b0, "Test 1");
#0
// only a quadruplet of all ones -> 1
AInputs = 1'b1;
BInputs = AInputs;
CInputs = AInputs;
DInputs = AInputs;
A = {DInputs, CInputs, BInputs, AInputs};
#10
tbassert(Y == 1'b1, "Test 2");
#0
// only a single bit causes -> 0
AInputs = 1'b0;
BInputs = 1'b1;
CInputs = 1'b1;
DInputs = 1'b1;
A = {DInputs, CInputs, BInputs, AInputs};
#10
tbassert(Y == 1'b0, "Test 3");
#0
// same on next input
AInputs = 1'b1;
BInputs = 1'b0;
CInputs = 1'b1;
DInputs = 1'b1;
A = {DInputs, CInputs, BInputs, AInputs};
#10
tbassert(Y == 1'b0, "Test 4");
#0
// same on next input
AInputs = 1'b1;
BInputs = 1'b1;
CInputs = 1'b0;
DInputs = 1'b1;
A = {DInputs, CInputs, BInputs, AInputs};
#10
tbassert(Y == 1'b0, "Test 5");
#0
// same on last input
AInputs = 1'b1;
BInputs = 1'b1;
CInputs = 1'b1;
DInputs = 1'b0;
A = {DInputs, CInputs, BInputs, AInputs};
#10
tbassert(Y == 1'b0, "Test 6");
#0
// mixed bits causes -> 0
AInputs = 1'b1;
BInputs = 1'b0;
CInputs = 1'b1;
DInputs = 1'b0;
A = {DInputs, CInputs, BInputs, AInputs};
#6
tbassert(Y == 1'b0, "Test 7");
#0
// same on other inputs, all input bits transition from previous
AInputs = 1'b0;
BInputs = 1'b1;
CInputs = 1'b0;
DInputs = 1'b1;
A = {DInputs, CInputs, BInputs, AInputs};
#6
tbassert(Y == 1'b0, "Test 8");
#0
// input transition to all ones causes output transition -> 1
AInputs = 1'b1;
CInputs = 1'b1;
A = {DInputs, CInputs, BInputs, AInputs};
#6
tbassert(Y == 1'b1, "Test 9");
#10
$finish;
end
endmodule