<> <> <> <> <> <> <> <<>> DIRECTORY CD, CDCells, CDCommandOps, CDIO, CDOps, CDSequencer, Core, CoreOps, CoreThyme, Rope, SinixOps, Sisyph, TerminalIO, ThymeGlobals; CoreThymeCmdsImpl: CEDAR PROGRAM IMPORTS CDCells, CDCommandOps, CDIO, CDOps, CoreOps, CoreThyme, Rope, SinixOps, Sisyph, TerminalIO, ThymeGlobals = BEGIN <<>> ROPE: TYPE = Rope.ROPE; ThymeHandle: TYPE = ThymeGlobals.Handle; <> thymeHandles: LIST OF ThymeHandle _ NIL; ExtractSelectedObjAndRunThyme: PROC [comm: CDSequencer.Command] = { selected: CD.Instance; multiple: BOOL; cellType: Core.CellType; wDir: ROPE _ CDIO.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]; <> CoreThyme.Simulate[thymeFileName, thymeHandle]; }; DirectExtractSelectedObjAndRunThyme: PROC [comm: CDSequencer.Command] = { selected: CD.Instance; multiple: BOOL; cellType: Core.CellType; wDir: ROPE _ CDIO.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"]; }; <> 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 cellcan'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]; }; <> CDCommandOps.RegisterWithMenu[menu: $OtherProgramMenu, entry: "Sisyph Extract and Thyme", proc: ExtractSelectedObjAndRunThyme, key: $CoreThymeExtractSelectedObjAndRunThyme]; < Thyme", proc: DirectExtractSelectedObjAndRunThyme, key: $DirectExtractToThyme]>> END.