RTL Design #19 · 2026-10-12 · Clock dividers · Easy · about 10 min
A tick that comes one cycle late
tick_gen divides the clock down to a slower beat: tick is a registered output that is high for one cycle in every period cycles.
- Count the rising edges since the last tick, or since reset. On the edge that makes the count reach
period,tickgoes high for one cycle and the count starts again. So after reset withperiod = 4,tickgoes high on the 4th edge, the 8th, the 12th, … periodis 1 to 255. Withperiod = 1,tickstays high.periodmay change at any time. Only the count matters: if it has already reached or passed the newperiod,tickgoes high on the very next edge.- Reset is synchronous: it clears the count and
tick.
Run asks for a tick every 4 cycles and then changes the period twice. The ticks don't come when they should. Fix tick_gen.sv.
Write and run your answer in the browser. The hidden tests check it, and it’s free.