Code Conversion
Binary→Thermometer Compare-Gen (8→9)
Generate-for compare converter from 8-bit binary to a 9-bit thermometer code slice.
About this block
Simulate it in the Verilog IDE
Binary→Thermometer Compare-Gen (8→9) is a Verilog reference block in the Code Conversion catalog. Encoders, decoders, priority encoders, and binary/gray converters. Marked Easy: a small block you can read, simulate, and synthesize in one sitting.
This IP core converts an 8-bit binary input into a 9-bit thermometer code output. It is designed for simple digital logic applications requiring unary representation, such as DAC control or simple priority encoders.
This module provides a reliable, synthesizable conversion from 8-bit binary to 9-bit thermometer code. It is suitable for low-complexity digital systems and has been fully verified using Icarus Verilog.
- Choose Open in IDE. RTL Studio loads the packaged workspace for Binary→Thermometer Compare-Gen (8→9).
- Read the Verilog module in the editor. The catalog line for this block: Generate-for compare converter from 8-bit binary to a 9-bit thermometer code slice.
- 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
- Full Range Support: Accepts 8-bit input (0-255).
- Thermometer Output: Produces a 9-bit output where the number of set bits equals the input value.
- Efficient Implementation: Uses a generate loop for clean, synthesizable logic.
- Verified: Fully tested with Icarus Verilog simulation covering edge cases and intermediate values.
Ports
| Port Name | Direction | Width | Description |
|---|---|---|---|
bin_in | Input | [7:0] | 8-bit binary input value |
thermo_out | Output | [8:0] | 9-bit thermometer code output |
Verification
The testbench covers ten distinct test cases including edge values:
- Input 0 results in all zeros in the output.
- Input 1 sets only the least significant bit.
- Input 255 sets all output bits to one.
- Intermediate values like 3, 4, 7, 8, 127, and 128 are also verified.
All tests passed successfully in the simulation log.
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 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