Question

In: Electrical Engineering

Using the conditional assignment statements, write the verilog code for 16:1 Mux. Write the test bench...

Using the conditional assignment statements, write the verilog code for 16:1 Mux. Write the test bench for this module.

Solutions

Expert Solution

//Code

module mux_16_1(

input [15:0] din,

input [3:0] sel,

output reg dout

);

always @ (sel or din)

dout = (sel == 4'b0000)? din[0] :

((sel == 4'b0001)? din[1] :

((sel == 4'b0010)? din[2] :

((sel == 4'b0011)? din[3] :

((sel == 4'b0100)? din[4] :

((sel == 4'b0101)? din[5] :

((sel == 4'b0110)? din[6] :

((sel == 4'b0111)? din[7] :

((sel == 4'b1000)? din[8] :

((sel == 4'b1001)? din[9] :

((sel == 4'b1010)? din[10] :

((sel == 4'b1011)? din[11] :

((sel == 4'b1100)? din[12] :

((sel == 4'b1101)? din[13] :

((sel == 4'b1110)? din[14] :

((sel == 4'b1111)? din[15] :

1'bz)))))))))))))));

endmodule

///testbench

module tb_mux_16_1;

// Inputs

reg [15:0] din;

reg [3:0] sel;

// Outputs

wire dout;

// Instantiate the Unit Under Test (UUT)

mux_16_1 uut (

.din(din),

.sel(sel),

.dout(dout)

);

initial begin

// Initialize Inputs

din = 0;

sel = 0;

// Wait 100 ns for global reset to finish

#100;

  

// Add stimulus here

din = 16'b1010101010101010;

#20 sel = 4'b0000;

#20 sel = 4'b0001;

#20 sel = 4'b0010;

#20 sel = 4'b0011;

#20 sel = 4'b0100;

#20 sel = 4'b0101;

#20 sel = 4'b0110;

#20 sel = 4'b0111;

#20 sel = 4'b1000;

#20 sel = 4'b1001;

#20 sel = 4'b1010;

#20 sel = 4'b1011;

#20 sel = 4'b1100;

#20 sel = 4'b1101;

#20 sel = 4'b1110;

#20 sel = 4'b1111;

end   

endmodule

//Simulated waveform


Related Solutions

1.Write verilog code for a 8:1 Mux using the blocks of 2:1 Mux; Draw the block...
1.Write verilog code for a 8:1 Mux using the blocks of 2:1 Mux; Draw the block diagram for this design and write the truth table to prove that the design works as intended. 2. Write verilog code for a 16:1 Mux using the blocks of 4:1 Mux; Draw the block diagram for this design and write the truth table to prove that the design works as intended.
Write the VERILOG code for an arithmetic/logic unit (ALU) with a test bench that does the...
Write the VERILOG code for an arithmetic/logic unit (ALU) with a test bench that does the following with 4 bit inputs , and can be tested in on nexys 4 board This is to be implement on : ISE Design Suite - Xilinx /* ALU Arithmetic and Logic Operations ---------------------------------------------------------------------- |ALU_Sel| ALU Operation ---------------------------------------------------------------------- | 0000 | ALU_Out = A + B; ---------------------------------------------------------------------- | 0001 | ALU_Out = A - B; ---------------------------------------------------------------------- | 0010 | ALU_Out = A * B;...
Can anyone write a Verilog code and a test bench for a universal shift register with...
Can anyone write a Verilog code and a test bench for a universal shift register with 4 bits using D flip flop? Thanks
Implement a 4x4 multiplier using gate level (verilog code and test bench)
Implement a 4x4 multiplier using gate level (verilog code and test bench)
Implement a JK Flip flop using behavioral modeling in verilog, also write its test bench code.
Implement a JK Flip flop using behavioral modeling in verilog, also write its test bench code.
Write the Verilog code and test bench for the following circuits: - Mealy State machine design...
Write the Verilog code and test bench for the following circuits: - Mealy State machine design for a Serial Adder Circuit - Moore State Machine design for a Serial Adder Circuit
Type up Verilog Verilog program , test bench and screenshot of the wavefore using verilog xilinx....
Type up Verilog Verilog program , test bench and screenshot of the wavefore using verilog xilinx. (PLEASE ONLY ANSWER IF YOU UNDERSTAND HOW TO USE XILINX. ******************no need to show me the state diagram or state table just the verilog code , test bench and the screenshot of the waveforem **************** Implement the function given below using each of the following methods. As few 16-1 multiplexers as possible. Behavioral Verilog. F( w , x, y , z) = ?(2 ,...
code an 8 bit LFSR random number generator in system verilog. Write a test bench, load...
code an 8 bit LFSR random number generator in system verilog. Write a test bench, load the seed 11111111, and generate the first 10 random numbers.
verilog code of a 64 x64 array with 128 parameters please include test bench
verilog code of a 64 x64 array with 128 parameters please include test bench
Write a Verilog code to implement 16 bit LFSR
Write a Verilog code to implement 16 bit LFSR
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT