use of com.jopdesign.io.SysDevice in project jop by jop-devel.
the class EratosthenesCsp method main.
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("Eratosthenes Sieve");
// System.out.print("Status: ");
// System.out.println(Native.rd(NoC.NOC_REG_STATUS));
SysDevice sys = IOFactory.getFactory().getSysDevice();
for (int i = 1; i < sys.nrCpu; i++) {
int ni = i + 1;
if (ni == sys.nrCpu)
ni = 0;
System.out.println(ni);
Runnable r = new EratosthenesCsp(i, ni);
Startup.setRunnable(r, i - 1);
}
EratosthenesCsp r = new EratosthenesCsp(0, 1);
// Startup.setRunnable(r, 0);
System.out.println("starting cpus.");
// start the other CPUs
sys.signal = 1;
// set the WD LED for the simulation
sys.wd = 1;
int i = 2;
// The main loop.
while (r.crtlvl < PRIMECNT) {
int lvl = 0;
int candidate = i;
// attempt to receive
if (NoC.isReceiving()) {
System.out.println("<");
// something to process
lvl = NoC.b_receive1();
candidate = NoC.b_receive1();
// level increases here
lvl++;
} else {
i++;
}
System.out.print(" Processing ");
System.out.print(candidate);
System.out.print(" level = ");
System.out.print(lvl);
if (r.sendAlong(lvl, candidate)) {
System.out.println("->");
NoC.nb_send1(1, lvl);
NoC.nb_send1(1, candidate);
} else {
// System.out.println(".");
}
// RtThread.sleepMs(10);
}
// print out the result for this processor
System.out.print("Primes on cpu0 ");
for (i = 0; i < PRIMECNT; i++) System.out.println(r.primes[i]);
}
use of com.jopdesign.io.SysDevice in project jop by jop-devel.
the class EratosthenesCsp2 method main.
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("Eratosthenes Sieve, v2");
// System.out.print("Status: ");
// System.out.println(Native.rd(NoC.NOC_REG_STATUS));
SysDevice sys = IOFactory.getFactory().getSysDevice();
for (int i = 1; i < sys.nrCpu; i++) {
int ni = i + 1;
if (ni == sys.nrCpu)
ni = 0;
// System.out.println(i+" -> "+cpuIndex2NoCAddress(ni));
Runnable r = new EratosthenesCsp2(i, cpuIndex2NoCAddress(ni));
Startup.setRunnable(r, i - 1);
}
EratosthenesCsp2 r = new EratosthenesCsp2(0, 1);
// Startup.setRunnable(r, 0);
System.out.println("starting cpus.");
// start the other CPUs
sys.signal = 1;
// set the WD LED for the simulation
sys.wd = 1;
int i = 2;
// The main loop.
while (r.crtlvl < PRIMECNT) {
int lvl = 0;
int candidate = i;
// attempt to receive
if (NoC.isReceiving()) {
// System.out.println("<");
// something to process
/////////////////////// receive a two word message instead ////////////////
// while(!NoC.isReceiving());
lvl = Native.rd(NoC.NOC_REG_RCVDATA);
// while(NoC.isReceiveBufferEmpty());
candidate = Native.rd(NoC.NOC_REG_RCVDATA);
Native.wr(0, NoC.NOC_REG_RCVRESET);
///////////////////////////////////////////////////////////////////////////
// level increases here
lvl++;
} else {
i++;
}
if (r.sendAlong(lvl, candidate)) {
////////////////// send a two word message instead ///////////////////////////
while (NoC.isSending()) ;
Native.wr(1, NoC.NOC_REG_SNDDST);
Native.wr(2, NoC.NOC_REG_SNDCNT);
Native.wr(lvl, NoC.NOC_REG_SNDDATA);
// while(NoC.isSendBufferFull());
Native.wr(candidate, NoC.NOC_REG_SNDDATA);
//////////////////////////////////////////////////////////////////////////////
} else {
// System.out.println(".");
}
// RtThread.sleepMs(10);
}
// print out the result for this processor
System.out.print("Primes on cpu0 ");
for (i = 0; i < PRIMECNT; i++) System.out.println(r.primes[i]);
}
use of com.jopdesign.io.SysDevice in project jop by jop-devel.
the class Thread method doInit.
/**
* Initialize all data structures and start the other processors
* on the CMP system.
*/
void doInit() {
synchronized (monitor) {
if (runCmp == null) {
SysDevice sys = IOFactory.getFactory().getSysDevice();
runCmp = new Helper[sys.nrCpu - 1];
for (int i = 0; i < sys.nrCpu - 1; ++i) {
runCmp[i] = new Helper();
Startup.setRunnable(runCmp[i], i);
}
// start the other CPUs
sys.signal = 1;
}
}
}
use of com.jopdesign.io.SysDevice in project jop by jop-devel.
the class Sound method main.
public static void main(String[] args) {
int time, off, val, idx;
SysDevice sys = DspioFactory.getDspioFactory().getSysDevice();
OutPort pwm = DspioFactory.getDspioFactory().getOutPort();
int[] samples = new int[16 * 4 * 1024];
val = 0;
for (int i = 0; i < 16 * 4 * 1024; ++i) {
// val += 149;
val += 1490;
if (val > 65535)
val = 0;
samples[i] = val >>> 6;
}
System.out.println("Period: " + PERIOD);
time = sys.cntInt;
val = 300;
time += 1000;
idx = 0;
for (; ; ) {
time += PERIOD;
++idx;
idx &= 0xffff;
val = 100 + samples[idx];
off = time + val;
sys.deadLine = time;
pwm.port = 3;
// some offset is needed - we have now a 1 offset
sys.deadLine = off;
// and a 1 phase offset. Is this ok?
pwm.port = 0;
}
}
use of com.jopdesign.io.SysDevice in project jop by jop-devel.
the class Measure method lowLevel.
public static void lowLevel() {
SysDevice sys = IOFactory.getFactory().getSysDevice();
int frequ = new STScheduler(1).getMsCycles() * 1000;
int shift = frequ / 10 / (TDMA_LENGTH) * TDMA_LENGTH + 1;
int[] a = new int[3];
for (int i = 0; i < a.length; ++i) {
a[i] = 1;
}
int time = sys.cntInt;
time = sys.cntInt - time;
int off = time;
int start = sys.cntInt + shift;
for (int i = 0; i < 30; ++i) {
sys.deadLine = start;
time = sys.cntInt;
int sum = 0;
for (int j = 0; j < a.length; ++j) {
a[j] += 12345678;
}
time = sys.cntInt - time;
System.out.println(time - off);
start += shift;
}
}
Aggregations