diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6b3bb45 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.vpp diff --git a/verilog_iverilog/multiplexer/Makefile b/verilog_iverilog/multiplexer/Makefile new file mode 100644 index 0000000..f79db3e --- /dev/null +++ b/verilog_iverilog/multiplexer/Makefile @@ -0,0 +1,11 @@ +SOURCES=multiplexer.v multiplexer-tb.v +VPP=multiplexer.vpp + +run: ${VPP} + vvp ${VPP} + +${VPP} : ${SOURCES} + iverilog $^ -o $@ + +clean: + rm -f ${VPP} diff --git a/verilog_iverilog/multiplexer/multiplexer-tb.v b/verilog_iverilog/multiplexer/multiplexer-tb.v new file mode 100644 index 0000000..bf2ac90 --- /dev/null +++ b/verilog_iverilog/multiplexer/multiplexer-tb.v @@ -0,0 +1,50 @@ +module hello; + wire out; + reg A,B,X; + multiplexer idk(A,B,X,out); +initial +begin + $display("RSLT\tOUT\tA\tB\tSLCT"); + A=1;B=1;X=1;#50 + if(out==1) + $display("PASS\t%b\t%b\t%b\t%b",out,A,B,X); + else + $display("FAIL\t%b\t%b\t%b\t%b",out,A,B,X); + A=1;B=0;X=1;#50 + if(out==0) + $display("PASS\t%b\t%b\t%b\t%b",out,A,B,X); + else + $display("FAIL\t%b\t%b\t%b\t%b",out,A,B,X); + A=0;B=1;X=1;#50 + if(out==1) + $display("PASS\t%b\t%b\t%b\t%b",out,A,B,X); + else + $display("FAIL\t%b\t%b\t%b\t%b",out,A,B,X); + A=0;B=0;X=1;#50 + if(out==0) + $display("PASS\t%b\t%b\t%b\t%b",out,A,B,X); + else + $display("FAIL\t%b\t%b\t%b\t%b",out,A,B,X); + A=1;B=1;X=0;#50 + if(out==1) + $display("PASS\t%b\t%b\t%b\t%b",out,A,B,X); + else + $display("FAIL\t%b\t%b\t%b\t%b",out,A,B,X); + A=1;B=0;X=0;#50 + if(out==1) + $display("PASS\t%b\t%b\t%b\t%b",out,A,B,X); + else + $display("FAIL\t%b\t%b\t%b\t%b",out,A,B,X); + A=0;B=1;X=0;#50 + if(out==0) + $display("PASS\t%b\t%b\t%b\t%b",out,A,B,X); + else + $display("FAIL\t%b\t%b\t%b\t%b",out,A,B,X); + A=0;B=0;X=0;#50 + if(out==0) + $display("PASS\t%b\t%b\t%b\t%b",out,A,B,X); + else + $display("FAIL\t%b\t%b\t%b\t%b",out,A,B,X); + $finish ; +end +endmodule diff --git a/verilog_iverilog/multiplexer/multiplexer.v b/verilog_iverilog/multiplexer/multiplexer.v new file mode 100644 index 0000000..6e372c9 --- /dev/null +++ b/verilog_iverilog/multiplexer/multiplexer.v @@ -0,0 +1,8 @@ +module multiplexer(A,B,X,out1); +input A,B,X; +output out1; + +assign out1 = (~X&A)|(B&X); + +endmodule +