Decade (Mod-10) Counter

Easy · Counters & Timers

Design a decade counter: a counter that counts 0, 1, 2, ..., 9, 0, 1, ... when enabled, with a wrap output that can be used as the enable (carry) of the next decade. Chaining such counters is how a digital clock or a BCD display counter is built.

Ports

PortDirWidthMeaning
clkinput1Clock.
rstinput1Synchronous, active-high reset (takes effect only at a rising edge of clk).
eninput1Count enable.
countoutput4Current count, 0..9 (registered).
wrapoutput1Combinational carry-out: wrap = en && (count == 9).

Behavior

count is a register updated at every rising edge of clk, in priority order:

  1. If rst = 1: count <= 0.
  2. Else if en = 1: count <= (count == 9) ? 0 : count + 1.
  3. Else: count holds its value.

count never takes the values 10..15.

wrap is combinational (no flip-flop): it is 1 during exactly those clock cycles in which count == 9 and en == 1, that is, in the cycle whose closing rising edge will roll the count over from 9 to 0. It must react to en within the same cycle. While rst = 1, the value of wrap is a don't-care (it is not checked).

Example

cyclerstencount during the cyclewrap
010?don't care
10100
2..9011..80
100090 (en = 0)
110191
120100

Sign up free to solve Decade (Mod-10) Counter in your browser.

More Counters & Timers problems