Chapter 5 – The State Editor

 

1)      Create a new project called “chap5”.

2)      Right-click in the “Sources in Project” window and select “New Source …”.

3)      Choose “State Diagram” and name it “state”.  Click “Next” and “Finish”

4)      Click the  button.  Choose “Geometric” on the next window and “Asynchronous” on the one that follows.

5)      On the last window, pick the following”

 

6)      When you click “Finish”, place the green box and you should see something like:

 

 

7)      Double-click “STATE0” and you should see:

 

8)      Click Output Wizard and enter as below:

 

9)      Continue through each state setting “lights” equal to the number of the state (You can just type it instead of using the output wizard.  When you are finished, it should resemble:

 

10)  Click the  button.  Set lights as a register and ignore any warnings.

11)  Close the state editor and return to the main window.

12)  Add a new source file.  There should be a “state.v” file.  Add this.  Also add “CPLD_control.v” from Chapter 2.

13)  “Create Schematic Symbol” on both Verilog files.

14)  Create a new schematic called “sch1”.  Add a “state” and “CPLD_control” part and connect them as shown below:

 

15)  Click the  button to add bus taps, and then draw wires from the taps to the inputs of “state” as follows:

 

16)  Connect the bus taps to the inputs of “state”.  Rename the bus “buttons_low(7:0)” by  double clicking it.  Use the  button to rename each wire as shown below:

 

17)  Close the schematic editor and return to the main window.  Use the “examples.ucf” from Chapter 2 to set the constraints.

18)  Program the chip.  If everything works like it’s supposed to, the switches should make some LEDs blink (but this is not important).  If you hold “B1” while pressing “B0”, the 7 segment LEDs should count up from zero.  You may have to press “B2” to reset it though.

 

Assignments

1)      Write a simple traffic light controller that cycles through two sets of lights.  Use 2 green LEDs, 2 red and 2 yellow.  It should act like to lights at a regular intersection.