DIRECTORY AlpsBool, AlpsHeur, AlpsPWGen, AlpsTile, CD, CDDirectory, CDExpr, CDIO, CDIOCommands, Commander, Convert, FS, PW, PWAlps, Rope, SymTab, TerminalIO; PWAlpsImpl: CEDAR PROGRAM IMPORTS AlpsBool, AlpsHeur, AlpsPWGen, CDDirectory, CDExpr, CDIO, CDIOCommands, Convert, FS, PW, Rope, TerminalIO EXPORTS PWAlps SHARES CDIOCommands = BEGIN OPEN PWAlps; Input: PROC [text: ROPE] RETURNS [ROPE] = {RETURN [TerminalIO.RequestRope[text]]}; Output: PROC [t1, t2, t3, t4, t5: ROPE _ NIL] = {AlpsBool.Output[t1, t2, t3, t4, t5]}; RefToListOfRopes: PUBLIC PROC [ref: REF] RETURNS [lropes: LIST OF ROPE] = { WITH ref SELECT FROM refListOfRef: REF LIST OF REF => lropes _ ListRefAnyToListOfRope[refListOfRef^]; refRef: REF REF => IF refRef^=NIL THEN RETURN[NIL] ELSE ERROR; ENDCASE => ERROR; }; ListRefAnyToListOfRope: PUBLIC PROC [list: LIST OF REF] RETURNS [LIST OF ROPE] = BEGIN RETURN[IF list=NIL THEN NIL ELSE CONS[NARROW[list.first], ListRefAnyToListOfRope[list.rest]]]; END; ReadContextFromAlpsFile: PUBLIC PROC[fileName: ROPE] RETURNS [context: Context] = { symTab: SymTab.Ref _ CDExpr.CombineTabs[ winner: CDExpr.ReadFile[fileName], loser: CDExpr.ReadFile[Rope.Cat[FS.GetDefaultWDir[], "AlpsDefaultParameters.alps"]]]; -- turn a xxx.alps file into a symtab found: BOOL; rope: ROPE; ref: REF; int: INT; bool: BOOL; context _ NEW[ContextRec]; Output["\nInterpreting parameters from description file ", fileName, " ...\n"]; [found, context.tileset] _ CDExpr.FetchRope[symTab, "TileSet"]; IF ~found THEN {Output["TileSet must be supplied!\n"]; ERROR}; [found, ref] _ CDExpr.FetchRef[symTab, "TruthTableFile"]; IF found THEN { [found, ref] _ CDExpr.FetchRef[symTab, "Inputs"]; IF ~found THEN {Output["Name of inputs must be supplied!\n"]; ERROR}; context.inputNames _ RefToListOfRopes[ref]; [found, ref] _ CDExpr.FetchRef[symTab, "Outputs"]; IF ~found THEN {Output["Name of outputs must be supplied!\n"]; ERROR}; context.outputNames _ RefToListOfRopes[ref]; [found, rope] _ CDExpr.FetchRope[symTab, "TruthTableFile"]; IF ~found THEN {Output["TruthTableFile must be supplied!\n"]; ERROR}; Output["Reading TruthTable in ", rope, " ...\n"]; context.table _ AlpsBool.ReadPLAFile[rope, context.inputNames, context.outputNames]; Output["... TruthTable in ", rope, " read!\n"]; FOR list: LIST OF ROPE _ context.inputNames, list.rest WHILE list#NIL DO latch: ROPE _ list.first; input: AlpsBool.VarNb _ 0; output: AlpsBool.OutputRef _ NIL; FOR i: AlpsBool.VarNb IN [1 .. context.table.size) DO IF Rope.Equal[context.table[i].name, latch] THEN {input _ i; EXIT}; ENDLOOP; IF input=0 THEN ERROR; FOR outs: LIST OF AlpsBool.OutputRef _ context.table.outputs, outs.rest WHILE outs#NIL DO IF Rope.Equal[outs.first.name, latch] THEN {output _ outs.first; EXIT}; ENDLOOP; IF output#NIL THEN { Output["Latch (both input and output): ", latch, "\n"]; output.type _ latch; output.fedBackInput _ input; context.table[input].fromOutput _ output; }; ENDLOOP; } ELSE { [found, ref] _ CDExpr.FetchRef[symTab, "AlpsTable"]; IF ~found THEN {Output["Either TruthTableFile or AlpsTable must be supplied\n"]; ERROR}; Output["Getting equations from AlpsTable\n"]; context.table _ NARROW[ref, REF AlpsBool.TableOfVariables]^; }; [found, int] _ CDExpr.FetchInt[symTab, "DistanceBetweenGlue"]; IF found THEN context.distanceBetweenGlue _ int ELSE {Output["DistanceBetweenGlue must be INT"]; ERROR}; [found, int] _ CDExpr.FetchInt[symTab, "DistanceBetweenContacts"]; IF found THEN context.distanceBetweenContacts _ int ELSE {Output["DistanceBetweenContacts must be INT"]; ERROR}; [found, bool] _ CDExpr.FetchBool[symTab, "Optimize"]; IF found THEN context.optimize _ bool ELSE {Output["Optimize must be BOOL"]; ERROR}; [found, int] _ CDExpr.FetchInt[symTab, "SuperOptimize"]; IF found THEN context.superOptimize _ int ELSE {Output["SuperOptimize must be INT"]; ERROR}; [found, bool] _ CDExpr.FetchBool[symTab, "Debug"]; IF found THEN context.debug _ bool ELSE {Output["Debug must be BOOL"]; ERROR}; }; AlpsCellFromContext: PUBLIC PROC [context: Context, design: CD.Design] RETURNS [obj: CD.Object] = { IF CDDirectory.Fetch[design, context.tileset].found THEN Output[context.tileset, " already present in design\n"] ELSE BEGIN to: CD.Design _ design; Check: PROC [design: CD.Design] RETURNS [ok: BOOL] = BEGIN ok _ design.technology=to.technology; IF ~ok THEN Output["Technology mismatch: includee is ", design.technology.name, "\n"]; END; from: CD.Design _ CDIO.ReadDesign[context.tileset, Check]; Output["Design ", context.tileset, " read and included in the design"]; [] _ CDIOCommands.MergeIn[design: to, from: from, name: context.tileset]; END; BEGIN input, aux, output, latch: INT; [input, aux, output, latch] _ AlpsBool.NbOfVars[context.table]; Output[" Input: ", Convert.RopeFromInt[input], " Aux: ", Convert.RopeFromInt[aux], " Output: "]; Output[Convert.RopeFromInt[output], " Latch: ", Convert.RopeFromInt[latch], "\n"]; END; BEGIN ok: BOOL _ TRUE; table: AlpsBool.TableOfVariables _ context.table; Output["Removing auxiliary variables\n"]; WHILE ok DO newTable: AlpsBool.TableOfVariables; Output["Removing ...\n"]; [newTable, ok] _ AlpsHeur.RemoveAuxVar[table, AlpsHeur.AlwaysBetter, 0]; IF ok THEN table _ newTable; ENDLOOP; context.table _ table; END; IF context.optimize THEN { context.table _ AlpsHeur.BestPermuteInfinitely[context.table, AlpsHeur.ImproveSizeAndDelay]; }; IF context.superOptimize#0 THEN { context.table _ AlpsHeur.AllPermute[context.table, AlpsHeur.ImproveSizeAndDelay, context.superOptimize]; }; BEGIN input, aux, output, latch: INT; [input, aux, output, latch] _ AlpsBool.NbOfVars[context.table]; Output[" Input: ", Convert.RopeFromInt[input], " Aux: ", Convert.RopeFromInt[aux], " Output: "]; Output[Convert.RopeFromInt[output], " Latch: ", Convert.RopeFromInt[latch], "\n"]; END; BEGIN alpsTileContext: AlpsTile.Context _ NEW[AlpsTile.ContextRec _ [design: design, table: context.table, distanceBetweenGlue: context.distanceBetweenGlue, distanceBetweenContacts: context.distanceBetweenContacts, debug: context.debug]]; obj _ AlpsPWGen.TableToLayout[alpsTileContext]; Output["Done!"]; END; }; MakeAlpsCommand: Commander.CommandProc -- [cmd: Commander.Handle] RETURNS [result: REF ANY _ NIL, msg: ROPE _ NIL] -- = { }; MakeAlpsProc: PW.UserProc = BEGIN context: Context _ ReadContextFromAlpsFile[Input["\nFile describing Alps: "]]; obj: CD.Object _ AlpsCellFromContext[context, design]; RETURN [obj]; END; PW.Register[MakeAlpsProc, "MakeAlps"]; END. ΤPWAlpsImpl.mesa Copyright c 1984 by Xerox Corporation. All rights reversed. Created by: Bertrand Serlet, September 26, 1985 6:26:16 pm PDT Last Edited: Serlet, July 1, 1985 10:50:43 pm PDT -- Input, Output and eventually Latches names -- Reading truth table Reading layout control parameters Including if necessary tileset Printing info Removing auxiliary variables Permutations RePrinting info Layout at last TO DO -- register this generator with PW Κ™˜– "Cedar" stylešœ™Jšœ Οmœ1™J™1—J˜šΟk ˜ Jšœ)˜)Jšžœžœ˜,Jšœžœ˜Jšžœ ˜ Jšœ˜šœ ˜ J˜——šΟb œžœž˜Jšžœ5žœžœžœ˜qJšžœ˜Jšžœ˜J˜Jšžœ˜Jšžœ˜ J˜Jš Οnœžœžœžœžœžœ!˜RJš œžœžœžœ*˜VJ˜š œžœžœžœžœ žœžœžœ˜Kšžœžœž˜Jš œžœžœžœžœ3˜PJšœžœžœ žœ žœžœžœžœžœžœ˜CJšžœ žœ˜—J˜—š œžœžœžœžœžœžœžœžœžœ˜PJšž˜Jšžœžœžœžœžœžœžœžœ2˜^Jšžœ˜—J˜š œž œ žœžœ˜Sšœ(˜(Jšœ#˜#Jšœ žœ4Οc%˜{—Jš œžœžœžœžœžœ˜8J˜Jšœ žœ ˜J˜JšœO˜OJ˜Jšœ?˜?Jšžœžœ)žœ˜>Jšœ9˜9šžœžœ˜J™-Jšœ1˜1Jšžœžœ0žœ˜EJšœ+˜+Jšœ2˜2Jšžœžœ1žœ˜FJšœ,˜,J˜Jšœ™Jšœ;˜;Jšžœžœ0žœ˜EJšœ1˜1JšœT˜TJšœ/˜/š žœžœžœžœ!žœžœž˜HJšœžœ˜Jšœ˜Jšœžœ˜!šžœžœž˜5Jšžœ*žœ žœ˜CJšžœ˜—Jšžœ žœžœ˜š žœžœžœ7žœžœž˜YJšžœ$žœžœ˜GJšžœ˜—šžœžœžœ˜Jšœ7˜7Jšœ[˜[J˜—Jšžœ˜Jšœžœ˜Jšœ4˜4JšžœžœCžœ˜XJšœ.˜.Jšœžœžœ˜˜>Jšžœžœ#žœ-žœ˜hJšœB˜BJšžœžœ'žœ1žœ˜pJšœ5˜5Jšžœžœžœ#žœ˜TJšœ8˜8Jšžœžœžœ'žœ˜\Jšœ2˜2Jšžœžœžœ žœ˜N—J˜J˜—J˜š  œžœžœžœ žœžœ ˜cJ˜™šžœ2žœ9ž˜uJšž˜Jšœžœ˜š  œžœ žœ žœžœ˜4Jšž˜Jšœ%˜%JšžœžœK˜VJšžœ˜—J˜Jšœžœ žœ$˜:JšœG˜GJšœI˜IJšžœ˜——J™šœ ™ Jšž˜Jšœžœ˜Jšœ?˜?J•StartOfExpansion[]šœ`˜`JšœR˜RJšžœ˜—J™™Jšž˜Jšœžœžœ˜Jšœ1˜1J˜)šžœžœ˜ Jšœ$˜$J˜JšœH˜HJšžœžœ˜Jšžœ˜—Jšœ˜Jšžœ˜—J™™ šžœžœ˜Jšœ\˜\J˜—šžœžœ˜!Jšœh˜hJ˜——J™šœ™Jšž˜Jšœžœ˜Jšœ?˜?J–[]šœ`˜`JšœR˜RJšžœ˜—J˜™Jšž˜Jšœ$žœΑ˜θJšœ/˜/J˜Jšžœ˜—J˜J˜—J˜–P -- [cmd: Commander.Handle] RETURNS [result: REF ANY _ NIL, msg: ROPE _ NIL] -- šŸœΠckOœ˜zJšœ™J˜—J™J™šŸ œžœ ˜Jšž˜JšœN˜NJšœ6˜6Jšžœ˜ Jšžœ˜—J˜J™"Jšžœ$˜&Jšžœ˜——…—X"Ε