This document contains Verilog code for an 8-input multiplexer (mux8) and barrel shifter. The mux8 module uses a case statement to output one of eight data inputs based on a 3-bit selection code. The barrel_shifter module instantiates eight mux8 modules to shift the input data left or right by the number of places indicated by the 3-bit shift selection input. A test bench is also provided to simulate shifting the data left by changing the shift selection input over time.
This document contains Verilog code for an 8-input multiplexer (mux8) and barrel shifter. The mux8 module uses a case statement to output one of eight data inputs based on a 3-bit selection code. The barrel_shifter module instantiates eight mux8 modules to shift the input data left or right by the number of places indicated by the 3-bit shift selection input. A test bench is also provided to simulate shifting the data left by changing the shift selection input over time.
This document contains Verilog code for an 8-input multiplexer (mux8) and barrel shifter. The mux8 module uses a case statement to output one of eight data inputs based on a 3-bit selection code. The barrel_shifter module instantiates eight mux8 modules to shift the input data left or right by the number of places indicated by the 3-bit shift selection input. A test bench is also provided to simulate shifting the data left by changing the shift selection input over time.
else if (c==3'b001) mux8 m6(q[2],{d[5:0],d[7:6]},s);
y = d[1]; mux8 m7(q[1],{d[6:0],d[7]},s);
else if (c==3'b010) mux8 m8(q[0],d[7:0],s);
y = d[2]; endmodule
else if (c==3'b011)
y = d[3]; TEST BENCH
else if (c==3'b100) initial begin y = d[4]; // Initialize Inputs else if (c==3'b101) d = 8'b00000001; y = d[5]; s = 3'b000; else if (c==3'b110) #100; y = d[6]; s = 3'b001; else if (c==3'b111) #100; y = d[7]; s = 3'b010; end #100; endmodule s = 3'b011;