Registers and Counters
Open in the Padhaiko app6.1 Register fundamentals, register types
A register is a group of flip-flops, one per bit, that stores a binary word and has a common clock. An -bit register uses flip-flops.
- Buffer (storage) register: loads all bits together on a clock edge and holds them. It uses D flip-flops, with a load or enable control.
- Shift register: moves the stored bits one position at every clock pulse, to the left or to the right.
- Bidirectional shift register: can shift either way, controlled by a left/right input.
- Universal shift register: has parallel load, shift left, shift right and hold (for example the IC 74194).
6.2 SISO, SIPO, PISO and PIPO registers
Shift registers are named by the way data enters and leaves.
| Type | Data in | Data out | Clock pulses to load n bits | Typical use |
|---|---|---|---|---|
| SISO | Serial | Serial | n | Delay line, serial transmission |
| SIPO | Serial | Parallel | n | Serial to parallel converter (receiver) |
| PISO | Parallel | Serial | 1 load, then n shifts | Parallel to serial converter (transmitter) |
| PIPO | Parallel | Parallel | 1 | Storage buffer |
In a SISO/SIPO register made of D flip-flops, the output of each stage is joined to the input of the next, and the serial data is applied to the first . After clock pulses the first bit entered is at the last stage. A PISO register has a gate at each input that selects between the parallel data (load mode) and the previous stage (shift mode).
Other forms: a ring counter feeds the last output back to the first input, so a single 1 circulates and the register has states. A Johnson (twisted-ring) counter feeds back of the last stage, giving states.
6.3 Data transfer timing diagrams
Serial transfer moves the word one bit per clock using one line, so bits need clock pulses. Parallel transfer moves all bits in one clock pulse using lines. Serial is cheap in wires; parallel is fast.
A timing diagram of a 4-bit SIPO register shows the clock, the serial input and the four outputs. Each rising clock edge moves every bit one stage to the right, so a bit entered at reaches after clock 1, after clock 2 and so on.
| Clock pulse | Serial input | Q3 | Q2 | Q1 | Q0 |
|---|---|---|---|---|---|
| Initial | - | 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 0 | 0 | 0 |
| 2 | 0 | 0 | 1 | 0 | 0 |
| 3 | 1 | 1 | 0 | 1 | 0 |
| 4 | 1 | 1 | 1 | 0 | 1 |
Here the data enters at and moves toward . After four pulses the register holds : the first bit entered (1) is at and the last bit (1) is at .
Transfer time: with a clock of frequency a serial transfer of bits takes , and a parallel transfer takes .
6.4 Asynchronous counters
A counter is a register that goes through a prescribed sequence of states on each clock pulse. In an asynchronous (ripple) counter the clock drives only the first flip-flop; each later flip-flop is clocked by the output of the previous one. The flip-flops therefore do not change at the same time: the change ripples through.
A 3-bit ripple up counter uses three T (or JK with ) flip-flops triggered on the falling edge, with clocking FF1 and clocking FF2. It counts 000, 001, 010, ..., 111 and returns to 000. Each stage halves the frequency, so a mod- counter divides the clock by .
Advantage: simple hardware. Disadvantages: the total delay is so the maximum clock frequency is low, and glitches appear in the decoded outputs while the change ripples.
6.5 Up, down and mod-n asynchronous counters
- Down counter: use of each stage to clock the next stage (with falling-edge flip-flops), or use with rising-edge flip-flops. The count falls 111, 110, ..., 000.
- Up-down counter: a control input selects (up) or (down) as the clock for the next stage, using a multiplexer-like gate.
- Mod- counter: a counter with states. The smallest number of flip-flops is the integer with . To count to and restart, a NAND gate detects the count and asynchronously clears all flip-flops.
Decade (mod-10) counter: four flip-flops count 0000 to 1001. At the count 1010 () a NAND gate with inputs and clears all flip-flops, so the state 1010 lasts only for a moment and the count returns to 0000.
| Clock | Q3 | Q2 | Q1 | Q0 | Decimal |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 1 |
| 2 | 0 | 0 | 1 | 0 | 2 |
| 3 | 0 | 0 | 1 | 1 | 3 |
| 4 | 0 | 1 | 0 | 0 | 4 |
| 5 | 0 | 1 | 0 | 1 | 5 |
| 6 | 0 | 1 | 1 | 0 | 6 |
| 7 | 0 | 1 | 1 | 1 | 7 |
| 8 | 1 | 0 | 0 | 0 | 8 |
| 9 | 1 | 0 | 0 | 1 | 9 |
| 10 | 1 | 0 | 1 | 0 | reset to 0 (Q3 and Q1 both 1) |
6.6 Synchronous counters
In a synchronous counter all flip-flops receive the same clock and change together. Combinational logic in front of the / (or ) inputs decides which flip-flops toggle at the next clock. Since no ripple occurs the maximum frequency is high and there are no decoding glitches, at the cost of extra gates.
For a binary up counter with T flip-flops: , , , . A flip-flop toggles when all lower bits are 1.
6.7 Up, down and mod-n synchronous counters
- Up-down counter: , and so on.
- Mod- counter design (excitation method): write the state table for , treat unused states as don't cares, read the required (or ) inputs from the excitation table, and minimise each with a K-map. The same steps are used for any sequence, such as 0, 2, 3, 6, 0.
Synchronous versus asynchronous counters
| Feature | Asynchronous (ripple) | Synchronous |
|---|---|---|
| Clock | Only the first stage | All stages together |
| Speed | Slow (delay adds up) | Fast |
| Glitches | Present in decoding | Almost none |
| Hardware | Less, no gates | More, extra gates |
| Maximum frequency |
6.8 Register and counter applications
- Frequency division and digital clocks: a chain of mod-10 and mod-6 counters divides a 1 Hz pulse into seconds, minutes and hours.
- Frequency counters and event counting: a counter counts input pulses in a fixed gate time.
- Serial and parallel data conversion: SIPO in a receiver, PISO in a transmitter (UART, SPI).
- Time delay: a shift register delays a signal by clock periods.
- Sequence generation and control: ring and Johnson counters give timing signals.
- Digital storage: buffer registers inside CPUs (accumulator, instruction register).
Worked Examples
1
Design a 3-bit synchronous mod-6 counter (counts 0 to 5) with T flip-flops, and verify its state sequence.
State table. Let . The states are 000, 001, 010, 011, 100, 101 and then back to 000. The states 110 and 111 are never reached: they are don't cares.
Find where each flip-flop must toggle (the T input is 1 when the bit changes, ).
| Present ABC | Next ABC | T2 | T1 | T0 |
|---|---|---|---|---|
| 000 | 001 | 0 | 0 | 1 |
| 001 | 010 | 0 | 1 | 1 |
| 010 | 011 | 0 | 0 | 1 |
| 011 | 100 | 1 | 1 | 1 |
| 100 | 101 | 0 | 0 | 1 |
| 101 | 000 | 1 | 0 | 1 |
Minimise with the don't cares 110, 111. (all rows). for the states 001 and 011, so . for the states 011 and 101; with the don't cares 111 the cells 011, 101, 111 give .
Check. From 011: , , , so all three bits toggle and 011 becomes 100. From 101: , , , giving 000 (the counter restarts at 0 after 5).
, , .
2
A 4-bit SIPO register is cleared and the serial data 1, 1, 0, 1 (first bit first) is shifted in, entering the left-most stage and moving right. Show the register after each pulse. If the clock is 2 MHz, how long does the serial load take, and how long would a parallel load take?
Shift table (, new bit enters ). Pulse 1: 1000. Pulse 2: 1100. Pulse 3 (bit 0): 0110. Pulse 4 (bit 1): 1011.
Times. Serial: 4 pulses at 2 MHz, so . Parallel: one pulse, .
After 4 pulses the register holds 1011 (first bit 1 at ). Serial load takes 2 s, parallel load takes 0.5 s.
3
Design a mod-10 (decade) ripple counter from JK flip-flops. State the number of flip-flops, the reset condition, and find the output frequency at and the frequency of the reset pulse train when the clock is 50 kHz.
Number of flip-flops. , so 4 flip-flops are needed.
Reset condition. The first count that must not be shown is 10 = 1010, where and for the first time. No count from 0 to 9 has both of them equal to 1. Hence a NAND gate with inputs and drives the asynchronous clear of all flip-flops: its output goes to 0 at 1010 and clears the counter to 0000.
Frequencies. The counter has 10 states, so it divides by 10. The complete count cycle repeats at kHz. The reset pulse appears once per cycle, so its repetition rate is also 5 kHz. is high only for the counts 8 and 9, so it is a 5 kHz wave with a duty cycle of 20 percent.
4 JK flip-flops; reset by NAND(, ) at 1010; counting frequency 5 kHz, the waveform is 5 kHz with a 20 percent duty cycle.
Exercises
Exercises: Registers and Counters
How many flip-flops are needed for a mod-12 counter? What gate detects the reset state if the counter is made asynchronous, and what is the output frequency for a 60 kHz clock?
, so 4 flip-flops are required.
No count from 0 to 11 has both and , and the first count that has is 12 = 1100. So a 2-input NAND gate with inputs and clears the counter at 12.
The counter divides by 12, so the output is kHz.
4 flip-flops; NAND of and ; 5 kHz.
Compare synchronous and asynchronous counters. A 4-bit ripple counter uses flip-flops with ns. What is the maximum clock frequency, and what is it for a synchronous counter whose AND gate delay is 10 ns?
Synchronous counters clock all stages together, so they are faster and glitch-free but need extra gates. Ripple counters need no gates but the delay adds up.
Ripple: the clock period must exceed ns, so MHz. Synchronous: period ns, so MHz.
Ripple counter 8.33 MHz; synchronous counter 25 MHz.
Write the state sequence of a 3-bit Johnson counter and of a 4-bit ring counter starting from the all-zero (Johnson) and 1000 (ring) states. How many states does each use?
Johnson counter (3 bits) feeds to the first stage: 000, 100, 110, 111, 011, 001, then 000 again. That is states.
Ring counter (4 bits) feeds back to the input: 1000, 0100, 0010, 0001 and back to 1000. That is states.
Johnson: 000, 100, 110, 111, 011, 001 (6 states). Ring: 1000, 0100, 0010, 0001 (4 states).
Design a 3-bit synchronous down counter using T flip-flops and verify that it counts 7, 6, 5, ..., 0, 7.
A bit toggles in a down counter when all lower bits are 0. So , and .
Check: from 000, , so all bits toggle and the next state is 111 (7). From 100, so again and the next state is 011 (3). From 111, only , so the next state is 110.
, , .
Explain the working of a PISO register. A 4-bit PISO is loaded with 1010 and shifted right with the serial output taken from . Give the serial output stream for four clock pulses.
A PISO has a mode (load/shift) control. When the control is load, the parallel data enters all flip-flops on one clock pulse. When the control is shift, each flip-flop takes the value of its neighbour, and the bits leave one at a time at the serial output.
With and the output at : before the first shift ; after pulse 1 the word is 0101 and ; after pulse 2 it is 0010 and ; after pulse 3 it is 0001 and . The serial stream starting from the first bit is 0, 1, 0, 1 (the LSB first).
Serial output (LSB first): 0, 1, 0, 1.