DIRECTORY AlpsBool, AlpsHeur, AlpsPWGen, AlpsTile, AMTypes, AMBridge, Buttons, CD, CDMenus, CDOps, CDOrient, CDSequencer, Commander, Containers, Convert, FS, Icons, Interpreter, IO, Labels, Menus, MBQueue, Rope, ViewerClasses; AlpsViewer: CEDAR PROGRAM IMPORTS AlpsBool, AlpsHeur, AlpsPWGen, AMBridge, Buttons, CDMenus, CDOps, CDSequencer, Commander, Containers, Convert, FS, Icons, Interpreter, IO, Labels, MBQueue, Rope = BEGIN ROPE: TYPE = Rope.ROPE; Input: PROC [text: ROPE] RETURNS [ROPE] = AlpsBool.Input; Output: PROC [t1, t2, t3, t4, t5: ROPE _ NIL] = AlpsBool.Output; Context: TYPE = REF ContextRec; ContextRec: TYPE = RECORD [ ac: AlpsTile.Context, printLevel: INT _ 4, permutLimit: INT _ 8, betterProc: AlpsHeur.TableComparisonProc _ AlpsHeur.ImproveAreaAndDelay, labelShared: Labels.Label, -- for redrawing the label when shared changes labelPermutLimit: Labels.Label, -- for redrawing the label when permutLimit changes labelBetterProc: Labels.Label, -- for redrawing the label when betterProc changes labelPrintDistGlue: Labels.Label, -- for redrawing the label when distanceBetweenGlue changes labelPrintDistContacts: Labels.Label, -- for redrawing the label when distanceBetweenContacts changes labelPrintLevel: Labels.Label, -- for redrawing the label when PrintLevel changes labelPrintVars: Labels.Label, -- for redrawing the label when variables change oldCheck: INT _ 0, oldTables: LIST OF AlpsBool.TableOfVariables _ NIL]; MakeNewTable: PROC [context: Context, newTable: AlpsBool.TableOfVariables] = { context.oldCheck _ 0; context.oldTables _ NIL; context.ac.table _ newTable; RepaintAll[context]; }; RepaintAll: PROC [context: Context] = { input, aux, output, latch: INT; checksum: INT _ AlpsBool.Checksum[context.ac.table]; area, size, ifs, minWidth, maxWidth, deep: INT; IF context.oldCheck#0 AND checksum#context.oldCheck THEN ERROR; context.oldCheck _ checksum; [area, size, ifs, maxWidth, deep] _ AlpsBool.TableStatistics[context.ac.table]; [input, aux, output, latch] _ AlpsBool.NbOfVars[context.ac.table]; minWidth _ AlpsBool.MinWidth[context.ac.table]; Labels.Set[context.labelShared, IF context.ac.shared THEN "TRUE" ELSE "FALSE"]; Labels.Set[context.labelPermutLimit, Convert.RopeFromInt[context.permutLimit]]; Labels.Set[context.labelBetterProc, SELECT context.betterProc FROM AlpsHeur.ImproveAreaAndDelay => "ImproveAreaAndDelay", AlpsHeur.ImproveSizeAndDelay => "ImproveSizeAndDelay", AlpsHeur.ImproveSize => "ImproveSize", AlpsHeur.ImproveDelay => "ImproveDelay", AlpsHeur.AlwaysBetter => "AlwaysBetter", ENDCASE => "**betterProc**"]; Labels.Set[context.labelPrintDistGlue, Convert.RopeFromInt[context.ac.distanceBetweenGlue]]; Labels.Set[context.labelPrintDistContacts, Convert.RopeFromInt[context.ac.distanceBetweenContacts]]; Labels.Set[context.labelPrintLevel, Convert.RopeFromInt[context.printLevel]]; Labels.Set[context.labelPrintVars, Rope.Cat[ Rope.Cat[ Rope.Cat[" In: ", Convert.RopeFromInt[input], " Aux: ", Convert.RopeFromInt[aux], " Out: "], Rope.Cat[Convert.RopeFromInt[output], " Latch: ", Convert.RopeFromInt[latch], " Check: ", Convert.RopeFromInt[checksum]], Rope.Cat[" Area: ", Convert.RopeFromInt[area]]], Rope.Cat[ Rope.Cat[" Size: ", Convert.RopeFromInt[size], " Ifs: ", Convert.RopeFromInt[ifs]], Rope.Cat[" Width: ", Convert.RopeFromInt[minWidth], "-", Convert.RopeFromInt[maxWidth]], Rope.Cat[" Deep: ", Convert.RopeFromInt[deep]]] ]]; }; Shared: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; context.ac.shared _ ~context.ac.shared; RepaintAll[context]; }; PermutLimit: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; context.permutLimit _ SELECT mouseButton FROM red => MIN [1+ context.permutLimit, 99], yellow => IF context.permutLimit>=90 THEN 1 ELSE 99, blue => MAX [context.permutLimit-1, 1], ENDCASE => ERROR; RepaintAll[context]; }; BetterProc: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; context.betterProc _ SELECT context.betterProc FROM AlpsHeur.ImproveAreaAndDelay => AlpsHeur.ImproveSizeAndDelay, AlpsHeur.ImproveSizeAndDelay => AlpsHeur.ImproveSize, AlpsHeur.ImproveSize => AlpsHeur.ImproveDelay, AlpsHeur.ImproveDelay => AlpsHeur.AlwaysBetter, AlpsHeur.AlwaysBetter => AlpsHeur.ImproveAreaAndDelay, ENDCASE => ERROR; RepaintAll[context]; }; DistGlue: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; context.ac.distanceBetweenGlue _ SELECT mouseButton FROM red => MIN [1 + context.ac.distanceBetweenGlue, 99], yellow => IF context.ac.distanceBetweenGlue> 90 THEN 2 ELSE 99, blue => MAX [context.ac.distanceBetweenGlue - 1, 2], ENDCASE => ERROR; RepaintAll[context]; }; DistContacts: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; context.ac.distanceBetweenContacts _ SELECT mouseButton FROM red => MIN [1 + context.ac.distanceBetweenContacts, 99], yellow => IF context.ac.distanceBetweenContacts> 90 THEN 5 ELSE 99, blue => MAX [context.ac.distanceBetweenContacts - 1, 5], ENDCASE => ERROR; RepaintAll[context]; }; PrintLevel: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; context.printLevel _ SELECT mouseButton FROM red => MIN [1 + context.printLevel, 999], yellow => IF context.printLevel> 900 THEN 0 ELSE 999, blue => MAX [context.printLevel - 1, 0], ENDCASE => ERROR; RepaintAll[context]; }; Checkpoint: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; context.oldTables _ CONS [context.ac.table, context.oldTables]; }; RollBack: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; IF context.oldTables=NIL THEN {Output["Sorry, no history!\n"]; RETURN}; context.ac.table _ context.oldTables.first; context.oldTables _ context.oldTables.rest; RepaintAll[context]; }; ReadPLA: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; filename: ROPE _ Input["\nName of the PLA file to be read: "]; Output["Reading ", filename, " ...\n"]; MakeNewTable[context, AlpsBool.ReadPLAFile[filename]]; Output[filename, " read \n"]; }; ReadTable: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; tableExpr: ROPE _ Input["\nExpression evaluating to a table: "]; result: AMTypes.TV; errorRope: ROPE; noResult: BOOL; ref: REF; Output["Evaluating ", tableExpr, " ...\n"]; [result, errorRope, noResult] _ Interpreter.Evaluate[tableExpr]; IF noResult OR result=NIL THEN { Output["Impossible to evaluate reason: ", errorRope, "\n"]; ERROR; }; TRUSTED {ref _ AMBridge.SomeRefFromTV[result]}; MakeNewTable[context, NARROW[ref, REF AlpsBool.TableOfVariables]^]; Output["AlpsTable read\n"]; }; ReadIfuFetch: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; filename: ROPE _ "/indigo/dragon/IFU/IFUPLA/IFetchControl.pla"; Output["Reading ", filename, " ...\n"]; MakeNewTable[context, AlpsBool.ReadPLAFile[filename]]; Output[filename, " read \n"]; }; ReadIfuPhA: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; filename: ROPE _ "/indigo/dragon/IFU/IFUPLA/IFUPLAPhA.pla"; Output["Reading ", filename, " ...\n"]; MakeNewTable[context, AlpsBool.ReadPLAFile[filename]]; Output[filename, " read \n"]; }; ReadIfuPhB: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; filename: ROPE _ "/indigo/dragon/IFU/IFUPLA/IFUPLAPhB.pla"; Output["Reading ", filename, " ...\n"]; MakeNewTable[context, AlpsBool.ReadPLAFile[filename]]; Output[filename, " read \n"]; }; ExampleC1MX07A: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; MakeNewTable[context, AlpsHeur.ExampleC1MX07A[]]; }; NWFinite: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; filename: ROPE _ "NW.tt"; outputs: LIST OF AlpsBool.OutputRef; Output["Reading ", filename, " ...\n"]; MakeNewTable[context, AlpsBool.ReadPLAFile[filename]]; outputs _ context.ac.table.outputs; WHILE outputs.first.type#output DO outputs _ outputs.rest ENDLOOP; outputs.first.type _ latch; outputs.first.fedBackInput _ 1; WHILE outputs.first.type#output DO outputs _ outputs.rest ENDLOOP; outputs.first.type _ latch; outputs.first.fedBackInput _ 2; WHILE outputs.first.type#output DO outputs _ outputs.rest ENDLOOP; outputs.first.type _ latch; outputs.first.fedBackInput _ 3; WHILE outputs.first.type#output DO outputs _ outputs.rest ENDLOOP; outputs.first.type _ latch; outputs.first.fedBackInput _ 4; RepaintAll[context]; Output[filename, " read \n"]; }; PrintAll: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; AlpsBool.PrintTable[context.ac.table, context.printLevel]; }; LayoutGen: Menus.MenuProc = BEGIN context: Context _ NARROW [clientData]; cell: CD.Object; ac: AlpsTile.Context _ NEW[AlpsTile.ContextRec _ context.ac^]; IF design=NIL THEN {Output["You must execute once RecordDesign in PatchWork Menu for Alps to know what your design is"]; RETURN}; ac.design _ design; ac.debug _ TRUE; cell _ AlpsPWGen.TableToLayout[ac]; CDOps.AddAnObject[design, cell, pos]; END; design: CD.Design _ NIL; pos: CD.Position _ [0, 0]; RecordDesign: PROC [command: CDSequencer.Command] = { design _ command.design; pos _ command.pos; }; DumpTT: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; stream: IO.STREAM _ FS.StreamOpen[Input["Filename for dumping Truth Table : "], $create]; AlpsBool.DumpTT[context.ac.table, stream]; IO.Close[stream]; Output["DumpTT done\n"]; }; DumpAlps: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; name: ROPE _ Input["Filename for dumping Table as an AlpsHeur PROC: "]; stream: IO.STREAM _ FS.StreamOpen[Rope.Cat[name, ".mesa"], $create]; AlpsBool.DumpAlps[context.ac.table, name, stream]; IO.Close[stream]; Output["DumpAlps in file ", name, ".mesa done\n"]; }; FactorizeBest: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; newTable: AlpsBool.TableOfVariables; ok: BOOL; Output["FactorizeBest started ...\n"]; [newTable, ok] _ AlpsHeur.FactorizeBest[context.ac.table, context.betterProc]; IF ok THEN {Output["FactorizeBest finished successfully\n"]; context.ac.table _ newTable; RepaintAll[context]} ELSE Output["FactorizeBest FAILED\n"]; }; Factorize10Best: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; newTable: AlpsBool.TableOfVariables _ context.ac.table; ok: BOOL _ TRUE; Output["Factorize10Best started ...\n"]; THROUGH [1..10] WHILE ok DO [newTable, ok] _ AlpsHeur.FactorizeBest[newTable, context.betterProc, 1] ENDLOOP; Output["Factorize10Best finished \n"]; context.ac.table _ newTable; RepaintAll[context]; }; FactorizeAllBest: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; newTable: AlpsBool.TableOfVariables _ context.ac.table; ok: BOOL _ TRUE; Output["FactorizeAllBest started ...\n"]; WHILE ok DO [newTable, ok] _ AlpsHeur.FactorizeBest[newTable, context.betterProc, 0] ENDLOOP; Output["FactorizeAllBest finished \n"]; context.ac.table _ newTable; RepaintAll[context]; }; RemoveAuxVar: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; newTable: AlpsBool.TableOfVariables; ok: BOOL; Output["RemoveAuxVar started ...\n"]; [newTable, ok] _ AlpsHeur.RemoveAuxVar[context.ac.table, context.betterProc]; IF ok THEN {Output["RemoveAuxVar finished successfully\n"]; context.ac.table _ newTable; RepaintAll[context]} ELSE Output["RemoveAuxVar FAILED\n"]; }; Remove10AuxVar: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; newTable: AlpsBool.TableOfVariables _ context.ac.table; ok: BOOL _ TRUE; Output["Remove10AuxVar started ...\n"]; THROUGH [1..10] WHILE ok DO [newTable, ok] _ AlpsHeur.RemoveAuxVar[newTable, context.betterProc, 1] ENDLOOP; Output["Remove10AuxVar finished \n"]; context.ac.table _ newTable; RepaintAll[context]; }; RemoveAllAuxVar: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; newTable: AlpsBool.TableOfVariables _ context.ac.table; ok: BOOL _ TRUE; Output["RemoveAllAuxVar started ...\n"]; WHILE ok DO [newTable, ok] _ AlpsHeur.RemoveAuxVar[newTable, context.betterProc, 0] ENDLOOP; Output["RemoveAllAuxVar finished \n"]; context.ac.table _ newTable; RepaintAll[context]; }; RemoveAndFactorize: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; table, newTable: AlpsBool.TableOfVariables; ok1, ok2: BOOL; table _ context.ac.table; Output["RemoveAndFactorize started ...\n"]; ok1 _ ok2 _ TRUE; DO [newTable, ok1] _ AlpsHeur.RemoveAuxVar[table, context.betterProc, 0]; IF ok1 THEN table _ newTable; IF ~ok1 AND ~ok2 THEN EXIT; [newTable, ok2] _ AlpsHeur.FactorizeBest[table, context.betterProc, 0]; IF ok2 THEN table _ newTable; IF ~ok1 AND ~ok2 THEN EXIT; ENDLOOP; Output["RemoveAndFactorize finished \n"]; context.ac.table _ table; RepaintAll[context]; }; FastPermute: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; newTable: AlpsBool.TableOfVariables; ok: BOOL; Output["FastPermute started ...\n"]; [newTable, ok] _ AlpsHeur.FastPermute[context.ac.table, context.betterProc]; IF ok THEN {Output["FastPermute finished successfully\n"]; context.ac.table _ newTable; RepaintAll[context]} ELSE Output["FastPermute FAILED\n"]; }; AllPermute: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; Output["AllPermute started ...\n"]; context.ac.table _ AlpsHeur.AllPermute[context.ac.table, context.betterProc, context.permutLimit]; Output["AllPermute finished ...\n"]; RepaintAll[context]; }; BestPermute: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; newTable: AlpsBool.TableOfVariables; ok: BOOL; Output["BestPermute started ...\n"]; [newTable, ok] _ AlpsHeur.BestPermute[context.ac.table, context.betterProc]; IF ok THEN {Output["BestPermute finished successfully\n"]; context.ac.table _ newTable; RepaintAll[context]} ELSE Output["BestPermute FAILED\n"]; }; BestPermuteInfinitely: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; Output["BestPermuteInfinitely started ...\n"]; context.ac.table _ AlpsHeur.BestPermuteInfinitely[context.ac.table, context.betterProc]; RepaintAll[context]; }; Latchize: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; fedBackInput: AlpsBool.VarNb _ 1; -- All this proc is a big HACK FOR outs: LIST OF AlpsBool.OutputRef _ context.ac.table.outputs, outs.rest WHILE outs#NIL DO IF outs.first.type=output THEN {outs.first.type _ latch; outs.first.fedBackInput _ fedBackInput; fedBackInput _ fedBackInput + 1}; ENDLOOP; Output["Latchize done\n"]; RepaintAll[context]; }; RemoveAndPermute: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; table, newTable: AlpsBool.TableOfVariables; ok1, ok2: BOOL; table _ context.ac.table; Output["RemoveAndPermute started ...\n"]; ok1 _ ok2 _ TRUE; WHILE ok1 DO [newTable, ok1] _ AlpsHeur.RemoveAuxVar[table, context.betterProc, 0]; IF ok1 THEN table _ newTable; [newTable, ok2] _ AlpsHeur.FastPermute[table, context.betterProc]; IF ok2 THEN table _ newTable; ENDLOOP; Output["RemoveAndPermute finished \n"]; context.ac.table _ table; RepaintAll[context]; }; Reverse: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; context.ac.table _ AlpsHeur.Reverse[context.ac.table]; RepaintAll[context]; }; Interp: Menus.MenuProc -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- = { context: Context _ NARROW [clientData]; table: AlpsBool.TableOfVariables _ context.ac.table; ERROR; }; Create: Commander.CommandProc = -- [cmd: Handle] -- BEGIN height: INTEGER = 15; -- used for positionning buttons. That is a hack! interval: INTEGER = 3; -- used for positionning buttons. That is a hack! queue: MBQueue.Queue _ MBQueue.Create[]; context: Context _ NEW [ContextRec _ [ac: NEW[AlpsTile.ContextRec]]]; viewer: ViewerClasses.Viewer = Containers.Create[ info: [name: "Alps", scrollable: FALSE, openHeight: 9*height+8*interval, icon: Icons.NewIconFromFile["AlpsViewer.icons", 16]], paint: TRUE]; subviewer: ViewerClasses.Viewer; wx, wy: INTEGER; -- current next viewer position Info: PROC [name: ROPE, border: BOOL _ TRUE] RETURNS [ViewerClasses.ViewerRec] = {RETURN [[name: name, parent: viewer, wx: wx, wy: wy, border: border]]}; NextWx: PROC [] = {wx _ wx + subviewer.ww + 1}; wx _ wy _ 0; subviewer _ Labels.Create[info: Info[" In: 999 Aux: 999 Out: 999 Latch: 999 Check: 9999 Area: 99999 Size: 99999 Ifs: 9999 Width: 999-999 Deep: 99", FALSE]]; context.labelPrintVars _ subviewer; NextWx[]; wy _ wy + height + interval; wx _ 0; subviewer _ Buttons.Create[info: Info["Shared"], clientData: context, proc: Shared, documentation: "Shared or not shared style"]; NextWx[]; subviewer _ Labels.Create[info: Info["FALSE", FALSE]]; context.labelShared _ subviewer; NextWx[]; subviewer _ Buttons.Create[info: Info["PermutLimit"], clientData: context, proc: PermutLimit, documentation: "*2/Min-Max//2 PermutLimit"]; NextWx[]; wx _ wx + 4; subviewer _ Labels.Create[info: Info["99", FALSE]]; context.labelPermutLimit _ subviewer; NextWx[]; subviewer _ Buttons.Create[info: Info["BetterProc"], clientData: context, proc: BetterProc, documentation: "Change BetterProc"]; NextWx[]; wx _ wx + 4; subviewer _ Labels.Create[info: Info["ImproveAreaAndDelay", FALSE]]; context.labelBetterProc _ subviewer; NextWx[]; subviewer _ Buttons.Create[info: Info["DistGlue"], clientData: context, proc: DistGlue, documentation: "Incr/Min-Max/Decr DistGlue"]; NextWx[]; wx _ wx + 4; subviewer _ Labels.Create[info: Info["99", FALSE]]; context.labelPrintDistGlue _ subviewer; NextWx[]; subviewer _ Buttons.Create[info: Info["DistContacts"], clientData: context, proc: DistContacts, documentation: "Incr/Min-Max/Decr DistContacts"]; NextWx[]; wx _ wx + 4; subviewer _ Labels.Create[info: Info["99", FALSE]]; context.labelPrintDistContacts _ subviewer; NextWx[]; wy _ wy + height + interval; wx _ 0; subviewer _ Buttons.Create[info: Info["PrintLevel"], clientData: context, proc: PrintLevel, documentation: "Incr/Min-Max/Decr PrintLevel"]; NextWx[]; wx _ wx + 4; subviewer _ Labels.Create[info: Info["9999", FALSE]]; context.labelPrintLevel _ subviewer; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["Checkpoint"], clientData: context, proc: Checkpoint]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["RollBack"], clientData: context, proc: RollBack]; NextWx[]; wy _ wy + height + interval; wx _ 0; subviewer _ MBQueue.CreateButton[q: queue, info: Info["ReadPLA"], clientData: context, proc: ReadPLA, documentation: "Read a PLA file in a Mayo-Curry format", fork: FALSE, guarded: TRUE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["ReadTable"], clientData: context, proc: ReadTable, documentation: "Read a table in Alps format to be evaluated", fork: FALSE, guarded: TRUE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["ReadIfuFetch"], clientData: context, proc: ReadIfuFetch, documentation: "Read IFU Fetch PLA file in a Mayo-Curry format", fork: FALSE, guarded: TRUE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["ReadIfuPhA"], clientData: context, proc: ReadIfuPhA, documentation: "Read IFU PhA PLA file in a Mayo-Curry format", fork: FALSE, guarded: TRUE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["ReadIfuPhB"], clientData: context, proc: ReadIfuPhB, documentation: "Read IFU PhB PLA file in a Mayo-Curry format", fork: FALSE, guarded: TRUE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["ExampleC1MX07A"], clientData: context, proc: ExampleC1MX07A, documentation: "Standard Cell C1MX07A", fork: FALSE, guarded: TRUE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["NWFinite"], clientData: context, proc: NWFinite, documentation: "NWFinite", fork: FALSE, guarded: TRUE]; NextWx[]; wy _ wy + height + interval; wx _ 0; subviewer _ MBQueue.CreateButton[q: queue, info: Info["PrintAll"], clientData: context, proc: PrintAll, documentation: "Print all variables"]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["LayoutGen"], clientData: context, proc: LayoutGen, documentation: "Generates layout"]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["DumpTT"], clientData: context, proc: DumpTT, documentation: "Dumps the truth table", fork: FALSE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["DumpAlps"], clientData: context, proc: DumpAlps, documentation: "Dumps the table as a program", fork: FALSE]; NextWx[]; wy _ wy + height + interval; wx _ 0; subviewer _ MBQueue.CreateButton[q: queue, info: Info["FactorizeBest"], clientData: context, proc: FactorizeBest, documentation: "Introduce a good aux. var. and factorizes all", fork: FALSE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["Factorize10Best"], clientData: context, proc: Factorize10Best, documentation: "Introduce 10 good aux. var. and factorizes all", fork: FALSE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["FactorizeAllBest"], clientData: context, proc: FactorizeAllBest, documentation: "Introduce lots of good aux. var. and factorizes all", fork: FALSE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["RemoveAuxVar"], clientData: context, proc: RemoveAuxVar, documentation: "Deletes the worse aux. var. and expands all", fork: FALSE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["Remove10AuxVar"], clientData: context, proc: Remove10AuxVar, documentation: "Deletes 10 aux. var. and expands all", fork: FALSE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["RemoveAllAuxVar"], clientData: context, proc: RemoveAllAuxVar, documentation: "Deletes all aux. var. and expands all", fork: FALSE]; NextWx[]; wy _ wy + height + interval; wx _ 0; subviewer _ MBQueue.CreateButton[q: queue, info: Info["RemoveAndFactorize"], clientData: context, proc: RemoveAndFactorize, documentation: "Deletes aux. var. and factorize while better", fork: FALSE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["FastPermute"], clientData: context, proc: FastPermute, documentation: "Tries to position variables so to minimize betterProc", fork: FALSE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["AllPermute"], clientData: context, proc: AllPermute, documentation: "Tries all permutations so to minimize betterProc", fork: FALSE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["BestPermute"], clientData: context, proc: BestPermute, documentation: "Tries to position variables so to minimize betterProc", fork: FALSE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["BestPermuteInfinitely"], clientData: context, proc: BestPermuteInfinitely, documentation: "Tries to permute 2 variables as long as necessary", fork: FALSE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["Latchize"], clientData: context, proc: Latchize, documentation: "Transforms to finite state machine", fork: FALSE]; NextWx[]; wy _ wy + height + interval; wx _ 0; subviewer _ MBQueue.CreateButton[q: queue, info: Info["RemoveAndPermute"], clientData: context, proc: RemoveAndPermute, documentation: "Deletes aux. var. and permutes once and again and again...", fork: FALSE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["Reverse"], clientData: context, proc: Reverse, documentation: "Reverse all vars (useful after a Dump)", fork: FALSE]; NextWx[]; subviewer _ MBQueue.CreateButton[q: queue, info: Info["Interp"], clientData: context, proc: Interp, documentation: "Causes an error so to call the interpretor", fork: FALSE]; NextWx[]; context.ac.table _ AlpsBool.InitTableOfVariables[1]; -- the only client data passed to buttons RepaintAll[context]; END; Commander.Register[key: "AlpsTool", proc: Create, doc: "Creates an Alps Viewer useful for generating ALPS CMOS layout. Alps wizzards only"]; CDSequencer.ImplementCommand[$RecordDesign, RecordDesign]; CDMenus.CreateEntry[CDMenus.GetMenu[$RectProgramMenu], "Record design for Alps", $RecordDesign]; END.  AlpsViewer.mesa Created by Bertrand Serlet, September 26, 1985 1:31:51 pm PDT Last edited by Serlet July 1, 1985 10:55:24 pm PDT Utilities Alps context record Paint Procs State Procs Process control Input Procs Output Procs Computation Procs Creation of a new Alps viewer Labels giving some info State buttons and labels Process State buttons and labels Input buttons Output buttons Computation buttons Buttons.SetDisplayStyle[buttonReadPLA, $BlackOnGrey]; Menus.AppendMenuEntry[menu, menuReadPLA, 0]; Ê´˜™J™=J™2—J™šÏk ˜ JšœEœIœœ.˜Ø—J˜•StartOfExpansion[]šÏb œœ˜Jšœpœœ˜«J˜Jš˜J™™ J™Jšœœœ˜Jš Ïnœœœœœ˜9JšŸœœœœ˜@—J˜šœ™J™Jšžœœœ ˜šœ œœ˜J˜Jšœ œ˜Jšœ œ˜JšœH˜HJšœÏc œ ˜IJšœ  3˜SJšœ 2˜QJšœ" ;˜]Jšœ&  œ ˜eJšœ 2˜QJšœ 0˜NJšœ œ˜Jšœ œœœ˜4—J˜šŸ œœ<˜NJšœ*œ˜KJšœ˜J˜——J˜™ J˜šŸ œœ˜'Jšœœ˜Jšœ œ'˜4Jšœ+œ˜/Jšœœœœ˜?Jšœ˜JšœO˜OJšœB˜BJšœ/˜/Jšœ œœœ ˜OJšœO˜Ošœ$œ˜BJšœ7˜7Jšœ7˜7Jšœ*˜*Jšœ+˜+Jšœ,˜,Jšœ˜$—Jšœ\˜\Jšœd˜dJšœM˜Mšœ,˜,šœ ˜ Jšœ]˜]Jšœ|˜|Jšœ2˜2—˜ JšœU˜UJšœX˜XJšœ/˜/—Jšœ˜—J˜——J˜™ J˜šžœœÐck…œ˜ Jšœœ˜'Jšœ(˜(Jšœ˜J˜—J˜šž œœ¡…œ˜¥Jšœœ˜'šœœ œ˜.Jšœœ˜)Jšœ œœœ˜5Jšœœ˜'Jšœœ˜—Jšœ˜J˜—J–† -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- ˜šž œœ¡…œ˜¤Jšœœ˜'šœœœ˜4Jšœ>˜>Jšœ6˜6Jšœ.˜.Jšœ/˜/Jšœ6˜6Jšœœ˜—Jšœ˜J˜—J–† -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- ˜–† -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- šžœœ¡…œ˜¢Jšœœ˜'šœ!œ œ˜9Jšœœ+˜5Jšœ œ$œœ˜@Jšœœ)˜4Jšœœ˜—Jšœ˜J˜—J–† -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- ˜šž œœ¡…œ˜¦Jšœœ˜'šœ%œ œ˜=Jšœœ/˜9Jšœ œ(œœ˜DJšœœ-˜8Jšœœ˜—Jšœ˜J˜——J˜™J™–† -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- šž œœ¡…œ˜¤Jšœœ˜'šœœ œ˜-Jšœœ ˜*Jšœ œœœ˜6Jšœœ˜(Jšœœ˜—Jšœ˜J˜—J–† -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- ˜šž œœ¡…œ˜¤Jšœœ˜'Jšœœ'˜?J˜—J˜šžœœ¡…œ˜¢Jšœœ˜'Jšœœœ"œ˜GJšœW˜WJšœ˜J˜——J–† -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- ˜šœ ™ J™–† -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- šžœœ¡…œ˜¡Jšœœ˜'Jšœ œ0˜>Jšœ'˜'Jšœ6˜6Jšœ˜J˜—J–† -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- ˜šž œœ¡…œ˜£Jšœœ˜'Jšœ œ1˜@Jš œœ œ œœ˜>Jšœ+˜+Jšœ@˜@šœ œœœ˜ Jšœ;˜;Jšœ˜J˜—Jšœ(˜/Jšœœœ˜CJšœ˜J˜—J–† -- [parent: REF ANY, clientData: REF ANY _ NIL, mouseButton: Menus.MouseButton _ red, shift: BOOL _ FALSE, control: BOOL _ FALSE] -- ˜šž œœ¡…œ˜¦Jšœœ˜'Jšœ œ1˜?Jšœ'˜'Jšœ6˜6Jšœ˜J˜—J˜šž œœ¡…œ˜¤Jšœœ˜'Jšœ œ-˜;Jšœ'˜'Jšœ6˜6Jšœ˜J˜—J˜šž œœ¡…œ˜¤Jšœœ˜'Jšœ œ-˜;Jšœ'˜'Jšœ6˜6Jšœ˜J˜—šžœœ¡…œ˜¨Jšœœ˜'Jšœ1˜1J˜—J˜šžœœ¡…œ˜¢Jšœœ˜'Jšœ œ ˜Jšœ œœ˜$Jšœ'˜'Jšœ6˜6Jšœ#˜#Jšœœœ˜BJšœ<˜Jšœœœgœ˜Jšœœ˜$Jšœ#˜#Jšœ%˜%Jšœ˜—J˜Jšžœœ œ˜Jšžœœ˜J˜šŸ œœ#˜5Jšœ,˜,Jšœ˜—J˜šžœœ¡…œ˜ Jšœœ˜'JšœœœœC˜YJšœ*˜*Jšœ˜Jšœ˜J˜—J˜šžœœ¡…œ˜¢Jšœœ˜'Jšœœ=˜GJšœœœœ.˜DJšœ2˜2Jšœ˜Jšœ3˜3J˜——J˜™J™šž œœ¡…œ˜§Jšœœ˜'Jšœ)œ˜.J˜&JšœN˜Nšœœ˜ Jšœc˜cJšœ"˜&—J˜—J˜šžœœ¡…œ˜©Jšœœ˜'Jšœ8˜8Jšœœœ˜J˜(Jšœ œœJœ˜mJšœX˜XJ˜—J˜šžœœ¡…œ˜ªJšœœ˜'Jšœ8˜8Jšœœœ˜J˜)JšœœJœ˜]JšœY˜YJ˜—J˜šŸ œœ¡…œ˜¦Jšœœ˜'Jšœ)œ˜.Jšœ%˜%JšœM˜Mšœœ˜ Jšœb˜bJšœ!˜%—J˜—J˜šŸœœ¡…œ˜¨Jšœœ˜'Jšœ8˜8Jšœœœ˜Jšœ'˜'Jšœ œœIœ˜lJšœW˜WJ˜—J˜šŸœœ¡…œ˜©Jšœœ˜'Jšœ8˜8Jšœœœ˜Jšœ(˜(JšœœIœ˜\JšœX˜XJ˜—J˜šžœœ¡…œ˜¬Jšœœ˜'Jšœ,˜,Jšœ œ˜Jšœ˜Jšœ+˜+Jšœ œ˜šœ˜JšœG˜GJšœœ˜Jšœœœœ˜JšœH˜HJšœœ˜Jšœœœœ˜Jšœ˜—JšœX˜XJ˜—J˜šŸ œœ¡…œ˜¥Jšœœ˜'Jšœ)œ˜.Jšœ$˜$JšœL˜Lšœœ˜ Jšœa˜aJšœ ˜$—J˜—J˜šŸ œœ¡…œ˜¤Jšœœ˜'Jšœ#˜#Jšœc˜cJšœ$˜$Jšœ˜J˜—J˜šŸ œœ¡…œ˜¥Jšœœ˜'Jšœ)œ˜.Jšœ$˜$JšœL˜Lšœœ˜ Jšœa˜aJšœ ˜$—J˜—J˜šŸœœ¡…œ˜¯Jšœœ˜'Jšœ.˜.JšœY˜YJšœ˜J˜—J˜šžœœ¡…œ˜¢Jšœœ˜'Jšœ" ˜@š œœœ:œœ˜\Jšœœd˜‚Jšœ˜—Jšœ/˜/J˜—J˜šžœœ¡…œ˜ªJšœœ˜'Jšœ,˜,Jšœ œ˜Jšœ˜Jšœ)˜)Jšœ œ˜šœœ˜ JšœG˜GJšœœ˜JšœC˜CJšœœ˜Jšœ˜—JšœV˜VJ˜—J˜šžœœ¡…œ˜¡Jšœœ˜'JšœK˜KJ˜—J˜šžœœ¡…œ˜ Jšœœ˜'Jšœ4˜4Jšœ˜J˜——J˜™J˜šžœ ˜3Jš˜Jšœœ 1˜GJšœ œ 1˜HJšœ(˜(Jšœœœ˜Ešœ1˜1Jšœ!œ`œ˜Œ—Jšœ ˜ Jšœœ ˜0š Ÿœœœ œœœ˜QJšœœA˜H—JšŸœœ#˜/J™™J™J˜ Jšœ˜œ2˜Ï—J™™J™Jšœ$˜$JšœŒ˜ŒJšœ.œ/˜bJšœ¡˜¡Jšœ+œ4˜dJšœ—˜—Jšœ<œ3˜tJšœœ˜œJšœ+œ6˜fJšœ¨˜¨Jšœ+œ:˜jJ˜—™ J˜Jšœ$˜$Jšœ¢˜¢Jšœ-œ3˜eJšœw˜wJšœr˜r—J˜šœ ™ J™Jšœ$˜$Jšœ¥œ œ ˜ÆJšœ®œ œ ˜ÏJšœ·œ œ ˜ØJšœ±œ œ ˜ÒJšœ±œ œ ˜ÒJšœ¢œ œ ˜ÃJšœ‰œ œ ˜ª—J˜šœ™J™J˜$Jšœ™˜™Jšœ˜˜˜Jšœ’œ ˜£Jšœœ ˜®—J˜™J™J˜$Jšœ¸œ ˜ÉJšœ½œ ˜ÎJšœÄœ ˜ÕJšœ´œ ˜ÅJšœ±œ ˜ÂJšœ´œ ˜ÅJ˜J˜$JšœÁœ ˜ÒJšœ¼œ ˜ÍJšœµœ ˜ÆJšœ¼œ ˜ÍJšœÌœ ˜ÝJšœ£œ ˜´J˜J˜$JšœËœ ˜ÜJšœ¥œ ˜¶Jšœ§œ ˜¸J˜—J˜Jšœ5™5Jšœ,™,Jšœ0œ )˜^Jšœ˜Jšœ˜——J˜J˜˜1J˜[—Jšœ:˜:Jšœ`˜`J˜Jšœ˜——…—mbˆ"