6. Procedure

Declaration of procedure

The “procedure” is a syntax that offers a control
that uses the state transition, the pipeline, and the sequential circuit.
There is an area where the atomic action exclusively
for the “procedure” is described besides the common action description.
When a “procedure” was once activated,
it transits to another “procedure”, or continues to operate until the end is declared.
To declare a “procedure”, the following description method is used.
It is possible to accompany dummy argument(s) when it is declared,
and multiple dummy arguments can be also given by delimiting them with comma.

proc_name Procedure_name (Dummy_argument1, Dummy_argument2, Dummy_argument3, …)

The dummy argument that can be accompanied by the “procedure” is limited to the “register”.

It is described as follows when a “procedure” is activated or it transits to another procedure
by a procedure action.

Procedure_name ()

When the above-mentioned command was used in a procedure action,
the former “procedure” ends, and the procedure to where it was transited is activated.
The “procedure” actually starts to be activated
from the next clock to the one that executed the activation.

And, “invoke” is used when activating another “procedure” without ending the “procedure”.
The “invoke” is used under the following description method.


Also, the “invoke” can pass the actual argument(s) to the specified procedure.
It is used as follows when actual argument is used with “invoke”.

Procedure_name.invoke (<Actual_argument>, <Actual_argument>, <Actual_argument>, …)

To end a procedure, it is described as follows in the procedure action.


The “finish” can specify the procedure name, and end it.
The “procedure” ends the action at the next clock to the one that declared the “finish”.

And, the procedure action is described as follows.

proc Procedure_name {


Let’s see Example 34 as an activation example of the “procedure”.

<<Example 34.procedure>>
declare ex34 {
   func_out cnt_end_call ;
module ex34 {
   reg r1=0, r2=0, r3=0 ;
   reg cnt_reg[4]=0;

   proc_name proc_count ; //Expression 1

   r1 := r2 ;
   r2 := r3 ;
   r3 := 0b1 ;

   if(~r1&r2&r3) proc_count() ; //Expression 2

   proc proc_count { //Expression 3
      any {
         cnt_reg == 0b1000 : {
            cnt_reg := 0b0000 ;
            cnt_end_call() ;
         else : cnt_reg++ ;

Example 34 shows an activation example of the “procedure”.
The ex34 has the procedure “proc_count” internally.
The declaration of “proc_count” is executed in the expression 1.
The expression 2 intends to activate the “proc_count” when the “if” syntax is true.
The procedure action of the “proc_count” activated in the expression 2 starts from the expression 3.

The procedure action of the “proc_count” counts up the “register”.
First, it counts up the register “cnt_reg” from 0b0000 1 by 1 by the “any” block.
Next, when the “cnt_reg” reached 0b1000,
it calls the control output terminal “cnt_end_call” after rewriting 0b0000 to the “cnt_reg”.
Since an action to end the “proc_count” has not been described in the ex34,
the “proc_count” continues to execute the procedure action when it was once activated.

Let’s see the simulation result of Example 34.

Next, let’s see the following Example 35 as an example
that uses the argument of a “procedure”.

<<Example 35.Procedure(with argument)>>
declare ex35 {
   output f[4] ;
module ex35 {
   wire w_result[4] ;

   reg r1=0, r2=0, r3=0 ;
   reg opr1[4], opr2[4] ;
   reg result[4] ;

   proc_name proc_fetch() ; //Expression 1
   proc_name proc_add(opr1, opr2) ; //Expression 2
   proc_name proc_writeback(result) ; //Expression 3

   r1:=r2; r2:=r3; r3:=0b1;

   if(~r1&r2&r3) proc_fetch() ; //Expression 4

   proc proc_fetch { //Expression 5
      proc_add(0b0101, 0b1010) ;

   proc proc_add { //Expression 6
      w_result = opr1 + opr2 ;
      proc_writeback(w_result) ;

   proc proc_writeback { //Expression 7
      f = result ;
      finish ;

Example 35 shows a usage example of the argument of “procedure”.
The module “ex35″ has the three “procedures”,
and the expressions 1, 2, and 3 are the declarations of “proc_fetch”, “proc_add”, and “proc_writeback” respectively.
The expressions 2 and 3 declare the “register” as a dummy argument at the same time as the declaration.

In the ex35, the “proc_fetch” is activated as the expression 4 triggered it.
Expression 4 is an action that activates the “proc_fetch” when the conditional syntax “if” is true.

When the “proc_fetch” in the expression 6 was activated, the procedure action is executed.
The procedure action of the “proc_fetch” activates “proc_add” with the actual arguments of 0b0101 and 0b1010.
The actual argument of the “proc_add” is assigned to the “register” that declared with the dummy argument.

When the “proc_add” in the expression 6 was activated, the procedure action is executed.
The procedure action in the expression 6 executes the following two actions.
? To assign the addition result of “opr1″ and “opr2″ to the “w_result”
? To activate the” proc_writeback” with the actual argument “w_result”

In addition, the procedure action of the “proc_writeback”
that starts from the expression 7 is an action to assign the “result” to “f”.

Let’s see the simulation result of Example 35.