RTL Design #31 · 2026-10-24 · Beat counting · Easy · about 10 min
A packet marker that counts stalled beats
beat_last marks the last beat of a fixed-length packet on a valid/ready stream. A packet is LEN beats long, and idx is the position of the beat currently offered, from 0 to LEN-1.
lastis high whilevalidis high and the beat offered is the last of its packet (idx == LEN-1).- A beat is transferred in a cycle where
validandreadyare both high. After the last beat is transferred, the next one is position 0. - A beat that is offered but not accepted is offered again, in the same position.
- Reset (synchronous, active low) sets
idxto 0.
With no back-pressure the packets come out the right length. Once the receiver stalls, last starts showing up in the wrong places. Fix beat_last.sv.
Write and run your answer in the browser. The hidden tests check it, and it’s free.