Datasets:
File size: 1,499 Bytes
987b273 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include <assert.h>
#include <stdio.h>
#include "../src/xireun.h"
enum plant { LOCKED, FIXED_COST, IMMEDIATE, DECOUPLED };
static void run(enum plant type) {
xr_gate g={0}; int64_t shift=0,end=100000;
unsigned active=0,tests=0;
for(unsigned i=0;i<120;++i) {
int64_t start=end+shift+2400;
int64_t next= type==LOCKED || type==DECOUPLED ? end+10000 :
type==FIXED_COST ? start+7600 : start+20;
int64_t requested=xr_after(&g,start,next,shift);
if(g.mode==XR_PROBE && requested) ++tests;
if(g.mode==XR_ACTIVE && requested) ++active;
shift=requested; end=next;
}
if(type==IMMEDIATE) assert(active==0 && tests==0);
if(type==FIXED_COST) assert(active==0 && tests>0);
if(type==LOCKED || type==DECOUPLED) assert(active>60);
printf("plant=%d probe_waits=%u active_waits=%u\n",type,tests,active);
}
int main(void) {
for(int i=0;i<4;i++) run((enum plant)i);
xr_gate g={0}; int64_t t=100000,d=0;
for(unsigned i=0;i<70;i++) {int64_t b=t+d+2000;t+=10000;d=xr_after(&g,b,t,d);}
assert(g.mode==XR_ACTIVE&&d>0);
int64_t b=t+d+300;t+=d+500; d=xr_after(&g,b,t,d);
assert(d==0 && g.mode==XR_ACTIVE);
b=t+2000;t+=10000;d=xr_after(&g,b,t,0);assert(d>0);
b=t+d+2000;t+=40000;d=xr_after(&g,b,t,d);assert(!d&&g.mode==XR_COOLDOWN);
assert(!xr_after(&g,t-1,t-2,0)&&g.mode==XR_OBSERVE);
puts("Early return, long stall, changed clock and serial/decoupled indistinguishability passed.");
}
|