CoreThymeCmdsImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Created by Pradeep Sindhu, March 31, 1986 6:25:43 pm PST
Pradeep Sindhu, April 29, 1986 0:19:46 am PDT
Bertrand Serlet October 17, 1986 10:46:42 pm PDT
Christian Jacobi, January 7, 1987 2:58:17 pm PST
Christian LeCocq February 19, 1987 5:47:54 pm PST
Barth, July 8, 1988 1:14:42 pm PDT
DIRECTORY
CD, CDCells, CDIO, CDOps, CDSequencer, CDSequencerExtras, Core, CoreOps, CoreThyme, Rope, SinixOps, Sisyph, TerminalIO, ThymeGlobals;
CoreThymeCmdsImpl: CEDAR PROGRAM
IMPORTS CDCells, CDIO, CDOps, CoreOps, CDSequencerExtras, CoreThyme, Rope, SinixOps, Sisyph, TerminalIO, ThymeGlobals = BEGIN
ROPE: TYPE = Rope.ROPE;
ThymeHandle: TYPE = ThymeGlobals.Handle;
Command Procs
thymeHandles: LIST OF ThymeHandle ← NIL;
ExtractSelectedObjAndRunThyme: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance;
multiple: BOOL;
cellType: Core.CellType;
wDir: ROPECDIO.GetWorkingDirectory[comm.design];
thymeHandle: ThymeHandle ← GetThymeHandle[wDir];
thymeFileName: ROPE;
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelectedAndCell[selected, multiple] THEN RETURN;
cellType ← NARROW [SinixOps.ExtractCDInstance[selected, comm.design, Sisyph.mode].result];
WHILE SinixOps.IsIcon[Sisyph.mode.decoration, cellType] DO
cellType ← CoreOps.Recast[cellType];
ENDLOOP;
IF CoreOps.GetCellTypeName[cellType]=NIL
THEN thymeFileName ← Rope.Cat[wDir, "CoreThymeDefaultFile.thy"]
ELSE thymeFileName ← Rope.Cat[wDir, CoreOps.GetCellTypeName[cellType], ".thy"];
CoreThyme.Translate[cellType, thymeFileName];
CoreOps.PrintCellType[cellType, TerminalIO.TOS[]];
CoreThyme.Simulate[thymeFileName, thymeHandle];
};
DirectExtractSelectedObjAndRunThyme: PROC [comm: CDSequencer.Command] = {
selected: CD.Instance;
multiple: BOOL;
cellType: Core.CellType;
wDir: ROPECDIO.GetWorkingDirectory[comm.design];
thymeHandle: ThymeHandle ← GetThymeHandle[wDir];
theRoot: ThymeGlobals.namePtr ← NEW[ThymeGlobals.nameBlk ← [name: "Main Circuit", details: NEW[ThymeGlobals.CircuitRec← []]] ];
gndNodeName: ThymeGlobals.namePtr ← NEW[ThymeGlobals.nameBlk ← [name: "Gnd", details: NEW[ThymeGlobals.NodeRec] ] ];
[selected, multiple] ← CDOps.SelectedInstance[comm.design];
IF ~IsSingleSelectedAndCell[selected, multiple] THEN RETURN;
cellType ← NARROW [SinixOps.ExtractCDInstance[selected, comm.design, Sisyph.mode].result];
WHILE SinixOps.IsIcon[Sisyph.mode.decoration, cellType] DO
cellType ← CoreOps.Recast[cellType];
ENDLOOP;
thymeHandle.vars ← NEW[ThymeGlobals.Variables ← [
line: "dummy: just to fool ThymeGlobalsImpl",
numPlots: 1,
plots: NEW[ThymeGlobals.PlotSeq[1]]
]];
ThymeGlobals.PutTopLevelCircuit[cellType, thymeHandle, theRoot, gndNodeName];
IF thymeHandle.echoInput THEN ThymeGlobals.Output[thymeHandle, theRoot, 0];
ThymeGlobals.Bomb[thymeHandle, theRoot, gndNodeName];
ThymeGlobals.TopoAnalysis[thymeHandle];
ThymeGlobals.MakePlotList[thymeHandle];
[] ← ThymeGlobals.RunIt[thymeHandle];
TerminalIO.PutRope["Direct Thyme Finished\n"];
};
Internal Utilities
IsSingleSelectedAndCell: PROC [selected: CD.Instance, multiple: BOOL] RETURNS [BOOL] = {
IF ~IsSingleSelected[selected, multiple] THEN RETURN [FALSE];
IF ~CDCells.IsCell[selected.ob] THEN {
TerminalIO.PutRope["\n** Selected instance is not a cell—can't do it.\n"];
RETURN[FALSE];
};
RETURN[TRUE];
};
IsSingleSelected: PROC [selected: CD.Instance, multiple: BOOL] RETURNS [BOOL] = {
IF selected=NIL THEN {
TerminalIO.PutRope["\n** No current selection--can't do it.\n"];
RETURN[FALSE];
};
IF multiple THEN {
TerminalIO.PutRope["\n** Multiple instances selected--can't do it.\n"];
RETURN[FALSE];
};
RETURN[TRUE];
};
GetThymeHandle: PROC [wDir: ROPE] RETURNS [thymeHandle: ThymeHandle] = {
FOR l: LIST OF ThymeHandle ← thymeHandles, l.rest WHILE l#NIL DO
IF l.first.outer#NIL AND l.first.stage=idle THEN {
CoreThyme.SetWorkingDirectory[wDir, l.first];
RETURN [l.first];
};
ENDLOOP;
thymeHandle ← CoreThyme.CreateThymeViewer[wDir];
thymeHandles ← CONS[thymeHandle, thymeHandles];
};
Initialization
CDSequencerExtras.RegisterCommand[key: $CoreThymeExtractSelectedObjAndRunThyme, proc: ExtractSelectedObjAndRunThyme, queue: doQueue];
END.