Question

Implement a 4x1 multipexer using behavioral modeling in verilog, also write its test bench.

Implement a 4x1 multipexer using behavioral modeling in verilog, also write its test bench.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:-------------
4x1 multipexer using behavioral modeling in verilog:-------------------

module mux4X1( in,sel,out);
input [3:0]in;
input [1:0]sel;
output reg out;

always @(*)
   begin
       case(sel)
           2'b00: out=in[0];
           2'b01: out=in[1];
           2'b10: out=in[2];
           2'b11: out=in[3];
           default: out=1'b0;
       endcase
   end
endmodule

Test bench:-------
module mux4X1;

reg[3:0] in;
reg[1:0] sel;
wire out;

integer i;

mux4X1 my_mux( sel, in, out );

initial
begin
#1 $monitor("in = %b", in, " | sel = ", sel, " | out = ", out );

for( i = 0; i <= 15; i = i + 1)
begin
in = i;
sel = 0; #1;
sel = 1; #1;
sel = 2; #1;
sel = 3; #1;
$display("-----------------------------------------");
end

end
endmodule

Add a comment
Know the answer?
Add Answer to:
Implement a 4x1 multipexer using behavioral modeling in verilog, also write its test bench.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT