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 en is 1, din is loaded into stage 0, and every other stage k takes the value that stage k-1 held just before the edge. So after one enabled edge, stage 0 holds the new din and stage 1 holds what stage 0 held before.
  • On edges where en is 0, nothing moves.
  • dout is the stage picked by sel (0 to 3), and it follows sel at once, without waiting for a clock.
  • rst_n is a synchronous active-low reset that clears all four stages to 0. It wins over en.

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.