Starting from:

$30

Assignment 4 Traffic Light System

CS223 Laboratory Assignment 4
Traffic Light System
Preliminary Work Submission Deadline:
All Sections: 28th Nov, Mon 09:00
Lab dates and times:
Section 1: 28th Nov, Mon 08:30-12:20 in EA-Z04
Section 2: 29th Nov, Tue 08:30-12:20 in EA-Z04
Section 3: 30th Nov, Wed 08:30-12:20 in EA-Z04
Section 4: 28th Nov, Mon 13:30-17:20 in EA-Z04
Section 5: 2nd Dec, Fri 08:30-12:20 in EA-Z04
Section 6: 29th Nov, Tue 13:30-17:20 in EA-Z04
Location: EA Z04 (in the EA building, straight ahead past the elevators)
Groups: Each student will do the lab individually. Group size = 1
Traffic Light System
In a community, people need stop signs and traffic lights to slow down drivers from going too
fast. If there were no traffic lights or stop signs, people’s lives would be in danger from divers
going too fast. These devices also play a role in road safety. While accidents still occur at
intersections, these crashes may have been prevented by the drivers yielding to the traffic
lights and improving the traffic lights timings. To reduce danger at the intersections, the time
for switching red light to green light and green light to red light should be regulated carefully.
Studies show if both lights are red for 3 seconds before either light turns green again prevents
a huge amount of accidents in traffic.
The traffic light system is similar to the example on pages 124-129 in the textbook. The roads
in which intersect are Road A and Road B. There are sensors SA and SB installed in each
roadto sense the traffic. Each sensor will be TRUE if traffic is present and FALSE if the road
is empty. There are two traffic lights LA and LB to control the traffic. The lights may change
every 3 seconds depending on the sensors and time. Every time the green light switches from
a light to the other one, the green light should turn to yellow for 3 seconds, then both lights
must be red for 3 seconds. Lastly, the other light should turn to yellow for 3 seconds and turn
to green. Suppose that a sensor output is TRUE, then its light should be green if the other
sensor output is FALSE. If both sensor outputs are TRUE, the green light should circulate
between LA and LB with 6 seconds time period (excluding the switching delay). Basically, in
case of at least one of the sensor outputs is TRUE, both lights cannot be green at the same
time and both lights can be red at the same time for only 3 seconds. If both sensor outputs are
FALSE (which should be the initial state), LA should be green and LB should be red. In other
words, you need to give privilege to Road A in this state.
(Hint: You may have to define new inputs other than the sensors SA and SB in order to
manage the time-varying changes of the lights. If you do, explain them clearly.)
● Preliminary Design Report (30 pts)
All the content in the preliminary report must be machine-printed. No hand-written or
hand-drawn content will be accepted.
A number of tasks in today's lab need advanced preparation. You should make your report as
neat as possible, with a cover page and pages for the System Verilog codes. You may need a
copy of your designs and System Verilog programs with you in the lab: to work with, to refer
to, to possibly correct and change, to discuss with the TA, to use in debugging.
A cover page that includes the following (in order from the top): course name and code
number, the number of the lab, the name and ID number, and the date of you submit the
report. The contents of the report should be as follows:
a) Your improved Moore machine state transition diagram, state encodings, state transition
table, output table, next state, and output equations.
b) Your Finite State Machine schematic.
c) How many flip-flops do you need to implement this problem?
d) Redesign of your outputs using decoders.
e) Your System Verilog design code and testbench.
● Simulation (30 pts)
Enter Verilog module to Xilinx ISE software and select simulation mode. Prepare a testbench
using the Verilog Test Fixture of the ISE software. In the simulation, try all possible variations
through the inputs (including the sensors SA and SB) and observe the LA and LB traffic
lights.
● Implementation on FPGA (40 pts)
In this part, you are going to implement your code on FPGA.
1) Slow down the clock to 3 seconds to see the change in the lights.
2) Use LEDs on the BASYS board for outputs of LA and LB traffic lights.
Red : *** (three leds)
Green: ** (two leds)
Yellow: * (one led)
3) The SA and SB sensors will be two left-most buttons. The sensor will be active when as
long as the button is set to 1.
Now test your code and show the result to your TA.
Cleanup!
Clean up your lab station, and return all the parts, etc. Throw away any parts that do not work.
Save your project on a flash memory stick. Delete the Xilinx Project you created and any files
you created today so that the computer is in the same state that you found it. Now turn off the
computer, and leave your lab workstation for others the way you would like to find it—clean
and organized.

More products