From 90287bca738db55966cbcf1b13a693d05643551f Mon Sep 17 00:00:00 2001 From: Erick Date: Mon, 28 Feb 2022 23:55:42 +0100 Subject: [PATCH] adding testbenches --- gates/testbench/mux.v | 32 ++++++++++++++++++++++++++++++++ gates/testbench/nand_tb.v | 17 +++++++++++++++++ gates/testbench/not_tb.v | 15 +++++++++++++++ gates/testbench/or_tb.v | 18 ++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 gates/testbench/mux.v create mode 100644 gates/testbench/nand_tb.v create mode 100644 gates/testbench/not_tb.v create mode 100644 gates/testbench/or_tb.v diff --git a/gates/testbench/mux.v b/gates/testbench/mux.v new file mode 100644 index 0000000..010821c --- /dev/null +++ b/gates/testbench/mux.v @@ -0,0 +1,32 @@ +include "mux.v" + +module mux_tb(); + reg a,b, sel; + output y; + mux dut(a, b, sel, y); + initial begin + a = 0; b = 0; sel = 0; + $monitor("IN: %b, %b ",a, b, "SEL: ",sel, " OUT: ",y); + #5; + a = 1; b = 0; sel = 0; + $monitor("IN: %b, %b ",a, b, "SEL: ",sel, " OUT: ",y); + #5; + a = 0; b = 1; sel = 0; + $monitor("IN: %b, %b ",a, b, "SEL: ",sel, " OUT: ",y); + #5; + a = 1; b = 1; sel = 0; + $monitor("IN: %b, %b ",a, b, "SEL: ",sel, " OUT: ",y); + #5; + a = 0; b = 0; sel = 1; + $monitor("IN: %b, %b ",a, b, "SEL: ",sel, " OUT: ",y); + #5; + a = 1; b = 0; sel = 1; + $monitor("IN: %b, %b ",a, b, "SEL: ",sel, " OUT: ",y); + #5; + a = 0; b = 1; sel = 1; + $monitor("IN: %b, %b ",a, b, "SEL: ",sel, " OUT: ",y); + #5; + a = 1; b = 1; sel = 1; + $monitor("IN: %b, %b ",a, b, "SEL: ",sel, " OUT: ",y); + end +endmodule \ No newline at end of file diff --git a/gates/testbench/nand_tb.v b/gates/testbench/nand_tb.v new file mode 100644 index 0000000..217aede --- /dev/null +++ b/gates/testbench/nand_tb.v @@ -0,0 +1,17 @@ +include "nand_gate.v" + +module nand_tb(); + reg ta,tb; + wire ty; + nand_gate dut(y, ta, tb); + initial begin + ta = 0; tb = 0; + $monitor("IN: %b, %b ",ta, tb, "OUT: ",y); + #5 ta = 1; tb = 0; + $monitor("IN: %b, %b ",ta, tb, "OUT: ",y); + #5 ta = 0; tb = 1; + $monitor("IN: %b, %b ",ta, tb, "OUT: ",y); + #5 ta = 1; tb = 1; + $monitor("IN: %b, %b ",ta, tb, "OUT: ",y); + end +endmodule \ No newline at end of file diff --git a/gates/testbench/not_tb.v b/gates/testbench/not_tb.v new file mode 100644 index 0000000..c4b0daa --- /dev/null +++ b/gates/testbench/not_tb.v @@ -0,0 +1,15 @@ +include "not_gate.v" + +module not_tb(); + reg ta; + wire ty; + + not_gate dut(y, ta); + + initial begin + ta=0; + $monitor("IN: %b", ta, "OUT: ", y) + ta=1; + $monitor("IN: %b", ta, "OUT: ", y) + end +endmodule \ No newline at end of file diff --git a/gates/testbench/or_tb.v b/gates/testbench/or_tb.v new file mode 100644 index 0000000..d0d89a2 --- /dev/null +++ b/gates/testbench/or_tb.v @@ -0,0 +1,18 @@ +include "or_gate.v" + +module or_tb(); + reg ta, tb; + wire ty; + + or_gate dut(y, ta, tb); + + initial begin + ta=0, tb=0; + $monitor("IN: %b, %b ",ta, tb, "OUT: ",y); + ta=0, tb=1; + $monitor("IN: %b, %b ",ta, tb, "OUT: ",y); + ta=1, tb=0; + $monitor("IN: %b, %b ",ta, tb, "OUT: ",y); + ta=1, tb=1; + end +endmodule \ No newline at end of file