Finite state machine model

Source: Internet
Author: User

The 4th style Verilog HDL model represents the same finite state. In this model, we use the Always statement along the trigger and the level-sensitive always statement to describe the trigger part and the combinational logic part of the state machine separately into two parts.

Note: The use of concurrent (non-blocking) assignment along the trigger's always statement, and the way the blocking assignment is used in level-sensitive always statements;
Example 4.4: Finite state machine Model 4.

Module FSM (Clock, Reset, A, F, G); Module declaration
Input Clock, Reset, A;
Output f,g;
reg [1:0] state, nextstate;

      parameter                                       //Status declaration
            idle  = 2 ' b00,  Start = 2 ' b01, 
            Stop = 2 ' B10, Clear = 2 ' B11;

Always @ (Posedge Clock)
if (! Reset) begin
State <= Idle; Default state
End
Else
State <= Nextstate; State transitions

Always @ (state or A) begin
f=0;
g=0;
if (state = = Idle) begin//In Idel, a judgment
if (A)
Nextstate = Start; Start state
Else
Nextstate = Idle; Keep the Idel state
g=1;
End
else if (state = = start)//in Start, yes! a judgment
if (! A
Nextstate = Stop; Stop State
Else
Nextstate = Start; Keep the start state
else if (state = = stop)//In stop status, a is judged
if (A)
Nextstate = Clear; Clear status
Else
Nextstate = Stop; Keep the Stop state
else if (state = = Clear) begin//is in clear, yes! a judgment
if (! A
Nextstate = Idle; Idel Status
Else
Nextstate = Clear; Keep the clear state
f=1;
End
Else
Nextstate= Idle; Default state
End
Endmodule

Finite state machine model

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.