Hi,
I got this instruction given:
> For each of the following three scenarios, initially assume that the East-West traffic has had a green traffic light for a long time.
1) If a North-South car is detected then the traffic lights will cycle to green in that direction. The walk light will not be on unless a pedestrian is detected then the lights have finished cycling to Green.
2) If a North-south pedestrian is detected then the lights will cycle in a similar fashion but the appropriate walk light will be displayed for a short interval when cycling to Green.
3) If an East-West pedestrian is detected then the appropriate walk light will be displayed for a short interval before returning to East-West having a green light for traffic only.
> Once the lights have changed to green in a particular direction they:
1) Will remain green for minimum time before another change in possible,
2) Will remain green unless an input situation requires the lights to cycle i.e. the lights do not cycle between directions without cars and/or pedestrians being present.
> If a pedestrian wishing to cross with the traffic is present and a car/or pedestrian is present on the cross road then the lights will cycle before the 1st mentioned pedestrian is shown a walk light.
> The intersection is symmetrical-neither road has precedence. The description given above may be applied to the other direction with obvious substitutions being used.
Some Points to Note:
1) The pedestrian buttons will not be held. They are only pressed briefly as would be the case for real pedestrian call buttons.
2) The car buttons may be assumed to be help since they represent car detectors in the road and would be active as long as the car was present. Cars that appear and then disappear before the lights change may be ignored.
3) The clock for the system should be at least `00 Hz so that system will be responsive to brief button presses.
4) All synchronous elements of the design should operate on the same clock.
5) To prevent input race conditions you must have single point synchronisation of external inputs before using them, as input to a synchronous circuit.
6) There must be no gated clocks and no latches.
7) An asynchronous reset single should be used to reset all synchronous circuits(input synchronization, counters and the state machine) when the board is initially powered up. It should not be used to restart the time as part of the usual circuit operation.
8) Asynchronous reset or set operations should not be otherwise used.
State machine provides the “intelligence” of the system. It controls the timer (mealy- style outputs), the lights (Moore-style outputs). Steady state machine respond to timer outputs, the car buttons (synchronised, the pedestrian buttons (synchronised & registered).
My Attempt:
Basically you need counter with multiple outputs to represent various time delays. It would have a synchronous clear input to re-start the time interval. I started doing basic traffic intersection which involves 4 different states. It allowed me sort out problems such as making a state machine, how are lights controlled?
State Machine approach: