Home › Practice › RTL Design › Running lights
Running lights
EasyRTLsequential
Four lights in a row, exactly one on. The lit light moves along and wraps around, like a marquee sign.
Concept first. A shift register moves its bits one place on every clock edge. A ring counter connects the last bit back to the first, so a single 1 inside it circulates forever instead of falling off the end. Starting with one 1 and the rest 0 is called one-hot. Four flip-flops give four states, and each state is already a ready-made "which light is on" signal, so no decoder is needed. Draw the four states one under another and see which way the 1 travels.
What to build.
ring4(clk, rst, en)with outputq[3:0].rstis synchronous, active-high:qbecomes0001.- On a rising edge with
en = 1,qrotates left: 0001, 0010, 0100, 1000, then back to 0001. Withen = 0it holds.
No install and no sign-up needed. You write your answer in the editor and Nishkam checks it.