RTL Studio Open IDE

Shift & Bit Manipulation

Byte Rotate 32-bit

Combinational module that rotates a 32-bit word by 0 to 3 bytes.

About this block

Simulate it in the Verilog IDE

Easyverilogsimsyn

Byte Rotate 32-bit 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 rotates the four bytes of a 32-bit word by a specified count. It supports rotation amounts from 0 to 3 bytes. The implementation uses combinational logic for high throughput. The shift amount is controlled by a 2-bit input signal.

This module provides a simple and efficient byte rotation for 32-bit data. It is suitable for data packing and unpacking applications. The design is fully combinational and easy to integrate.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for Byte Rotate 32-bit.
  2. Read the Verilog module in the editor. The catalog line for this block: Combinational module that rotates a 32-bit word by 0 to 3 bytes.
  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

  • Rotates 32-bit data by 0, 1, 2, or 3 bytes.
  • Pure combinational logic with no clock dependency.
  • Supports arbitrary 32-bit input values.
  • Verified with comprehensive testbench cases.

Ports

Port NameDirectionWidthDescription
data_inInput32Input data word to be rotated
shift_bytesInput2Number of bytes to rotate right (0-3)
data_outOutput32Rotated output data word

Verification

The testbench covers all rotation counts and edge cases. All seven test cases passed successfully.

Test CaseInput DataShift BytesExpected OutputResult
TC10xFDEADBEEF00xFDEADBEEFPASS
TC20xFDEADBEEF10xEEFDEADBPASS
TC30xFDEADBEEF20xDBEEFDEAPASS
TC40xFDEADBEEF30xEADBEEFDPASS
TC50x1234567810x78123456PASS
TC60x0000000010x00000000PASS
TC70xFFFFFFFF30xFFFFFFFFPASS

More in Shift & Bit Manipulation

All Shift & Bit Manipulation blocks