For the code below, is it even possible to do this? This is only a learning exercise and really don't know what to do.
[combinable], while{ select{, I have no clue as to what goes where.
Code: Select all
/*
* 3core.xc
*
* Created on: Jun 9, 2017
* Author: len
*
* XS1-L16A-128-QF124-C10 Device
*/
#include <xs1.h>
#include <platform.h>
#define DELAY 20000
#define TRUE 1
on tile [1] : port out port1E = XS1_PORT_1E;
// on tile 0 core0.
void worker (chanend ch)
{
timer tmr;
unsigned t;
unsigned workdata = 0;
while (TRUE)
{
tmr :> t;
tmr when timerafter (t+ DELAY*3) :> void;
ch <: workdata;
}
}
//on tile[0}.core[2]
void mimic (chanend dh)
{
timer tm;
unsigned t1;
unsigned count = 1;
while (TRUE)
{
tm :> t1;
tm when timerafter (t1+ DELAY+1000) :> void;
dh <: count;
}
}
// on tile 1 core0
void boss (chanend ch, chanend dh )
{
unsigned bossdata;
timer time;
unsigned d;
while (TRUE)
{
ch :> bossdata;
port1E <: bossdata;
time :> d;
time when timerafter (d+ (DELAY)) :> void;
dh :> bossdata;
port1E <: bossdata;
time :> d;
time when timerafter (d+ (DELAY*2)) :> void;
}
}
int main (void)
{
chan ch; chan dh;
par {
on tile [0] : worker ( ch );
on tile [0] : mimic ( dh );
//on tile [0].core[2] : mimic ( dh );
on tile [1] : boss ( ch, dh );
}
return 0;
}