Copyright c 1984 by Xerox Corporation. All rights reserved.
Last edited by Twilliams, August 27, 1984 6:28:59 pm PDT
Last edited by Curry, September 14, 1986 10:00:56 am PDT
Last edited by McCreight, May 20, 1986 6:16:49 pm PDT
Don Curry April 3, 1987 12:27:39 pm PST
Last Edited by: Louis Monier April 3, 1987 5:50:12 pm PST
IFUPLAImpl:
CEDAR
PROGRAM
IMPORTS Commander, CommandTool, FS, IO, PLAOps, REFBit, Rope
EXPORTS IFUPLA =
BEGIN
PLAs: TYPE = IFUPLA.PLAs;
PLA: TYPE = PLAOps.PLA;
ReadIFUPLAs: Commander.CommandProc =
{FOR pla: PLAs IN PLAs DO IFUPLARead[pla, cmd.out] ENDLOOP};
ReadIFUPLA: Commander.CommandProc = {
list: LIST OF IO.ROPE ← CommandTool.ParseToList[cmd].list;
CheckForOtherReferences:
PROC[pla: PLAs] = {
FOR other: PLAs
IN PLAs
DO
Ck:
PROC [p1, p2: PLAs] = {
IF REFBit.Size[plas[p1].data] # REFBit.Size[plas[plaDescriptions[p2].input].data]
THEN ERROR};
IF pla = plaDescriptions[other].input
AND plas[other]
#NIL THEN
{Ck[pla, other]; plas[other].data ← plas[pla].data};
IF other = plaDescriptions[pla].input
AND plas[other]
#NIL THEN
{Ck[other, pla]; plas[pla].data ← plas[other].data} ENDLOOP};
PLAOps.FlushPLACache[];
IF list=
NIL
THEN
FOR pla: PLAs
IN PLAs
DO
plas[pla] ← NIL; IFUPLARead[pla, cmd.out];
CheckForOtherReferences[pla] ENDLOOP
ELSE
{
root: IO.ROPE ← list.first.Substr[0, list.first.Index[0, "."]];
FOR pla: PLAs
IN PLAs
DO
IF NOT root.Equal[plaDescriptions[pla].fileName, FALSE] THEN LOOP;
plas[pla] ← NIL;
IFUPLARead[pla, cmd.out];
CheckForOtherReferences[pla];
EXIT ENDLOOP} };
ReadAndAnalyzeIFUPLAs: Commander.CommandProc = {
name: IO.ROPE ← "IFUPLAStats.txt";
out: IO.STREAM ← FS.StreamOpen[name, $create];
out.PutF["%g, - %g\n", IO.rope[name], IO.time[]];
FOR pla: PLAs
IN PLAs
DO
name: IO.ROPE ← plaDescriptions[pla].fileName.Substr[6];
IFUPLARead[pla, cmd.out];
ShowPLA[out, name, plas[pla]];
ENDLOOP;
out.Close[];
cmd.out.PutF[" Statistics file: %g\n", IO.rope[name]]};
FlushAll:
PROC = {
PLAOps.FlushPLACache[];
FOR pla: PLAs IN PLAs DO plas[pla] ← NIL ENDLOOP};
IFUPLARead:
PROC [ plaType: PLAs, log:
IO.
STREAM ←
IO.noWhereStream]={
fileName: IO.ROPE ← IO.PutFR["%g.ttt", IO.rope[plaDescriptions[plaType].fileName]];
IF plas[plaType]=NIL THEN plas[plaType] ← PLAOps.ReadPLAFile[fileName, log, TRUE];
IF plaDescriptions[plaType].input # plaType
THEN
-- use another PLA's input
IF REFBit.Size[plas[plaType].data] = REFBit.Size[plas[plaDescriptions[plaType].input].data]
THEN plas[plaType].data ← plas[plaDescriptions[plaType].input].data
ELSE ERROR;
plaSizes[plaType][input] ← REFBit.Size[plas[plaType].data];
plaSizes[plaType][output] ← REFBit.Size[plas[plaType].out]};
ShowPLA:
PROC[out:
IO.
STREAM, name:
IO.ROPE, pla:
PLA, fields, outs:
INT ← 0] = {
terms: INT ← pla.termList.length;
ins: INT ← REFBit.Desc[pla.data].bitForm.size;
IF fields=0 THEN fields ← REFBit.Desc[pla.out].fieldForm.size;
IF outs=0 THEN outs ← REFBit.Desc[pla.out].bitForm.size;
out.PutF["%16g Ins:%2g Terms:%3g Outs:%2g/%3g",
IO.rope[name],
IO.int[ins],
IO.int[terms],
IO.int[fields],
IO.int[outs] ];
out.PutF[" PhSz:%3g MxI/T:%2g MxT/O:%2g\n",
IO.int[PhSize[outs, terms]],
IO.int[MaxInsPerTerm[pla]],
IO.int[MaxTermsPerOut[pla]]]};
PhSize:
PROC[outs, terms:
INT]
RETURNS[max:
INT ← 0] =
{RETURN[outs + MAX[outs*2, terms]]};
MaxInsPerTerm:
PROC[pla:
PLA]
RETURNS[max:
INT ← 0] = {
bitFormat: PLAOps.Format ← REFBit.Desc[pla.data].bitForm;
FOR term: PLAOps.Term ← pla.termList.begin, term.next
WHILE term#
NIL
DO
thisTermMax: INT ← 0;
FOR in:
INT
IN [0..bitFormat.size)
DO
IF PLAOps.GetInQrt[term, bitFormat[in].firstBit]#dontcare
THEN thisTermMax ← thisTermMax+1 ENDLOOP;
max ← MAX[max, thisTermMax] ENDLOOP};
MaxTermsPerOut:
PROC[pla:
PLA]
RETURNS[max:
INT ← 0] = {
bitFormat: PLAOps.Format ← REFBit.Desc[pla.out].bitForm;
FOR out:
INT
IN [0..bitFormat.size)
DO
thisOutMax: INT ← 0;
FOR term: PLAOps.Term ← pla.termList.begin, term.next
WHILE term#
NIL
DO
IF PLAOps.GetOutQrt[term, bitFormat[out].firstBit]=one
THEN thisOutMax ← thisOutMax+1 ENDLOOP;
max ← MAX[max, thisOutMax] ENDLOOP};
IFUPLAEval:
PUBLIC
PROC [ plaType: PLAs ] = {PLAOps.GetOutForData[plas[plaType]]};
plas: PUBLIC ARRAY PLAs OF PLA;
PlaDescription: TYPE = RECORD [ fileName: IO.ROPE, input: IFUPLA.PLAs ];
plaDescriptions:
PUBLIC
ARRAY
IFUPLA.PLAs
OF PlaDescription ← [
fetchControl: ["IFUPLAFetchControl", fetchControl],
fetchRdDecode: ["IFUPLAFetchRdDecode", fetchRdDecode],
fetchWtDecode: ["IFUPLAFetchWtDecode", fetchWtDecode],
instrDecode: ["IFUPLAInstrDecode", instrDecode],
instrDecode0: ["IFUPLAInstrDecode0", instrDecode0],
instrDecode1: ["IFUPLAInstrDecode1", instrDecode0],
instrDecode2: ["IFUPLAInstrDecode2", instrDecode0],
instrDecode3: ["IFUPLAInstrDecode3", instrDecode0],
instrDecode4: ["IFUPLAInstrDecode4", instrDecode0],
instrDecode5: ["IFUPLAInstrDecode5", instrDecode0],
instrDecode6: ["IFUPLAInstrDecode6", instrDecode0],
interlock: ["IFUPLAInterlock", interlock],
mainPipeControl: ["IFUPLAMainPipeControl", mainPipeControl],
stackAControl: ["IFUPLAStackAControl", stackAControl],
stackBControl: ["IFUPLAStackBControl", stackBControl],
stackDecode: ["IFUPLAStackDecode", stackDecode],
ltDrPadIO: ["IFUPLAPassLtDrPadIO", ltDrPadIO],
rtDrPadIO: ["IFUPLAPassRtDrPadIO", rtDrPadIO] ];
plaSizes: PUBLIC ARRAY IFUPLA.PLAs OF ARRAY IFUPLA.Sense OF NAT ← ALL[ALL[0]];
Commander.Register[key:"IFUPLA", proc: ReadIFUPLAs,
doc: "Reads in the IFU PLA's - results are cached"];
Commander.Register[key:"IFUPLARead", proc: ReadIFUPLA,
doc: "Reads in an IFU PLA given file name. (flushes previous cached read)"];
Commander.Register[key:"IFUPLAStats", proc: ReadAndAnalyzeIFUPLAs,
doc: "Build statistics file for the IFU PLA's"];
END.