Shift & Bit Manipulation
Bitfield Pack Insert 32-bit
Combinational module to insert a variable-width field into a 32-bit data word at a specified offset.
About this block
Simulate it in the Verilog IDE
Bitfield Pack Insert 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 provides a robust solution for dynamic bitfield manipulation.
It is optimized for combinational performance without pipeline stages.
Use this module when you need to update specific bit ranges in a 32-bit word dynamically.
- Choose Open in IDE. RTL Studio loads the packaged workspace for Bitfield Pack Insert 32-bit.
- Read the Verilog module in the editor. The catalog line for this block: Combinational module to insert a variable-width field into a 32-bit data word at a specified offset.
- Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
- 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
- Variable Field Widths: Supports widths from 0 to 32 bits.
- Variable Offsets: Supports insertion offsets from 0 to 31 bits.
- Edge Case Handling: Gracefully handles zero-width fields (no change to output).
- Combinational Logic: Fully synchronous-free, ensuring minimal latency.
Ports
| Port Name | Direction | Width | Description |
|---|---|---|---|
data_in | Input | 32 | Input data word to be modified |
field_in | Input | 32 | Field value to insert |
offset | Input | 5 | Bit position where the field starts (0-31) |
width | Input | 5 | Number of bits to insert (0-32) |
data_out | Output | 32 | Modified data word |
Verification
The testbench covers five key scenarios to ensure correctness:
- TC1: Inserts an 8-bit field at offset 0.
- TC2: Inserts a 4-bit field at offset 12.
- TC3: Inserts a 16-bit field at offset 16.
- TC4: Inserts a 1-bit field at offset 31.
- TC5: Verifies that a 0-width field results in no change to the output.
All test cases passed successfully in the simulation log.
More in Shift & Bit Manipulation
- 16-Bit Bidirectional Shift Register (L/R + Load)
- 32-Bit Barrel (Nop / LSL / LSR / ROL)
- 32-Bit Funnel Shifter
- 32-bit Synthesizable Barrel Shifter — L2 Upgrade
- 8-Bit Barrel (Shift/Rotate × Left/Right) — L1 Upgrade — L2 Upgrade
- 8-Bit Bit Reversal (Endianness Independent) — L1 Upgrade
- 8-Bit Bit Reversal (Endianness Swap) — L1 Upgrade — L2 Upgrade
- 8-Bit Byte-Swap (Endianness Converter) — L1 Upgrade
- 8-Bit Parallel-to-Serial Converter
- 8-Bit Uni-Dir Shift Register (Load + SI) — L1 Upgrade — L2 Upgrade
- Arithmetic Right Shift 8-Bit — L1 Upgrade
- Bit-Field Extract 16→8
- Byte Rotate 32-bit
- Circular Shift Param 8-bit
- Funnel Shift Merge 16-bit — L2 Upgrade
- Nibble Interleave / Deinterleave 16-bit — L2 Upgrade