Seven, then⦠six, four, zero, eight
Last class's homework: two T flip-flops, each clocked by the one before, count. Add two more and you have a 4-bit counter.
It sits at 0111 = 7. The clock edge arrives. What values appear on the four outputs, in order, before it reaches 8?
Each flip-flop takes tpd = 20 ns to respond, and each is clocked by the previous output. List the outputs at 0, 20, 40, 60 and 80 ns.
Argue it in pairs for two minutes. There may be more than one defensible answer.
The ripple counter: each flip-flop clocks the next
- n T flip-flops with T = 1 (or JK with J = K = 1). The clock drives only FF0; every Qi is the clock of FFi+1.
- Negative-edge flip-flops: FFi+1 toggles when Qi falls 1 β 0, exactly when binary counting carries: an up-counter. Clock the next stage from QΜi (or use positive-edge flip-flops) and it counts down.
- Every stage halves the frequency: a free frequency divider.
Ideal (zero-delay) waveforms: Q2Q1Q0 counts 0, 1, 2 β¦ 7. The real ones are shifted by one tpd more at each stage.
Live lab: watch the carry ripple
Worked example: ripple delay and fmax
Given
A 4-bit ripple up-counter of negative-edge T flip-flops, tpd = 20 ns each. It holds 0111. The count is read by a circuit that needs it stable for a strobe time ts = 30 ns before the next edge.
Find
(a) The output values and when they occur after the clock edge. (b) The maximum clock frequency.
One slot = 20 ns. The clock falls at the marker.
Method: ripple counter delay (Mano; Taub & Schilling)
Solution
Predict the answer first. Then reveal one step at a time.
Mod-N: cut the count short
- Choose the fewest flip-flops with 2n β₯ N. Detect the state N with a NAND of the Q's that are 1 in N, and feed it to every flip-flop's asynchronous CLRΜ.
- Decade (mod-10): N = 10 = 1010, so NAND(Q3, Q1). The counter reaches 1010, is cleared to 0000 within a few nanoseconds, and counts 0 β¦ 9.
- Price: state 1010 still appears, briefly, as a glitch. The 74LS90 decade counter is built this way.
In the counter lab (slide 3), pick Mod-10 and watch 9 β 8 β 10 β 0: the 10 lasts one gate delay.
Your turn Β· 1: a mod-6 ripple counter
Design a mod-6 ripple up-counter from negative-edge T flip-flops with active-low CLRΜ.
(a) How many flip-flops? (b) Which gate drives CLRΜ? (c) The clock is 60 kHz: what are the frequency and duty cycle of the top output?
Work it out first.
Press Solve when the class has an answer.
Synchronous counters: one clock for everyone
- All flip-flops share the clock, so all change together, one tpcq after the edge. No ripple, no false states.
- Binary up-counter: a bit toggles when every bit below it is 1:
The minimum period no longer grows with n (with parallel AND gates). Any sequence at all can be designed with the excitation table:
| Q β QβΊ | J K | D | T |
|---|---|---|---|
| 0 β 0 | 0 x | 0 | 0 |
| 0 β 1 | 1 x | 1 | 1 |
| 1 β 0 | x 1 | 0 | 1 |
| 1 β 1 | x 0 | 1 | 0 |
Excitation = the characteristic table read backwards: "I need this transition; what inputs give it?" JK has the most x's, so the simplest gates.
Worked example: a synchronous mod-5 counter from JK flip-flops
Given
JK flip-flops, common clock. Count 0, 1, 2, 3, 4, 0, β¦
Find
J and K for each flip-flop, and what happens if it powers up in an unused state.
| QβQβQβ | QβΊ | JβKβ | JβKβ | JβKβ |
|---|---|---|---|---|
| 000 | 001 | 0x | 0x | 1x |
| 001 | 010 | 0x | 1x | x1 |
| 010 | 011 | 0x | x0 | 1x |
| 011 | 100 | 1x | x1 | x1 |
| 100 | 000 | x1 | 0x | 0x |
| 101β111 | x | xx | xx | xx |
Method: counter design with the JK excitation table (Mano)
Solution
Predict the answer first. Then reveal one step at a time.
Live lab: the same count, synchronously
Registers: words that move
- A register is n D flip-flops on one clock: it stores an n-bit word. Connect each Q to the next D and it shifts one place per edge.
- Four ways in and out: SISO (delay line), SIPO (serial β parallel: receive a UART byte), PISO (parallel β serial: send it), PIPO (plain storage).
- Close the loop and it counts: ring counter (Qnβ1 β D0, one circulating 1, n states) and Johnson counter (QΜnβ1 β D0, 2n states).
| Counter (n flip-flops) | States | Decode |
|---|---|---|
| Binary | 2n | n-input AND |
| Ring | n | none (one-hot) |
| Johnson | 2n | 2-input AND |
Ring and Johnson counters have unused states too (16 β 4 = 12 for a 4-bit ring). Power up in one and it never recovers unless you design it to.
Live lab: shift, ring, twist
Recent states, newest first:
Your turn Β· 2: the Johnson counter
A 4-bit shift register, QΜβ fed back to Dβ, starts at 0000 and is clocked at 8 MHz.
(a) List the states until it repeats. (b) Frequency and duty of each output? (c) Show that each state can be decoded with a 2-input gate.
Work it out first.
Press Solve when the class has an answer.
Real world: clocks, signs and the prayer-time display
The digital clock above the mosque door or on the wall of a Dhaka pharmacy is counters all the way down: a 32.768 kHz crystal, a 15-stage ripple divider (215 = 32,768) giving exactly 1 Hz, then mod-10 and mod-6 counters for seconds and minutes, mod-12 or mod-24 for hours.
The scrolling LED sign over a shop is shift registers: a microcontroller pushes each column serially into a chain of 74HC595s, then latches all outputs at once.
A pulse oximeter or ECG monitor computes heart rate by counting clock ticks between beats: a synchronous counter, read on a known edge. A ripple counter read mid-change could report 0 ms or 1000 ms for one beat.
Pop quiz
Question 1 / 5
A 5-bit ripple counter is clocked at 1 MHz. The frequency at the last output (Q4) isβ¦
Three things to remember
Ripple: each flip-flop clocks the next. Simple, divides by 2n, but settles nΒ·tpd after the edge and shows false states.
Synchronous: one clock, design with the excitation table (JK: 0x, 1x, x1, x0), check unused states. Mod-N ripple: NAND the 1-bits of N into CLRΜ.
Registers store and shift words (SISO, SIPO, PISO, PIPO). Ring: n states, Johnson: 2n states, decoded by 2-input gates.
Homework: design a synchronous mod-6 counter (0 β¦ 5) with D flip-flops and check its unused states. Next class: memories and PLAs.
Class Test 1
Covers Weeks 1β4
Diode gates (DRL), RTL and DTL Β· the BJT switch and MOS gates Β· TTL, ECL, IΒ²L and CMOS Β· latches and flip-flops (timing diagrams, characteristic equations, setup and hold).
Rules
Closed book, answer on the question paper. Calculators allowed, phones away. Show the working for the calculation questions.
Questions are handed out on paper. Today's counters are not in this test.