COSC 201: Computer Organization

Lab 6: Finite State Machines

Purpose
Learn how finite state machines work and build a circuit for an FSM
Method
Define a FSM for a traffic light and create a circuit for it.
Preparation
Read Appendix B from H&P
Files to Use
           trafficLightTT.txt,   trafficMain.circ and trafficStart.circ
What to Hand In
Completed trafficLightTTXX.txt and trafficXX.circ (XX are your initials.)

The following specification indicates how the traffic light at Broad and College streets works.(If you don't like this spec, you can go time the light and construct your own specification, then work from there.)We ignore the yellow light, assuming that a separate part of the circuit triggers the yellow for four seconds at the appropriate time, based on the transitions from green to red.
  1. The clock cycle is 15 seconds.
  2. Broad street is green (BG) when college street is red, and Broad street is red (BR) when college street is green.
  3. Broad street is never red (BR) for more than 30 seconds.
  4. Broad street stays green (BG) at least 30 seconds.
  5. If there are no cars waiting (Bcar = 0 and Ccar = 0), then the next light is BG.
  6. If Broad street has been green (BG) for 30 seconds there is a car on College (Ccar = 1), then the next light is BR.
  7. If Broad street has been green (BG) for 30 seconds there is no car on College (Ccar = 0), then the light remains green on Broad (BG).
  8. If Broad street has been red (BR) for 15 seconds and there is no car on Broad and there is a car on College (Bcar = 0 and Ccar = 1), then the light stays red on Broad (BR).
  9. If Broad street has been red (BR) for 15 seconds and there is a car on Broad (Bcar = 1), then the light changes to green on Broad (BG).

Use a four state finite state machine to model this control: states are BG0, BG1, BR0, BR1, where BG0 means Broad Green for first clock cyle, BG1 means Broad green for a second or later clock cycle, BR0 means Broad Red for a first clock cycle and BR1 means Broad red for second clock cycle.This can be represented by two bits, the BG bit is 1 if BG and 0 if BR, the other bit is 0 for first clock cycle, 1 for second or later clock cycle.The inputs are Bcar which can be 0 or 1 and Ccar which can be 0 or 1, indicating whether there are one or more cars at the light on the given street.

1. Draw a finite state machine diagram for the traffic light - use drawing tools and send this along with the trafficLightTTXX.txt file.

2. Complete the truth table given in the trafficLightTT.txt file and add a truth table that includes don't-care entries.

3. Complete the circuits for the transitions in the file trafficStart.circ and save it as trafficXX.circ. Then add this file to the trafficMain.circ file: (a) open the trafficMain.circ file; (b) delete the component labeled "transition" and under the project menu unload libraries and unload trafficStart; (c) under the menu selection Project-load library-logisim library select your traffic file, then put the component in place of the transition component.

4. Experiment with your circuit to see that it behaves as expected. The output should show when the light is green or red for Broad street..

Hand in your file trafficLightTTXX.txt, including your state diagram and with the truth tables filled out, and your trafficLightXX.circ file via email.