SystemVerilog #65 · 2026-11-27 · Blocking vs non-blocking in a shift chain · Easy · about 15 min
A delay line with a tap select
Write dly_tap in dly_tap.sv: a delay line of four 8-bit stages, numbered 0 to 3, with a selectable tap.
- On a rising clock edge where
enis 1,dinis loaded into stage 0, and every other stagektakes the value that stagek-1held just before the edge. So after one enabled edge, stage 0 holds the newdinand stage 1 holds what stage 0 held before. - On edges where
enis 0, nothing moves. doutis the stage picked bysel(0 to 3), and it followsselat once, without waiting for a clock.rst_nis a synchronous active-low reset that clears all four stages to 0. It wins overen.
Example, after reset, sel = 0, en = 1, din = 5, 6, 7 on three consecutive edges:
| after edge | din at the edge |
dout |
|---|---|---|
| 1 | 5 | 5 |
| 2 | 6 | 6 |
| 3 | 7 | 7 |
With sel = 2 the same input would show 0, 0, 5 after those edges: two stages further back.
Fill in dly_tap.sv. Run drives this example on sel = 0.
Write and run your answer in the browser. The hidden tests check it, and it’s free.