SinixTest.mesa
Copyright © 1984 by Xerox Corporation. All rights reversed.
Created by Bertrand Serlet August 30, 1985 11:41:04 am PDT
Bertrand Serlet June 1, 1986 2:38:01 pm PDT
Pradeep Sindhu December 2, 1985 6:42:39 pm PST
DIRECTORY
CD, CDCells, CDDirectory, CDMenus, CDOps, CDRects, CDSequencer, CDViewer, CDViewHighlight,
CMos, CMosB,
Core, CoreClasses, CoreOps, CoreProperties,
PW, PWPins,
Rope, Sinix, SinixCMos,
TerminalIO, ViewerClasses;
SinixTest: CEDAR PROGRAM
IMPORTS CDCells, CDDirectory, CDMenus, CDOps, CDRects, CDViewer, CDViewHighlight, CMos, CMosB, CoreClasses, CoreOps, CoreProperties, PW, PWPins, Sinix, SinixCMos, TerminalIO =
BEGIN
ROPE: TYPE = Rope.ROPE;
CellType: TYPE = Core.CellType;
lastResult: REF;
lastInstance: CD.Instance;
lastMode: Sinix.Mode;
Extract: PROC [comm: CDSequencer.Command] = {
first: CD.Instance; multiple: BOOL;
obj: PW.Object;
[first, multiple] ← CDOps.SelectedInstance[comm.design];
IF multiple THEN {PW.WriteF["Multiple instances selected. No action.\n"]; RETURN};
obj ← first.ob; lastInstance ← first;
lastMode ← SELECT comm.design.technology FROM
CMos.cmos   => SinixCMos.extractAMode,
CMosB.cmosB  => SinixCMos.extractBMode,
ENDCASE   => ERROR;
[lastResult] ← Sinix.Extract[obj, lastMode, first.properties];
CoreOps.Print[lastResult, TerminalIO.TOS[]];
};
Check: PROC [comm: CDSequencer.Command] = {
first: CD.Instance; multiple: BOOL;
obj: PW.Object;
[first, multiple] ← CDOps.SelectedInstance[comm.design];
IF multiple THEN {PW.WriteF["Multiple instances selected. No action.\n"]; RETURN};
obj ← first.ob; lastInstance ← first;
lastMode ← SELECT comm.design.technology FROM
CMosB.cmosB  => SinixCMos.checkBMode,
ENDCASE   => ERROR;
[lastResult] ← Sinix.Extract[obj, lastMode, first.properties];
CoreOps.Print[lastResult, TerminalIO.TOS[]];
};
HighLightOb: PROC [ob: CD.Object] RETURNS [hob: CD.Object] = {
SELECT ob.class.objectType FROM
$Rect  => hob ← CDRects.CreateRect[ob.size, CD.shadeLayer];
$Cell  => {
cellPtr, hcellPtr: CD.CellPtr;
hob ← CDCells.CreateEmptyCell[];
cellPtr ← NARROW [ob.specificRef];
hcellPtr ← NARROW [hob.specificRef];
hcellPtr.contents ← HighLightListInst[cellPtr.contents];
hob.size ← ob.size;
};
ENDCASE => {
hob ← CDDirectory.Expand[ob, NIL, NIL].new;
IF hob=NIL THEN RETURN[CDRects.CreateRect[ob.size, CD.undefLayer]];
hob ← HighLightOb[hob];
};
};
HighLightInst: PROC [inst: CD.Instance] RETURNS [hinst: CD.Instance] = {
hinst ← NEW [CD.InstanceRep ← [
ob: IF inst.ob.class.objectType=$PinOb0 THEN CDRects.CreateRect[inst.ob.size, CD.shadeLayer] ELSE HighLightOb[inst.ob],
location: inst.location, orientation: inst.orientation]];
};
HighLightListInst: PROC [instances: LIST OF CD.Instance] RETURNS [hlist: LIST OF CD.Instance ← NIL] = {
WHILE instances#NIL DO
hlist ← CONS[HighLightInst[instances.first], hlist]; instances ← instances.rest;
ENDLOOP;
};
HighLightWire: PROC [design: CD.Design, wire: Core.Wire, instance: CD.Instance, pins: BOOL] = {
viewers: LIST OF ViewerClasses.Viewer ← CDViewer.ViewersOf[design];
hinsts: LIST OF CD.Instance ← NIL;
instances: LIST OF CD.Instance ← (IF pins THEN Sinix.GetPinsProp ELSE Sinix.GetWireGeometryProp)[lastMode, wire];
hob: CD.Object ← CDCells.CreateEmptyCell[];
hcellPtr: CD.CellPtr ← NARROW [hob.specificRef];
hcellPtr.contents ← HighLightListInst[instances];
IF instances=NIL THEN PW.WriteF["*** No geometry to highlight for this wire\n"];
hob.size ← instance.ob.size;
hinsts ← CONS [PWPins.NewInstance[hob, instance.location, instance.orientation], hinsts];
WHILE viewers#NIL DO
CDViewHighlight.ShowInstance[viewers.first, hinsts, TRUE];
viewers ← viewers.rest;
ENDLOOP;
};
FindSelectedWire: PROC [rootCellType: Core.CellType] RETURNS [selectedWire: Core.Wire ← NIL] = {
ContainsSelectedListInst: PROC [list: LIST OF CD.Instance] RETURNS [yes: BOOLFALSE] = {
FOR instances: LIST OF CD.Instance ← list, instances.rest WHILE instances#NIL DO
IF instances.first.selected THEN RETURN [TRUE];
ENDLOOP;
FOR instances: LIST OF CD.Instance ← list, instances.rest WHILE instances#NIL DO
IF ContainsSelectedOb[instances.first.ob] THEN RETURN [TRUE];
ENDLOOP;
};
ContainsSelectedOb: PROC [ob: CD.Object] RETURNS [yes: BOOLFALSE] = {
IF ob=NIL THEN RETURN;
SELECT ob.class.objectType FROM
$Rect  => {};
$Cell  => {
cellPtr: CD.CellPtr ← NARROW [ob.specificRef];
yes ← ContainsSelectedListInst[cellPtr.contents];
};
ENDCASE => {
ob ← CDDirectory.Expand[ob, NIL, NIL].new;
yes ← ContainsSelectedOb[ob];
};
};
data: CoreClasses.RecordCellType ← NARROW [rootCellType.data];
FOR i: NAT IN [0 .. data.internal.size) DO
wire: Core.Wire ← data.internal[i];
IF ContainsSelectedListInst[NARROW [CoreProperties.GetProp[wire.properties, lastMode.wireGeometryProp]]] THEN RETURN [wire];
ENDLOOP;
FOR i: NAT IN [0 .. data.size) DO
IF data[i].type.class=CoreClasses.recordCellClass THEN {
selectedWire ← FindSelectedWire[data[i].type];
IF selectedWire#NIL THEN RETURN;
};
ENDLOOP;
};
HighLightSelected: PROC [command: CDSequencer.Command] = {
HighLightSelectedBoth[command, NARROW [NARROW [lastResult, CellType].data, CoreClasses.RecordCellType].internal, FALSE];
};
HighLightSelectedPins: PROC [command: CDSequencer.Command] = {
HighLightSelectedBoth[command, NARROW [lastResult, CellType].public, TRUE];
};
HighLightSelectedBoth: PROC [command: CDSequencer.Command, root: Core.Wire, pins: BOOL] = {
name: ROPEPW.RequestRope["Full Name of Wire : "];
selectedWire: Core.Wire ← CoreOps.FindWire[root, name];
IF selectedWire=NIL THEN {PW.WriteF["*** No such wire!\n"]; RETURN};
HighLightWire[command.design, selectedWire, lastInstance, pins];
};
CDMenus.ImplementEntryCommand[$OtherProgramMenu, "HighLightSelected", HighLightSelected, $HighLightSelected];
CDMenus.ImplementEntryCommand[$OtherProgramMenu, "HighLightSelectedPins", HighLightSelectedPins, $HighLightSelectedPins];
CDMenus.ImplementEntryCommand[$OtherProgramMenu, "Sinix Extract", Extract, $Extract];
CDMenus.ImplementEntryCommand[$OtherProgramMenu, "Sinix Check", Check, $Check];
END.