This document describes a lab assignment to design a state machine that controls two stoplights. The state machine must follow the normal stoplight pattern of red, yellow, green for each light as well as a "quiet" pattern. It must also have an input that causes it to enter a hold state with both lights red. The student implements the design in Xilinx ISE, simulates it, and programs an FPGA board with LEDs connected to outputs to demonstrate the working stoplight patterns.
State Machine Design - Traffic Light Controller EGRE 254
1. Jake Ramey EGRE 254 – Digital Logic Design Lab 10 due 4/22/14
Rahel Mekonnen
1
ELECTRICAL ENGINEERING
School of Engineering
EGRE 254 – DIGITAL LOGIC DESIGN
Laboratory No.10: State Machine Design
Lecture Course Instructor: R. Klenke
Lab Section: Thursday 1530
Date Performed: 4 April 2014
Date Due: 22 April 2014
Student's Name: Jacob Ramey
Partner's Name: Rahel Mekonnen
Honor Pledge: I have neither given nor received any unauthorized help on this
lab. Signed:
_____________________________________________
2. Jake Ramey EGRE 254 – Digital Logic Design Lab 10 due 4/22/14
Rahel Mekonnen
2
Introduction:
The purpose of thislabis to designastate machine that controlsthe operationof twostoplights.It
shouldfollow the normal operationof the stoplightaswell asthe follow the ‘quiet’model,whichis
slightlydifferent.There mustbe aninputincorporatedsothatwhenasserted,all inputswill hold atthe
Redstate.
Background and Theory:
To construct a Moore state machine that keepsanycars fromcrashing,we mustincorporate a
couple safetymeasures.
Figure 1: Showing the orientation of the stoplights- this will affect the design since we must make it so anytime
one light is green, the other is red to avoid crashes.
There needstobe 2 inputs- the firstshouldbe behave that,whenasserted,the machinewill
switchto a red state andholdthere until the inputisturnedoff. The secondinputshouldswitchthe
stoplightcontrollerfromabusyroad model toa quietroadmodel- Busy(2R,4G,1Y) and the quietmodel
will followasimilarsetuptothe one inthe previouslabreports.
3. Jake Ramey EGRE 254 – Digital Logic Design Lab 10 due 4/22/14
Rahel Mekonnen
3
Procedure:
First,designaMoore state machine withthe parametersdescribed.Draw the state transition
table,the state diagram,andthe minimal expressionsforeachflipflopsvariables.Create the circuitthat
was designedfromthe above descriptioninXilinuxISEsuite.
Whenbuildingthe circuitinXilinux use the Dflipflopthatisinthe libraryalreadyandthe
necessaryAND,OR,NOT,NOR,XOR or NANDlogicforstate transitionsandoutputs.Simulate the results
inXilinux ISimshowingthe correctoperationof the problemstatementaswell asthe resetfunctionality.
It isimportantto showall the outputsfor eachlight.
Submita printoutof the schematicandsimulationoutputs,aswell asthe state transition
diagramthat was drawnfor the problemstatement.Show the resultstothe TA at the beginningof the
labperiod- handwrittenprelabswill notbe accepted.
Once the correct resultshave beensimulatedandsignedoff bythe TA’sorinstructors,hookup
the LEDs onthe cadetboard and attach themto the Pmodsas seenin Figure 2. In orderto buildthe
stoplightcircuitdescribedbelow, twoPmodconnectorswill be needed.
4. Jake Ramey EGRE 254 – Digital Logic Design Lab 10 due 4/22/14
Rahel Mekonnen
4
Figure 2: Schematic showing the configuration of the components for the stoplight. A Pmod transition is placed in
series with an LED and a resistor.
Generate the programmingfile necessarytoinstalltothe FPGA so that itfunctionsasa
stoplight.Connectthe Pmodstothe FPGA as and inserieswiththe LED sothat whenthe FPGA closes
the path and allowselectricitytoflow(behavinglikeaswitch),thatparticular LED will turnon.
Experimental Results
Figure 3: Schematic of actual design implemented into Xilinux
5. Jake Ramey EGRE 254 – Digital Logic Design Lab 10 due 4/22/14
Rahel Mekonnen
5
Figure 4: Simulation Results of the above schematic in figure 3
Figure 5: The VDHL code necessary to get the simulation results shown in Figure 4.
Figure 6: the User constraints file
6. Jake Ramey EGRE 254 – Digital Logic Design Lab 10 due 4/22/14
Rahel Mekonnen
6
Conclusion
The use of an FPGA isa great wayto designa logical systemif one isavailableforuse.After
designingthe programinXilinux ISEandsimulatingthe results,the circuitwasable tobe programmed
ontoa boardthat carriesall the necessarylogicgatestoimplementthe functionsdefinedinthe
program.WhenconnectingPmodstothe FPGA and the BASYS2 board,the transistors are connectedin
serieswiththe LED andact as a switch- turningthe LED on or off at the appropriate times.The
groundingof the LEDs was not directlydone onthe board,butthe groundingof the Pmodwassufficient
for the entire circuitsince all currentflowedintothe Pmod.