8000 Constant state variable depending on Actor parameters: incoherence ? · Issue #6 · orcc/orcc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Constant state variable depending on Actor parameters: incoherence ? #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
alorence opened this issue Nov 29, 2012 · 2 comments
Open
Assignees
Milestone

Comments

@alorence
Copy link
Contributor

Duplicated from old SF ticket 9, originally posted by Karol Desnos

If a constant state variable of an actor gets its value from an actor parameter, then :

  1. Orcc requires the definition of a default value for the actor parameter in the actor code. (else, "error: Cannot use the variable par in this context because it has no initial value").
  2. In the generated C code, the parameter and the const state variable have different values if the actor is instanciated with a non-default parameter value.

Is this a desired behavior ?
Actor Example:

actor toto(int par = 3) int in ==> int out :
    int CONST_VAR = par;

    process: action in:[ x ] ==> out:[ y ]
    var
        int y,
    do
        y := x + par;
    end
end

If the actor is instanciated with parameter value "par=7", C Backend will generate:

/////////////////////////////////////////////////////////////////////////
// Parameter values of the instance
#define par 7

/////////////////////////////////////////////////////////////////////////
// State variables of the actor
#define CONST_VAR 3
@ghost ghost assigned alorence Nov 29, 2012
@alorence
Copy link
Contributor Author

Discussion :

Mickael Raulet said :
yes!
I believe for 1 you can use int CONST_VAR := par; this will let you initialize the variable
for 2 it is normal.

Karol Desnos said :
Using CONST_VAR := par; instead of CONST_VAR = par; did not impact the value taken by CONST_VAR nor removed the error if "par" has no default value.
When CONST_VAR := par; is used, instead of a #define, CONST_VAR is now a non-const global variable that still takes the default value of "par" instead of the value given in the parameter list of the actor instance.
This following generated code implies that an actor parameter keeps its default value during the actor initialization and takes the instance-specific value afterward.

void Toto_initialize(unsigned int fifo_input_id) {

    /* Set initial value to global variable */
    CONST_VAR = 3;
    [...]
}

(I just want to confirm this behavior before implementing it in the embedded C backend)

@alorence
Copy link
Contributor Author

Attached project : https://gist.github.com/4171786

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant
0