EMT 235 Digital Electronic Principles II Sequential Logic

  • Slides: 26
Download presentation
EMT 235 Digital Electronic Principles II Sequential Logic (Chapter 3: Finite state machine)

EMT 235 Digital Electronic Principles II Sequential Logic (Chapter 3: Finite state machine)

Topics • Analysis of synchronous sequential logic circuits • Design of synchronous sequential logic

Topics • Analysis of synchronous sequential logic circuits • Design of synchronous sequential logic circuits

Finite state machine • • A mathematical model employed to design sequential logic circuits.

Finite state machine • • A mathematical model employed to design sequential logic circuits. Sequential logic circuits can be classified according to the type of output function, as follows: 1) Mealy machine – the output of the sequential circuit at time t, is dependent on the present state and input(s) at time t.

Finite state machine 2) Moore machine – the output of the sequential circuit at

Finite state machine 2) Moore machine – the output of the sequential circuit at time t is only dependent on the present state at time t.

Analysis of clocked synchronous sequential logic circuit Given a sequential logic circuit: (1) Obtain

Analysis of clocked synchronous sequential logic circuit Given a sequential logic circuit: (1) Obtain the output equations and the flip-flop input equations. (2) Construct the next-state table i. List all the combinations of the present state and inputs in the next-state table. ii. Substitute the present state and input(s) of a given row into the flip-flop input equation to obtain the input of each flip-flop. iii. Refer to the truth table of the flip-flop to obtain the next state of the flip-flop. iv. Substitute the present state and inputs in a given row into the output equation(s) to obtain the output(s) directly of the sequential logic circuit. v. Repeat for the following next rows to complete the next-state table. (3) Produce the state-diagram.

Design of counters Analysis of sequential logic circuits

Design of counters Analysis of sequential logic circuits

state table (transition table) • a tabular representation of the functional relationships among the

state table (transition table) • a tabular representation of the functional relationships among the present states, inputs, next states and outputs of a sequential circuit. § § Present state – the current state of all the flip-flops at time, t. Input (X) – the value of X for each possible present state. Next state – the states of the flip-flops one clock cycle later at time t+1. Output (Y)– the value of Y at time t for each present state and input condition • In general, a state table can either be written as • or in a two (2) dimensional form as

Example 1 Schematic of a sequential circuit 1 a. Flip-flop input equations 1 b.

Example 1 Schematic of a sequential circuit 1 a. Flip-flop input equations 1 b. Output equation Output is dependent on the present state (QA and QB) and input (x) Mealy state machine

Example 1 cont … 2. Excitation table of the sequential circuit Present state Input

Example 1 cont … 2. Excitation table of the sequential circuit Present state Input QA QB x 0 0 0 Flip-flop inputs Output JA KA JB KB z 0 0 1 1 1 0 0 1 0 1 0 1 1 1 0 0 0 0 1 1 0 1 1 1 0 1 0 0 1 1 1 2. Truth table of a J-K flip-flop J K CLK Q Q Comments 0 0 Q 0 No change 1 0 SET 0 1 RESET 1 1 Q 0 Toggle There is error in the output (z) column. Please refer to www 10 FSM_portal_vg 2. ppt page 9 for correction.

Example 1 cont … 2. State table Present state Input Next state Output 2.

Example 1 cont … 2. State table Present state Input Next state Output 2. State table (the states are replaced with alphanumeric symbols) Present state Next state x z QA QB x QA+ QB+ z 0 0 1 0 S 0 0 S 1 0 0 0 1 S 0 1 0 1 0 1 S 1 0 S 2 1 0 1 1 0 S 1 1 S 3 0 1 0 0 1 S 2 0 S 0 1 1 0 1 0 S 2 1 S 1 0 1 1 0 S 3 0 1 1 0 1 S 3 1 S 2 1 Alphanumeric symbols can be used to replace the states. If 00 is replaced with S 0, If 01 is replaced with S 1, If 10 is replaced with S 2, and If 11 is replaced with S 3

Example 1 cont … 3. State diagram Input: x State: QAQB Output: z (Mealy

Example 1 cont … 3. State diagram Input: x State: QAQB Output: z (Mealy state machine the output is labeled after the input and is preceded by a slash (/). )

Example 2 Schematic of a sequential circuit 1 a. Flip-flop input equations 1 b.

Example 2 Schematic of a sequential circuit 1 a. Flip-flop input equations 1 b. Output equation Output is dependent on the present state (QA and QB) Moore state machine

Example 2 cont … 2. Excitation table of the sequential circuit 2. Truth table

Example 2 cont … 2. Excitation table of the sequential circuit 2. Truth table of a J-K flip-flop Present state J K CLK Q Q Comments 0 0 Q 0 No change 1 0 SET 0 1 RESET 1 1 Q 0 Toggle Input QA QB x 0 0 0 Flip-flop inputs Output JA KA JB KB z 0 1 0 0 1 1 0 0 0 0 1 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 0 1 1 1 1 1 0 1

2. State table Present state Input Example 2 cont … 2. State table (states

2. State table Present state Input Example 2 cont … 2. State table (states are replaced with alphanumeric symbols) Next state Output QA QB x QA+ QB+ z 0 0 0 1 0 1 0 0 0 1 1 0 1 0 0 1 1 1 0 0 1 1 1 0 1 1 Present state x Next state z S 0 0 S 2 1 S 0 1 S 1 0 S 0 0 S 1 1 S 1 0 S 2 0 S 3 1 S 2 1 S 3 0 S 1 1 S 3 1 S 1 1 3. State diagram Input: x Output: x Alphanumeric symbols can be used to replace the states. If 00 is replaced with S 0, State: QAQB If 01 is replaced with S 1, If 10 is replaced with S 2, and (Moore state machine the output is labeled after the If 11 is replaced with S 3 present state and is preceded by a slash (/). )

Example 3 Schematic of a sequential circuit 2. Excitation table of the sequential circuit

Example 3 Schematic of a sequential circuit 2. Excitation table of the sequential circuit Present Inputs Flip-flop Output state inputs 1 a. Flip-flop input equations DA = X Y Q A 1 b. Output equations Z = QA Output is dependent on the present state (QA) Moore state machine 2. Truth table of a D flip-flop QA X Y DA Z 0 0 0 0 1 1 0 0 1 1 D CLK Q Q Comments 1 0 1 1 1 0 SET state 1 1 0 0 0 RESET state 1 1 1

Example 3 cont … State: QA 4. State table Present state Inputs Next state

Example 3 cont … State: QA 4. State table Present state Inputs Next state Output QA X Y QA + Z 0 0 0 0 1 1 0 0 1 1 1 0 1 1 1 0 0 1 1 1 Input: XY Output: Z 5. State diagram (Moore state machine: output only dependent on the present state) The output is labeled after the present state and is preceded by a slash (/).

Design of sequential circuit • The following are the general steps used to design

Design of sequential circuit • The following are the general steps used to design a sequential circuit 1. Specification • Write a specification for the circuit or what we want to design. 2. Formulation • Obtain state diagram and state table for the specification. 3. State assignment • Assign binary codes to the states. 4. FF input equation determination • Determine the flip-flop type to be used. • Derive the flip-flop input equations from the state table.

Design of sequential circuit cont … 5. Output equation determination • Derive output equation

Design of sequential circuit cont … 5. Output equation determination • Derive output equation from the state table. 6. Technology mapping • Circuit implementation. 7. Verification • To verify the correctness of the final design.

Example 3: (Coffee vending machine) 1) Specification: • Consider a coffee vending machine that

Example 3: (Coffee vending machine) 1) Specification: • Consider a coffee vending machine that § Accepts 5 ¢ and 10 ¢, and recording the total amount of credit taken. § Dispenses a cup of coffee when the credit is more or equal to 15 ¢. § No change is returned to the customer. • Coffee machine states • • • The vending machine can be in different states based on the amount of money input by the user. All coins are multiples of 5 ¢. Thus, the machine can be in the following states: § 0 ¢ credit § 5 ¢ credit § 10 ¢ credit 1) 15 ¢ credit

Example 3: (Coffee vending machine) cont … • Coffee vending machine inputs § a

Example 3: (Coffee vending machine) cont … • Coffee vending machine inputs § a 10 ¢ is paid § a 5 ¢ is paid • Coffee vending machine outputs § a cup of coffee (C)

Example 3 (Coffee vending machine) cont … • The finite-state machine finite state machine

Example 3 (Coffee vending machine) cont … • The finite-state machine finite state machine can now be constructed. • For each possible input(s) and each possible state, we need to know what is the next state the machine should go to and what to output(s) (if anything). • For example: § If the machine is in a “ 5 ¢ credit” state and the user input a 10 ¢, the machine should enter a transition into a state S 3 (15 ¢) and output a cup of coffee. • A state diagram and/or a state table can be constructed by considering every possible input on every possible state.

Example 3: (Coffee vending machine) cont … (2) State diagram (2). Symbolic state table

Example 3: (Coffee vending machine) cont … (2) State diagram (2). Symbolic state table Present state Inputs Next state Output, (coffee) 10 ¢ 5¢ 0 ¢ credit 0 1 5 ¢ credit 0 0 ¢ credit 1 0 10 ¢ credit 0 0 ¢ credit X X 5 ¢ credit 0 0 5 ¢ credit 0 1 10 ¢ credit 0 5 ¢ credit 1 0 15 ¢ credit 0 5 ¢ credit X X 10 ¢ credit 0 0 10 ¢ credit 0 1 15 ¢ credit 0 10 ¢ credit 1 0 15 ¢ credit 0 10 ¢ credit X X 15 ¢ credit 0 0 0 ¢ credit 1 15 ¢ credit 0 1 5 ¢ credit 1 15 ¢ credit 1 0 10 ¢ credit 1 15 ¢ credit X X

Example 3: (Coffee vending machine) cont … Present state Inputs Next state Output (coffee)

Example 3: (Coffee vending machine) cont … Present state Inputs Next state Output (coffee) 5¢ 10 ¢ 0 0 0 0 0 1 0 (3). State Assignment • Replace “ 0 ¢ credit” state with 00 • Replace “ 5 ¢ credit” state S 1 with 01 • Replace “ 10 ¢ credit” state S 2 with 10 • Replace “ 15 ¢ credit” state S 3 with 11 0 0 1 1 X X X 0 1 0 1 1 0 0 0 1 1 0 (4). Excitation table of J-K flip-flop 0 1 1 1 X X X 1 0 0 0 1 1 1 0 1 0 1 0 1 1 X X X 1 1 0 0 1 1 1 0 1 0 1 1 1 1 1 X X X (3). Encoded state table

Present state Inputs (4). State table with J-K flipflop inputs Next state Output Flip-flop

Present state Inputs (4). State table with J-K flipflop inputs Next state Output Flip-flop inputs (coffee) J 1 5¢ K 1 J 0 K 0 Q 1 Q 0 10 ¢ 0 0 0 0 X 0 0 0 1 0 0 X 1 X 0 0 1 X 0 0 1 1 X X X X 0 1 0 0 X X 0 0 1 1 0 0 1 X X 1 0 1 X X 0 0 1 1 1 X X X X 1 0 0 0 1 0 0 X 1 0 0 1 1 1 0 X 0 1 X 1 0 1 1 X X X X 1 1 0 0 1 X 1 1 1 0 1 1 X 0 1 1 1 0 1 X 0 X 1 1 1 X X X X

Example 3: (Coffee vending machine) cont … (4). Karnaugh maps to get FF input

Example 3: (Coffee vending machine) cont … (4). Karnaugh maps to get FF input equations 10¢ 5¢ Q 1 Q 0 00 00 0 01 11 0 X 10¢ 5¢ 10 Q Q 00 1 00 X (5). Karnaugh maps 01 11 10 X X X 01 0 1 X 1 01 X X X X 11 1 1 X 0 10 X X 10 0 0 X 0 J 1 = Q 0(5¢) + (10 ¢) K 1 = Q 0(10¢) 10¢ 5¢ Q Q 00 01 11 10 1 0 00 0 1 X 0 01 X X X 11 X X 10 0 1 1 0 00 X X X 01 0 1 X 0 X X 11 1 0 X 1 10 X X J 0 = (5¢) + Q 1(10¢) K 0 = Q 1(5¢) + Q 1(5¢) to get FF output equations 10¢ 5¢ Q 1 Q 0 00 00 0 01 11 10 0 X 0 01 0 0 X 0 11 1 1 X 1 10 0 0 X 0 Coffee = Q 1 Q 0

Example 3: (Coffee vending machine) cont … (6). Circuit implementation

Example 3: (Coffee vending machine) cont … (6). Circuit implementation