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?

Aluminum Cable Tray

Good quality aluminum cable tray is a type of cable management system that is used to support and organize cables and wires in various industrial and commercial settings. It is made of high-quality aluminum material that is lightweight, durable, and corrosion-resistant, making it an ideal choice for harsh and corrosive environments.
The aluminum cable tray is designed to provide a safe and secure pathway for cables and wires, preventing them from getting tangled or damaged. It can be easily installed on walls, ceilings, and floors, and can be customized to fit specific requirements and applications.
One of the key advantages of using aluminum cable tray is its versatility. It can be used in a wide range of industries, including power generation, telecommunications, data centers, and transportation. It can also be used in various applications, such as indoor and outdoor installations, high and low voltage applications, and hazardous locations.


Aluminum Cable Tray,Aluminium Cable Tray,Aluminum Alloy Cable Trunking,Aluminum Alloy Cable Ladder

Rayhot Technology Group Co.,Ltd , https://www.cnrayhot.com

This entry was posted in on