Automatically generate a state transition diagram of the state machine FSM using ModelSim

One of the important contents of HDL code design is to design the program state machine FSM. The state transition controls the flow of the whole program. In order to understand the program, we often need to draw the state machine state transition, which seems intuitive, but Is there a way to automatically generate a state transition diagram?

Is there such a tool in ISE or ModelSim?

The answer is yes. There are such tools in ModelSim. Let's take ISE13.4 and ModelSim6.5 as examples. Use the simplest state machine code to explain how to automatically generate state transition diagrams.

code show as below:
Module Top_fsm(
Input clk,
Input rst,
Output reg fsm_out
);

Parameter IDLE = 3'd0, S1 = 3'd1, S2 = 3'd2, S3 = 3'd3, S4 = 3'd4, S5 = 3'd5;
Reg [2:0] status;
Always @ (posedge clk)
If(!rst)begin
Status <= IDLE;
End
Else begin
Case(status)
IDLE: begin
Fsm_out <= 1'b0;
Status <= S1;
End
S1: begin
Fsm_out <= 1'b1;
Status <= S2;
End
S2: begin
Fsm_out <= 1'b0;
Status <= S3;
End
S3: begin
Fsm_out <= 1'b1;
Status <= S4;
End
S4: begin
Fsm_out <= 1'b0;
Status <= S5;
End
S5: begin
Fsm_out <= 1'b1;
Status <= IDLE;
End
Default:begin
Fsm_out <= 1'b0;
End
Endcase
End
Endmodule

We switch directly to the ModelSim emulation mode in ISE as shown:

Switch directly to ModelSim simulation mode in ISE

Double-click on the Simulate Behavioral Model to open ModelSim.

Execute the View---FSM list command in ModelSim, as shown below:

Execute the View---FSM list command in ModelSim

Then you will find that there is one more label on the left side of ModelSim, as shown in the following two figures:

This is the case before the command is executed:

The execution of the command is like this:

At this time, under the FSM List tab, you can see the following content, double-click:

Then the following state transition diagram appears:

Then the following state transition diagram appears

At this time, the state transition diagram generated by the observation finds that all the states return the state IDLE in the case of reset. This is not expected. If you look closely at the menu bar, you can find that there is an FSM View item:

FSM View item

Remove the checkmark in front of the Show TransiTIons to "Reset" item and you will see that the return status IDLE is not displayed in the reset state, as shown below:

Show Transitions to

Attentive people will find that the state has not returned to IDLE in S5, but in the previous state transition diagram, there is indeed a state of Cond2:1 to state IDLE, which is estimated to be caused by software.

Simple applications are all these, deeper features to explore yourself.

Finally, let me talk about the shortcomings of this automatically generated state transition diagram: because the state transition diagram generated by default must be a circle, when your state is more complicated, it is not a simple switch, the generated state transition diagram is also It will be very messy and messy, and the readability will drop directly. I don't know if it can be adjusted or what better tool is generated?

Game Machine Wire Assembly

we are ok to provide cable assembly design assistance, rapid in-house prototyping(CAD, SOLIDWORK), manufacturing engineering, tool making, also accept flexible Qty,even including working round-the-clock to meet tight turning-round time requirements.


Our wire harness products are customized for various industry, like automotive, elecrical, mechanical, etc.

<

Electric harness
Date Cable For Communication
Radio Frequency Cable and Flat Cable
LCD Backlight Display Cable
Computer peripheral Cable
Stored-program control cable
<
Adapter For Outdoors BillBoard
WireHarness For Control System
Converter Cable For Tunnel Enery-saving Lamp
Wire Harness For ATM
Wire Harness For POS Machine
<
Wire Harness For Refilling tankers
Main Wiring Harness For Elevator Control
Power Cord For Circuit Box

<

Wireharness For Game machine
Converter Cable For Solar Energy

Game machine wire assembly, wiring harness for game machine, electrical wiring harness, custom wire harness for game machine

ETOP WIREHARNESS LIMITED , http://www.oemmoldedcables.com