RTL Studio Open IDE

Shift & Bit Manipulation

Bit-Field Extract 16→8

Extracts an 8-bit field from a 16-bit input word using a barrel shifter and mask.

About this block

Simulate it in the Verilog IDE

Easyverilogsimsyn

Bit-Field Extract 16→8 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 purely combinational module that extracts an 8-bit field from a 16-bit input word.

It utilizes a barrel shifter to align the desired field to the least significant bits, followed by masking logic to isolate the 8-bit output.

This module is ideal for data packing, unpacking, and bit-field extraction tasks in communication protocols where low latency is critical.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for Bit-Field Extract 16→8.
  2. Read the Verilog module in the editor. The catalog line for this block: Extracts an 8-bit field from a 16-bit input word using a barrel shifter and mask.
  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.

Ports

Port NameDirectionWidthDescription
in_wordInput16Input data word containing the field to extract
offsetInput4Shift amount to align the field (0-15)
out_fieldOutput8Extracted 8-bit field

Architecture

The module operates in two stages:

  1. Alignment: A barrel shifter right-shifts the 16-bit input word by the amount specified in offset.
  2. Extraction: The lower 8 bits of the shifted word are assigned to the output.

Verification

The IP has been verified with six test cases covering various offsets and input patterns. The testbench tb/tb_bit_field_extract_16to8.v drives these vectors and checks for mismatches.

### Test Cases

Test CaseInput (in_word)Offset (offset)Expected Output (out_field)Description
TC116'hDEAD08'hADExtract LSBs
TC216'hDEAD48'hEAExtract middle bits
TC316'hDEAD88'hDEExtract MSBs
TC416'hFFFF08'hFFAll Ones
TC516'h000088'h00All Zeros
TC616'hAAAA18'h55Alternating Pattern

### Running Simulation

  1. Compile the RTL and Testbench.
  2. Run the simulation.
  3. Check the log output for PASS messages.

Expected Log Output:

More in Shift & Bit Manipulation

All Shift & Bit Manipulation blocks