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.
| Port | Dir | Width | Meaning |
|---|---|---|---|
clk | input | 1 | Clock. |
rst | input | 1 | Synchronous, active-high reset (takes effect only at a rising edge of clk). |
en | input | 1 | Count enable. |
count | output | 4 | Current count, 0..9 (registered). |
wrap | output | 1 | Combinational carry-out: wrap = en && (count == 9). |
count is a register updated at every rising edge of clk, in priority order:
rst = 1: count <= 0.en = 1: count <= (count == 9) ? 0 : count + 1.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).
| cycle | rst | en | count during the cycle | wrap |
|---|---|---|---|---|
| 0 | 1 | 0 | ? | don't care |
| 1 | 0 | 1 | 0 | 0 |
| 2..9 | 0 | 1 | 1..8 | 0 |
| 10 | 0 | 0 | 9 | 0 (en = 0) |
| 11 | 0 | 1 | 9 | 1 |
| 12 | 0 | 1 | 0 | 0 |
Sign up free to solve Decade (Mod-10) Counter in your browser.