Motivation FSMs 1 Combinational logic functions can be
Motivation FSMs 1 Combinational logic functions can be represented, and defined, by truth tables. Sequential logic function cannot, because their behavior depends upon both the state of their inputs and their current state. Implementing the control logic for a CPU will require using sequential logic functions, and we need a tool to express and model those functions mathematically. CS@VT September 2009 Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens
Finite State Machine FSMs 2 A finite state machine (FSM) is… - a finite set of states Q = {S 0, S 1, . . . , SN}, and - a set of possible input values I = {i 0, i 1, . . . , i. K}, and - a set of possible output values O = {o 0, o 1, . . . , o. M}, and - a next state function F: Qx. I S, and - an output function G: Qx. I O The next state function maps the current inputs and the current state the next state of the FSM. The output function maps the current state and possibly the current inputs to a set of asserted outputs. CS@VT September 2009 Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens
Simple Example FSMs 3 Here's a simple FSM representing a basic digital function. We have: Q = {E, O} I = {0, 1, end} O = {'E', 'O'} 0 1 E What's the next state function? start O end/O 1 halt end/E What does it DO? CS@VT September 2009 0 Current State Input Next State E 0 E E 1 O E end halt O 0 O O 1 E O end halt Computer Organization I Output 'E' 'O' © 2006 -09 Mc. Quain, Feng & Ribbens
Traffic Light Controller FSMs 4 Consider a traffic light (red/green only) at an intersection of a north-south street with an east-west street; there are two input signals: NScar: Indicates that a car is over the detector placed in the roadbed in front of the light on the northsouth road (going north or south). EWcar: Indicates that a car is over the detector placed in the roadbed in front of the light on the east-west road (going east or west). The traffic light should change from one direction to the other only if a car is waiting to go in the other direction; otherwise the light should continue to show green in the same direction as the last car that crossed the intersection. CS@VT September 2009 Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens
Traffic Light Controller Output Signals FSMs 5 There are two output signals: NSlite: When this signal is asserted (1), the light on the north-south road is green; when this signal is deasserted (0), the light on the north-south road is red. EWlite: When this signal is asserted (1), the light on the east-west road is green; when this signal is deasserted (0), the light on the east-west road is red. Arguably, it is acceptable if both output signals are deasserted at the same time, but clearly they must never both be asserted at the same time. CS@VT September 2009 Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens
Traffic Light Controller States FSMs 6 We need two states: NSgreen: the traffic light is green in the north-south direction EWgreen: the traffic light is green in the east-west direction CS@VT September 2009 Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens
TL Controller Schematic CS@VT September 2009 FSMs 7 Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens
TL Controller Next-State & Output Fns FSMs 8 Inputs Current State NScar EWcar Next State NSgreen 0 0 NSgreen 0 1 EWgreen NSgreen 1 0 NSgreen 1 1 EWgreen 0 0 EWgreen 0 1 EWgreen 1 0 NSgreen EWgreen 1 1 NSgreen Outputs CS@VT September 2009 Current State NSlite EWlite NSgreen 1 0 EWgreen 0 1 Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens
TL Controller Next-State Analysis FSMs 9 Inputs Current State NScar EWcar Next State NSgreen 0 0 0 NSgreen 0 1 1 NSgreen 1 0 0 NSgreen 1 1 1 EWgreen 0 0 1 EWgreen 0 1 1 EWgreen 1 0 0 NSgreen EWgreen 1 1 0 NSgreen EWgreen Let's represent the states NSGreen and EWGreen by 0 and 1, respectively. Then: CS@VT September 2009 Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens
TL Controller Output Analysis FSMs 10 Outputs CS@VT September 2009 Current State NSlite EWlite 0 NSgreen 1 0 1 EWgreen 0 1 Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens
TL Controller Implementation From slide #9 CS@VT September 2009 FSMs 11 1 -bit storage device Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens
Relationship to Hardware FSMs 12 Common design issues in hardware control can be efficiently represented analyzed using FSMs. CS@VT September 2009 Computer Organization I © 2006 -09 Mc. Quain, Feng & Ribbens
- Slides: 12