Wrote my first verilog project ( a multiplexer ) with a testbench and added a .gitignore

This commit is contained in:
(Tim) Efthymios Kritikos 2023-01-24 20:27:15 +00:00
parent fb8208ef55
commit 9b350ec117
4 changed files with 70 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.vpp

View File

@ -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}

View File

@ -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

View File

@ -0,0 +1,8 @@
module multiplexer(A,B,X,out1);
input A,B,X;
output out1;
assign out1 = (~X&A)|(B&X);
endmodule