Using a replicated par statement means you cannot pass any port arguments to contained functions as xc doesn't yet allow you to construct port arrays. It must be possible to bypass this with a bit of assembly though. In particular I have tried something along the lines of
Code: Select all
led:
entsp 0
// r0: port, r1: value
out res[r0], r1
retsp 0
Although this causes an ET_ILLEGAL_RESOURCE exception when run with a replicatior (in this case for the XMP-64, where the led is port 1E on cores 0, 4, 8, ...)
Code: Select all
void led(int outPort, int value);
void run(int number) {
unsigned outPort = (unsigned) XS1_PORT_1E;
if(number % 4 == 0)
led(outPort, 1);
while(1) {}
}
int main() {
chan c[64];
par (int i=0; i<64; i++) {
on stdcore[i] : run(i);
}
return 0;
}
Which I presume is because I'm not initialising the port, which the manual mentions you need to do with the SETC instruciton, but I'm not sure exactly how to do this. Can anyone shed any light on this?
Cheers,
Jamie