Each state is designed to take one second. To achieve this, a clock module was imported into the design to convert the 25MHz base clock into seconds and milliseconds. This clock was then used to transition the states of the controller. The code used to achieve the state transitions on each seconds was as follows, where S transitions each second as defined by the clock manager. This process insures that a state will last for exactly one second and will always transition.
process(S) begin if S'event and S = '1' then state <= nextstate; end if; end process;
The design made use of 5 concurrent processes, each of which control specific tasks. The tasks that each process controlled are as follows: Clock manager, …show more content…
Where each second of the traffic flow, with the yellow and red light phases included count as an individual state. However, to add pedestrian crossing functionality some of these states have slight alterations which cause certain behaviors to change within those states if a pedestrian crossing button is active.
An implementation file was generated to map the signals generated within the design to physical output pins, to connect the appropriate LED’s, switches and buttons. The design used a separate signal for each group of traffic lights, in 3 bit vectors in the order red, yellow and green. There were 10 of these vectors to control all 30 individual LED’s. 2 bit vectors were used for the pedestrian crossing LED’s.
Each flow would remain green for the relevant traffic for the total duration as listed in figure 5, with an additional second for both yellow and red states. At the end of each flow, bar flows 5 and 6, there will be an all red state where every traffic light is red. Flow 5, will always transition to flow 1, for this reason the traffic straight through from A will continue to remain green during the yellow and red states as they will go green anyway in flow 1. A similar system is used from the transition from 6 to 1, where straight through traffic from C will remain