← ProblemsCircuits / Sequential Logic / Counters

4-digit decimal counter

15%countersvectors

Build a 4-digit BCD (binary-coded decimal) counter. Each decimal digit occupies one nibble of q:

  • q[3:0] — ones digit
  • q[7:4] — tens digit
  • q[11:8] — hundreds digit
  • q[15:12] — thousands digit

The ones digit increments every clock cycle; each upper digit increments only when all digits below it wrap. Also output the increment enables for the upper three digits, derived combinationally from the current count:

  • ena[1] = 1 when the ones digit equals 9
  • ena[2] = 1 when the ones and tens digits both equal 9
  • ena[3] = 1 when the ones, tens, and hundreds digits all equal 9

reset is synchronous, active-high, and clears the count to 0000.