[Indigo]<Dragon>Cache>Rosemary>Cache.df=>CacheMicroMachineImpl.Mesa
Last Edited by: Barth, April 2, 1984 12:31:26 pm PST
DIRECTORY
Atom,
CacheMicroMachine,
IO,
Rope USING [ROPE],
ViewerIO;
CacheMicroMachineImpl:
CEDAR
PROGRAM
IMPORTS Atom, IO, ViewerIO
EXPORTS CacheMicroMachine =
BEGIN OPEN CacheMicroMachine, Rope;
LogicBlockRec:
TYPE =
RECORD[
name: ROPE,
decodes: LIST OF DecodeRec ← NIL];
DecodeRec:
TYPE =
RECORD[
timing: TimingType,
decode: ATOM];
Grant: TYPE = [0..1];
tree: ARRAY Grant OF ARRAY SequenceNumber OF ARRAY CycleNumber OF LIST OF ATOM;
granted: Grant;
curSequence: SequenceNumber;
curCycle: CycleNumber;
registeredBlocks: LIST OF LogicBlockRec ← NIL;
currentBlock: ROPE ← NIL;
LogicBlock:
PUBLIC
PROC[blockName: Rope.
ROPE] = {
registeredBlocks ← CONS[[blockName], registeredBlocks];
};
NewDecode:
PUBLIC
PROC[t: TimingType, d:
ATOM] = {
registeredBlocks.first.decodes ← CONS[[t, d], registeredBlocks.first.decodes];
};
Master: PUBLIC PROC = {granted ← 1};
Slave: PUBLIC PROC = {granted ← 0};
Sequence:
PUBLIC
PROC [number: SequenceNumber] = {
curSequence ← number;
};
Cycle:
PUBLIC
PROC [number: CycleNumber, decodes:
LIST
OF
ATOM] = {
tree[granted][curSequence][number] ← decodes;
FOR d:
LIST
OF
ATOM ← decodes, d.rest
UNTIL d=
NIL
DO
FOR lb:
LIST
OF LogicBlockRec ← registeredBlocks, lb.rest
UNTIL lb=
NIL
DO
FOR rd:
LIST
OF DecodeRec ← lb.first.decodes, rd.rest
UNTIL rd=
NIL
DO
IF d.first=rd.first.decode THEN GOTO Found;
ENDLOOP;
REPEAT
Found => NULL;
FINISHED => ERROR;
ENDLOOP;
ENDLOOP;
};
SetState:
PUBLIC
PROC [slave:
BOOL, sequence: SequenceNumber, cycle: CycleNumber] = {
granted ← IF slave THEN 0 ELSE 1;
curSequence ← sequence;
curCycle ← cycle;
};
Decode:
PUBLIC
PROC[decode:
ATOM]
RETURNS [asserted:
BOOL] = {
FOR d:
LIST
OF
ATOM ← tree[granted][curSequence][curCycle], d.rest
UNTIL d=
NIL
DO
IF d.first=decode THEN GOTO Found;
REPEAT
Found => RETURN[TRUE];
FINISHED => RETURN[FALSE];
ENDLOOP;
};
Analysis:
PUBLIC
PROC = {
out: IO.STREAM;
numberOfDecodes: INT ← 0;
numberOfDecodesUsedOnce: INT ← 0;
numberOfDecodeUses: INT ← 0;
numberOfDecodesInSequence: INT ← 0;
nCycles: INT;
[out: out] ← ViewerIO.CreateViewerStreams["Microcode Analysis"];
out.PutF["Cache M Bus controller microcode analysis\n"];
FOR lb:
LIST
OF LogicBlockRec ← registeredBlocks, lb.rest
UNTIL lb=
NIL
DO
numberOfDecodesInBlock: INT ← 0;
numberOfDecodesUsedOnceThisBlock: INT ← 0;
numberOfDecodeUsesInBlock: INT ← 0;
numberOfDecodesInSequenceInBlock: INT ← 0;
out.PutF["\nBlock name = %g\n", IO.rope[lb.first.name]];
FOR rd:
LIST
OF DecodeRec ← lb.first.decodes, rd.rest
UNTIL rd=
NIL
DO
numberOfSequencesDecodeUsed: INT ← 0;
numberOfCycles: INT ← 0;
numberOfDecodes ← numberOfDecodes + 1;
numberOfDecodesInBlock ← numberOfDecodesInBlock + 1;
FOR m: Grant
IN Grant
DO
FOR s: SequenceNumber
IN SequenceNumber
DO
seenThisSequence: BOOL ← FALSE;
FOR c: CycleNumber
IN CycleNumber
DO
IF tree[m][s][c]#NIL THEN numberOfCycles ← numberOfCycles + 1;
FOR d:
LIST
OF
ATOM ← tree[m][s][c], d.rest
UNTIL d=
NIL
DO
IF d.first=rd.first.decode
THEN {
numberOfDecodeUses ← numberOfDecodeUses + 1;
numberOfDecodeUsesInBlock ← numberOfDecodeUsesInBlock + 1;
IF
NOT seenThisSequence
THEN {
seenThisSequence ← TRUE;
EXIT;
};
};
ENDLOOP;
ENDLOOP;
IF seenThisSequence
THEN {
numberOfSequencesDecodeUsed ← numberOfSequencesDecodeUsed + 1;
numberOfDecodesInSequence ← numberOfDecodesInSequence + 1;
numberOfDecodesInSequenceInBlock ← numberOfDecodesInSequenceInBlock + 1;
};
ENDLOOP;
ENDLOOP;
nCycles ← numberOfCycles;
out.PutF[" %g=%g", IO.rope[Atom.GetPName[rd.first.decode]], IO.int[numberOfSequencesDecodeUsed]];
IF numberOfSequencesDecodeUsed=1 THEN numberOfDecodesUsedOnceThisBlock ← numberOfDecodesUsedOnceThisBlock +1;
ENDLOOP;
numberOfDecodesUsedOnce ← numberOfDecodesUsedOnce + numberOfDecodesUsedOnceThisBlock;
out.PutF["\nNumber of decodes = %g\n", IO.int[numberOfDecodesInBlock]];
out.PutF["Number of decode uses = %g\n", IO.int[numberOfDecodeUsesInBlock]];
out.PutF["Number of decodes used once = %g\n", IO.int[numberOfDecodesUsedOnceThisBlock]];
out.PutF["Number of decode uses excluding multiple cycles within a sequence = %g\n", IO.int[numberOfDecodesInSequenceInBlock]];
ENDLOOP;
out.PutF["\nNumber of decodes = %g\n", IO.int[numberOfDecodes]];
out.PutF["Number of decode uses = %g\n", IO.int[numberOfDecodeUses]];
out.PutF["Number of decodes used once = %g\n", IO.int[numberOfDecodesUsedOnce]];
out.PutF["Number of decode uses excluding multiple cycles within a sequence = %g\n", IO.int[numberOfDecodesInSequence]];
out.PutF["Number of cycles = %g\n", IO.int[nCycles]];
out.PutF["\n"];
};
END.