Hard · State machines06. Sequence a SAR conversion
Control a 4-bit successive-approximation converter. Trial each DAC bit from most significant to least significant, retaining it when the comparator says the input is at least the trial voltage.
Specification
- Inputs clk, reset, start, cmp; outputs trial[3:0], busy, done.
- Synchronous reset sets trial=0, busy=0, done=0. Idle start sets trial=8 and busy=1.
- Each following rising edge accepts cmp for the current bit and sets the next trial bit. After four comparisons hold the final code, clear busy, and pulse done for one cycle.
- Ignore start while busy; cmp=1 means keep the current bit. All 16 input codes are tested.
97 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.