A forum for Spin users
You are not logged in.
Pages: 1
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
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
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
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
thanks, this helps me a great deal ![]()
Offline
Pages: 1