Download Finite State Automata and Flip-Flops: Implementing FSAs using Flip-Flops and more Slides Computer Science in PDF only on Docsity! 1 Finite State Machine Design Intro to Computer Architecture Flip-Flops and Finite State Automata • Finite State Automata (FSA) have states. • The system has to remember the current state. • Flip-Flops are one bit memories. • Flip-Flops can be used to remember the current state of an FSA . • A sequential logic circuit using Flip-Flops can implement an FSA. D Flip-Flop • A D flip-flop has l d t C D Qnext Comment 0 X Q No changeon y one a a input, D, plus enable, C prev 1 0 0 Reset 1 1 1 Set Clock • Many sequential logic circuits use a clock input. • A flip-flop can change state on a clock rising edge. • The new state will be available on the falling edge. Docsity.com 2 Overview of Design Process 1. Specifications start with a word description 2 C t Fi it St t A t t t d l. rea e a n e a e u oma a o mo e the system 3. Create a state table to indicate next states 4. Convert next states and outputs to output d fli fl i t tian p op npu equa ons 5. Simplify logic expressions 6. Draw resulting circuits Example • Create a sequential circuit that detects h th ti 1 i tw en ree or more consecu ve npu s have been received. • Inputs are checked each clock pulse. • The output will be true only when three or more 1 inputs have been detected . • The output will be false when zeroes and less than three inputs of 1 have been received. FSA for 3 Consecutive 1 inputs • State S0 : zero 1s detected • State S1 : one 1 detected • State S2 : two 1s detected • State S3 : three 1s detected ° Note that each state has 2 output arrows Moore Machine • With a Moore Finite State Automata, the t t i i t d ith th t t f thou pu s assoc a e w e s a e o e FSA. • Often the new state will be available during the second half of a clock pulse. • The output is related to the state and not how the FSA got to the state. • In our example, state 3 (three consecutive 1’s) has an output of 1. All other are zero. Docsity.com 5 Flip-Flops Required • If there are n states in the FSA, it will i l ( ) fli flrequ re og2 n p- ops. • If n is not an even power of two, you have to round up. • When n is not an even power of two, the truth table may have “don’t care” entries . Example: Parity Checker • Even parity is when the count of the “1” bit i bs s an even num er. • We want the output to be true when the parity is even. Parity FSA • The parity changes h 1 i i tw en a s npu • The parity stays the same on 0 input. How many flip-flops will be required to implement the parity? 1. 1 2. 2 3. 3 4. none Docsity.com 6 FSA Truth Table Q In D out 0 0 0 0 0 1 1 0 1 0 1 1 1 1 0 1 output = Q new D = Q’ * in + Q * in’ new D = Q XOR in Parity Implementation Computer Theory • In the 1930’s people started to develop the th f tieory o compu ng. • Noam Chomsky, a linguist, defined a series of machine that could recognize input of different complexity. • There is an equivalence between computing solutions and recognizing an input language. Chomsky Hierarchy Docsity.com 7 Regular Languages • A regular language can be recognized by Fi it St t A t ta n e a e u oma a. • Compilers use FSA to remove comments, separate strings and numbers and divide the input into a series of “tokens”. Context Free Languages • Most computer languages, like Java, C++, P l d PHP t t fear an , are con ex ree languages. • Context Free languages can be recognized by a FSA with a stack memory. Context Sensitive and R.E. • Context Sensitive languages and R i l E bl lecurs ve y numera e anguages can be recognized by a Turing Machine. • A Turing Machine can compute anything that a modern “real” computer can. • The Turing-Church thesis states: “Every function which would naturally be regarded as computable, can be computed by a Turing machine” Turing Machine • A Turing Machine has a FSA and a tape for memory. • Based on the state of the FSA and the current symbol on the tape, the Turing Machine can write a new symbol, move the tape left or right and change the state of the FSA . Docsity.com