Spinroot

A forum for Spin users

You are not logged in.

#1 2012-06-11 10:21:44

HJW
Member
Registered: 2012-03-28
Posts: 9

Array hidden in parameter

Hi,

I want to give a selfdefined datatye to a process. But I keep getting the error message "Error: hidden array in parameter a"

My code looks like this:

typedef Array{
    int el[10]
};

proctype p(Array a){
*code*
};

Any idea why this doesn't work or how I could initialise a process with information stored in an array capsuled in a selfdefined datatype?

Offline

#2 2012-06-11 11:15:49

feng_lei_76
Member
Registered: 2011-05-13
Posts: 43

Re: Array hidden in parameter

The input parameter of a proctype cannot be an array.  In this code, the array el[10] is hidden inside the structure a.  Then you get the error message for the misuse.

Offline

#3 2012-06-11 19:02:05

HJW
Member
Registered: 2012-03-28
Posts: 9

Re: Array hidden in parameter

Thank you for your answer. So I can't have an array as an input parameter. Is there a workround for this?

The model I want tow write has several processes communicating with each other. In this array I wanted to store the channels each process knows at initialisation. I could write each one in the input parameters. But that doesn't scale very well when I want to try my model with different numbers of processes.

Offline

#4 2012-06-11 21:34:25

feng_lei_76
Member
Registered: 2011-05-13
Posts: 43

Re: Array hidden in parameter

If the data array needs to be shared by multiple processes, then it should be global.

If each process only uses one element in the array, you could pass the index of that entry as the argument like this

proctype proc_a(byte idx)

The idx is the position in the data array.

If each process uses multiple elements, you may use a binary value to represent the indices in the array.  For example, if you know that a process uses at most 8 elements in the global data array, you may define it as this

proctype proc_a(byte idices)

For instance, if proc_a uses element 0, 3 and 7, the parameter is then idices = 0b10001001.  If you have more than 8 elements, you can use int and even multiple int arguments.

Offline

#5 2012-06-12 18:34:10

HJW
Member
Registered: 2012-03-28
Posts: 9

Re: Array hidden in parameter

thanks, this helps me a great deal smile

Offline

Board footer

Powered by FluxBB