Declaration of state variable
The state variable is a syntax to define the StateMachine, and it is called “state”.
The state variable can be given to an action description by declaring the “state”.
The declaration of “state” can be executed
in the common action description part and the procedure action.
And, the “state” can be used only in the procedure action that declared.
Moreover, the “state” described at the head of the declaration is activated
at the same time as the module activation.
The declaration method of “state” is as follows.
state_name State_name
In the declaration of the “state”, the “state” that declared first is activated
just after the module was activated.
The following method is used when a state action is described.
state State_name Action_description
The activated “state” continues the action until it transits to another “state”.
The “goto” syntax is used when declaring multiple “states” it transits among the “states”.
The usage method of “goto” syntax is shown as follows.
goto State_name
It is possible to activate another “state” by this “goto” syntax.
The former “state” stops when it moved to another “state”.
It takes one clock for the “state” to transit to.
And, in case of an interruption of the “state” due to a transition of the procedure action,
it begins from the same “state” at the interruption when the former procedure action was activated.
Furthermore, the “state” can describe an action description only in the place where it declared.
The declaration of “state” is executed in the common action description, or the procedure action.
The difference between “state” and “procedure” is the point where the “state” can be used also
in the common operation part and the procedure action.
And, when it is used in a procedure action,
it is different in the point where it memorizes the “state” at the end of the procedure action.
In addition, when the “state” is used in a procedure action, even if it transited to another procedure action,
the “state” still memorizes the state of the “state” when the former procedure transited.
This makes it possible to start the action from the same “state” when the procedure transited to.
Let’s see Example 36 as usage example of the “state” in the common action description.
declare ex36 { } module ex36 { reg r1[4]=0 ; { state_name st1, st2, st3 ; //Expression 1 state st1 { //Expression 2 r1 := 0b0010 ; goto st2 ; } state st2 { //Expression 3 r1 := 0b0011 ; goto st3 ; } state st3 { //Expression 4 r1 := 0b0001 ; goto st1 ; } } } |
In Example 36, the “states” of st1, st2, and st3 declare in the expression 1.
At the time, the “state” of st1 that declared first is activated first.
And, when a “goto” syntax is used in the state action of st1,
it transits to another “state” such as st2 and st3.
So, let’s see the simulation result of Example 36.

Next, let’s see Example 37 as usage example of the “state” in the procedure action.
declare ex37 { func_in do ; } module ex37 { proc_name proc1() ; function do proc1() ; proc proc1 { state_name st1,st2,st3 ; //Expression 1 state st1 goto st2 ; //Expression 2 state st2 goto st3 ; //Expression 3 state st3 { //ޮ4 goto st1; finish ; } } } |
In Example 37, “state” is used in the procedure action.
The expression 1 declares the “states” of st1, st2, and st3.
At the time, the “state” of st1 that declared first is activated first.
And, when a “goto” syntax is used in the state action of st1,
it transits to another “state” such as st2 and st3.
Let’s see the simulation result of Example 37.
Next, let’s see Example 38 as the “state” example 2 in the procedure action.
declare ex38 { func_in interrupt ; func_out cnt_start_call ; func_out cnt_end_call ; } module ex38 { reg r1=0, r2=0, r3=0 ; reg reg_cnt[8] = 0 ; reg cnt_buff[8] = 0 ; proc_name proc_count, proc_exec ; r1:=0b1; r2:=r1; r3:=r2; if(~r3 & r2 & r1) proc_count() ; proc proc_count { //Declaration of state state_name st1_start, st2_count, st3_end ; //Prat of parallel operation besides state action if(interrupt) proc_exec() ; //State st1_start state st1_start { cnt_start_call() ; goto st2_count ; } //State st2_count state st2_count { //In a state of count any { reg_cnt == 0xFF : { reg_cnt := 0x00 ; goto st3_end ; } else : reg_cnt := reg_cnt + 0x01 ; } } //State st3_end state st3_end { cnt_end_call() ; goto st1_start ; } } proc proc_exec { cnt_buff := reg_cnt ; proc_count() ; } } |
Example 38 has the two procedure actions of “proc_count” and “proc_exec”.
And, there are the three state actions of “st1_start”, “st2_count”, and “st3_end” in the” proc_count”.
As for the module in Example 38, the procedure action “proc_count” is activated first.
The “proc_count” continue to count up on the register “reg_cnt” during being activated.
In addition, when the control input terminal “interrupt” was activated,
it transits from the “proc_count” to the “proc_exec”.
Let’s see the simulation result of Example 38.
