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 | in | 1 bit | Clock |
rst | in | 1 bit | Synchronous reset (active high) |
start | in | 1 bit | Begin one staircase |
step | in | 12-bit unsigned | Increment between codes |
dac_data | out | 12-bit vector | DAC data pins |
wr_n | out | 1 bit | DAC write strobe, active low and idle high |
busy | out | 1 bit | High while a staircase runs |
done | out | 1 bit | One-clock pulse on the final dwell's last clock |
Behavior
- A request from
startis accepted only while idle, and its staircase begins on the next clock stepis captured at acceptance- Later changes to
stepdo not affect a running staircase - Any
startassertion whilebusyis high is ignored busygoes high at acceptance and remains high through the final dwell's last clock- A captured
stepof 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_datatakes the new code whilewr_nis high - On dwell clock 2,
wr_ngoes low whiledac_dataholds the code - On dwell clock 3,
wr_nreturns high whiledac_datastill holds the code - On dwell clock 4,
wr_nremains high anddac_datastill holds the code - The DAC latches on the rising edge of
wr_n, which occurs on dwell clock 3 dac_datais stable from the clock before that edge through the clock after itdonepulses for exactly one clock, on dwell clock 4 of the final codebusyremains high during thedonepulse- On the next clock,
busyanddonefall together, and the unit becomes idle - While idle,
wr_nis high, and both status outputs are low rsthigh at any rising edge setsdac_datato zero, raiseswr_n, 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, 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_nedge - It checks the final
donepulse whilebusyremains high, followed by their shared falling edge - It asserts reset during different dwell phases and checks that no cancelled staircase resumes
Constraints
everything is synchronous to clk; inputs are sampled on rising edges, and all outputs are registered.
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.