State Machine Designs
The State Editor allows you to specify functionality using the "bubble state diagram" concept. Once you have described the state machine (or machines) using the State Editor's available graphics objects, the State Editor generates behavioral VHDL, Verilog, or XABEL code (depending on which language type was selected when the state diagram was begun). This code can then be synthesized to a gate-level netlist.
Creating the State Editor Design
- Click the FSM Editor icon in the Design Entry box on the Project Manager's Flow tab.
- When the State Editor window appears, you may select an existing FSM macro or create a new one. The following steps describe creating a new FSM macro with the Design Wizard.
- From the Design Wizard window, select Next.
- From the Design Wizard - Language window, choose VHDL, Verilog, or ABEL (Schematic Flow only) and select Next.
- In the Design Wizard - Name window, enter a name for your design. Select Next.
- Define your ports in the Design Wizard-Ports window. Select Next.
- In the Design Wizards - Machines window, select the number of State Machines that you want. Click Finish. The Wizard creates the ports and gives you a template in which you can enter your macro design.
- Create the design in the State Editor.
Defining States
- From the State Editor window, select FSM State or click on the State button in the vertical toolbar.
- Place the state bubble. The default state name is S1.
- Click on the state name to select it, then click again to edit the text.
- Type the desired state name.
- Click on the state bubble to select it. Click and drag the small squares to change the size and shape of the bubble. When the state bubble is large enough to hold the name, click and drag the state name to center it in the bubble.
- Repeat steps 1-4 to create new states.
To ensure that the state machine powers up in the correct state, you must define an asynchronous reset condition. This reset will not be connected in the schematic, but its presence directs the compiler to define the state encoding so that the machine will power up in the correct state.
- Select FSM Reset, or click Reset in the vertical toolbar.
- Place the reset symbol in the state diagram. Click inside a state bubble to define this as the reset state.
- To define the reset as asynchronous, right-click on the reset symbol and select Asynchronous.
Defining Transitions, Conditions, and Actions
Transitions define the changes from one state to another. They are drawn as arrows between state bubbles.
If there is more than one transition leaving a state, you must associate a condition with each transition. A condition is a Boolean expression. When the condition is true, the machine moves along the transition arrow.
Actions are HDL statements that are used to make assignments to output ports or internal signals. Actions can be executed at several points in the state diagram. The most commonly used actions are state actions and transition actions. State actions are executed when the machine is in the associated state. Transition actions are executed when the machine goes through the associated transition.
- From the State Editor window, select File Save to save the state diagram.
- Select Project Add to project.
- Select Synthesis Synthesize.
To complete the design, read the following sections in the order listed: