RTL Design #37 · 2026-10-30 · Clock gating · Medium · about 15 min
A clock gate that makes runt pulses
clk_gate is a latch-based clock gate: gclk is clk when en is 1 and stays low when en is 0.
enmay change at any time, including in the middle of a high phase ofclk.gclkmust never produce a runt pulse (a pulse shorter than the high phase ofclk) and must never be cut short.- A pulse is whole or it isn't there. The value of
enthat counts for a rising edge ofclkis the one it had whenclkwas last low. A change ofenwhileclkis high only takes effect from the next rising edge. enis a plain input: don't register it with a flip-flop, which would delay it by a whole cycle.
Run drops en in the middle of a pulse and raises it in the middle of a high phase. Fix clk_gate.sv.
Write and run your answer in the browser. The hidden tests check it, and it’s free.