-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogic_gates_tb.v
46 lines (35 loc) · 1.67 KB
/
logic_gates_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
// Testbench for Logic Gates
`include "Logic_Gates.v" // The include directive is used to include the contents of one file into another during preprocessing.
module logic_gates_tb;
reg a, b;
wire and_out, or_out, not_out_a, not_out_b, nand_out, nor_out, xor_out, xnor_out;
// Instantiate the logic gates module
logic_gates uut (
.a(a),
.b(b),
.and_out(and_out),
.or_out(or_out),
.not_out_a(not_out_a),
.not_out_b(not_out_b),
.nand_out(nand_out),
.nor_out(nor_out),
.xor_out(xor_out),
.xnor_out(xnor_out)
);
// Test procedure
initial begin
$dumpfile("Logic_Gates.vcd"); // vcd - value change dump
$dumpvars(0,logic_gates_tb);
$display("A B | AND OR NOT_A NOT_B NAND NOR XOR XNOR");
$display("__________________________________________");
a = 0; b = 0;
#10 $display("%b %b | %b %b %b %b %b %b %b %b", a, b, and_out, or_out, not_out_a, not_out_b, nand_out, nor_out, xor_out, xnor_out);
a = 0; b = 1;
#10 $display("%b %b | %b %b %b %b %b %b %b %b", a, b, and_out, or_out, not_out_a, not_out_b, nand_out, nor_out, xor_out, xnor_out);
a = 1; b = 0;
#10 $display("%b %b | %b %b %b %b %b %b %b %b", a, b, and_out, or_out, not_out_a, not_out_b, nand_out, nor_out, xor_out, xnor_out);
a = 1; b = 1;
#10 $display("%b %b | %b %b %b %b %b %b %b %b", a, b, and_out, or_out, not_out_a, not_out_b, nand_out, nor_out, xor_out, xnor_out);
$finish;
end
endmodule