A counter on a cricket scoreboard moves from one value to the next each time a run is scored. A binary counter is a sequential circuit that moves through a fixed series of binary values on every clock pulse. Counters are used in clocks, timers and address generation.
Counting with Flip-Flops
A counter made of n flip-flops can go through 2 to the power n states. A 4-bit binary counter counts from 0000 to 1111, which is 0 to 15, and then returns to 0000. It is therefore called a modulo-16 counter. The J-K flip-flops used in the counter have J = K = 1, so each one toggles when it receives a clock edge.
Definition: Binary counter. A sequential circuit made of flip-flops whose outputs move through the binary numbers in order with each clock pulse.
Asynchronous (Ripple) Counter
In an asynchronous counter only the first flip-flop receives the external clock. The clock of every following flip-flop is the output of the one before it. The change therefore ripples through the chain, and for this reason it is also called a ripple counter. It is simple, but the delay of every stage adds up, which limits the speed.
Synchronous Counter
In a synchronous counter all the flip-flops receive the same clock pulse at once. Logic gates decide which flip-flops should toggle. Flip-flop 0 always toggles, flip-flop 1 toggles when Q0 = 1, flip-flop 2 toggles when Q1 and Q0 are both 1, and flip-flop 3 toggles when Q2, Q1 and Q0 are all 1. Since all outputs change together, there is no accumulated delay, and the counter is faster.
Table 2.14: Comparison of asynchronous and synchronous counters
| Property | Asynchronous | Synchronous |
|---|---|---|
| Clock | Each stage clocked by the previous | Common clock for all |
| Speed | Slower, delay adds up | Faster |
| Extra gates | Not needed | Needed |
| Glitches in output | Possible | Rare |
Example 2.8: Counting sequence of a 4-bit counter
Problem: A 4-bit binary counter starts at 0101. Write the next four states and the state after 12 pulses.
Solution:
- The next states are 0110, 0111, 1000 and 1001.
- Starting at 5, after 12 pulses the count is (5 + 12) modulo 16 = 17 modulo 16 = 1.
Result: The next four states are 0110, 0111, 1000 and 1001, and after 12 pulses the counter shows 0001.
n = 5
for _ in range(4):
n = (n + 1) % 16
print(format(n, "04b"))
print(format((5 + 12) % 16, "04b"))
Output
0110
0111
1000
1001
0001
Common mistakes
- Believing that all flip-flops of a ripple counter change at the same instant.
- Forgetting that a 4-bit counter returns to 0000 after 1111.
- Using the wrong toggle condition for the higher flip-flops of a synchronous counter.
Key takeaways
- n flip-flops give a modulo 2 to the power n counter.
- In a ripple counter the output of one flip-flop clocks the next.
- In a synchronous counter every flip-flop has the same clock.
- A 4-bit counter counts from 0000 to 1111 and then returns to 0000.
Practice questions
- What is the modulus of a 4-bit binary counter?
- Why is a synchronous counter faster than a ripple counter?
- What is the state of a 4-bit counter one pulse after 1111?
Answers to the practice questions
-
- All its flip-flops change on the same clock pulse, so the stage delays do not add up.
-
Sources
- Official BCA syllabus Computer Architecture, course code 25BCA401DS02, Unit II
