RTL Design #29 · 2026-10-22 · Up/down counters · Easy · about 10 min

A counter that counts when asked to do both

updown_sat is a 4-bit counter with synchronous active-low reset to 0, and the inputs up and down. At each rising clock edge:

  • up alone adds 1, but not past 10: at 10 it stays at 10.
  • down alone subtracts 1, but not below 0: at 0 it stays at 0.
  • up and down together, or neither, leave cnt unchanged.

Run counts up, then pushes up and down together, and the count moves when it shouldn't. Fix updown_sat.sv.

Write and run your answer in the browser. The hidden tests check it, and it’s free.