Finite State Machine
180 likes | 458 Vues
Finite State Machine. Switching and Logic Lab Standard Laboratory Exercises. Suggestions and Warnings. Read for detail and comprehension Should be able to complete within normal laboratory period.
Finite State Machine
E N D
Presentation Transcript
Finite State Machine Switching and Logic Lab Standard Laboratory Exercises
Suggestions and Warnings • Read for detail and comprehension • Should be able to complete within normal laboratory period. • Make sure you program unused pins as tri-state inputs or you may burnout EPM7128S device on PLDT-2.
Vending Machines • Project 1 -- Basic Vending Machine • Combinational Logic • State • Moore Outputs • Sequential Devices -- D Flip-Flops • Project 2 -- Modified Vending Machine • Provides change • Add state and modify transitions
State Diagram 2 State Bits
Vending Entity ENTITY Vending IS PORT ( Nickel, Dime, Reset, Clk : IN BIT; Dispense : OUT BIT ); END Vending;
Vending Architecture ARCHITECTURE Moore OF Vending IS TYPE State_Type is (ZeroCents,FiveCents,TenCents, FifteenCents); SIGNAL State : State_Type; BEGIN --FSM Logic --Moore Output logic goes here END Moore;
Finite State Machine Logic --FSM Logic Goes Here FSM: PROCESS BEGIN IF Reset = '1' THEN State <= ZeroCents; ELSIF (CLK'event AND Clk = '1') THEN • • • • • END PROCESS FSM; Sequential Process Statement
Moore Output Logic --Moore Output logic goes here Output: PROCESS(State) BEGIN CASE State IS WHEN FifteenCents => Dispense <= '1'; WHEN Others => Dispense <= '0'; END CASE; END PROCESS Output; Dispense = State_Bit_0 & State_Bit_1;1 1Technology Map Netlist Viewer
State Logic CASE State IS WHEN ZeroCents => IF Dime = '1' THEN State <= TenCents; ELSIF Nickel = '1' THEN State <= FiveCents; ELSE State <= ZeroCents; END IF; WHEN FiveCents => IF Dime = '1' THEN State <= FifteenCents; ELSIF Nickel = '1' THEN State <= TenCents; ELSE State <= FiveCents; END IF;
State Logic (Continued) WHEN TenCents => IF Dime = '1' THEN State <= FifteenCents; ELSIF Nickel = '1' THEN State <= FifteenCents; ELSE State <= TenCents; END IF; WHEN FifteenCents => IF Reset = '1' THEN State <= ZeroCents; ELSE State <= FifteenCents; END IF; END CASE;
State Equations1 State_Bit_1.T = Dime & !State_Bit_1 + !State_Bit_1 & State_Bit_0 &Nickel State_Bit_1.Clk = Clk State_Bit_1.Rst = Reset State_Bit_0.D = !(Dime & !State_Bit_0 & State_Bit_1 + Nickel & Dime & !State_Bit_0 & State_Bit_1 + !Nickel & !Dime & ! State_Bit_0 State_Bit_0.Clk = Clk State_Bit_0.Rst = Reset 1Technology Map Netlist Viewer
Simulation & Verification Scenarios • Nickel, Nickel, Nickel Dispense • Nickel, Dime Dispense • Dime, Dime Dispense • Nickel, Nickel, Dime Dispense • Do not violate setup and hold time in simulation
8 Steps to Success • Create Project (tri-state as input all unused pins) • Capture Logic • Analysis and Synthesis • Pin Assignments • Full Compile • Timing Simulation • Programming • Exercise circuit
Revised Vending Machine • Gives nickel change from 20¢ • Does not require reset after 15¢ and 20 ¢ states. 20¢ Change, Dis 0¢ 5¢ 10¢ 15¢ Dis Reset
8 Steps to Success • Create Project (tri-state as input all unused pins) • Capture Logic • Analysis and Synthesis • Pin Assignments • Full Compile • Timing Simulation • Programming • Exercise circuit
Unused Pins as Tri-State Inputs • Select “Assignments” • Select “Device” • Select “Device & Pin Options” • Select “Unused Pins” Tab • Select “As inputs, tri-stated” • OK