WireGeometryImpl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Bruce Wagar, August 16, 1987 6:15:31 pm PDT
Contains the implementation of the wire geometry programs.
DIRECTORY
CD, CDCommandOps, CDInstances, CDOps, CDSequencer, Core, CoreClasses, CoreGeometry, CoreOps, IO, PW, RefTab, Rope, Sinix, SinixOps, TerminalIO, WireGeometry;
WireGeometryImpl: CEDAR PROGRAM
IMPORTS CDCommandOps, CDInstances, CoreClasses, CoreGeometry, CoreOps, IO, PW, RefTab, Rope, SinixOps, TerminalIO
EXPORTS WireGeometry
= BEGIN OPEN WireGeometry;
InstanceList: TYPE = CD.InstanceList;
Command Procs
ExtractAndShowPins: PROC [command: CDSequencer.Command] = {
Extracts selected object and displays the pins of specified public wire.
design: CD.Design = command.design;
mode: Sinix.Mode = SinixOps.GetExtractMode[tech: design.technology];
root, cell: CellType;
trans: CoreGeometry.Transformation;
[root: root, cell: cell, trans: trans] ← SinixOps.SelectedCellType[design: design, mode: mode];
IF root # NIL THEN {
cellName: ROPE = CoreOps.GetCellTypeName[cellType: cell];
wireName: ROPE = TerminalIO.RequestRope[prompt: "\nEnter name of public wire that pins are to be shown for: "];
wire: Wire = GetWire[cell: cell, name: wireName];
IF wire = NIL
THEN
TerminalIO.PutRopes[t1: cellName, t2: " contains no such wire.\n"]
ELSE {
AddCDInstance: EachInstanceProc = {
Converts instance to a CD instance and tacks it onto instanceList.
instanceList ← CONS[CDInstances.NewInst[ob: instance.obj, trans: instance.trans], instanceList]
};
instanceList: InstanceList ← NIL;
[] ← CoreGeometry.EnumeratePins[decoration: mode.decoration, public: wire, eachInstance: AddCDInstance];
TerminalIO.PutF[format: "%g's geometry in %g contains %g pins.\n", v1: IO.rope[wireName], v2: IO.rope[cellName], v3: IO.int[CountCDInstances[instanceList: instanceList]]];
[] ← PW.Draw[obj: PW.CreateCell[instances: instanceList]]
}
}
};
ExtractAndShowAllGeometry: PROC [command: CDSequencer.Command] = {
Extracts selected object and displays all the geometry of specified wire.
design: CD.Design = command.design;
mode: Sinix.Mode = SinixOps.GetExtractMode[tech: design.technology];
root, cell: CellType;
trans: CoreGeometry.Transformation;
[root: root, cell: cell, trans: trans] ← SinixOps.SelectedCellType[design: design, mode: mode];
IF root # NIL THEN {
cellName: ROPE = CoreOps.GetCellTypeName[cellType: cell];
wireName: ROPE = TerminalIO.RequestRope[prompt: "\nEnter name of wire that geometry is to be shown for: "];
wire: Wire = GetWire[cell: cell, name: wireName];
IF wire = NIL
THEN
TerminalIO.PutRopes[t1: cellName, t2: " contains no such wire.\n"]
ELSE {
AddCDInstance: EachInstanceProc = {
Converts instance to a CD instance and tacks it onto instanceList.
instanceList ← CONS[CDInstances.NewInst[ob: instance.obj, trans: instance.trans], instanceList]
};
instanceList: InstanceList ← NIL;
[] ← EnumerateAllGeometry[decoration: mode.decoration, cell: cell, wire: wire, eachInstance: AddCDInstance];
TerminalIO.PutF[format: "%g's geometry in %g contains %g instances.\n", v1: IO.rope[wireName], v2: IO.rope[cellName], v3: IO.int[CountCDInstances[instanceList: instanceList]]];
[] ← PW.Draw[obj: PW.CreateCell[instances: instanceList]]
}
}
};
Main Routines
GetWire: PUBLIC PROC [cell: CellType, name: ROPE] RETURNS [wire: Wire ← NIL] = {
Retrieves a wire with the corresponding name (short or full). Returns NIL if name = NIL or there is no such wire.
IF NOT Rope.IsEmpty[name] THEN {
index: INT = CoreOps.GetWireIndex[wire: cell.public, name: name];
IF index >= 0 THEN
RETURN [cell.public[index]];
wire ← CoreOps.FindWire[root: cell.public, name: name];
IF wire = NIL AND cell.class = CoreClasses.recordCellClass THEN
RETURN [CoreOps.FindWire[root: NARROW[cell.data, CoreClasses.RecordCellType].internal, name: name]]
}
};
CountCDInstances: PROC [instanceList: InstanceList] RETURNS [count: NAT ← 0] = {
Counts the number of CDInstances in instanceList.
UNTIL instanceList = NIL DO
count ← count + 1;
instanceList ← instanceList.rest
ENDLOOP
};
EnumerateAllGeometry: PUBLIC PROC [decoration: Decoration, cell: CellType, wire: Wire, eachInstance: EachInstanceProc] RETURNS [quit: BOOLFALSE] = {
Takes a Core cell and a specified wire of that cell and enumerates all the instances that comprise that wire. Instances can be enumerated more than once.
SELECT cell.class FROM
CoreClasses.recordCellClass => {
recordCell: CoreClasses.RecordCellType = NARROW[cell.data];
quit ← CoreGeometry.EnumerateGeometry[decoration: decoration, wire: wire, eachInstance: eachInstance];
FOR i: NAT IN [0..recordCell.size) UNTIL quit = TRUE DO
EnumerateSubInstances: CoreOps.EachWirePairProc = {
Enumerates next level instances.
EachTransSubInstance: EachInstanceProc = {
Applies eachInstance to the appropriate transformed subInstances.
RETURN [eachInstance[instance: CoreGeometry.Transform[trans: trans, instance: instance]]]
};
IF actualWire = wire THEN
quit ← EnumerateAllGeometry[decoration: decoration, cell: instanceType, wire: publicWire, eachInstance: EachTransSubInstance]
};
cellInstance: CoreClasses.CellInstance = recordCell[i];
instanceType: CellType = cellInstance.type;
trans: CoreGeometry.Transformation = CoreGeometry.GetTrans[decoration: decoration, cellInstance: cellInstance];
quit ← CoreOps.VisitBinding[actual: cellInstance.actual, public: instanceType.public, eachWirePair: EnumerateSubInstances].quit
ENDLOOP
};
CoreClasses.transistorCellClass =>
quit ← CoreGeometry.EnumerateGeometry[decoration: decoration, wire: wire, eachInstance: eachInstance];
ENDCASE => {
recastCell: CellType = CoreOps.Recast[me: cell];
wireTab: RefTab.Ref ← CoreOps.CreateBindingTable[wire1: cell.public, wire2: recastCell.public];
quit ← EnumerateAllGeometry[decoration: decoration, cell: recastCell, wire: NARROW[RefTab.Fetch[x: wireTab, key: wire].val], eachInstance: eachInstance]
}
};
GetAllGeometry: PUBLIC PROC [decoration: Decoration, cell: CellType, wire: Wire] RETURNS [geometry: Instances ← NIL] = {
Takes a Core cell and a specified wire of that cell and returns a list of all the instances that comprise that wire.
AddInstance: EachInstanceProc = {
Tacks instance onto geometry.
geometry ← CONS [instance, geometry]
};
[] ← EnumerateAllGeometry[decoration: decoration, cell: cell, wire: wire, eachInstance: AddInstance];
};
Initialization
CDCommandOps.RegisterWithMenu[
menu: $OtherProgramMenu,
entry: "Extract and Show Pins",
doc: "shows the pins of specified wire",
proc: ExtractAndShowPins,
key: $ExtractAndShowPins];
CDCommandOps.RegisterWithMenu[
menu: $OtherProgramMenu,
entry: "Extract and Show All Geometry",
doc: "shows all the geometry of specified wire",
proc: ExtractAndShowAllGeometry,
key: $ExtractAndShowAllGeometry]
END.