Code Conversion
Binary→Thermometer LUT (4→15, Case) — L1 Upgrade — L2 Upgrade
A registered 4-bit to 15-bit thermometer code converter with valid/ready interface and skid buffer for backpressure handling.
About this block
Simulate it in the Verilog IDE
Binary→Thermometer LUT (4→15, Case) — L1 Upgrade — L2 Upgrade is a Verilog reference block in the Code Conversion catalog. Encoders, decoders, priority encoders, and binary/gray converters. Marked Hard: a larger reference. Simulate the packaged testbench before you change the RTL.
This IP core converts a 4-bit binary input into a 15-bit thermometer-encoded output. It features a registered output path for improved timing closure and a Valid/Ready interface with a skid buffer to handle backpressure gracefully.
This IP provides a robust binary-to-thermometer conversion with flow control.
The registered output and skid buffer ensure reliable operation in pipelined designs.
- Choose Open in IDE. RTL Studio loads the packaged workspace for Binary→Thermometer LUT (4→15, Case) — L1 Upgrade — L2 Upgrade.
- Read the Verilog module in the editor. The catalog line for this block: A registered 4-bit to 15-bit thermometer code converter with 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
- Input: 4-bit binary vector (
data_in[3:0]). - Output: 15-bit thermometer vector (
data_out[14:0]). - Interface: AXI-like Valid/Ready handshaking.
- Skid Buffer: Prevents data loss when the consumer is not ready (
ready_inis low). - Registered Output: Improves timing closure by registering the final output.
- Reset: Active-low synchronous reset (
rst_n).
Ports
| Port Name | Direction | Width | Description |
|---|---|---|---|
clk | Input | 1 | Clock input |
rst_n | Input | 1 | Active-low reset |
valid_in | Input | 1 | Input valid signal |
data_in | Input | [3:0] | 4-bit binary input |
ready_in | Input | 1 | Output ready signal |
valid_out | Output | 1 | Output valid signal |
data_out | Output | [14:0] | 15-bit thermometer output |
Architecture
The module consists of three main stages:
- Combinational LUT: Maps the 4-bit input to a 15-bit thermometer pattern using a
casestatement. - Skid Buffer: Stores the input data (
data_in) and a valid flag whenready_inis deasserted. This ensures no data is lost during backpressure. - Registered Output: Registers the LUT result or the skid buffer data to produce
valid_outanddata_out.
### Data Flow
- If
valid_inis high andready_inis high, the data passes through the LUT and is registered. - If
valid_inis high andready_inis low, the data is stored in the skid buffer.valid_outremains low. - When
ready_inbecomes high, the skid buffer drains its stored data to the output.
Verification
The testbench verifies:
- TC1: Basic pass-through for all 16 input values (0-15).
- TC2: Backpressure hold and drain logic.
All tests are designed to pass successfully under normal operating conditions.
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 Priority Decoder (One-Hot to Binary) — L1 Upgrade — L2 Upgrade
- 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)
- 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