Skip to main content

Sequence detector 1001 using D flip-flops

Short answer

Mealy machine with 2 D flip-flops; states S0(00), S1(01), S2(10), S3(11). D1 = (Q1 xor Q0) A', D0 = Q1 Q0' + A, Y = Q1 Q0 A.

A sequential machine which has one input, A and one output, Y. The machine is required to give the output high when the input contains a serial message of 1001, use only D flip-flops for realizing the design.

The machine has one input A and one output Y; Y = 1 when the last four bits received on A are 1, 0, 0, 1. Only D 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 D flip-flops (Q1Q0Q_1Q_0) are used, clocked on the positive edge. (A Moore machine would need 5 states.)

Step 1: States

Present stateMeaningNext (A=0)Next (A=1)Y (A=0)Y (A=1)
S0reset / no useful bitsS0S100
S1"1" receivedS2S100
S2"10" receivedS3S100
S3"100" receivedS0S101

Step 2: State diagram

 Main path (label = A/Y):
 S0 -1/0-> S1 -0/0-> S2 -0/0-> S3 -1/1-> S1
 Other transitions:
 S0 -0/0-> S0    S1 -1/0-> S1
 S2 -1/0-> S1    S3 -0/0-> S0

Step 3: State assignment

StateS0S1S2S3
Q1 Q00 00 11 01 1

Step 4: Excitation table

D excitation: D=Q+D = Q^+ (D equals the next state).

Q1 Q0AQ1+ Q0+D1D0Y
0 000 0000
0 010 1010
0 101 0100
0 110 1010
1 001 1110
1 010 1010
1 100 0000
1 110 1011

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

D1: Q1 / Q0A00011110
00001
11000
D0: Q1 / Q0A00011110
00110
11110
Y: Q1 / Q0A00011110
00000
10010

Step 6: Equations

D1=Q1Q0‾A‾+Q1‾Q0A‾D0=Q1Q0‾+AY=Q1Q0A\begin{aligned} &D_1 = Q_1\overline{Q_0}\overline{A} + \overline{Q_1}Q_0\overline{A} \\ &D_0 = Q_1\overline{Q_0} + A \\ &Y = Q_1Q_0A \end{aligned}

Step 7: Logic diagram

   +-----+       +-----+
D0>|D   Q|-Q0 D1>|D   Q|-Q1
   | FF0 |       | FF1 |
   |     |       |     |
   +--^--+       +--^--+
      |             |
CLK---+-------------+
A = serial input, common to the gates
D1 = Q1.Q0'.A' + Q1'.Q0.A'
D0 = Q1.Q0' + A
Y = Q1.Q0.A

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

Check with an input stream

A1001001100
StateS0S1S2S3S1S2S3S1S1S2
Y0001001000

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

Note: D1=A‾ (Q1⊕Q0)D_1 = \overline{A}\,(Q_1 \oplus Q_0), so FF1 needs one XOR and one AND gate.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Digital Logic chapter 9 questions →