SCUtilImpl:
CEDAR
PROGRAM
IMPORTS CoreProperties, IO, Rope, RTBasic, SC, 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;
FindPinByWire:
PUBLIC
PROCEDURE [object: SCPrivate.Object, wire: Core.Wire]
RETURNS [pin: SCPrivate.ObjectPin ←
NIL] =
BEGIN
pins: SCPrivate.ObjectPins ← object.pins;
FOR pinIndex:
NAT
IN [0 .. object.numPins)
WHILE pin =
NIL
DO
IF wire = pins.p[pinIndex].publicWire 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;
FindNetByWire:
PUBLIC
PROCEDURE [handle:
SC.Handle, wire: Core.Wire]
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 wire = nets.nets[netIndex].wire 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;
FindObjectByCell:
PUBLIC
PROCEDURE [handle:
SC.Handle, cellType: Core.CellType]
RETURNS [object: SCPrivate.Object ←
NIL] =
BEGIN
objects: SCPrivate.Objects ← NARROW[handle.structureData, SCPrivate.StructureData].objects;
FOR objectIndex:
NAT
IN [1 .. objects.count]
WHILE object =
NIL
DO
IF cellType = objects.ob[objectIndex].cellType 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;
IsPowerName:
PUBLIC
PROCEDURE [handle:
SC.Handle, name: Rope.
ROPE]
RETURNS [found:
BOOLEAN ←
FALSE] = {
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};
DirectionFromSide:
PUBLIC
PROC [side: CoreGeometry.Side]
RETURNS [CDSymbolicObjects.Direction] ~ {
RETURN[
SELECT side
FROM
bottom=> south, right => east, top => north, left => west, ENDCASE => SC.Error[callingError, "Not suppose to happen."]]};
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.PutRope[title];
TerminalIO.PutF1[" width = %g", IO.int[width]];
TerminalIO.PutF1[", height = %g", IO.int[height]];
TerminalIO.PutF1[", area = %g", IO.int[area]];
IF startArea > 0
THEN {
reduction: SC.Number ← (startArea - area)*100/startArea;
TerminalIO.PutRope[IO.PutFR[" reduction = %g%%\n", IO.real[reduction]]]};
TerminalIO.PutRope["\n"];
};
WriteStructure:
PUBLIC
PROCEDURE [handle:
SC.Handle] = {
EachInstance: SCInstUtil.EachInstanceProc = {
EachPin: SCInstUtil.EachPinProc = {
TerminalIO.PutRope[Rope.Cat[" Pin: ", netPin.pin.name, " Net: ", netPin.net.name, "\n"]]};
TerminalIO.PutRope[Rope.Cat[" Instance: ", instance.name, " Object: ", instance.object.name, "\n"]];
[] ← SCInstUtil.EnumeratePinsOnInst[instance, EachPin]};
TerminalIO.PutRope[Rope.Cat["Handle: ", handle.name, "\n"]];
[] ← SCInstUtil.EnumerateAllInstances[handle, EachInstance]};
XYToPQ:
PUBLIC
PROC [handle:
SC.Handle, pos:
SC.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:
SC.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]]};
DestroyRules:
PUBLIC
PROC [handle:
SC.Handle] ~ {
rules: SC.DesignRules ← handle.rules;
rules.rowRules.technology ← NIL;
rules.rowRules ← NIL;
rules.sideRules.technology ← NIL;
rules.sideRules ← NIL;
rules.technology ← NIL;
rules.properties ← NIL;
handle.rules ← NIL};
DestroyParms:
PUBLIC
PROC [handle:
SC.Handle] = {
parms: SCPrivate.Parms ← NARROW[handle.parms];
parms.libDesign ← NIL;
parms.ftObject ← NIL;
parms.portObject ← NIL;
handle.parms ← NIL};
Memb:
PROC [rope: Rope.
ROPE, list:
LIST
OF Rope.
ROPE]
RETURNS [
BOOL] = {
UNTIL list =
NIL
DO
IF Rope.Equal[list.first, rope] THEN RETURN[TRUE];
list ← list.rest;
ENDLOOP;
RETURN[FALSE];
};
GetCoreInvestmentProp:
PUBLIC
PROC [cellType: Core.CellType, prop:
ATOM]
RETURNS [
SC.HowLongToWork] ~ {
get an investment property from a cell
value: ATOM ← NARROW[CoreProperties.GetCellTypeProp[cellType, prop]];
investment:
SC.HowLongToWork ←
SELECT value
FROM
SC.veryLongValue => veryLong,
SC.longValue => long,
SC.mediumValue => medium,
SC.shortValue => short,
SC.veryShortValue => veryShort,
ENDCASE => noInvestmentProp;
RETURN[investment];
};
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.