Sequential Logic Circuits
Open in the Padhaiko app5.1 Latches and flip-flops: SR, D, T and JK
A sequential circuit has outputs that depend on the present inputs and on the stored past (its state). The basic memory element is the bistable: a circuit with two stable states that stores one bit.
A latch is level sensitive: its output can change at any time while the enable (clock) is active. A flip-flop (FF) is edge triggered: it can change only at a clock edge. A latch or flip-flop has outputs and .
SR latch and SR flip-flop
An SR latch is two cross-coupled NOR gates (or NAND gates). sets to 1, resets to 0.
| S | R | Q next | Action |
|---|---|---|---|
| 0 | 0 | Q | No change (hold) |
| 0 | 1 | 0 | Reset |
| 1 | 0 | 1 | Set |
| 1 | 1 | Not allowed | Both outputs forced to 0, then the final state is unpredictable |
The NAND version has active-low inputs and and its forbidden condition is . A gated (clocked) SR latch adds two AND gates so that and act only while the clock is HIGH.
D flip-flop
The D (data/delay) flip-flop removes the forbidden state by making from a single input: the output copies at the clock edge, . It is used for storage and for shift registers.
T flip-flop
The T (toggle) flip-flop toggles when and holds when , so . With permanently it divides the clock frequency by 2.
JK flip-flop
The JK flip-flop is an SR flip-flop with the forbidden state turned into a toggle: acts as set, as reset, and toggles.
| J | K | Q next | Action |
|---|---|---|---|
| 0 | 0 | Q | Hold |
| 0 | 1 | 0 | Reset |
| 1 | 0 | 1 | Set |
| 1 | 1 | Toggle |
5.2 Excitation tables, characteristic equations
The characteristic equation gives in terms of the inputs and the present state . The excitation table answers the opposite question: for a wanted change , which inputs must be applied? It is used in design.
| Flip-flop | Characteristic equation |
|---|---|
| SR | with |
| D | |
| T | |
| JK |
| Q | Q next | S | R | J | K | D | T |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | X | 0 | X | 0 | 0 |
| 0 | 1 | 1 | 0 | 1 | X | 1 | 1 |
| 1 | 0 | 0 | 1 | X | 1 | 0 | 1 |
| 1 | 1 | X | 0 | X | 0 | 1 | 0 |
5.3 Master-slave flip-flops
In a level-triggered JK latch with , the output toggles, and if the clock stays HIGH longer than the gate propagation delay the new output feeds back and toggles again and again. This is the race-around condition.
A master-slave flip-flop cures it with two latches in series. The master is enabled when CLK = 1 and the slave (with inverted clock) when CLK = 0. While the clock is HIGH the master follows the inputs and the slave holds the old output; when the clock falls the master is frozen and the slave copies it. The output therefore changes once per clock cycle, at the falling edge, and the feedback from the output cannot reach the master during that time.
Limitation: the master can catch a brief glitch (1's catching) while the clock is HIGH, so inputs must stay stable during the HIGH time. Edge-triggered flip-flops remove this by sampling only at the edge.
5.4 Flip-flop timing diagrams
A timing diagram shows the clock, the inputs and the outputs against time. For an edge-triggered D flip-flop (positive edge) the value of just before each rising edge appears at right after the edge. Other important timing parameters:
- Setup time : how long the inputs must be stable before the clock edge.
- Hold time : how long they must stay stable after the edge.
- Propagation delay : the time from the clock edge until the output changes.
The maximum clock frequency of a simple synchronous circuit is .
5.5 Flip-flops as the state machines
A flip-flop is the simplest state machine: it has two states ( and ), the inputs decide the next state at each clock edge, and the output is the state. A state diagram draws each state as a circle and each transition as an arrow labelled with the input that causes it.
| Present state Q | T = 0 next state | T = 1 next state |
|---|---|---|
| 0 | 0 | 1 |
| 1 | 1 | 0 |
A circuit with flip-flops has up to states. Chapter 7 uses this idea to design sequential machines.
5.6 Flip-flop conversions
To make flip-flop X act as flip-flop Y, use the excitation table of X and the characteristic table of Y, then find the inputs of X as functions of the inputs of Y and (K-map).
| Needed | Using | Connections |
|---|---|---|
| D flip-flop | JK | , |
| T flip-flop | JK | |
| JK flip-flop | SR | , |
| T flip-flop | D | |
| D flip-flop | SR | , |
| Toggle (divide by 2) | D |
5.7 Flip-flop applications
- Data storage and registers: one flip-flop stores one bit, so flip-flops store an -bit word.
- Data transfer and shift registers: serial to parallel and parallel to serial conversion.
- Counting: a chain of toggle flip-flops makes a binary counter.
- Frequency division: each T flip-flop halves the frequency; stages divide by .
- Switch debouncing: an SR latch gives one clean transition from a bouncing mechanical switch.
- Synchronisation: a D flip-flop samples an asynchronous signal on the clock edge.
Worked Examples
1
A negative-edge-triggered JK flip-flop starts with . The inputs at the five successive active clock edges are , , , , . Find after every edge.
Use .
Edge 1, , : (set). Edge 2, , : (hold).
Edge 3, , : (toggle). Edge 4, , : (reset, stays 0). Edge 5, , : (toggle).
after the five edges: 1, 1, 0, 0, 1.
2
Convert an SR flip-flop into a JK flip-flop. Derive the inputs and in terms of , and , and show that the forbidden state never occurs.
Build the conversion table. For every write the wanted of a JK flip-flop and read the needed from the SR excitation table. For : gives so ; gives 0, ; gives 1, ; gives 1, . For : gives 1, ; gives 0, ; gives 1, ; gives 0, .
K-maps with don't cares. only in the rows , , so (the X entries need not be used). only in the rows , , so .
No forbidden state. , because . Therefore can never happen.
and ; the product always.
3
A 16 kHz clock drives three T flip-flops in cascade (each with , the output of one clocking the next). Find the output frequency of each stage and the period of the last output.
Each T flip-flop with divides the frequency by 2, because completes one cycle for every two clock cycles.
Frequencies. First stage: kHz. Second stage: kHz. Third stage: kHz. This equals kHz.
Period of the last output. ms.
8 kHz, 4 kHz and 2 kHz; the last output has a period of 0.5 ms.
Exercises
Exercises: Sequential Logic Circuits
Explain the race-around condition in a JK flip-flop and how a master-slave arrangement removes it.
With a level-triggered JK flip-flop toggles. If the clock pulse width is longer than the propagation delay of the gates, the new output returns to the inputs and the output toggles again, several times during one pulse. The final value is then uncertain.
In a master-slave flip-flop the master latch is enabled during CLK = 1 and the slave during CLK = 0, so they are never transparent together. The output (slave) changes only when the clock falls, once per cycle, and the changed output cannot reach the master while the master is active. Race-around is therefore eliminated.
Race-around is repeated toggling when and is greater than the propagation delay; master-slave action restricts the output to one change per clock cycle.
Convert a JK flip-flop into (a) a D flip-flop and (b) a T flip-flop. Check each against the characteristic equation.
(a) For a D flip-flop . Put and in : .
(b) For a T flip-flop . Put : .
D: , . T: .
Convert a D flip-flop into a T flip-flop and draw (as a table) its behaviour for the toggle input sequence starting from .
For a T flip-flop , and a D flip-flop has , so (one XOR gate in front of the D input).
Starting at : ; ; ; ; ; . The sequence is 1, 0, 0, 1, 1, 0.
; after each edge: 1, 0, 0, 1, 1, 0.
A positive-edge D flip-flop has ns, ns and is followed by logic with a delay of 23 ns before the next flip-flop. Find the maximum clock frequency. If the clock frequency is 20 MHz, what is the period and the slack?
Minimum period ns, so MHz.
At 20 MHz the period is ns, so the slack is ns and the circuit works.
MHz; at 20 MHz the period is 50 ns with 10 ns slack.
Derive the characteristic equation of the JK flip-flop from its characteristic table, and write the excitation table values of and for the transitions and .
The rows of the characteristic table with are (set, set, toggle from 0, and hold of a stored 1). Plot them on a K-map with as rows and as columns: the cells and form a pair with , fixed, giving ; the cells and form a pair with , fixed, giving .
So . For : requires and is a don't care (toggle or set both work). For : requires and is a don't care.
; : , ; : , .