IFUPLAFetchPreDecodeImpl.mesa
Copyright c 1984 by Xerox Corporation. All rights reserved.
Last edited by Curry, September 11, 1986 0:18:56 am PDT
McCreight, March 20, 1986 7:03:39 pm PST
DIRECTORY
Basics,
Commander,
DragOpsCross,
IFUPLAFetchPreDecode,
IO,
PLAOps;
IFUPLAFetchPreDecodeImpl: CEDAR PROGRAM
IMPORTS Basics, Commander, IO, PLAOps =
BEGIN OPEN IFUPLAFetchPreDecode, PO: PLAOps;
FetchPreDecodePLA: PLAOps.PLA;
FetchPreDecodeProc:  PROC[args: FetchPreDecodeIn] RETURNS[result: FetchPreDecodeOut];
GenFetchPreDecodePLA: PUBLIC PROC = {
op0: PO.BoolExpr ← BE[m:[op: 4], d:[op: 4]];
op1: PO.BoolExpr ← BE[m:[op: 2], d:[op: 2]];
op2: PO.BoolExpr ← BE[m:[op: 1], d:[op: 1]];
oneByter: PO.BoolExpr ← PO.Or[
PO.And[ PO.Not[op0], PO.Not[op1], PO.Not[op2] ],
PO.And[ PO.Not[op0], op1 ]
];
twoByter: PO.BoolExpr ← PO.And[ op0, PO.Not[op1] ];
threeByter: PO.BoolExpr ← PO.And[ op0, op1 ];
fiveByter: PO.BoolExpr ← PO.And[ PO.Not[op0], PO.Not[op1], op2 ];
bytesAvail0:  PO.BoolExpr ← BE[m:[fetchBytesM1: 16], d:[fetchBytesM1: 16 ]];
bytesAvail1:  PO.BoolExpr ← BE[m:[fetchBytesM1: 31], d:[fetchBytesM1: 0 ]];
bytesAvail2:  PO.BoolExpr ← BE[m:[fetchBytesM1: 31], d:[fetchBytesM1: 1 ]];
bytesAvail3:  PO.BoolExpr ← BE[m:[fetchBytesM1: 31], d:[fetchBytesM1: 2 ]];
bytesAvail4:  PO.BoolExpr ← BE[m:[fetchBytesM1: 31], d:[fetchBytesM1: 3 ]];
notReady: PO.BoolExpr ← PO.Or[
bytesAvail0,
PO.And[ bytesAvail1, PO.Or[ twoByter, threeByter, fiveByter ] ],
PO.And[ bytesAvail2, PO.Or[ threeByter, fiveByter ] ],
PO.And[ PO.Or[ bytesAvail3, bytesAvail4 ], fiveByter ]
];
Set[out:[notInstReady: TRUE], s: notReady];
Set[out:[instFault0:TRUE], s:PO.And[notReady, BE[m:[iPFaulting:TRUE], d:[iPFaulting:TRUE]]]];
Set[out:[opLength: 5, opLengthb: 5], s: fiveByter ];
Set[out:[opLength: 1, opLengthb: 1], s: oneByter ];
Set[out:[opLength: 2, opLengthb: 2], s: twoByter ];
Set[out:[opLength: 3, opLengthb: 3], s: threeByter ];
Now select the offset to be used in the jump target address adder.
Set[out:[jumpOffset: alpha],
s: BE[m:[op: 7], d:[op: 4]]];
CheckInstRange[0, dJB, 7, 4];
Set[out:[jumpOffset: beta],
s: BE[m:[op: 7], d:[op: 7]]];
FOR inst: DragOpsCross.Inst IN [dRJEB..dRJLEBJ] DO
CheckInstRange[1, inst, 7, 7];
ENDLOOP;
FOR inst: DragOpsCross.Inst IN [dJEBB..dJNEBBJ] DO
CheckInstRange[1, inst, 7, 7];
ENDLOOP;
Set[out:[jumpOffset: alphaBeta],
s: BE[m:[op: 7], d:[op: 6]]];
CheckInstRange[2, dJDB, 7, 6];
CheckInstRange[2, dLFC, 7, 6];
Set[out:[jumpOffset: xa],
s: BE[m:[op: 7], d:[op: 2]]];
CheckInstRange[3, dJSR, 7, 2];
};
reservations: ARRAY [0..25) OF RECORD [ mask, val: WORD ];
CheckInstRange: PROC [group: [0..25), inst: DragOpsCross.Inst, mask, val: WORD] = {
Matches: PROC [g: [0..25)] RETURNS [BOOL] = {
diffs: WORD = Basics.BITXOR[val, reservations[g].val];
RETURN [Basics.BITAND[reservations[g].mask, diffs] = 0] };
reservations[group] ← [mask: mask, val: val];
FOR g: [0..25) DECREASING IN [0..group) DO IF Matches[g] THEN ERROR ENDLOOP;
IF NOT Matches[group] THEN ERROR;
IF Basics.BITAND[mask, Basics.BITXOR[val, Basics.BITSHIFT[LOOPHOLE[inst], -5] ] ] # 0
THEN ERROR};
BE: PROC [m, d: FetchPreDecodeIn] RETURNS[PO.BoolExpr] = {
mRef:  REF FetchPreDecodeIn ← NARROW[FetchPreDecodePLA.mask];
dRef:  REF FetchPreDecodeIn ← NARROW[FetchPreDecodePLA.data];
mRef^ ← m; dRef^ ← d; RETURN[PO.GetBEForDataMask[FetchPreDecodePLA]]};
Set: PROC [s: PO.BoolExpr ← NIL, m, d: FetchPreDecodeIn ← [ ], out: FetchPreDecodeOut] = {
res: REF FetchPreDecodeOut ← NARROW[FetchPreDecodePLA.out];
IF s=NIL
THEN s ←       BE[m,d]
ELSE s ←   PO.And[s, BE[m,d] ];
res^ ← out; PO.SetOutForBE[FetchPreDecodePLA, s]};
GenFetchPreDecode: Commander.CommandProc = {
filename: IO.ROPEPO.DefaultCMDLine[cmd.commandLine, defaultFile];
FetchPreDecodePLA ← PO.NewPLA["IFUPLAFetchPreDecode.FetchPreDecodeIn", "IFUPLAFetchPreDecode.FetchPreDecodeOut"];
GenFetchPreDecodePLA[];
[ ] ← PO.ConvertTermListToCompleteSum[FetchPreDecodePLA.termList, FALSE, FALSE, cmd.out];
[ ] ← PO.FindAMinimalCover[FetchPreDecodePLA.termList, 120, cmd.out];
PO.WritePLAFile[filename, cmd.out, FetchPreDecodePLA] };
defaultFile: IO.ROPE = "IFUPLAFetchPreDecode.ttt";
doc:   IO.ROPE = "Expects the name of a ttt file";
Commander.Register[key:"GenFetchPreDecode",  proc: GenFetchPreDecode,  doc: doc];
END.