Finite-State Machine Design


Shared context
Initially copy input bits. After two consecutive input zeros, complement following bits; after two consecutive input ones while complementing, return to copying. The triggering second bit still uses the old mode. Use J-K flip-flops.
Answer & solution
Answer: Four-state Mealy machine A,B,C,D with transitions A:0/0→B,1/1→A; B:0/0→C,1/1→A; C:0/1→C,1/0→D; D:0/1→C,1/0→A. (no official key was published)
1. Define A as copy mode with no pending zero, B as copy mode after one zero, C as complement mode with no pending one, and D as complement mode after one one. Start at A. Edge labels are input/output.
2. In copy mode output equals input. Thus A on 0 emits 0 and moves to B; A on 1 emits 1 and stays A. B on 1 emits 1 and resets to A; B on 0 emits 0 and moves to C because the second zero has just occurred.
3. In complement mode output is inverted. Thus C on 0 emits 1 and stays C; C on 1 emits 0 and moves to D. D on 0 emits 1 and resets to C; D on 1 emits 0 and returns to A after the second one.
4. The transition-triggering symbol is processed using the old mode, matching the printed example: input 101100|01001011|0|11 gives output 101100|10110100|0|11.
5. These four states record exactly the information needed: the current mode and whether the first symbol of its switching pair has been seen. Runs of the nontriggering symbol reset the pending-pair state.