Make a mod-N counter
Place a Counter from the Memory library. Set Data Bits to enough bits for N minus 1, Maximum Value to N minus 1 in hex, and Action On Overflow to Wrap around. Connect a clock and an output pin.
For N = 60: Data Bits 6, Maximum Value 0x3B.
Describe this circuit
Components: Input pin CLK; Counter 1; Output pin Q; Output pin C.
- Input pin CLK connects to Counter 1 (net CLK, clk).
- Counter 1 connects to Output pin Q (net q, Q), 4 bits wide.
- Counter 1 connects to Output pin C (net cy, C).
Download circ-counter-mod-10.circ.
What happens at the maximum: Action On Overflow
| # | Tick | Wrap around | Stay at value | Continue counting | Load next value |
|---|---|---|---|---|---|
| 0 | 000 | 000 | 000 | 000 | |
| 1 | 001 | 001 | 001 | 001 | |
| 2 | 010 | 010 | 010 | 010 | |
| 3 | 011 | 011 | 011 | 011 | |
| 4 | 100 | 100 | 100 | 100 | |
| 5 | 101 | 101 | 101 | 101 | |
| 6 | 000 | 101 | 110 | 010 | |
| 7 | 001 | 101 | 111 | 011 | |
| 8 | 010 | 101 | 000 | 100 | |
| 9 | 011 | 101 | 001 | 101 | |
| 10 | 100 | 101 | 010 | 010 | |
| 11 | 101 | 101 | 011 | 011 | |
| 12 | 000 | 101 | 100 | 100 |
Counting down with Wrap around, the counter went 0 to 5 (F43). The Carry is 1 while the value is 0 when counting down.
The control pins
| Output | out | Output: current value of counter |
|---|---|---|
| Data | in | Data: value to load into counter |
| Clock | in | Clock: value may update on trigger |
| Clear | in | Clear: when 1, resets to 0 asynchronously |
| Load | in | Load: when 1, loads from data input |
| Up Down | in | Up Down: when 1, counter increments, when 0, counter decrements |
| Enable | in | Enable: when 1, counter increments or decrements |
| Carry | out | Carry: is 1 when value reaches maximum (minimum if decrementing) |
No rows match.
In our runs, an Up Down input left unconnected counted up and an unconnected count enable counted (the units counter in the cascade below has no enable wire). We did not test Load or Clear.
Up/down counting
Describe this circuit
Components: Input pin CLK; Input pin UD; Counter 1; Output pin Q.
- Input pin CLK connects to Counter 1 (net CLK, clk).
- Input pin UD connects to Counter 1 (net UD, ud).
- Counter 1 connects to Output pin Q (net q, Q), 4 bits wide.
Download circ-counter-up-down.circ.
Cascading counters for more digits
Use two counters: units with maximum 9 and tens with maximum 5. Connect the units Carry to the tens count enable and give both the same clock. Do not feed the carry into the clock.
Describe this circuit
Components: Input pin CLK; Counter units; Counter tens; Output pin U; Output pin T.
- Input pin CLK connects to Counter units, Counter tens (net CLK, clk).
- Counter units connects to Output pin U (net u, U), 4 bits wide.
- Counter units connects to Counter tens (net cu).
- Counter tens connects to Output pin T (net t, T), 4 bits wide.
Download circ-counter-cascade-00-59.circ. For the full clock see Digital clock.
Why the counter adds 2, skips, or resets by itself
We have not reproduced these, so we only list what to check: that the clock reaches the counter once per step (not through a gate), that nothing feeds the carry back into the clock, that you press Ctrl+F9 for a full cycle (Clock and simulation), and that Clear is not wired to a floating or glitching signal.
Counters from flip-flops
For labs that require it, build a counter from flip-flops; we have not published a tested version yet. TTL counters are on TTL 7400 series.
Counter in older versions and course handouts
| Feature | 2.7.1 | 5.0.0 |
|---|---|---|
| Action On Overflow options | 2.7.1: untested | 5.0.0: yeswrap, stay, continue, load (F43) |
| Appearance | 2.7.1: untested | 5.0.0: yesa large block with labelled pins |
| Ports at 8 bits | 2.7.1: untested | 5.0.0: yes8 ports |
Cells say untested where we did not run 2.7.1. See also all components.