Code Conversion
8-Bit Priority Decoder (One-Hot to Binary) — L1 Upgrade — L2 Upgrade
An 8-bit priority decoder that converts one-hot input to binary index, featuring registered output, valid/ready interface, and skid buffer for backpressure handling.
About this block
Simulate it in the Verilog IDE
8-Bit Priority Decoder (One-Hot to Binary) — L1 Upgrade — L2 Upgrade is a Verilog reference block in the Code Conversion catalog. Encoders, decoders, priority encoders, and binary/gray converters. Marked Medium: more state or a wider datapath, still one workspace in the IDE.
The 8-Bit Priority Decoder is a high-performance digital IP core designed to convert an 8-bit one-hot encoded input vector into a 3-bit binary index. It identifies the most significant bit (MSB) set to logic high in the input, assigning higher priority to higher indices (bit 7 is highest priority).
This design is optimized for pipelined systems, featuring:
- Registered Output: Meets timing constraints and supports high-frequency operation.
- Valid/Ready Handshake: Standard flow control protocol for backpressure handling.
- Skid Buffer: Ensures data integrity by buffering pending results when the output is stalled, preventing data loss.
- Deterministic Latency: Predictable performance for system timing analysis.
This IP implements an 8-bit priority decoder that converts a one-hot encoded input vector into a 3-bit binary index. It identifies the most significant bit (MSB) set to logic high in the input. The design features a registered output stage with a valid/ready handshake protocol and a skid buffer to handle backpressure, ensuring data integrity in pipelined systems. It provides deterministic latency and robust flow control.
- Choose Open in IDE. RTL Studio loads the packaged workspace for 8-Bit Priority Decoder (One-Hot to Binary) — L1 Upgrade — L2 Upgrade.
- Read the Verilog module in the editor. The catalog line for this block: An 8-bit priority decoder that converts one-hot input to binary index, featuring registered output, valid/ready interface, and skid buffer for backpressure handling.
- 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
- One-Hot to Binary Conversion: Efficiently maps 8-bit one-hot input to a 3-bit binary index.
- Priority Logic: Higher indices have higher priority (bit 7 > bit 0).
- Flow Control: Supports backpressure via
valid_in/ready_inhandshake. - Skid Buffer: Handles output stalls without dropping input data.
- Asynchronous Reset: Active-low reset (
rst_n) for synchronous initialization. - Verified: Comprehensive testbench coverage with Icarus Verilog simulation.
Interface
| Signal Name | Direction | Width | Description |
|---|---|---|---|
clk | Input | 1 | Clock signal |
rst_n | Input | 1 | Asynchronous active-low reset |
data_in | Input | 8 | One-hot encoded input vector |
valid_in | Input | 1 | Input valid signal (asserted when data_in is valid) |
ready_in | Input | 1 | Output ready signal (driven by downstream consumer) |
valid_out | Output | 1 | Output valid signal (asserted when result is valid) |
result | Output | 3 | Binary index of the highest priority bit |
Architecture
The design consists of two main parts:
- Combinational Priority Encoder: Finds the MSB of
data_in. - Registered Stage with Skid Buffer: Handles valid/ready handshaking and stores pending data in a skid buffer when
ready_inis low.
More in Code Conversion
- 16-Bit Priority Encoder — L1 Upgrade — L2 Upgrade
- 4-Bit BCD to Binary Converter — L2 Upgrade
- 4-Bit Binary to BCD Converter (Shift-and-Add-3)
- 4-Bit Thermometer to Binary Encoder
- 8-Bit One-Hot Encoder
- 8-Bit Thermometer to Binary Encoder
- 8-Bit to 16-Bit Sign Extender
- 8-to-16 Zero Extension — L1 Upgrade
- Binary to Excess-3 4-bit — L1 Upgrade — L2 Upgrade
- Binary→Thermometer Compare-Gen (8→9)
- Binary→Thermometer LUT (4→15, Case) — L1 Upgrade — L2 Upgrade
- Gray-Code Incrementer 8-Bit
- N-Bit Gray to Binary Decoder
- N-bit Priority Encoder — L1 Upgrade — L2 Upgrade
- One-Hot→Binary Case Decode (4→2) — L1 Upgrade — L2 Upgrade
- One-Hot→Binary MSB-Priority OR Tree (8→3) — L1 Upgrade