Skip to content

Lec 02-25-2025: Sequential Circuits & Master-Slave Flip Flop

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.

The clock behaves as such:

Signalclock = 1clock = 0
YFollows DHolds last value
QHolds last valueFollows Y

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.

clock waveform 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.

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 waveforms over time

Given C and D, we can determine Y and Q by considering the following:

  • Y: output of the master f/f
  • Q: output of the slave f/f

Behavior of Y:

  • When clock is 1, Y is a copy of D
  • When clock is 0, Y doesn’t change

Behavior of Q:

  • When clock is 0, Q is a copy of Y
  • When clock is 1, Q doesn’t change

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}

Which corresponds to the below state diagram. Since a state diagram needs a transition for every possible input in every state, 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 X determining which transition to take.

The first step is to enumerate every combination of present state and input, and look up the corresponding next state from the diagram:

Present StateInput    Next Statef/f inputsABXABJAKAJBKB0000000101010100110110010101111101111100\begin{array}{cc|c|cc|cccc} \text{Present State} & & \text{Input} & \text{\ \ \ \ Next State} & & & \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. A regular characteristic table tells you what Q(t+1)Q(t+1) will be 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) (from the state diagram), and we need to figure out what JJ and KK inputs would cause 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 a 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:

Present StateInput    Next Statef/f inputsABXABJAKAJBKB000000X0X001010X1X010101XX1011010XX010010X00X10111X01X11011X0X011100X1X1\begin{array}{cc|c|cc|cccc} \text{Present State} & & \text{Input} & \text{\ \ \ \ Next State} & & & \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 X.

JAJ_A:

K-map for J_A: A vs BX, row A=0: 0 0 0 1, row A=1: X X X X, circle on BX=10 column gives J_A = BX'

JA=BXJ_A = BX'

KAK_A:

K-map for K_A: A vs BX, row A=0: X X X X, row A=1: 0 0 1 0, circle on BX=11 cell gives K_A = BX

KA=BXK_A = BX

JBJ_B:

K-map for J_B: A vs BX, row A=0: 0 1 X X, row A=1: 0 1 X X, circle on BX=01 column gives J_B = X

JB=XJ_B = X

KBK_B:

K-map for K_B: A vs BX, row A=0: X X 0 1, row A=1: X X 1 0, two circles give K_B = A'X' + AX

KB=AX+AX=AXK_B = A'X' + AX = \overline{A \oplus X} JA=BXKA=BXJB=XKB=AXJ_A = BX' \qquad K_A = BX \qquad J_B = X \qquad K_B = \overline{A \oplus X} logic circuit with inputs X, B', B, A', A on left bus; NOT gate on X feeding AND gate with B for J_A; AND gate with B and X for K_A; both feeding JK flip flop A (outputs A, A'); second JK flip flop B (J_B, K_B inputs with connections from bus); feedback lines from A, A', B, B' back into the input bus