<> <> <> DIRECTORY Core, CoreOps, IFUPLAInstrDecode, IO, PLAOps, REFBit, Rope, TerminalIO, WireIconExtras; IFUPLAInstrDecodeAux: CEDAR PROGRAM IMPORTS CoreOps, IO, PLAOps, REFBit, Rope, TerminalIO, WireIconExtras = BEGIN log: IO.STREAM _ TerminalIO.CreateStream[]; PLA: TYPE = PLAOps.PLA; Term: TYPE = PLAOps.Term; ROPE: TYPE = Rope.ROPE; root: ROPE = "InstrDecode"; plaRoot: ROPE = Rope.Cat["IFUPLA", root]; PLAs: TYPE = REF PLAsRec; PLAsRec: TYPE = RECORD[seq: SEQUENCE size: CARDINAL OF PLA]; main: PLA _ InitMain[]; subs: PLAs _ InitSubs[]; fields: PLAs _ InitFields[]; nofSubPlas: INT = IFUPLAInstrDecode.InstrDecodeOutCount; -- 1; InitMain: PROC RETURNS[pla: PLA] = { pla _ PLAOps.ReadPLAFile[plaRoot.Cat[".ttt"], log, TRUE]; ShowPLA["Main ", pla]; TerminalIO.PutF["\n"]}; InitSubs: PROC RETURNS[plas: PLAs] = { subTerms: INT _ 0; maxOuts: INT _ 0; phSize: INT _ 0; plas _ NEW[PLAsRec[nofSubPlas]]; FOR index: INT IN [0..nofSubPlas) DO plaName: ROPE _ IO.PutFR["%g%g", IO.rope[plaRoot], IO.int[index] ]; subpla: PLA _ PLAOps.ReadPLAFile[plaName.Cat[".ttt"], log, TRUE]; outs: INT _ REFBit.Desc[subpla.out].bitForm.size; terms: INT _ subpla.termList.length; plas[index] _ subpla; maxOuts _ MAX[maxOuts, outs]; subTerms _ subTerms + terms; phSize _ phSize + PhSize[outs, terms]; ENDLOOP; FOR index: INT IN [0..nofSubPlas) DO ShowPLA[IO.PutFR["Sub%g ", IO.int[index]], plas[index]] ENDLOOP; TerminalIO.PutF["MaxOuts: %3g\n", IO.int[maxOuts]]; TerminalIO.PutF["PhSize: %3g\n", IO.int[phSize]]; TerminalIO.PutF["SubTerms: %3g\n", IO.int[subTerms]]; TerminalIO.PutF["\n"]}; InitFields: PROC RETURNS[plas: PLAs] = { subTerms: INT _ 0; maxOuts: INT _ 0; phSize: INT _ 0; format: PLAOps.Format _ REFBit.Desc[main.out].fieldForm; plas _ NEW[PLAsRec[format.size]]; TerminalIO.PutF["\n"]; FOR field: INT IN [0..format.size) DO plas[field] _ PLAOps.NewPLA[main.data, main.out]; plas[field].time _ main.time; plas[field].termList _ PLAOps.CopyTermListForField [main.termList, format[field].firstBit, format[field].bitSize]; maxOuts _ MAX[maxOuts, format[field].bitSize]; subTerms _ subTerms + plas[field].termList.length; phSize _ phSize + PhSize[format[field].bitSize, plas[field].termList.length]; TerminalIO.PutF[(IF (field+1 MOD 10)=0 THEN "!" ELSE ".")]; ENDLOOP; TerminalIO.PutF["\n"]; FOR field: INT IN [0..format.size) DO ShowPLA[ IO.PutFR["Field%g", IO.int[field]], plas[field], 1, format[field].bitSize] ENDLOOP; TerminalIO.PutF["MaxOuts: %3g\n", IO.int[maxOuts]]; TerminalIO.PutF["PhSize: %3g\n", IO.int[phSize]]; TerminalIO.PutF["SubTerms: %3g\n", IO.int[subTerms]]; TerminalIO.PutF["\n"]}; <> <> <> <> <> <> <> <> <> <> <> <<[main.termList, format[field].firstBit, format[field].bitSize];>> <> <> <> <> <> <> <> <> <> <<>> ShowPLA: PROC[name: ROPE, pla: PLA, fields, outs: INT _ 0] = { terms: INT _ pla.termList.length; IF fields=0 THEN fields _ REFBit.Desc[pla.out].fieldForm.size; IF outs=0 THEN outs _ REFBit.Desc[pla.out].bitForm.size; TerminalIO.PutF["PLA:%5g Terms:%3g Outs:%3g/%3g PhSz:%3g", IO.rope[name], IO.int[terms], IO.int[fields], IO.int[outs], IO.int[PhSize[outs, terms] ] ]; TerminalIO.PutF[" MxI/T:%2g MxT/O:%2g\n", 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: 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: 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}; CheckConsistancyOfInstrDecodePLAs: PROC[plas: PLAs] = { DeCONS: PROC[rope: ROPE, list: LIST OF ROPE] RETURNS[LIST OF ROPE] = { IF Rope.Equal[rope, list.first] THEN RETURN[list.rest]; FOR temp: LIST OF ROPE _ list, temp.rest WHILE temp.rest#NIL DO IF NOT Rope.Equal[rope, temp.rest.first] THEN LOOP; temp.rest _ temp.rest.rest; EXIT REPEAT FINISHED => TerminalIO.PutF ["\n ERROR: %g not driven by any of the Instruction Decode PLA's", IO.rope[rope]] ENDLOOP; RETURN[list]}; main: Core.Wire _ WireIconExtras.RecWire[plaRoot.Cat[".", root, "Out"]]; outlist: LIST OF ROPE; FOR index: INT IN [0..nofSubPlas) DO sub: Core.Wire _ WireIconExtras.RefWire[plas[index].out, "SubPLAOut"]; FOR field: INT IN [0..sub.size) DO outlist _ CONS[CoreOps.GetShortWireName[sub[field]], outlist] ENDLOOP ENDLOOP; FOR field: INT IN [0..main.size) DO outlist _ DeCONS[CoreOps.GetShortWireName[main[field]], outlist] ENDLOOP; IF outlist#NIL THEN ERROR}; -- main pla did not define these outputs END.