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
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
Utilities
ROPE: TYPE = Rope.ROPE;
Input: PROC [text: ROPE] RETURNS [ROPE] = AlpsBool.Input;
Output: PROC [t1, t2, t3, t4, t5: ROPENIL] = AlpsBool.Output;
Alps context record
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];
};
Paint Procs
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]]]
]];
};
State Procs
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];
};
Process control
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];
};
Input Procs
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"];
};
Output Procs
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.STREAMFS.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.STREAMFS.StreamOpen[Rope.Cat[name, ".mesa"], $create];
AlpsBool.DumpAlps[context.ac.table, name, stream];
IO.Close[stream];
Output["DumpAlps in file ", name, ".mesa done\n"];
};
Computation Procs
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: BOOLTRUE;
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: BOOLTRUE;
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: BOOLTRUE;
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: BOOLTRUE;
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;
};
Creation of a new Alps viewer
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: BOOLTRUE] RETURNS [ViewerClasses.ViewerRec] =
{RETURN [[name: name, parent: viewer, wx: wx, wy: wy, border: border]]};
NextWx: PROC [] = {wx ← wx + subviewer.ww + 1};
Labels giving some info
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[];
State buttons and labels
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[];
Process State buttons and labels
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[];
Input buttons
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[];
Output buttons
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[];
Computation buttons
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[];
Buttons.SetDisplayStyle[buttonReadPLA, $BlackOnGrey];
Menus.AppendMenuEntry[menu, menuReadPLA, 0];
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.