1 / 25

Finite State Machines

Finite State Machines. By Mike Chen. Finite State Machines vs. Combinational Logic Units. Combinational logic units are a type of logic circuit whose output is a pure function of the present input only.

mave
Download Presentation

Finite State Machines

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Finite State Machines By Mike Chen

  2. Finite State Machines vs. Combinational Logic Units • Combinational logic units are a type of logic circuit whose output is a pure function of the present input only. • Finite State Machines, used in sequential logic, have outputs that depend on both the present input as well as the history of the input.

  3. A Finite State Machine • A sequential logic unit which • Takes an input and a current state • Produces an output and a new state • It is called a Finite State Machine because it can have, at most, a finite number of states. • It is composed of a combinational logic unit and flip-flops placed in such a way as to maintain state information.

  4. Representing a Finite State Machine • It can be represented using a state transition table which shows the current state, input, any outputs, and the next state.

  5. Representing a Finite State Machine • It can also be represented using a state diagram which has the same information as the state transition diagram. Input / Output State0 State1 Input / Output

  6. Example 1: A Modulo-4 Synchronous Counter • Counts from 0 to 3 and then repeats. • It has a clock input (CLK) and a RESET input. • Outputs appear as a sequence of values (q1 and q0) at time steps corresponding to the clock. • As the outputs are generated, a new state (s1s0) is generated which takes on values of 00, 01, 10, and 11 and are fed back to the input.

  7. The Mod-4 Counter • Requires four states, encoded in binary, with at least two bits for them to be encoded uniquely. • A = 00 • B = 01 • C = 10 • D = 11 • The input requires only a single bit. • 0 | 1

  8. State Transition Diagram for the Mod-4 Counter

  9. State Table for the Mod-4 Counter

  10. State Assignment for the Mod-4 Counter

  11. Truth Table for the Mod-4 Counter

  12. Logic Design for Mod-4 Counter

  13. Example 2: A Sequence Detector • Design a sequence detector using D flip-flops and 8-to-1 multiplexers. • The sequence detector outputs a 1 when exactly two of the last three inputs are 1. • An input of 011011100 produces the output of 001111010 • There is a one-bit serial input line and we will assume that initially no inputs have been seen. • Note: the sequence detector cannot output a 1 until at least three inputs have been read.

  14. The Sequence Detector • There are a total of eight sequences that the machine can observe: • 000, 001, 010, 011, 100, 101, 110, 111 • We will assume that state A is the initial state where no inputs have been fed into the machine. • In states B and C, only one input has been fed into the machine and therefore we cannot output a 1.

  15. State Transition Diagram for the Sequence Detector

  16. State Table and State Assignment for the Sequence Detector

  17. Truth Table for the Sequence Detector

  18. Creating the Circuit for the Sequence Detector • There needs to be one flip-flop for each state variable, so a total of three are needed. • Also, there are three next state functions and one output function, so four 8-to-1 multiplexers are needed.

  19. Logic Diagram for the Sequence Detector

  20. Example 3: A Vending Machine Controller • Design a vending machine controller using D-flip flops and a Programmable Logic Array (PLA). • The vending machine accepts three types of inputs: a nickel (5¢), a dime (10¢), or a quarter (25¢). • When the value of the total inserted coins equals or exceeds 20¢, the machine dispenses the merchandise, returns any excess change, and waits for the next transaction.

  21. The Vending Machine Controller • For simplicity, we will assume that if the machine currently has 15¢ and the user inserts a quarter, the merchandise will be dispensed, 15¢ will be returned, and the machine will keep 5¢ and await for more money. • This way, we can use 4 states to represent all possible states: A (00) = 0¢ C (10) = 10¢ B (01) = 5¢ D (11) = 15¢ • We will need two bits each to uniquely encode all possible states as well as inputs.

  22. State Transition Diagram for the Vending Machine Input / Output2Output1Output0 Input = Nickel | Dime | Quarter Output2 = 1|0 = Dispense / Do not dispense merchandise Output1 = 1|0 = Return / Do not return a nickel in change Output0= 1|0 = Return / Do not return a dime in change

  23. State Table and State Assignment for the Vending Machine Present State = sn Input = xn Output = zn

  24. Truth Table for the Vending Machine • For the FSM circuit, we will need: • Two D flip-flops to represent the two state bits. • PLA that takes four inputs (two for the present state bits and two for the coin bits) and has five outputs (two for the next state bits and three for the dispense and return bits).

  25. Logic Design for the Vending Machine x1 z2 5x5 PLA x0 z1 z0 Assumes the clock input is asserted only on an event such as the user inserting a coin into the machine. Q D s0 CLK Q D s1

More Related