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