Wrote my first verilog project ( a multiplexer ) with a testbench and added a .gitignore
This commit is contained in:
parent
fb8208ef55
commit
9b350ec117
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.vpp
|
11
verilog_iverilog/multiplexer/Makefile
Normal file
11
verilog_iverilog/multiplexer/Makefile
Normal 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}
|
50
verilog_iverilog/multiplexer/multiplexer-tb.v
Normal file
50
verilog_iverilog/multiplexer/multiplexer-tb.v
Normal 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
|
8
verilog_iverilog/multiplexer/multiplexer.v
Normal file
8
verilog_iverilog/multiplexer/multiplexer.v
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
module multiplexer(A,B,X,out1);
|
||||||
|
input A,B,X;
|
||||||
|
output out1;
|
||||||
|
|
||||||
|
assign out1 = (~X&A)|(B&X);
|
||||||
|
|
||||||
|
endmodule
|
||||||
|
|
Loading…
Reference in New Issue
Block a user