Skip to content

Lec 02-25-2025: Master-Slave Flip Flop, Registers & Clocked Sequential Circuit Design | CSCI 343

In the previous lecture, we introduced clocked flip-flops, which are designed to only change state on a clock edge, but there’s still a problem when multiple flip-flops need to change state together. Consider a circuit with two flip-flops, A and B, that are supposed to swap states on the same clock edge:

state diagram with two states (01) and (10), arrow from (01) to (10)

Each f/f must change state instantly at the same time, otherwise we might end up at the wrong state. For example, if A updates before B, then B might read A’s new value instead of A’s old value when computing its own next state, producing a wrong result.

The master-slave approach solves this by splitting each flip-flop into two stages. The first stage (master) captures the input during one clock phase, and the second stage (slave) transfers that captured value to the output during the opposite phase. This way, the output only changes after the input has already been locked in — the two stages can never interfere with each other.

master-slave D latch circuit diagram -- D input feeds into master D latch (with clock C), output Q of master feeds into input D of slave D latch (with inverted clock C via NOT gate), slave outputs Q and Q'

The master uses the clock directly, and the slave uses an inverted copy of the clock — so when the master is open (clock=1), the slave is locked, and vice versa. The output Q of the master (called Y) becomes the input to the slave.

So the final output Q only ever changes on the falling edge of the clock (the transition from 1 to 0), which is when the slave unlocks and copies whatever Y was holding. The clock signal below shows this — the rising edge is where the master opens, and the falling edge is where the slave opens and Q updates:

clock signal showing positive edge triggering on rising edge and negative edge on falling edge

When D and C are 1, Y follows D and the state of the master becomes 1. Once C drops to 0 (negative edge), the master locks in whatever Y was holding, and that is when the slave unlocks and copies Y into Q.

Given the signals for C and D, we can determine Y and Q by considering how they respond to the clock:

Signalclock = 1clock = 0
YCopy of DHolds last value
QHolds last valueCopy of Y
timing diagram with four signals C (green), D (yellow), Y (blue, output of master f/f), and Q (blue, output of slave f/f) showing their signals over time

A register is a group of flip-flops that collectively store multiple bits of data. Since each flip-flop holds one bit, an nn-bit register is built from nn flip-flops sharing a common clock — all bits are captured simultaneously on the same clock edge, which is what the master-slave design was set up to ensure.

A standard 4-bit register using D flip-flops accepts all 4 bits of input at once (parallel input) and makes all 4 bits available simultaneously as output (parallel output):

4-bit parallel register circuit

A shift register is capable of shifting its binary information to the right or to the left. All flip-flops receive a common clock pulse that causes the shift from one stage to the next:

4-bit shift register circuit

The input end is where new bits enter, and the output end is where bits fall off — the shift direction is simply determined by which end the input enters. Since the input enters at D0D_0 and the flip-flops are chained left to right (Q0D1Q1D2Q_0 \to D_1 \to Q_1 \to D_2 \to \cdots), each clock pulse pushes the entire chain one position to the right, and the bit at Q3Q_3 drops out.

Bidirectional Shift Register with Parallel Load

Section titled “Bidirectional Shift Register with Parallel Load”

The most general shift register combines all modes into one circuit. Each stage uses a 4×14 \times 1 MUX to select between four possible operations, controlled by select lines s1s_1 and s0s_0:

4-bit bidirectional shift register with parallel load

The most general shift register has the following functions:

  • Clear control to clear registers to 0
  • CP input for clock pulses to synchronize all operations
  • A shift-right control to enable shift right operations
  • A shift-left control to enable a shift-left operation
  • A parallel-load control to enable a parallel transfer
  • NN parallel output lines
  • A control state that leaves the information unchanged even if the clock pulse is continuously applied

Designing a Clocked Sequential Circuit with JK Flip Flops

Section titled “Designing a Clocked Sequential Circuit with JK Flip Flops”

Now that we know how flip-flops work, we can use them to design a circuit that implements a specific behavior from a state specification. The JK flip-flop is a common choice for this kind of design because of its flexibility in controlling state transitions, as is apparent from its characteristic table.

The process follows a standard recipe: write down the state transitions, figure out what J and K inputs are needed to produce each transition, then use K-maps to minimize the resulting Boolean expressions into circuit logic.

Say we want to design a clocked sequential circuit for the following specification using JK flip flops:

01 by a 10 \to 1 \text{ by a 1} 12 by a 01 \to 2 \text{ by a 0} 23 by a 12 \to 3 \text{ by a 1} 30 by a 13 \to 0 \text{ by a 1}

To draw the state diagram for these state rules, we’ll use the inputs as the transition functions (as edge labels). We can extrapolate the missing transitions as being “otherwise, stay in the same state” (i.e. self-loops on each state for where a transitiion wasn’t specified):

State diagram: four states 00, 01, 10, 11 arranged in a circle with transitions and self-loops

We use two flip-flops A and B to represent the four states (00, 01, 10, 11), with an input xx determining which transition to take.

The first step is to list every combination of present state and input (which we’ll call xx), and look up the corresponding next state from the diagram:

Q(t)InputQ(t+1)f/f inputsABxABJAKAJBKB0000000101010100110110010101111101111100\begin{array}{cc|c|cc|cccc} Q(t) & & \text{Input} & Q(t+1) & & & \text{f/f inputs} & & \\ \hline A & B & x & A & B & J_A & K_A & J_B & K_B \\ \hline 0 & 0 & 0 & 0 & 0 & & & & \\ 0 & 0 & 1 & 0 & 1 & & & & \\ 0 & 1 & 0 & 1 & 0 & & & & \\ 0 & 1 & 1 & 0 & 1 & & & & \\ 1 & 0 & 0 & 1 & 0 & & & & \\ 1 & 0 & 1 & 1 & 1 & & & & \\ 1 & 1 & 0 & 1 & 1 & & & & \\ 1 & 1 & 1 & 0 & 0 & & & & \\ \end{array}

The next step is to fill in the JJ and KK columns. This is where the excitation table comes in. The characteristic table tells you what Q(t+1)Q(t+1) will be for a given JJ and KK, but here we’re working in reverse: we already know Q(t)Q(t) and Q(t+1)Q(t+1), and we need to figure out what JJ and KK inputs would produce that transition. The excitation table gives us exactly that mapping:

Q(t)Q(t+1)JK000X011X10X111X0\begin{array}{cc|cc} Q(t) & Q(t+1) & J & K \\ \hline 0 & 0 & 0 & X \\ 0 & 1 & 1 & X \\ 1 & 0 & X & 1 \\ 1 & 1 & X & 0 \\ \end{array}

The XX entries are don’t-cares. When the flip-flop is being set (JJ), KK doesn’t matter, and vice versa. This is actually one of the reasons JK flip-flops are useful for this kind of design: the don’t-cares give the K-map minimization more flexibility later.

For each row in the state transition table, we apply the excitation table independently to flip-flop A and flip-flop B. Turning our focus on the first row for flip flop A, we’ll look at present state AA, next state AA, and JAJ_A, KAK_A. Since current state of a AA is 0, and the next state of AA is at 0, then we look at the excitation table for where Q(t)=0Q(t)=0 and Q(t+1)=0Q(t+1)=0, which tells us that in order to drive this transition, then JAJ_A must be 0 and KAK_A can be anything (X). We repeat this process for every row and for both flip-flops, filling in the JJ and KK columns:

Q(t)InputQ(t+1)f/f inputsABxABJAKAJBKB000000X0X001010X1X010101XX1011010XX010010X00X10111X01X11011X0X011100X1X1\begin{array}{cc|c|cc|cccc} Q(t) & & \text{Input} & Q(t+1) & & & \text{f/f inputs} & & \\ \hline A & B & x & A & B & J_A & K_A & J_B & K_B \\ \hline 0 & 0 & 0 & 0 & 0 & 0 & X & 0 & X \\ 0 & 0 & 1 & 0 & 1 & 0 & X & 1 & X \\ 0 & 1 & 0 & 1 & 0 & 1 & X & X & 1 \\ 0 & 1 & 1 & 0 & 1 & 0 & X & X & 0 \\ 1 & 0 & 0 & 1 & 0 & X & 0 & 0 & X \\ 1 & 0 & 1 & 1 & 1 & X & 0 & 1 & X \\ 1 & 1 & 0 & 1 & 1 & X & 0 & X & 0 \\ 1 & 1 & 1 & 0 & 0 & X & 1 & X & 1 \\ \end{array}

With the table filled in, we can minimize each of the four input expressions using K-maps. Each K-map has three variables: A, B, and xx.

JA:J_A:

K-map for J_A

JA=BxJ_A = Bx'

KA:K_A:

K-map for K_A

KA=BxK_A = Bx

JB:J_B:

K-map for J_B

JB=xJ_B = x

KB:K_B:

K-map for K_B

KB=Ax+Ax=AxK_B = A'x' + Ax = \overline{A \oplus x}
logic circuit diagram

This is a concrete instance of the sequential circuit structure introduced in the previous lecture — the combinational logic gates on the left compute the next state from the current inputs, the two JK flip-flops on the right (acting as memory units) store the current state, and the feedback lines from A,A,B,BA, A', B, B' back into the input bus are exactly the state feedback loop from the block diagram:

Sequential circuit block diagram and clock pulse timing diagram

An excitation table is the reverse of a characteristic table: given a desired transition from Q(t)Q(t) to Q(t+1)Q(t+1), it tells you what inputs are required to produce that transition.

RS Flip-Flop:

Q(t)Q(t+1)SR000X0110100111X0\begin{array}{cc|cc} Q(t) & Q(t+1) & S & R \\ \hline 0 & 0 & 0 & X \\ 0 & 1 & 1 & 0 \\ 1 & 0 & 0 & 1 \\ 1 & 1 & X & 0 \\ \end{array}

D Flip-Flop:

Q(t)Q(t+1)D000011100111\begin{array}{cc|c} Q(t) & Q(t+1) & D \\ \hline 0 & 0 & 0 \\ 0 & 1 & 1 \\ 1 & 0 & 0 \\ 1 & 1 & 1 \\ \end{array}

JK Flip-Flop:

Q(t)Q(t+1)JK000X011X10X111X0\begin{array}{cc|cc} Q(t) & Q(t+1) & J & K \\ \hline 0 & 0 & 0 & X \\ 0 & 1 & 1 & X \\ 1 & 0 & X & 1 \\ 1 & 1 & X & 0 \\ \end{array}

T Flip-Flop:

Q(t)Q(t+1)T000011101110\begin{array}{cc|c} Q(t) & Q(t+1) & T \\ \hline 0 & 0 & 0 \\ 0 & 1 & 1 \\ 1 & 0 & 1 \\ 1 & 1 & 0 \\ \end{array}