Practice
Pressure Rig DAC Staircase
Bracken Gauge Works uses a pressure calibration rig to check rows of brass-faced gauges. A 12-bit parallel DAC feeds a reference sensor with a steady test level.
The DAC datasheet is strict. The data pins must settle before the write strobe rises. They must also remain stable after that edge.
The shipped sequencer changed the code as it raised the strobe. The DAC caught half-changed values, so the reference voltage skipped steps on its way up.
Red pen marks covered the bent curves on the morning's calibration sheets.
Your task: build a stepper that walks from zero to full scale. Give every code four clocks, and treat the DAC timing rules as law.
Interface
| Port | Direction | Type | Description |
|---|---|---|---|
clk_i | in | 1 bit | Clock |
rst_i | in | 1 bit | Synchronous reset (active high) |
start_i | in | 1 bit | Begin one staircase |
step_i | in | 12-bit unsigned | Increment between codes |
dac_data_o | out | 12-bit vector | DAC data pins |
wr_n_o | out | 1 bit | DAC write strobe, active low and idle high |
busy_o | out | 1 bit | High while a staircase runs |
done_o | out | 1 bit | One-clock pulse on the final dwell's last clock |
Behavior
- A request from
start_iis accepted only while idle, and its staircase begins on the next clock step_iis captured at acceptance- Later changes to
step_ido not affect a running staircase - Any
start_iassertion whilebusy_ois high is ignored busy_ogoes high at acceptance and remains high through the final dwell's last clock- A captured
step_iof zero counts as one - The first emitted code is zero
- Each later code adds the captured effective step to the previous code
- The final emitted code is always exactly
0xFFF - An addition that would pass
0xFFFsaturates to0xFFF - The code
0xFFFis emitted once and only once, as the staircase's last code - Every code has a fixed four-clock dwell, and consecutive dwells run back to back
- On dwell clock 1,
dac_data_otakes the new code whilewr_n_ois high - On dwell clock 2,
wr_n_ogoes low whiledac_data_oholds the code - On dwell clock 3,
wr_n_oreturns high whiledac_data_ostill holds the code - On dwell clock 4,
wr_n_oremains high anddac_data_ostill holds the code - The DAC latches on the rising edge of
wr_n_o, which occurs on dwell clock 3 dac_data_ois stable from the clock before that edge through the clock after itdone_opulses for exactly one clock, on dwell clock 4 of the final codebusy_oremains high during thedone_opulse- On the next clock,
busy_oanddone_ofall together, and the unit becomes idle - While idle,
wr_n_ois high, and both status outputs are low rst_ihigh at any rising edge setsdac_data_oto zero, raiseswr_n_o, clears both status outputs, and returns the unit to idle- Reset cancels all staircase progress, and nothing resumes afterward
What the bench checks
- The testbench checks idle acceptance, next-clock startup, captured
step_i, and ignored requests while busy - It checks code order with steps that advance normally, equal zero, land on
0xFFF, or pass it - It checks that every staircase starts at zero and emits
0xFFFexactly once - It checks all four dwell clocks cycle by cycle, including data stability around the rising
wr_n_oedge - It checks the final
done_opulse whilebusy_oremains high, followed by their shared falling edge - It asserts reset during different dwell phases and checks that no cancelled staircase resumes
Constraints
TIMING: everything is synchronous to
clk_i; inputs are sampled on rising edges, and all outputs are registered.
SCOPE: this models the DAC's digital pins and timing contract. The analog output, reference, and settling are out of scope.
Do not add ports.
Click Run to execute your code. Output will appear here.