ECE 301 – Digital Electronics Sequential Logic Circuits: State Assignment And State Minimization (Lecture #20)
State Assignment Problem ECE 301 - Digital Electronics
State Assignment Problem Some state assignments are better than others. The state assignment influences the complexity of the state machine. The combinational logic required in the state machine design is dependent on the state assignment. Types of state assignment Binary encoding: 2N states → N Flip-Flops Gray-code encoding: 2N states → N Flip-Flops One-hot encoding: N states → N Flip-Flops ECE 301 - Digital Electronics
FSM: State Assignment Example: Design a FSM that detects a sequence of two or more consecutive ones on an input bit stream. The FSM should output a 1 when the sequence is detected, and a 0 otherwise. This is another example of a sequence detector. ECE 301 - Digital Electronics
ECE 301 - Digital Electronics FSM: State Assignment Input: 0 1 1 1 0 1 0 1 1 0 1 1 1 0 1 … Output: 0 0 1 1 0 0 0 0 1 0 0 1 1 0 0 … ECE 301 - Digital Electronics
ECE 301 - Digital Electronics FSM: State Assignment C z = 1 Reset B z = A w 1 S0 / 0 S1 / 0 S2 / 1 State Diagram ECE 301 - Digital Electronics
ECE 301 - Digital Electronics FSM: State Assignment Present State Next State Output w = 0 w = 1 S0 S1 S2 1 State Table ECE 301 - Digital Electronics
FSM: State Assignment #1 State Assigned Table Present State Next State Output w = 0 w = 1 QA QB QA+ QB+ z S0 S1 1 S2 d Using Binary Encoding for the State Assignment ECE 301 - Digital Electronics
FSM: State Assignment #1 State Assigned Table Present State Next State FF Inputs w = 0 w = 1 QA QB QA+ QB+ DA DB S0 1 S1 S2 d Characteristic Equation: D = Q+ ECE 301 - Digital Electronics
FSM: State Assignment #1 ECE 301 - Digital Electronics
FSM: State Assignment #1 K-Map and Boolean expression for z ECE 301 - Digital Electronics
FSM: State Assignment #1 DA = w.(QA + QB) z A z = QA w B DB = w.QA'.QB' ECE 301 - Digital Electronics
FSM: State Assignment #2 State Assigned Table Present State Next State Output w = 0 w = 1 QA QB QA+ QB+ z S0 S1 1 S2 d Using Gray-code Encoding for the State Assignment ECE 301 - Digital Electronics
FSM: State Assignment #2 State Assigned Table Present State Next State FF Inputs w = 0 w = 1 QA QB QA+ QB+ DA DB S0 1 S1 S2 d Characteristic Equation: D = Q+ ECE 301 - Digital Electronics
FSM: State Assignment #2 K-Map and Boolean expression for DA, DB and z ECE 301 - Digital Electronics
FSM: State Assignment #2 D Q Y 2 1 w Clock z y Resetn A B DA = w.QB DB = w z = QA ECE 301 - Digital Electronics
FSM: State Assignment #3 State Assigned Table Present State Next State w = 0 w = 1 QA QB QC QA+ QB+ QC+ S0 1 S1 S2 For each state only one flip-flop is set to 1. The remaining combination of state variables are not used. Using One-hot Encoding for the State Assignment Characteristic Equation: D = Q+ ECE 301 - Digital Electronics
FSM: State Assignment #3 ECE 301 - Digital Electronics
FSM: State Assignment #3 Resetn D Q Clock DA = w.QC' z z = QA A B C DB = w.QC DC = w.' w ECE 301 - Digital Electronics
ECE 301 - Digital Electronics State Minimization ECE 301 - Digital Electronics
FSM: State Minimization Definition: Two states Si and Sj are said to be equivalent if and only if for every possible input sequence, the same output sequence will be produced regardless of whether Si or Sj is the initial state. ECE 301 - Digital Electronics
FSM: State Minimization Definition: A partition consists of one or more blocks, where each block comprises a subset of states that may be equivalent, but the states in a given block are definitely not equivalent to the states in other blocks. ECE 301 - Digital Electronics
State Minimization: Partitioning State Minimization through Partitioning: Form an initial partition (P1) that includes all states. Form a second partition (P2) by separating the states into two blocks based upon their output values. Form a third partition (P3) by separating the states into blocks corresponding to the next state values. Continue partitioning until two successive partitions are the same (i.e. PN-1 = PN). All states in any one block are equivalent. Equivalent states can be combined into a single state. ECE 301 - Digital Electronics
State Minimization: Partitioning Example: Use partitioning to minimize the number of states in the following Finite State Machine (FSM). ECE 301 - Digital Electronics
State Minimization: Partitioning F / 0 E / 0 D / 1 B / 1 C / 0 A / 1 State Diagram ECE 301 - Digital Electronics
State Minimization: Partitioning Present Next state Output state w = 1 z A B C D F E G ECE 301 - Digital Electronics
State Minimization: Partitioning Initial Partition: P1 = (ABCDEFG) The initial partition contains all states in the state diagram / table. ECE 301 - Digital Electronics
State Minimization: Partitioning Separate states based on output value. P2 = (ABD)(CEFG) Present Next state Output state w = 1 z A B C D F E G ECE 301 - Digital Electronics
State Minimization: Partitioning Separate states based on next state values. P3 = (ABD)(CEG)(F) ABD CEFG 1 1 BDB CFG FFEF ECDG unique state ECE 301 - Digital Electronics
State Minimization: Partitioning Separate states based on next state values. P4 = (AD)(CEG)(F)(B) ABD CEG 1 1 BDB CFG FFF ECG unique states ECE 301 - Digital Electronics
State Minimization: Partitioning Separate states based on next state values. P5 = (AD)(CEG)(F)(B) AD CEG 1 1 BB CG FFF ECG same as previous partition (P4) ECE 301 - Digital Electronics
State Minimization: Partitioning Since P4 = P5, state minimization is complete. The equivalent states are: A = D C = E = G B F Thus, the FSM can be realized with just 4 states. ECE 301 - Digital Electronics
FSM: State Minimization Present Next state Output state w = 1 z A B C F Minimized State Table ECE 301 - Digital Electronics
FSM: State Minimization Minimized State Diagram ECE 301 - Digital Electronics
Acknowledgments The slides used in this lecture were taken, with permission, from those provided by McGraw-Hill for Fundamentals of Digital Logic with VHDL Design (3rd Edition). They are the property of and are copyrighted by McGraw-Hill Higher Education. ECE 301 - Digital Electronics