DIRECTORY AlpsBool, AlpsHeur, AlpsPWGen, AlpsTile, CD, CDDirectory, CDExpr, CDExtras, CDIO, Commander, Convert, FS, PW, PWAlps, Rope, SymTab, TerminalIO; PWAlpsImpl: CEDAR PROGRAM IMPORTS AlpsBool, AlpsHeur, AlpsPWGen, CDDirectory, CDExpr, CDExtras, CDIO, Convert, FS, PW, Rope, TerminalIO EXPORTS PWAlps = BEGIN OPEN PWAlps; Input: PROC [text: ROPE] RETURNS [ROPE] = {RETURN [TerminalIO.RequestRope[text]]}; Output: PROC [t1, t2, t3, t4, t5, t6: ROPE _ NIL] = {AlpsBool.Output[t1, t2, t3, t4, t5, t6]}; 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, 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.ObPtr] = { 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"]; [] _ CDExtras.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: ", Rope.Cat[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]; }; BEGIN input, aux, output, latch: INT; [input, aux, output, latch] _ AlpsBool.NbOfVars[context.table]; Output[" Input: ", Convert.RopeFromInt[input], " Aux: ", Convert.RopeFromInt[aux], " Output: ", Rope.Cat[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.ObPtr _ AlpsCellFromContext[context, design]; RETURN [CDDirectory.Name[obj]]; END; PW.Register[MakeAlpsProc, "MakeAlps"]; END. ΞPWAlpsImpl.mesa Copyright c 1984 by Xerox Corporation. All rights reversed. Created by: Bertrand Serlet, April 9, 1985 9:09:38 am PST 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 ΚJ˜– "Cedar" stylešœ™Jšœ Οmœ1™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šœ2˜2Jšžœžœžœ žœ˜N—J˜J˜—J˜š  œžœžœžœ žœžœ ˜bJ˜™šžœ2žœ9ž˜uJšž˜Jšœžœ˜š  œžœ žœ žœžœ˜4Jšž˜Jšœ%˜%JšžœžœK˜VJšžœ˜—J˜Jšœžœ žœ$˜:JšœG˜GJšœE˜EJšžœ˜——J™šœ ™ Jšž˜Jšœžœ˜Jšœ?˜?J•StartOfExpansion[]šœ΅˜΅Jšžœ˜—J™™Jšž˜Jšœžœžœ˜Jšœ1˜1J˜)šžœžœ˜ Jšœ$˜$J˜JšœH˜HJšžœžœ˜Jšžœ˜—Jšœ˜Jšžœ˜—J™™ šžœžœ˜Jšœ\˜\J˜——J™šœ™Jšž˜Jšœžœ˜Jšœ?˜?J–[]šœ΅˜΅Jšžœ˜—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šœ5˜5Jšžœ˜Jšžœ˜—J˜J™"Jšžœ$˜&Jšžœ˜——…—0!H