PadhaikoAll subjects

Registers and Counters

Digital Logic (ENEX 152)

Open in the Padhaiko app

6.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.

6.2 SISO, SIPO, PISO and PIPO registers

Shift registers are named by the way data enters and leaves.

Shift Register Types
TypeData inData outClock pulses to load n bitsTypical use
SISOSerialSerialnDelay line, serial transmission
SIPOSerialParallelnSerial to parallel converter (receiver)
PISOParallelSerial1 load, then n shiftsParallel to serial converter (transmitter)
PIPOParallelParallel1Storage 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.

Serial-in Shift Right Register (data 1, 0, 1, 1 entered in this order)
Clock pulseSerial inputQ3Q2Q1Q0
Initial-0000
111000
200100
311010
411101

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

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.

Count Sequence of a Decade Counter
ClockQ3Q2Q1Q0Decimal
000000
100011
200102
300113
401004
501015
601106
701117
810008
910019
101010reset 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

Synchronous versus asynchronous counters

Asynchronous and Synchronous Counters
FeatureAsynchronous (ripple)Synchronous
ClockOnly the first stageAll stages together
SpeedSlow (delay adds up)Fast
GlitchesPresent in decodingAlmost none
HardwareLess, no gatesMore, extra gates
Maximum frequency

6.8 Register and counter applications


Worked Examples

Example 1

1 (8 marks)

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, ).

Excitation of the Mod-6 Counter
Present ABCNext ABCT2T1T0
000001001
001010011
010011001
011100111
100101001
101000101

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).

Answer:

, , .

Example 2

2 (6 marks)

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, .

Answer:

After 4 pulses the register holds 1011 (first bit 1 at ). Serial load takes 2 s, parallel load takes 0.5 s.

Example 3

3 (8 marks)

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.

Answer:

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

Question 1

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.

Answer:

4 flip-flops; NAND of and ; 5 kHz.

Question 2

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.

Answer:

Ripple counter 8.33 MHz; synchronous counter 25 MHz.

Question 3

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.

Answer:

Johnson: 000, 100, 110, 111, 011, 001 (6 states). Ring: 1000, 0100, 0010, 0001 (4 states).

Question 4

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.

Answer:

, , .

Question 5

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).

Answer:

Serial output (LSB first): 0, 1, 0, 1.

← Sequential Logic CircuitsSequential Machine Designs →