Question

In: Electrical Engineering

Design a circuit and write a verilog code description of the 16-bit right rotator using barrel...

Design a circuit and write a verilog code description of the 16-bit right rotator using barrel shift method

Solutions

Expert Solution

VERILOG CODE:

module multiplexer_16_4(X, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, S3, S2, S1, S0);
   parameter WIDTH=16;     // How many bits wide are the lines

   output [WIDTH-1:0] X;   // The output line

   input [WIDTH-1:0]  A15;  // Input line with id 4'b1111
   input [WIDTH-1:0]  A14;  // Input line with id 4'b1110
   input [WIDTH-1:0]  A13;  // Input line with id 4'b1101
   input [WIDTH-1:0]  A12;  // Input line with id 4'b1100
   input [WIDTH-1:0]  A11;  // Input line with id 4'b1011
   input [WIDTH-1:0]  A10;  // Input line with id 4'b1010
   input [WIDTH-1:0]  A9;   // Input line with id 4'b1001
   input [WIDTH-1:0]  A8;   // Input line with id 4'b1000
   input [WIDTH-1:0]  A7;   // Input line with id 4'b0111
   input [WIDTH-1:0]  A6;   // Input line with id 4'b0110
   input [WIDTH-1:0]  A5;   // Input line with id 4'b0101
   input [WIDTH-1:0]  A4;   // Input line with id 4'b0100
   input [WIDTH-1:0]  A3;   // Input line with id 4'b0011
   input [WIDTH-1:0]  A2;   // Input line with id 4'b0010
   input [WIDTH-1:0]  A1;   // Input line with id 4'b0001
   input [WIDTH-1:0]  A0;   // Input line with id 4'b0000
   input              S3;   // Most significant selection bit
   input              S2;   
   input              S1;   
   input              S0;   // Least significant selection bit
   
   assign X = (S3 == 0 
               ? (S2 == 0 
                  ? (S1 == 0 
                     ? (S0 == 0 
                        ? A0       // {S3,S2,S1,S0} = 4'b0000
                        : A1)      // {S3,S2,S1,S0} = 4'b0001
                     : (S0 == 0 
                        ? A2       // {S3,S2,S1,S0} = 4'b0010
                        : A3))     // {S3,S2,S1,S0} = 4'b0011
                  : (S1 == 0 
                     ? (S0 == 0 
                        ? A4       // {S3,S2,S1,S0} = 4'b0100
                        : A5)      // {S3,S2,S1,S0} = 4'b0101
                     : (S0 == 0 
                        ? A6       // {S3,S2,S1,S0} = 4'b0110
                        : A7)))    // {S3,S2,S1,S0} = 4'b0111
               : (S2 == 0 
                  ? (S1 == 0 
                     ? (S0 == 0 
                        ? A8       // {S3,S2,S1,S0} = 4'b1000
                        : A9)      // {S3,S2,S1,S0} = 4'b1001
                     : (S0 == 0 
                        ? A10      // {S3,S2,S1,S0} = 4'b1010
                        : A11))    // {S3,S2,S1,S0} = 4'b1011
                  : (S1 == 0 
                     ? (S0 == 0 
                        ? A12      // {S3,S2,S1,S0} = 4'b1100
                        : A13)     // {S3,S2,S1,S0} = 4'b1101
                     : (S0 == 0 
                        ? A14      // {S3,S2,S1,S0} = 4'b1110
                        : A15)))); // {S3,S2,S1,S0} = 4'b1111
endmodule 

The 16-bit barrel shifter generated the following waveform:


Related Solutions

Write a Verilog code to implement 16 bit LFSR
Write a Verilog code to implement 16 bit LFSR
Design and write a verilog code and testbench for a 16-bit RISC MIPS Processor on vivado...
Design and write a verilog code and testbench for a 16-bit RISC MIPS Processor on vivado and show waveform.
Design a 4-bit multiplier by using 4 bit full adder and write a verilog code.
Design a 4-bit multiplier by using 4 bit full adder and write a verilog code.
Design a 32 bit after using a single 4 bit using verilog code
Design a 32 bit after using a single 4 bit using verilog code
write the code for 16-bit ALU using vivado. Approach : A hierarchical design approach for 16-bit...
write the code for 16-bit ALU using vivado. Approach : A hierarchical design approach for 16-bit ALU using a Full Adders (16-bit), Multiplier (16-bit), Full Subtractor (16-bit), and shift left A register. include test bench. S0 S1 Alu-operation 0 0 addition 0 1 subtraction 1 0 multiplication 1 1 shift right
Design an 8-bit adder. Show the truth table, logic circuit, and Verilog code.
Design an 8-bit adder. Show the truth table, logic circuit, and Verilog code.
Design a 32 bit adder using a single 4 bit adder using verilog code
Design a 32 bit adder using a single 4 bit adder using verilog code
Write the Verilog code for a 12-bit shift register with ability to shift left or right,...
Write the Verilog code for a 12-bit shift register with ability to shift left or right, synchronized parallel load, asynchronous reset, and serial output? The register is able to load the 12-bit input value (at the positive edge of the clock) if the load signal is one, shift the value in register one bit to the right (at the positive edge of the clock) if the rss signal is one, shift the value in register one bit to the left(at...
Design an 8-bit adder. Show Verilog code and testbench.
Design an 8-bit adder. Show Verilog code and testbench.
Design of 4 Bit Adder/Subtractor using Loops (Behavior Modeling Style) (verilog Code) -
Design of 4 Bit Adder/Subtractor using Loops (Behavior Modeling Style) (verilog Code) -
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT