How to write the state machine in OpenGL

Source: Internet
Author: User
Tags fsm

The state machine is the universal key of the time series circuit. All time series circuits can be implemented through the state machine. In the past, I used to write a program using a conventional state machine. Currently, it is popular to use a three-stage state machine. It seems that three paragraphs do not have many advantages.

There are few registers in the CPLD, and the individual feels that it is also possible to use a paragraph, mainly saving resources.

The state of a time series circuit is a collection of state variables. The values of these state variables at any time contain all historical information that must be considered to determine the future behavior of the circuit.

The state machine is encoded using the VerilogHDL language. It is recommended that the state machine be divided into three always segments.

When a three-stage modeling describes the output of the FSM state machine, you only need to specify the case sensitive table as the sub-State Register, and then directly describe the output of this state in the case branch of each sub-state, you do not need to consider the status transfer condition.

Although the Code structure is complicated, the advantage of the three-stage description method is that FSM achieves synchronous register output, eliminating the instability and Glitch of the combined logical output, in addition, it is more conducive to Time Series path grouping. Generally, it has better integrated and layout wiring effects on FPGA/CPLD and other programmable logic devices.

The columns are as follows:

 

// The first process synchronizes the time series always module and formats the description sub-State Register to the current State Register

Always @ (posedge CLK or negedge rst_n) // async Reset

If (! Rst_n)

Current_state <= idle;

Else

Current_state <= next_state; // note that a non-blocking value is used.

 

// The second process, which combines the logic always module to describe the state transfer condition judgment

Always @ (current_state) // Level Trigger

Begin

Next_state = x; // the state to be initialized so that the system enters the correct State After resetting.

Case (current_state)

S1: If (...)

Next_state = S2; // blocking value assignment

...

Endcase

End

 

// The third process synchronizes the time series always module and formats the output of the description sub-State Register.

Always @ (posedge CLK or negedge rst_n)

... // Initialization

Case (next_state)

S1:

Out1 <= 1'b1; // note the non-blocking Logic

S2:

Out2 <= 1' B1;

Default:... // The role of default is to eliminate the need for comprehensive tools to integrate the lock.

Endcase

End

How to write the state machine in OpenGL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.