BEGIN
OPEN ArbiterTest, ChipTest;
real: Tester;
stop: PUBLIC BOOL;
comment: PUBLIC Rope.ROPE ← "No tests run yet..";
testMachine: PUBLIC Rope.ROPE ← "3#154#0";
Pins48: TYPE = [1..48];
arbInputs: PUBLIC ARRAY ArbIndex OF LogicValue;
arbOutputs: PUBLIC ARRAY ArbIndex OF LogicValue;
arbMCmd: PUBLIC ARRAY MCmdIndex OF LogicValue;
arbReset, arbNewRq, arbPhA, arbPhB: PUBLIC LogicValue;
States: TYPE = [0..4);
state: States ← 0;
aState: ARRAY States OF BOOL ← [FALSE, TRUE, FALSE, FALSE];
bState: ARRAY States OF BOOL ← [FALSE, FALSE, FALSE, TRUE];
PinToChannel:
PROC[pin: [1..48]]
RETURNS [channel: Channel] = {
IF pin IN [1..24] THEN RETURN[pin+35] ELSE RETURN [92+25-pin]};
inputPin0: Pins48 ← 47;
outputPin0: Pins48 ← 2;
inputPin1: Pins48 ← 3;
outputPin1: Pins48 ← 4;
inputPin11: Pins48 ← 23;
outputPin11: Pins48 ← 25;
inputPin12: Pins48 ← 26;
outputPin12: Pins48 ← 27;
mCmdPin0: Pins48 ← 43;
resetPin: Pins48 ← 40;
newRqPin: Pins48 ← 41;
phAPin: Pins48 ← 38;
nPhAPin: Pins48 ← 37;
phBPin: Pins48 ← 36;
nPhBPin: Pins48 ← 35;
inputChannels: ARRAY ArbIndex OF Channel;
outputChannels: ARRAY ArbIndex OF Channel;
mCmdChannels: ARRAY MCmdIndex OF Channel;
resetChannel: Channel;
newRqChannel: Channel;
phAChannel: Channel;
nPhAChannel: Channel;
phBChannel: Channel;
nPhBChannel: Channel;
ApplyInputsSenseOutputs:
PUBLIC
PROC =
TRUSTED {
Process.Detach[FORK ReallyApplyInputsSenseOutputs[]]};
ReallyApplyInputsSenseOutputs:
PUBLIC
PROC = {
t: Tester;
v: RWChannelVecRef = NEW[ChannelVec ← ALL[FALSE]];
o: ChannelVecRef;
d: RWChannelVecRef = NEW[ChannelVec ← ALL[TRUE]];
real ← OpenTester[testMachine];
real.Initialize[];
t ← real;
[] ← t.PutBBuf[d]; -- use the disable vector to initialize the b buffer to all ones so that the xor inverts so that the entire chain of logic in the tester is noninverting.
FOR i: ArbIndex
IN ArbIndex
DO
d[inputChannels[i]] ← FALSE;
ENDLOOP;
d[resetChannel] ← FALSE;
d[newRqChannel] ← FALSE;
d[phAChannel] ← TRUE;
d[nPhAChannel] ← TRUE;
d[phBChannel] ← TRUE;
d[nPhBChannel] ← TRUE;
[] ← t.PutDisables[d];
comment ← IO.PutFR["Beginning test on %g...", IO.rope[testMachine]];
stop ← FALSE;
state ← 0;
FOR i: ArbIndex
IN ArbIndex
DO
arbInputs[i] ← 1;
arbOutputs[i] ← 0;
ENDLOOP;
arbReset ← 0;
arbNewRq ← 0;
arbPhA ← 0;
arbPhB ← 0;
UNTIL stop
DO
FOR i: ArbIndex
IN ArbIndex
DO
v[inputChannels[i]] ← arbInputs[i]=1;
ENDLOOP;
v[resetChannel] ← arbReset=1;
v[newRqChannel] ← arbNewRq=1;
v[phAChannel] ← arbPhA#0;
v[nPhAChannel] ← arbPhA=0;
v[phBChannel] ← arbPhB#0;
v[nPhBChannel] ← arbPhB=0;
[] ← t.PutABuf[v];
t.Step[];
o ← t.GetIBuf[];
FOR i: ArbIndex
IN ArbIndex
DO
arbOutputs[i] ← IF o[outputChannels[i]] THEN 1 ELSE 0;
ENDLOOP;
FOR i: MCmdIndex
IN MCmdIndex
DO
arbMCmd[i] ← IF o[mCmdChannels[i]] THEN 1 ELSE 0;
ENDLOOP;
ENDLOOP;
comment ← "Finished test";
};
AdvanceClocks:
PUBLIC
PROC ={
state ← (state + 1) MOD 4;
arbPhA ← IF aState[state] THEN 1 ELSE 0;
arbPhB ← IF bState[state] THEN 1 ELSE 0;
};
[] ← ViewRec.ViewInterface[name: "ArbiterTest", viewerInit: [name: "Arbiter test"]];
inputChannels[0] ← PinToChannel[inputPin0];
outputChannels[0] ← PinToChannel[outputPin0];
FOR i: ArbIndex
IN [1..10]
DO
inputChannels[i] ← PinToChannel[inputPin1 + 2*(i-1)];
outputChannels[i] ← PinToChannel[outputPin1 + 2*(i-1)];
ENDLOOP;
inputChannels[11] ← PinToChannel[inputPin11];
outputChannels[11] ← PinToChannel[outputPin11];
FOR i: ArbIndex
IN [12..15]
DO
inputChannels[i] ← PinToChannel[inputPin12 + 2*(i-12)];
outputChannels[i] ← PinToChannel[outputPin12 + 2*(i-12)];
ENDLOOP;
FOR i: MCmdIndex
IN MCmdIndex
DO
mCmdChannels[i] ← PinToChannel[mCmdPin0 + i];
ENDLOOP;
resetChannel ← PinToChannel[resetPin];
newRqChannel ← PinToChannel[newRqPin];
phAChannel ← PinToChannel[phAPin];
nPhAChannel ← PinToChannel[nPhAPin];
phBChannel ← PinToChannel[phBPin];
nPhBChannel ← PinToChannel[nPhBPin];