From 540aac9fcad82b358e0713726e89d9f12e87b518 Mon Sep 17 00:00:00 2001 From: Erick Date: Tue, 1 Mar 2022 00:36:52 +0100 Subject: [PATCH] add demux and testbench --- gates/demux.v | 9 +++++++++ gates/testbench/demux._tb.v | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 gates/demux.v create mode 100644 gates/testbench/demux._tb.v diff --git a/gates/demux.v b/gates/demux.v new file mode 100644 index 0000000..c7b7265 --- /dev/null +++ b/gates/demux.v @@ -0,0 +1,9 @@ +module demux(y, z, a, sel); + input a, sel; + output y, z; + wire notSel; + + not(notSel, sel); + and(z, a, sel); + and(y, a, notSel); +endmodule \ No newline at end of file diff --git a/gates/testbench/demux._tb.v b/gates/testbench/demux._tb.v new file mode 100644 index 0000000..e814b61 --- /dev/null +++ b/gates/testbench/demux._tb.v @@ -0,0 +1,18 @@ +module demux_tb(); + reg a,b, sel; + output y; + demux dut(y, z, a, sel); + initial begin + a = 0; sel = 0; + $monitor("IN: %b ",a, "SEL: ",sel, " OUT: a: %b, b: %b", y, z); + #5; + a = 1;sel = 0; + $monitor("IN: %b ",a, "SEL: ",sel, " OUT: a: %b, b: %b", y, z); + #5; + a = 0; sel = 1; + $monitor("IN: %b ",a, "SEL: ",sel, " OUT: a: %b, b: %b", y, z); + #5; + a = 1; sel = 1; + $monitor("IN: %b ",a, "SEL: ",sel, " OUT: a: %b, b: %b", y, z); + end +endmodule \ No newline at end of file