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. Computer Organization I
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. Computer Organization I
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 0 E What's the next state function? start O end/O 1 end/E What does it DO? 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' halt
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. Computer Organization I
Traffic Light Controller Output Signals 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. Computer Organization I FSMs 5
Traffic Light Controller States 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 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. Computer Organization I FSMs 6
TL Controller Next-State & Output Fns Computer Organization I FSMs 7
TL Controller Schematic FSMs 8 Computer Organization I
TL Controller Next-State Analysis FSMs 9 Let's represent the states NSGreen and EWGreen by 0 and 1, respectively. Then: Computer Organization I
TL Controller Output Analysis Computer Organization I FSMs 10
TL Controller Implementation Computer Organization I FSMs 11
Relationship to Hardware FSMs 12 Common design issues in hardware control can be efficiently represented analyzed using FSMs. Computer Organization I
- Slides: 12