RouteUtilImpl.mesa
Copyright © 1985, 1987 by Xerox Corporation. All rights reserved.
by Bryan Preas July 10, 1985 6:57:00 pm PDT
last edited by Bryan Preas July 20, 1987 4:12:16 pm PDT
DIRECTORY Basics, CD, CDBasics, CDCells, CDRects, DABasics, D2Orient, Real, RefTab, Rope, Route, RoutePrivate, RouteChannel, RouteTechnology, RouteUtil, RTBasic;
RouteUtilImpl: CEDAR PROGRAM
IMPORTS CDBasics, CDCells, CDRects, Real, RefTab, Route, RouteTechnology, RouteUtil, RTBasic
EXPORTS RouteUtil = BEGIN
LayerToRoutingLayer: PUBLIC PROC [routingArea: RoutePrivate.RoutingArea, layer: CD.Layer] RETURNS [routingLayer: RoutePrivate.RoutingLayer] =
BEGIN
trunkLayer: CD.Layer ← routingArea.rules.trunkLayer;
branchLayer: CD.Layer ← routingArea.rules.branchLayer;
IF layer = trunkLayer THEN routingLayer ← trunk
ELSE IF layer = branchLayer THEN routingLayer ← branch
ELSE Route.Error[programmingError, "Invalid layer"];
END;
RoutingLayerToLayer: PUBLIC PROC [routingArea: RoutePrivate.RoutingArea, routingLayer: RoutePrivate.RoutingLayer] RETURNS [layer: CD.Layer] =
BEGIN
trunkLayer: CD.Layer ← routingArea.rules.trunkLayer;
branchLayer: CD.Layer ← routingArea.rules.branchLayer;
IF routingLayer = trunk THEN layer ← trunkLayer
ELSE IF routingLayer = branch THEN layer ← branchLayer
ELSE Route.Error[programmingError, "Invalid routing layer"];
END;
RoutingLayerName: PUBLIC ARRAY RoutePrivate.RoutingLayerOrNone OF Rope.ROPE ← ["trunk", "branch", "none"];
Length: PUBLIC PROC [pos1, pos2: DABasics.Position] RETURNS [length: DABasics.Number] = {
return lent of line segment from pos1 to pos2.
length ← Real.Round[Real.SqRt[Real.FAdd[Real.FMul[Real.FSub[pos1.x, pos2.x], Real.FSub[pos1.x, pos2.x]], Real.FMul[Real.FSub[pos1.y, pos2.y], Real.FSub[pos1.y, pos2.y]]]]]};
XYToPQ: PUBLIC PROC [routingArea: RoutePrivate.RoutingArea, pos: DABasics.Position] RETURNS [pqPos: RTBasic.PQPos] =
convert a position from x-y to p-q space.
BEGIN
chanDirection: DABasics.Direction ← routingArea.rules.trunkDirection;
SELECT chanDirection FROM
horizontal => RETURN[[pos.x, pos.y]];
vertical => RETURN[[pos.y, pos.x]];
ENDCASE;
END;
PQToXY: PUBLIC PROC [routingArea: RoutePrivate.RoutingArea, pqPos: RTBasic.PQPos] RETURNS [pos: DABasics.Position] =
convert a position from p-q to x-y space.
BEGIN
chanDirection: DABasics.Direction ← routingArea.rules.trunkDirection;
SELECT chanDirection FROM
horizontal => RETURN[[pqPos.p, pqPos.q]];
vertical => RETURN[[pqPos.q, pqPos.p]];
ENDCASE;
END;
SimpleCompare: PUBLIC PROCEDURE [result1, result2: DABasics.Number]
RETURNS [result: Basics.Comparison] = {
result ← IF result1 < result2 THEN less
ELSE IF result1 > result2 THEN greater
ELSE equal
};
CompareResult: PUBLIC PROCEDURE [result1, result2: Route.IntermediateResult]
RETURNS [result: Basics.Comparison] = {
result ← RouteUtil.SimpleCompare[result1.numIncompletes, result2.numIncompletes];
IF result # equal THEN RETURN;
result ← RouteUtil.SimpleCompare[result1.numTrunkTracks, result2.numTrunkTracks];
IF result # equal THEN RETURN;
result ← RouteUtil.SimpleCompare[result1.polyLength, result2.polyLength];
IF result # equal THEN RETURN;
result ← RouteUtil.SimpleCompare[result1.polyToMetal, result2.polyToMetal];
IF result # equal THEN RETURN;
result ← RouteUtil.SimpleCompare[result1.metalToMetal2, result2.metalToMetal2];
IF result # equal THEN RETURN;
result ← RouteUtil.SimpleCompare[result1.metalLength, result2.metalLength];
IF result # equal THEN RETURN;
result ← RouteUtil.SimpleCompare[result1.metal2Length, result2.metal2Length];
RETURN;
}; -- CompareResult
Include: PUBLIC PROC [cell: CD.Object←NIL, ob: CD.Object,
position: CD.Position←[0, 0], orientation: D2Orient.Orientation←original] RETURNS [application: CD.Instance] = {
include an object in a design
application ← CDCells.IncludeOb[design: NIL, cell: cell, ob: ob, trans: [off: position, orient: orientation], mode: dontResize].newInst};
GetVia: PUBLIC PROC [size: DABasics.Position, layer1, layer2: CD.Layer, cdLambda: DABasics.Number] RETURNS [cell: CD.Object ← NIL] = {
this is technology dependent; this needs to be fixed
cmosB via rules are used if 'Big Contacts" exist
minBigContact: CD.Object ← RouteTechnology.GetBigContact[[1, 1], layer1, layer2];
IF minBigContact = NIL THEN
no big contacts, must do it with small ones
cell ← RouteTechnology.GetContact[layer1, layer2]
ELSE { -- big contact exists, determine size to use
contactSize: CD.Position ← CDBasics.SizeOfRect[minBigContact.bbox];
IF contactSize.x <= size.x AND contactSize.y <= size.y THEN {
use 2, 3, or 4 lambda square vias tha give largest perimeter
perim2x2: DABasics.Number ← Real.Round[size.x/(6*cdLambda)]*Real.Round[size.y/(6*cdLambda)]*8*cdLambda; -- 2x2 contacts go in a 6x6 square
perim3x3: DABasics.Number ← Real.Round[size.x/(7*cdLambda)]*Real.Round[size.y/(7*cdLambda)]*12*cdLambda; -- 3x3 contacts go in a 7x7 square
perim4x4: DABasics.Number ← Real.Round[size.x/(8*cdLambda)]*Real.Round[size.y/(8*cdLambda)]*16*cdLambda; -- 4x4 contacts go in a 8x8 square
SELECT TRUE FROM
perim4x4 >= perim2x2 AND perim4x4 >= perim3x3 =>
cell ← RouteTechnology.GetBigContact[[8*cdLambda, 8*cdLambda], layer1, layer2];
perim3x3 >= perim2x2 AND perim3x3 >= perim4x4 =>
cell ← RouteTechnology.GetBigContact[[7*cdLambda, 7*cdLambda], layer1, layer2];
perim2x2 >= perim4x4 AND perim2x2 >= perim3x3 =>
cell ← RouteTechnology.GetBigContact[[6*cdLambda, 6*cdLambda], layer1, layer2];
ENDCASE}
ELSE -- big contact too big, must do it with small ones
cell ← RouteTechnology.GetContact[layer1, layer2]
}};
StitchVias: PUBLIC PROC [size: DABasics.Position, layer1, layer2: CD.Layer, cdLambda: DABasics.Number, viaTable: RefTab.Ref] RETURNS [obj: CD.Object] = {
contact: CD.Object ← GetVia[size, layer1, layer2, cdLambda];
contactSize: CD.Position ← CDBasics.SizeOfRect[contact.bbox];
minSize: DABasics.Number ← 6*cdLambda; -- technology dependent!!! this needs to be fixed
val: RefTab.Val ← IF viaTable = NIL THEN NIL ELSE RefTab.Fetch[viaTable, NEW[DABasics.Position ← size]].val;
IF val # NIL THEN obj ← NARROW[val]
ELSE IF contactSize.x >= size.x AND contactSize.y >= size.y THEN
obj ← contact -- special case for performance
ELSE {
sizeX: DABasics.Number ← MAX[contactSize.x, minSize];
sizeY: DABasics.Number ← MAX[contactSize.y, minSize];
numYInts: DABasics.Number ← MAX[1, size.y/sizeY];
lastYLoc: DABasics.Number ← 0;
lastXLoc: DABasics.Number;
cover: DABasics.Position;
obj ← CDCells.CreateEmptyCell[];
FOR index: DABasics.Number IN [1 .. numYInts] DO
numXInts: DABasics.Number ← MAX[1, size.x/sizeX];
lastXLoc ← 0;
FOR index: DABasics.Number IN [1 .. numXInts] DO
[] ← RouteUtil.Include[obj, contact, [lastXLoc, lastYLoc]];
lastXLoc ← lastXLoc + sizeX;
ENDLOOP;
lastYLoc ← lastYLoc + sizeY;
ENDLOOP;
cover ← [lastXLoc - sizeX + contactSize.x, lastYLoc - sizeY + contactSize.y];
[] ← RouteUtil.Include[obj, CDRects.CreateRect[cover, layer1]];
[] ← RouteUtil.Include[obj, CDRects.CreateRect[cover, layer2]];
RTBasic.RepositionCell[obj]}};
LineToRect: PUBLIC PROC [pos1, pos2: DABasics.Position, width: DABasics.Number] RETURNS [position: CD.Position, size: CD.Position] = {
convert a line and a width to a rectangle and an orgin
SELECT TRUE FROM
pos1.x = pos2.x => { -- line is vertical
size ← [width, ABS[pos1.y - pos2.y]];
position ← [pos1.x - width/2, MIN[pos1.y, pos2.y]]};
pos1.y = pos2.y => { -- line is horizontal
size ← [ABS[pos1.x - pos2.x], width];
position ← [MIN[pos1.x, pos2.x], pos1.y - width/2]};
ENDCASE => Route.Error[programmingError, "Diagional lines not allowed."]};
END.