Medium · Data converters04. Encode a flash ADC
Seven comparators form a 3-bit flash ADC. Convert their thermometer word into a binary code and identify invalid bubble patterns.
Specification
- Input therm[6:0]; outputs code[2:0] and valid.
- Valid words are 0000000, 0000001, 0000011, …, 1111111. Code is the number of low-order ones.
- For any other word set valid=0 and code=0. All 128 patterns are checked.
128 supplied checksRun uses the testbench in tb.sv. Submit checks your design with the original supplied testbench, even if you edit tb.sv.
Practice results stay in this browser. They do not count as server-verified scores.
Explore the analog circuit →
Language and tools
Choose Verilog 2005 or SystemVerilog 2012. Icarus supports a subset of SystemVerilog; classes, UVM and full SVA are outside this runtime. Download the project to continue in OSS CAD Suite with Icarus, Yosys and GTKWave.
Open-source credits and runtime provenance
Drag the dividers to resize. Focus a divider and use its arrow keys for precise adjustments.