Skip to main content

Sequence detector for 1010

Short answer

Design as an overlapping Mealy detector with two JK flip-flops. State encoding: A=00, B=01, C=10, D=11. The inputs are J1 = Q0 X', K1 = Q0 X + Q0' X'; J0 = X, K0 = X'; output Z = Q1 Q0 X'.

Design a sequential machine that has one serial input X and output Z. The machine is required to have an output Z = 1 when the input X contains the serial message 1010.

The machine has one serial input X and one output Z; Z = 1 when the last four bits received are 1, 0, 1, 0. Since no flip-flop type is specified, JK flip-flops are used.

A Mealy machine is used (output depends on the present state and the present input), and overlapping sequences are detected. Since the sequence has 4 bits, 4 states are needed, so 2 JK flip-flops (Q1Q0Q_1Q_0) are used, clocked on the positive edge. (A Moore machine would need 5 states.)

Step 1: States

Present stateMeaningNext (X=0)Next (X=1)Z (X=0)Z (X=1)
Areset / no useful bitsAB00
B"1" receivedCB00
C"10" receivedAD00
D"101" receivedCB10

Step 2: State diagram

 Main path (label = X/Z):
 A -1/0-> B -0/0-> C -1/0-> D -0/1-> C
 Other transitions:
 A -0/0-> A    B -1/0-> B
 C -0/0-> A    D -1/0-> B

Step 3: State assignment

StateABCD
Q1 Q00 00 11 01 1

Step 4: Excitation table

JK excitation: 0→0: J=0, K=X; 0→1: J=1, K=X; 1→0: J=X, K=1; 1→1: J=X, K=0.

Q1 Q0XQ1+ Q0+J1K1J0K0Z
0 000 00X0X0
0 010 10X1X0
0 101 01XX10
0 110 10XX00
1 000 0X10X0
1 011 1X01X0
1 101 0X0X11
1 110 1X1X00

Step 5: K-maps (rows Q1Q_1, columns Q0XQ_0X)

J1: Q1 / Q0X00011110
00001
1XXXX
K1: Q1 / Q0X00011110
0XXXX
11010
J0: Q1 / Q0X00011110
001XX
101XX
K0: Q1 / Q0X00011110
0XX01
1XX01
Z: Q1 / Q0X00011110
00000
10001

Step 6: Equations

J1=Q0X‾,K1=Q0X+Q0‾X‾J0=X,K0=X‾Z=Q1Q0X‾\begin{aligned} &J_1 = Q_0\overline{X},\quad K_1 = Q_0X + \overline{Q_0}\overline{X} \\ &J_0 = X,\quad K_0 = \overline{X} \\ &Z = Q_1Q_0\overline{X} \end{aligned}

Step 7: Logic diagram

   +-----+       +-----+
J0>|J   Q|-Q0 J1>|J   Q|-Q1
   | FF0 |       | FF1 |
K0>|K    |    K1>|K    |
   +--^--+       +--^--+
      |             |
CLK---+-------------+
X = serial input, common to the gates
J1 = Q0.X'   K1 = Q0.X + Q0'.X'
J0 = X   K0 = X'
Z = Q1.Q0.X'

The gates for each flip-flop input are built from the equations; the output gate gives Z directly (Mealy output).

Check with an input stream

X0101010100
StateAABCDCDCDC
Z0000101010

Z = 1 appears exactly on the clock in which the last bit of 1010 arrives; overlapping sequences are also detected.

Note: K1=Q0⊕X‾K_1 = \overline{Q_0 \oplus X} (an XNOR gate), and FF0 simply follows the input (J0=XJ_0 = X, K0=X‾K_0 = \overline{X}).

✓ Answer checked by Claude Opus 5.5 (high effort)

All Digital Logic chapter 9 questions →