Lecture 23 Logistics Last lecture Today HW8 due Wednesday, March 11

Slides:



Advertisements
Similar presentations
ENGIN112 L23: Finite State Machine Design Procedure October 27, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 23 Finite State Machine.
Advertisements

Finite State Machines (FSMs)
Circuits require memory to store intermediate data
CS 151 Digital Systems Design Lecture 25 State Reduction and Assignment.
Sequential Circuit Design
Give qualifications of instructors: DAP
Contemporary Logic Design Finite State Machine Design © R.H. Katz Transparency No Chapter #8: Finite State Machine Design Finite State.
Contemporary Logic Design FSM Optimization © R.H. Katz Transparency No Chapter #9: Finite State Machine 9.4 Choosing Flip-Flops 9.5 Machine Partitioning.
ECE 301 – Digital Electronics Introduction to Sequential Logic Circuits (aka. Finite State Machines) and FSM Analysis (Lecture #17)
ECE 331 – Digital Systems Design Introduction to Sequential Logic Circuits (aka. Finite State Machines) and FSM Analysis (Lecture #19)
ENGIN112 L25: State Reduction and Assignment October 31, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 25 State Reduction and Assignment.
Lecture 17 General finite state machine (FSM) design
Lecture 18 More Moore/Mealy machines.
1 Lecture 22 State encoding  One-hot encoding  Output encoding State partitioning.
Computer Organization & Programming Chapter 5 Synchronous Components.
1 Lecture 13 Overview of sequential logic  Basic concepts  An example.
1 CSE370, Lecture 18 Lecture 20 u Logistics n HW6 due Wednesday n Lab 7 this week (Tuesday exception) n Midterm 2 Friday (covers material up to simple.
DLD Lecture 26 Finite State Machine Design Procedure.

1 CSE370, Lecture 24 Lecture 26 u Logistics n HW8 due Friday n Ant extra credit due Friday n Final exam a week from today, 12/8 8:30am-10:20am here n Review.
Overview Part 1 - Storage Elements and Sequential Circuit Analysis
Finite state machine optimization
4.
Finite state machine optimization
© Copyright 2004, Gaetano Borriello and Randy H. Katz
Lecture 28 Logistics Today
Lecture 26 Logistics Last lecture Today HW8 due Friday
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
Lecture 27 Logistics Last lecture Today: HW8 due Friday
EEL 3705 / 3705L Digital Logic Design
Typical Timing Specifications
Sequential logic examples
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
Assistant Prof. Fareena Saqib Florida Institute of Technology
FINITE STATE MACHINES (FSMs)
332:437 Lecture 12 Finite State Machine Design
Instructor: Alexander Stoytchev
Lecture 27 Logistics Last lecture Today: HW8 due Friday
KU College of Engineering Elec 204: Digital Systems Design
David Culler Electrical Engineering and Computer Sciences
Lecture 28 Logistics Today
EEL 3705 / 3705L Digital Logic Design
CSE 370 – Winter Sequential Logic-2 - 1
CSE 370 – Winter Sequential Logic - 1
Lecture 15 Logistics Last lecture Today HW4 is due today
Lecture 16 Logistics Last lecture Today HW5 out, due next wednesday
CSE 370 – Winter Sequential Logic-2 - 1
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
Instructor: Alexander Stoytchev
Lecture 16 Logistics Last lecture Today HW5 out, due next wednesday
CSE 370 – Winter Sequential Logic-2 - 1
Instructor: Alexander Stoytchev
ECE 352 Digital System Fundamentals
Lecture 24 Logistics Last lecture Today HW7 back today
Lecture 20 Logistics Last lecture Today Graded HW back today
Lecture 19 Logistics Last lecture Today
Lecture 20 Logistics Last lecture Today HW6 due Wednesday
Lecture 17 Logistics Last lecture Today HW5 due on Wednesday
Instructor: Alexander Stoytchev
Lecture 18 Logistics Last Lecture Today HW6 due today Midterm 2
Lecture 18 Logistics Last lecture Today HW5 due today (with extra 10%)
Lecture 22 Logistics Last lecture Today HW7 is due on Friday
ECE 352 Digital System Fundamentals
EGR 2131 Unit 12 Synchronous Sequential Circuits
ECE 352 Digital System Fundamentals
ECE 352 Digital System Fundamentals
Lecture 22 Logistics Last lecture Today HW7 is due on Friday
ECE 352 Digital System Fundamentals
Announcements Assignment 7 due now or tommorrow Assignment 8 posted
CSE 370 – Winter Sequential Logic-2 - 1
Presentation transcript:

Lecture 23 Logistics Last lecture Today HW8 due Wednesday, March 11 Ant extra credit due Friday, March 13 Final exam, Wednesday March 18, 2:30-4:20 pm here Review session Monday, March 16, 4:30 pm, Place TBA Last lecture General FSM Minimization Today State encoding One-hot encoding Output encoding State partitioning

FSM design FSM-design procedure State diagram state-transition table 3. State minimization 4. State encoding 5. Next-state logic minimization 6. Implement the design

Usual example: A vending machine 15 cents for a cup of coffee Doesn’t take pennies or quarters Doesn’t provide any change Reset N Vending Machine FSM Open Coin Sensor Release Mechanism D Clock

A vending machine: After state minimization 0¢ Reset symbolic state table present inputs next output state D N state open 0¢ 0 0 0¢ 0 0 1 5¢ 0 1 0 10¢ 0 1 1 – – 5¢ 0 0 5¢ 0 0 1 10¢ 0 1 0 15¢ 0 1 1 – – 10¢ 0 0 10¢ 0 0 1 15¢ 0 1 0 15¢ 0 1 1 – – 15¢ – – 15¢ 1 D' N' 10¢ D D' N' 5¢ N 15¢ [open] D N D' N' N + D 1

A vending machine: State encoding present state inputs next state output Q1 Q0 D N D1 D0 open 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 0 1 1 – – – 0 1 0 0 0 1 0 0 1 1 0 0 1 0 1 1 0 1 1 – – – 1 0 0 0 1 0 0 0 1 1 1 0 1 0 1 1 0 1 1 – – – 1 1 – – 1 1 1

A vending machine: Logic minimization 0 0 1 1 0 1 1 1 X X X X 1 1 1 1 Q1 D1 Q0 N D 0 0 1 0 0 0 1 0 X X 1 X 0 0 1 0 Q1 Open Q0 N D 0 1 1 0 1 0 1 1 X X X X 0 1 1 1 Q1 D0 Q0 N D D1 = Q1 + D + Q0 N D0 = Q0’ N + Q0 N’ + Q1 N + Q1 D OPEN = Q1 Q0

A vending machine: Implementation

State encoding Assume n state bits and m states 2n! / (2n – m)! possible encodings Example: 3 state bits, 4 states, 1680 possible state assignments Want to pick state encoding strategy that results in optimizing your criteria FSM size (amount of logic and number of FFs) FSM speed (depth of logic and fan-in/fan-out) FSM ease of design or debugging

State-encoding strategies No guarantee of optimality An intractable problem Most common strategies Binary (sequential) – number states as in the state table Random – computer tries random encodings Heuristic – rules of thumb that seem to work well e.g. Gray-code – try to give adjacent states (states with an arc between them) codes that differ in only one bit position One-hot – use as many state bits as there are states Output – use outputs to help encode states Hybrid – mix of a few different ones (e.g. One-hot + heuristic)

One-hot encoding One-hot: Encode n states using n flip-flops Assign a single “1” for each state Example: 0001, 0010, 0100, 1000 Propagate a single “1” from one flip-flop to the next All other flip-flop outputs are “0” The inverse: One-cold encoding Assign a single “0” for each state Example: 1110, 1101, 1011, 0111 Propagate a single “0” from one flip-flop to the next All other flip-flop outputs are “1” “almost one-hot” encoding (modified one-hot encoding) Use no-hot (000…0) for the initial (reset state) Assumes you never revisit the reset state till reset again.

One-hot encoding (con’t) Often the best/convenient approach for FPGAs FPGAs have many flip-flops Draw FSM directly from the state diagram + One product term per incoming arc - Complex state diagram  complex design - Many states  many flip flops

Vending Machine: One-hot encoded transition table 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 1 – – – – – 0 0 1 0 0 0 0 0 1 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 0 1 1 – – – – – 0 1 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 1 0 1 0 0 0 0 1 1 – – – – – 1 0 0 0 – – 1 0 0 0 1 present state inputs next state output Q3Q2Q1Q0 D N D3 D2D1D0 open Reset D' N' 0¢ D' N' N 5¢ D N 10¢ D' N' D N + D 15¢ [open] 1

Advantage of one-hot encoding: Designing from the state diagram 0¢ Reset 5¢ N N + D 10¢ D 15¢ [open] D' N' 1 D0 = Q0D’N’ D1 = Q0N + Q1D’N’ D2 = Q0D + Q1N + Q2D’N’ D3 = Q1D + Q2D + Q2N + Q3 OPEN = Q3

Output encoding Reuse outputs as state bits ad hoc - no tools Why create new functions when you can use outputs? Bits from state assignments are the outputs for that state Take outputs directly from the flip-flops ad hoc - no tools Yields small circuits for most FSMs Combinational Logic Inputs Outputs State Inputs State Outputs Storage Elements

Vending machine --- already in output encoding form 0¢ Reset 5¢ N N + D 10¢ D 15¢ [open] D' N' 1 D0 = Q0D’N’ D1 = Q0N + Q1D’N’ D2 = Q0D + Q1N + Q2D’N’ D3 = Q1D + Q2D + Q2N + Q3 OPEN = Q3

FSM partitioning Break a large FSM into two or more smaller FSMs Rationale Less states in each partition Simpler minimization and state assignment Smaller combinational logic Shorter critical path But more logic overall Partitions are synchronous Same clock!!!

Example: Partition the machine Partition into two halves C1 C2 C3 C4 C5 S1 S3 S2 S6 S4 S5

Introduce idle states for each partition SA and SB handoff control between machines C1 C2 C3 C4 C5 S1 S3 S2 S6 S4 S5 S1 S6 C1 C1•S1 (C2•S6)’ C2•S6 C2 (C1•S1+ C3•S2+ C4•S3+ C5•S2)’ S2 SA SB C3•S2+ C4•S3 S5 C3+C5 S3 C4 S4 C5•S2

Partitioning rules Rule #1: Source-state transformation Replace by transition to idle state (SA) C1 C1 S1 S6 S1 SA Rule #2: Destination state transformation Replace with exit transition from idle state C2 C2•S6 S1 S6 S1 SA

Partitioning rules (con’t) Rule #3: Multiple transitions with same source or destination Source  Replace by transitions to idle state (SA) Destination  Replace with exit transitions from idle state C3 S2 C3+C5 C3•S2 + S5 S2 S5 C4•S3 SA SB C4 C5 C4 S3 S4 S3 C5•S2 S4 Rule #4: Hold condition for idle state “OR exit conditions and invert” C2•S6 C2•S6 S1 SA

Example: Six-state up/down counter Break into 2 parts U  count up D  count down D U S0 S2 S1 S5 S3 S4

Example: 6 state up/down counter Count sequence S0, S1, S2, S3, S4, S5 S2 goes to SA and holds, leaves after S5 S5 goes to SB and holds, leaves after S2 Down sequence is similar S0 S5 U•S5 U U U D D (D•S3 + U•S5)’ (D•S0+ U•S2)’ D•S0 D SA SB S1 S4 D•S3 D D D U U U•S2 U S2 S3

Example: 6 state up/down counter Compare behavior on UUUUUU: S0 S5 U•S5 U U U D D (D•S3 + U•S5)’ D•S0 D SA (D•S0+ U•S2)’ S1 SB S4 D•S3 D D D U U U•S2 U S2 S3

Example: 6 state up/down counter 4-state machines need 2 state bits each – total 4 state bits Enough to represent 16 states, though the combination of the two FSMs has only 6 different configurations Why do this? Each FSM may be much simpler to think about (and design logic for) than the original FSM (not here, though) Essential to do this partitioning for large FSMs S0 S5 U•S5 U U U D D D•S0 D SA (D•S3 + U•S5)’ (D•S0+ U•S2)’ S1 SB S4 D•S3 D D D U U U•S2 U S2 S3

Minimize communication between partitions Ideal world: Two machines handoff control Separate I/O, states, etc. Real world: Minimize handoffs and common I/O Minimize number of state bits that cross boundary Merge common outputs

Mealy versus Moore partitions Mealy machine partitioning is undesirable Inputs can affect outputs immediately “output” can be a handoff to another machine!!! Moore machine partitioning is desirable Input-to-output path always broken by a flip-flop But…may take several clock cycles for input to propagate to output

Another Encoding Example: Digital combination lock An output-encoded FSM Punch in 3 values in sequence and the door opens If there is an error the lock must be reset After the door opens the lock must be reset Inputs: sequence of number values, reset Outputs: door open/close reset value open/closed new clock

Separate data path and control Design datapath first After the state diagram Before the state encoding Control has 2 outputs Mux control to datapath Lock open/closed reset open/closed new C1 C2 C3 comparator value equal multiplexer controller mux control clock 4

Draw the state diagram closed mux=C1 start equal & new not equal & new not new S0 S1 S2 S3 ERR mux=C2 mux=C3 open

Design the datapath Choose simple control 3-wire mux for datapath comparator equal multiplexer mux control 4 value C1i C2i C3i mux control valuei equal Choose simple control 3-wire mux for datapath Control is 001, 010, 100 Open/closed bit for lock state Control is 0/1

Output encode the FSM FSM outputs State are: S0, S1, S2, S3, or ERR Mux control is 100, 010, 001 Lock control is 0/1 State are: S0, S1, S2, S3, or ERR Can use 3, 4, or 5 bits to encode Have 4 outputs, so choose 4 bits Encode mux control and lock control in state bits Lock control is first bit, mux control is last 3 bits S0 = 0001 (lock closed, mux first code) S1 = 0010 (lock closed, mux second code) S2 = 0100 (lock closed, mux third code) S3 = 1000 (lock open) ERR = 0000 (error, lock closed)

FSM has 4 state bits and 2 inputs... Output encoded! Outputs and state bits are the same How do we minimize the logic? FSM has 4 state bits and 2 inputs (equal, new) 6-variable K-map for all five states? Way too complicated Notice the state assignment is close to one-hot ERR state (0000) is only deviation Is there a clever design we can use?

Encode 4 state bits closed mux=C1 start equal & new not equal & new not new S0 S1 S2 S3 ERR mux=C2 mux=C3 open A clever way for ERR is to use both Preset/Reset in existing flipflops. Not equal & new S0+ = S0N’ S1+ = S0EN + S1N’ S2+ = S1EN + S2N’ S3+ = S2EN + S3 Preset0 = start Preset1,2,3 = 0 Reset0 = start’(E’N + (Q0+Q1+Q2+Q3)’) Reset1,2,3 = start + (E’N + (Q0+Q1+Q2+Q3)’) Already in ERR

Reset0 = start’(E’N + (Q0+Q1+Q2+Q3)’) D0 = Q0N’ D1 = Q0EN + Q1N’ D2 = Q1EN + Q2N’ D3 = Q2EN + Q3 S0 E N S1 N’ S1 Preset0 = start Preset1,2,3 = 0 Reset0 = start’(E’N + (Q0+Q1+Q2+Q3)’) Reset1,2,3 = start + (E’N + (Q0+Q1+Q2+Q3)’) S1 E N S2 N’ S2 S0 S1 S2 S3 S2 E N S3