SCUtilImpl.mesa ///StdCell/SCUtilImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Bryan Preas, August 26, 1985 5:47:05 pm PDT
DIRECTORY
CD,
D2Basic,
IO,
Rope,
RTBasic,
SC,
SCInstUtil,
SCPrivate,
SCUtil,
TerminalIO;
SCUtilImpl: CEDAR PROGRAM
IMPORTS IO, Rope, RTBasic, SCInstUtil, TerminalIO
EXPORTS SCUtil
SHARES SC =
BEGIN
FindPin: PUBLIC PROCEDURE [object: SCPrivate.Object, pinName: Rope.ROPE] RETURNS [pin: SCPrivate.ObjectPin ← NIL] =
BEGIN
pins: SCPrivate.ObjectPins ← object.pins;
FOR pinIndex: NAT IN [0 .. object.numPins) WHILE pin = NIL DO
IF Rope.Equal[pinName, pins.p[pinIndex].name] THEN pin ← pins.p[pinIndex];
ENDLOOP;
END;
FindNet: PUBLIC PROCEDURE [handle: SC.Handle, netName: Rope.ROPE] RETURNS [net: SCPrivate.Net ← NIL] =
BEGIN
structureData: SCPrivate.StructureData ← NARROW[handle.structureData];
nets: SCPrivate.Nets ← structureData.nets;
FOR netIndex: NAT IN [1 .. nets.count] WHILE net = NIL DO
IF Rope.Equal[netName, nets.nets[netIndex].name] THEN net ← nets.nets[netIndex];
ENDLOOP;
END;
FindObject: PUBLIC PROCEDURE [handle: SC.Handle, objectName: Rope.ROPE] RETURNS [object: SCPrivate.Object ← NIL] =
BEGIN
structureData: SCPrivate.StructureData ← NARROW[handle.structureData];
objects: SCPrivate.Objects ← structureData.objects;
FOR objectIndex: NAT IN [1 .. objects.count] WHILE object = NIL DO
IF Rope.Equal[objectName, objects.ob[objectIndex].name] THEN object ← objects.ob[objectIndex];
ENDLOOP;
END;
FindInstance: PUBLIC PROCEDURE [handle: SC.Handle, instanceName: Rope.ROPE] RETURNS [instance: SCPrivate.Instance ← NIL] =
BEGIN
structureData: SCPrivate.StructureData ← NARROW[handle.structureData];
instances: SCPrivate.Instances ← structureData.instances;
FOR instanceIndex: NAT IN [1 .. instances.count] WHILE instance = NIL DO
IF Rope.Equal[instanceName, instances.inst[instanceIndex].name] THEN instance ← instances.inst[instanceIndex];
ENDLOOP;
END;
FindBus: PUBLIC PROCEDURE [handle: SC.Handle, busName: Rope.ROPE] RETURNS [bus: SCPrivate.AcBus ← NIL] =
BEGIN
layoutData: SCPrivate.LayoutData ← NARROW[handle.layoutData];
acBuses: SCPrivate.AcBuses ← layoutData.acBuses;
FOR lrSide: SCPrivate.LRSide IN SCPrivate.LRSide WHILE bus = NIL DO
FOR busIndex: NAT IN [0 .. acBuses[lrSide].count) WHILE bus = NIL DO
IF Rope.Equal[busName, acBuses[lrSide].sigs.c[busIndex].name] THEN bus ← acBuses[lrSide].sigs.c[busIndex];
ENDLOOP;
ENDLOOP;
END;
IsPowerName: PUBLIC PROCEDURE [handle: SC.Handle, name: Rope.ROPE] RETURNS [found: BOOLEANFALSE] = {
layoutData: SCPrivate.LayoutData ← NARROW[handle.layoutData];
powerBuses: SCPrivate.PowerBuses ← layoutData.powerBuses;
IF Rope.Equal[name, powerBuses[left].name, FALSE] OR Rope.Equal[name, powerBuses[right].name, FALSE] THEN found ← TRUE};
WriteResults: PUBLIC PROCEDURE [title: Rope.ROPE, handle: SC.Handle, startArea: SC.Number] RETURNS [area: SC.Number] = {
layoutData: SCPrivate.LayoutData ← NARROW[handle.layoutData];
width: SC.Number ← layoutData.totWidth/layoutData.layoutParms.unitsPerLam;
height: SC.Number ← layoutData.totHeight/layoutData.layoutParms.unitsPerLam;
area ← width*height;
TerminalIO.WriteRope[Rope.Cat[title, " width = "]];
TerminalIO.WriteInt[width];
TerminalIO.WriteRope[", height = "]; TerminalIO.WriteInt[height];
TerminalIO.WriteRope[", area = "]; TerminalIO.WriteInt[area];
TerminalIO.WriteLn[];
IF startArea > 0 THEN {
reduction: SC.Number ← (startArea - area)*100/startArea;
TerminalIO.WriteRope[IO.PutFR[" reduction = %g%%\n", IO.real[reduction]]]}};
WriteStructure: PUBLIC PROCEDURE [handle: SC.Handle] = {
EachInstance: SCInstUtil.EachInstanceProc = {
EachPin: SCInstUtil.EachPinProc = {
TerminalIO.WriteRope[Rope.Cat[" Pin: ", netPin.pin.name, " Net: ", netPin.net.name, "\n"]]};
TerminalIO.WriteRope[Rope.Cat[" Instance: ", instance.name, " Object: ", instance.object.name, "\n"]];
[] ← SCInstUtil.EnumeratePinsOnInst[instance, EachPin]};
TerminalIO.WriteRope[Rope.Cat["Handle: ", handle.name, "\n"]];
[] ← SCInstUtil.EnumerateInstances[handle, EachInstance]};
XYToPQ: PUBLIC PROC [handle: SC.Handle, pos: D2Basic.Pos] RETURNS [pqPos: RTBasic.PQPos] = {
convert a position from x-y to p-q space.
layoutData: SCPrivate.LayoutData ← NARROW[handle.layoutData];
rowDirection: SC.Direction ← layoutData.layoutParms.rowDirection;
RETURN[RTBasic.XYToPQ[rowDirection, pos]]};
PQToXY: PUBLIC PROC [handle: SC.Handle, pqPos: RTBasic.PQPos] RETURNS [pos: D2Basic.Pos] = {
convert a position from p-q to x-y space.
layoutData: SCPrivate.LayoutData ← NARROW[handle.layoutData];
rowDirection: SC.Direction ← layoutData.layoutParms.rowDirection;
RETURN[RTBasic.PQToXY[rowDirection, pqPos]]};
translate: PUBLIC ARRAY SC.Side OF ARRAY SCPrivate.OrientationOrNone OF SC.Side;
translate[bottom] ← [bottom, bottom, left, top, right, bottom, top, left, right];
translate[left] ← [left, left, top, right, bottom, right, left, bottom, top];
translate[top] ← [top, top, right, bottom, left, top, bottom, right, left];
translate[right] ← [right, right, bottom, left, top, left, right, top, bottom];
END.