1Finite State Recognizers and Sequence DetectorsECE 152A – Summer 2009August 10, 2009ECE 152A - Digital Design Principles2Reading AssignmentBrown and Vranesic8 Synchronous Sequential Circuits8.4 Design of Finite State Machines Using CAD Tools8.4.1 Verilog Code for Moore-Type FSMs8.4.2 Synthesis of Verilog Code8.4.3 Simulating and Testing the Circuit8.4.4 Alternative Styles of Verilog Code8.4.5 Summary of Design Steps When Using CAD Tools8.4.6 Specifying the State Assignment in Verilog Code8.4.7 Specification of Mealy FSMs Using Verilog2August 10, 2009ECE 152A - Digital Design Principles3Reading AssignmentRoth14 Derivation of State Graphs and Tables14.1 Design of a Sequence Detector14.2 More Complex Design Problems14.2 Guidelines for Construction of State GraphsAugust 10, 2009ECE 152A - Digital Design Principles4Mealy and Moore MachinesMealy MachineOutput is a function of present state and present inputOutputs valid on clock edge (transition)Simpler (possibly)Faster (possibly)Outputs “glitch”Used for synchronous (clocked) designs3August 10, 2009ECE 152A - Digital Design Principles5Mealy and Moore MachinesMoore MachineOutput is a function of present state onlyOutputs valid after state transitionMore “stable” than Mealy machineOutputs do not glitchAsynchronous (no clock) or synchronous designsAugust 10, 2009ECE 152A - Digital Design Principles6Deterministic RecognizersState DiagramAlso referred to as Deterministic Transition GraphNext state transition is determined uniquely by present state and present inputDeterministic RecognizerClassifies input strings into two classes:Those it acceptsThose it rejects4August 10, 2009ECE 152A - Digital Design Principles7Deterministic RecognizersSequential Lock AnalogyAccepted string corresponds to of the combination of the lockAccepted string opens the lockRejected string leaves the lock closedProvides a basis for general purpose, finite state machine (FSM) designControllers, peripheral interfaces, etc.August 10, 2009ECE 152A - Digital Design Principles8Deterministic RecognizersDefinition of statesStarting (or initial) state must be definedThe states whose assigned output is 1 are referred to as accepting (or terminal) statesThe states whose assigned output is 0 are called rejecting (or nonterminal) statesAbove definition of states and control implies a Moore finite-state machine With the requirement of a defined initial state5August 10, 2009ECE 152A - Digital Design Principles9Deterministic RecognizersDefinition of acceptance and recognitionA string is accepted by a machine if and only if the state that the machine enters after having read the rightmost symbol is an accepting stateOtherwise, the string is rejectedThe set of strings recognized by a machine thus consists of all the input strings that take the machine from its starting state to an accepting stateAugust 10, 2009ECE 152A - Digital Design Principles10Regular ExpressionsConcerned here with the characterization of sets of strings recognized by finite automataA compact language for describing such sets of strings is known as the language of regular expressionsExample 01(01)* describes the set consisting of those strings that can be formed by concatenating one or more 01 strings01 + 0101 + 010101 + 01010101 + ...6August 10, 2009ECE 152A - Digital Design Principles11Design ExampleDesign a Moore machine that recognizes the input string ending with 101Any string ending in 101 will be acceptedRegular expression is (1+0)*(101)111101 recognizes (accepts) string on sixth inputThe machine’s output goes to one each time the sequence 101 is detected10101 recognizes (accepts) string on the fifth inputCircuit’s output goes high on third input and fifth inputAugust 10, 2009ECE 152A - Digital Design Principles12Design ExampleState Diagram0020103100001111Starting StateAccepting State7August 10, 2009ECE 152A - Digital Design Principles13Design ExampleState table with secondary state assignment01100102101101130011001100100000ZA+B+A+B+ABx=1x=0PSNSAugust 10, 2009ECE 152A - Digital Design Principles14Design ExampleNext State MapsABx00 010111 10ABx00 010111 10111A+= x’B + xAB’B+= x1 111z=AB (from state table)8August 10, 2009ECE 152A - Digital Design Principles15Design ExampleDesign can now be implemented In discrete hardware, directly from next state maps with D flip-flops or using excitation tables for T or JK flip-flopsIn Verilog directly from state tableVerilog implementation followsAugust 10, 2009ECE 152A - Digital Design Principles16Moore Machine – Verilog Implementation Verilog Codestate[1] = state variable A state[0] = state variable BSymbolic states zero, one, two, three9August 10, 2009ECE 152A - Digital Design Principles17Moore Machine – Verilog ImplementationTiming SimulationInput sequence1 1 0 1 0 1 1 0 0terminal statestring acceptedMoore output (stable for following period)August 10, 2009ECE 152A - Digital Design Principles18Conversion to Mealy MachineRecall difference between Mealy and Moore machine is in generation of outputNote state table for design example01100102101101130011001100100000ZA+B+A+B+ABx=1x=0PSNSNext states are the same, butoutput is different10August 10, 2009ECE 152A - Digital Design Principles19Conversion to Mealy MachineAssign Moore output (state) to Mealy transition01100102101101130011001100100000ZA+B+A+B+ABx=1x=0PSNS11,100,010201,010.011301,010,001101,000,0000A+B+, ZA+B+, ZABx=1x=0PSNSAugust 10, 2009ECE 152A - Digital Design Principles20Conversion to Mealy MachineNote that rows 1 and 3 of the state table are identicalIdentical rows can be combined into a single state11,100,010201,010.011301,010,001101,000,0000A+B+, ZA+B+, ZABx=1x=0PSNS01,100,010201,010,001101,000,0000A+B+A+B+ABx=1x=0PSNS11August 10, 2009ECE 152A - Digital Design Principles21Conversion to Mealy MachineBecause outputs in a Mealy machine are associated with the transition and not the next state, states 1 and 3 can be combinedCall combined state “state 1” and eliminate state 3New state 1 entered with output of 0 from old state 1New state 1 entered with output of 1 from unchanged state 2Technically, no longer a finite state recognizer because of Mealy implementationNo longer an acceptance “state”August 10, 2009ECE 152A - Digital
View Full Document