Finite State Machines Fundamental Concepts.PDF - School of ...

144 downloads 134 Views 23KB Size Report
Finite State Machine Module: Fundamental Concepts ... shows the states named as A, B, and C. The states are defined by the values stored in the registers; for.
Finite State Machines

Finite State Machine Module: Fundamental Concepts Combinational logic circuits can perform many complex tasks, but they have no memory of past actions or events. They generate outputs based only on the current input values. A Finite State Machine, a type of sequential circuit, combines a combinational logic circuit with registers in order to include memory in the logic decisions. The “state” is a set of system variables that contain information about the sequence of inputs that led from an initial state to the current state. The current state is stored as a value in one or more registers. This circuit is easily built using a decoder and OR gates. A Finite State Machine can be represented by a transition diagram that shows what states are available and what input values cause a transformation from one state to another. The following transition diagram shows the states named as A, B, and C. The states are defined by the values stored in the registers; for example, State B corresponds to S1S0 = 01 where S1 is the value of Register 1 and S0 is the value of Register 0. The external input is X.

X=1

A (00) X=0

X=1 X=1

C (10) X=0

X=0

B (01)

Figure 1: State Transition Diagram.

The value of X on each arrow indicates what input value will cause the state to transition to the next state. For example, to get from state A to state B, the input X must be 0. If the input X is 1, then state A will stay in state A. The actual transition occurs after the next clock pulse in the circuit.

 Bonnie H. Ferri, School of Electrical and Computer Engineering, Georgia Tech, [email protected]

1

Finite State Machines

This diagram can be summarized in a truth table where NS1 represents the next value of S1 , that is, the value after the state transition:

State S1 S0 X New State NS1 NS0 A 0 0 0 B 0 1 A

0

0

1

A

0

0

B

0

1

0

C

1

0

B

0

1

1

A

0

0

C

1

0

0

C

1

0

C

1

0

1

A

0

0

--

1

1

0

--

--

--

--

1

1

1

--

--

--

Because there are three states, two registers are needed to be able to count up to three. The last two rows are empty because there is no fourth state. If the state machine is built correctly, it should never end up in the fourth state (which would be represented as S1=1, S0=1), and these rows can be ignored. The right side of the table shows the values in the next state. The top row of the table shows that State A (S1=0, S0=0) transitions to State B (S1=0, S0=1) when X=0. The second line shows that the system stays in State A (00) when X=1. The third line shows that the system transitions from State B (01) to State C (10) when X = 0; and so on. A finite state machine can be built from a decoder, OR gates, and registers (or flip-flops).

Decoders: A decoder has n inputs and 2n outputs. Below is the truth table for a 3-to-8 decoder—that is, 3 inputs and 8 outputs where A0 – A2 represent the inputs and Y0-Y7 represent the outputs. The circuit converts the binary representation of a number into an output pattern which has a “1” on the output pin associated with the decimal representation of the input with all other outputs are “0”. For example, the binary number 011 is equal to the decimal value 3, so Y3 = 1 with all other outputs equal to 0.

A2 A1 A0 Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 0 0 0 0 0 0 0 0 0 0 1 0

0

1

0

0

0

0

0

0

1

0

0

1

0

0

0

0

0

0

1

0

0

0

1

1

0

0

0

0

1

0

0

0

1

0

0

0

0

0

1

0

0

0

0

1

0

1

0

0

1

0

0

0

0

0

1

1

0

0

1

0

0

0

0

0

0

1

1

1

1

0

0

0

0

0

0

0

 Bonnie H. Ferri, School of Electrical and Computer Engineering, Georgia Tech, [email protected]

2

Finite State Machines

The icon for a 3 to 8 decoder is Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7

A0 A1 A2

3 to 8 decoder

A decoder can implement a combinational circuit that has multiple inputs and outputs. For example, look at the output NS0 in the state transition table. NS0 = 1 when S1S0X = 000. Let the decoder inputs be defined as A2A1A0 = S1S0X, then NS0 = Y0. Similarly, NS1 = 1 when S1S0X = 010 or when S1S0X = 100. So let NS1 = Y2 OR Y4. The NS1 and NS0 signals are connected to the registers, so that the registers will be updated with the new state when the clock signal goes from low to high.

Registers: Registers are the basic units of memory in a digital circuit. They can store a 0 or 1 and output it for other circuits to use. To change the value in the register, the new value is put on the incoming pin and the clock signal is changed from 0 to 1 (positive edge) to store the new value. Registers can be made from D flip flops.

IN

The value of IN (0 or 1) is only stored in the register when CLOCK goes from 0 to 1. OUT is always equal to whatever is currently stored in the register.

OUT

CLOCK State Machine Circuit Diagram: A state machine can be implemented with registers to hold the memory and a decoder and OR gates to perform the combinational logic. The state transition diagram in Figure 1 can be implemented using the circuit diagram shown in Figure 2.

 Bonnie H. Ferri, School of Electrical and Computer Engineering, Georgia Tech, [email protected]

3

Finite State Machines

X

NS0 NS1 Decoder

S1 CLOCK S0 CLOCK Figure 2: Schematic for the state machine with state transition diagram shown in Figure 1. .

 Bonnie H. Ferri, School of Electrical and Computer Engineering, Georgia Tech, [email protected]

4