RTL Studio Open IDE

Shift & Bit Manipulation

32-Bit Barrel (Nop / LSL / LSR / ROL)

Combinational 32-bit barrel with op encoding: pass-through, logical left, logical right, and rotate left.

About this block

Simulate it in the Verilog IDE

Easyverilogsimsyn

32-Bit Barrel (Nop / LSL / LSR / ROL) is a Verilog reference block in the Shift & Bit Manipulation catalog. Shifters, rotators, bit masks, and bitwise manipulation blocks. Marked Easy: a small block you can read, simulate, and synthesize in one sitting.

This IP core implements a fully combinational 32-bit barrel shifter capable of logical shifts and rotate operations. It supports four distinct operation modes controlled by a 2-bit opcode: No-Op, Logical Left Shift, Logical Right Shift, and Rotate Left. The design is optimized for synthesis, using parallel computation and a multiplexer structure to ensure low latency and high performance. It is suitable for integration into datapaths requiring fast bitwise manipulation.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for 32-Bit Barrel (Nop / LSL / LSR / ROL).
  2. Read the Verilog module in the editor. The catalog line for this block: Combinational 32-bit barrel with op encoding: pass-through, logical left, logical right, and rotate left.
  3. Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
  4. Run Yosys in the same IDE for a generic netlist. Sky130 liberty mapping is a separate Pro library option.

RTL Studio is the Verilog simulator and IDE around this block: Slang lint, Verilator, VCD waveforms, and Yosys, in the browser. Simulation guide · Yosys guide.

Features

  • Data Width: 32-bit input and output.
  • Shift Amount: 5-bit input, supporting shifts from 0 to 31.
  • Operation Modes:

- No Op: Passes input directly to output. - Logical Left Shift (LLS): Shifts left, filling vacated bits with zeros. - Logical Right Shift (LRS): Shifts right, filling vacated bits with zeros. - Rotate Left (RLL): Shifts left with wrap-around behavior.

  • Architecture: Fully combinational, no clock dependency.
  • Verification: Includes a comprehensive testbench verifying all modes and edge cases.

Interface

Port NameDirectionWidthDescription
dataInput32Input data vector
amountInput5Shift/Rotate amount (0-31)
opInput2Operation selector
resultOutput32Output result vector

Architecture

The module uses a parallel computation structure. It calculates all four possible results simultaneously. A multiplexer selects the final result based on the op signal.

Integration

### Instantiation Example

To instantiate this module in your design, use the following Verilog code:

### Synthesis Notes

  • The design is fully combinational.
  • Ensure that amount is within the valid range [0, 31].
  • The op signal should be driven by a stable value to avoid glitches in the output.
  • For optimal timing, consider adding pipeline registers if this IP is part of a critical path.

Verification

The design includes a comprehensive testbench (tb/tb_shifter_rotate_32bit.v).

### Running Simulation

  1. Open your preferred Verilog simulator (e.g., ModelSim, Vivado Simulator, Icarus Verilog).
  2. Compile the source file rtl/shifter_rotate_32bit.v and the testbench tb/tb_shifter_rotate_32bit.v.
  3. Run the simulation.

### Test Cases

Test CaseDescriptionExpected Result
TC1No OpInput passed unchanged
TC2Logical Left Shift00000001 << 4 equals 00000010
TC3Logical Right Shift80000000 >> 4 equals 08000000
TC4aRotate Left (1 bit)00000001 rotates to 00000002
TC4bRotate Left (MSB)80000000 rotates to 00000001
TC4cRotate Left (0 bits)Input passed unchanged
TC4dRotate Left (31 bits)00000001 rotates to 80000000

All test cases passed successfully in simulation. The simulation log confirms zero errors.

More in Shift & Bit Manipulation

All Shift & Bit Manipulation blocks