WireGeometryImpl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Bruce Wagar, August 16, 1987 6:15:31 pm PDT
Bertrand Serlet September 14, 1987 4:02:29 pm PDT
Contains the implementation of the wire geometry programs.
DIRECTORY
CD, CDCommandOps, CDInstances, CDSequencer, Core, CoreClasses, CoreGeometry, CoreOps, IO, PW, Rope, Sinix, SinixOps, TerminalIO;
WireGeometryImpl: CEDAR PROGRAM
IMPORTS CDCommandOps, CDInstances, CoreClasses, CoreGeometry, CoreOps, IO, PW, Rope, SinixOps, TerminalIO = BEGIN
InstanceList: TYPE = CD.InstanceList;
CellType: TYPE = Core.CellType;
Wire: TYPE = Core.Wire;
WireSeq: TYPE = Core.WireSeq;
ROPE: TYPE = Rope.ROPE;
Instance: TYPE = CoreGeometry.Instance;
Instances: TYPE = CoreGeometry.Instances;
Decoration: TYPE = CoreGeometry.Decoration;
EachInstanceProc: TYPE = CoreGeometry.EachInstanceProc;
Command Procs
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;
[] ← CoreGeometry.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
};
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]
};
[] ← CoreGeometry.EnumerateAllGeometry[decoration: decoration, cell: cell, wire: wire, eachInstance: AddInstance];
};
Initialization
CDCommandOps.RegisterWithMenu[
menu: $OtherProgramMenu,
entry: "Extract and Show All Geometry",
doc: "shows all the geometry of specified wire",
proc: ExtractAndShowAllGeometry,
key: $ExtractAndShowAllGeometry]
END.