SCNewRouteImpl.mesa: Implements of SC.DetailedRoute
Copyright © 1986, 1987 by Xerox Corporation. All rights reserved.
Frank Bowers June 3, 1986 10:58:48 am PDT
Last Edited by: Bryan Preas August 12, 1987 4:08:01 pm PDT
DIRECTORY
CD, CDCells, CDOps, CDProperties, Convert, Core, CoreGeometry, CoreOps, CoreRoute, DABasics, Rope, Route, RouteUtil, RoutePrivate, RTBasic, SC, SCChanUtil, SCInstUtil, SCNetUtil, SCPrivate, SCNewRoutePinsUtil, SCRowUtil, SCUtil, Sinix, SinixOps;
SCNewRouteImpl: CEDAR PROGRAM
IMPORTS CDCells, CDOps, CDProperties, Convert, CoreGeometry, CoreOps, CoreRoute, Rope, Route, RouteUtil, RTBasic, SC, SCChanUtil, SCInstUtil, SCNetUtil, SCNewRoutePinsUtil, SCRowUtil, SCUtil, SinixOps
EXPORTS SCPrivate
SHARES SC = BEGIN
Local Types
SegInChan: TYPE = REF SegInChanRec;
SegInChanRec: TYPE = RECORD [
segNum: INT ← 0,
netNum: SCPrivate.ZMaxNetsSr ← 0,
leftExit, rightExit: BOOL ← FALSE,
pinsInSeg: PinsInSeg ← NIL];
PinsInSeg: TYPE = LIST OF RoutePrivate.Pin;
Detail Route Operation
DetailRoute: PUBLIC PROC [handle: SC.Handle] RETURNS [result: SC.Result] = {
lgRows: SCPrivate.LgRows ← NARROW[handle.layoutData, SCPrivate.LayoutData].lgRows;
SCInstUtil.AllOffsets[handle];
[lgRows.maxRowWidth, lgRows.numMaxRows] ← SCRowUtil.FindMaxRow[handle];
ConstructRows[handle];
result ← NEW[SC.ResultRec ← [handle: handle, object: RouteChannels[handle]]];
SCInstUtil.AsgnChanPos[handle];
[] ← SCUtil.WriteResults["End detailed routing\n", handle, 0]};
Construct The Rows
ConstructRows: PROC [handle: SC.Handle] = {
ForEachRow: SCRowUtil.EachRowProc = {
[row: SCPrivate.MaxRowSr, lgRow: SCPrivate.LgRow] RETURNS [quit: BOOLFALSE]
lgRow.cdOb ← ConstructRow[handle, lgRow]};
[] ← SCRowUtil.EnumerateRows[handle: handle, eachRow: ForEachRow]};
ConstructRow: PROC [handle: SC.Handle, lgRow: SCPrivate.LgRow] RETURNS [row: CD.Object ← CDCells.CreateEmptyCell[]] ~ {
LeftEnumerateSegments: PROC [eachSegment: PROC [CoreRoute.Segment]] ~ {
enumerate public wires for left side of row
EachWirePin: CoreGeometry.EachWirePinProc = {
PROC [wire: Wire, min, max: INT, side: Side, layer: CD.Layer] RETURNS [quit: BOOL ← FALSE];
IF side=left THEN eachSegment[[label: CoreOps.GetShortWireName[wire], min: min, max: max, layer: layer]]};
[] ← CoreGeometry.EnumerateWireSides[mode.decoration, lgRow.lgsOnRow[1].object.cellType, EachWirePin]};
RightEnumerateSegments: PROC [eachSegment: PROC [CoreRoute.Segment]] ~ {
enumerate public wires for right side of row
EachWirePin: CoreGeometry.EachWirePinProc = {
PROC [wire: Wire, min, max: INT, side: Side, layer: CD.Layer] RETURNS [quit: BOOL ← FALSE];
IF side=right THEN eachSegment[[label: CoreOps.GetShortWireName[wire], min: min, max: max, layer: layer]]};
[] ← CoreGeometry.EnumerateWireSides[mode.decoration, lgRow.lgsOnRow[lgRow.nLgsOnRow].object.cellType, EachWirePin]};
ForEachInstance: SCRowUtil.EachInstProc = {
[pos: NAT, instance: SCPrivate.Instance] RETURNS [quit: BOOLFALSE]
object: CD.Object ← instance.object.cdOb;
instOrientation: CD.Orientation ← SCInstUtil.CDOrien[instance];
instPosition: CD.Position ← CDOps.FitObjectI[ob: object, location: [offset, 0], orientation: instOrientation].off;
cdInst: CD.Instance ← RouteUtil.Include[cell: row, ob: object, position: instPosition, orientation: instOrientation];
CDProperties.PutInstanceProp[cdInst, $InstanceName, instance.name];
offset ← offset + RTBasic.IRSize[object].x};
mode: Sinix.Mode = SinixOps.GetExtractMode[handle.rules.rowParms.technology];
layoutData: SCPrivate.LayoutData ← NARROW[handle.layoutData];
maxRowWidth: CD.Number ← layoutData.lgRows.maxRowWidth;
rowLength: SC.Number ← lgRow.size.p;
rowOffset: SC.Number ← lgRow.rowOrg.p - layoutData.lgRows.horzRowOrg;
offset: SC.Number ← 0;
IF rowOffset > 0 THEN {
leftObject: CD.Object ← CoreRoute.ExtendObject[enumerateSegments: LeftEnumerateSegments, size: [rowOffset, lgRow.size.q], side: left, extendProc: CoreRoute.ExtendSegment];
[] ← RouteUtil.Include[cell: row, ob: leftObject, position: [offset, 0]];
offset ← offset + RTBasic.IRSize[leftObject].x};
[] ← SCRowUtil.EnumerateAllInstsOnRow[handle, lgRow.rowNum, ForEachInstance];
IF rowOffset + rowLength < maxRowWidth THEN {
rightObject: CD.Object ← CoreRoute.ExtendObject[enumerateSegments: RightEnumerateSegments, size: [maxRowWidth - (rowOffset + rowLength), lgRow.size.q], side: right, extendProc: CoreRoute.ExtendSegment];
[] ← RouteUtil.Include[cell: row, ob: rightObject, position: [offset, 0]];
offset ← offset + RTBasic.IRSize[rightObject].x};
RTBasic.RepositionCell[row]};
Route The Channels
RouteChannels: PROC [handle: SC.Handle] RETURNS [obj: CD.Object ← CDCells.CreateEmptyCell[]] ~ {
route the channels and include rows and channels into the layout
RouteChannel: PROC [enumerateNets: Route.EnumerateChannelNetsProc, rowChan: SCPrivate.RowChan] ~ {
route the specified channeland include in the object being constructed
BrokenNet: Route.BrokenNetProc ~ {
PROC [channelData, netData: REF, sourceNet: Label, regionNumber, numberOfRegions: NAT] RETURNS [newLabel: Label];
net: SCPrivate.Net ← NARROW[netData];
IF net.externNet = internalNet THEN newLabel ← NIL
ELSE {
net.numberOfRegions ← net.numberOfRegions + 1;
newLabel ← CoreRoute.LabelBrokenNet[net.name, net.numberOfRegions];
net.brokenNets ← CONS[newLabel, net.brokenNets]}};
channel: CD.Object ← Route.Channel[enumerateNets: enumerateNets, min: lgRows.horzRowOrg, max: lgRows.horzRowOrg + lgRows.maxRowWidth, rulesParameters: handle.rules.rowParms, name: Rope.Cat[handle.name, "Chan", Convert.RopeFromInt[rowChan.chanNum]], brokenNets: BrokenNet, channelData: handle].object;
[] ← RouteUtil.Include[cell: obj, ob: channel, position: [0, offset]];
offset ← offset + RTBasic.IRSize[channel].y;
rowChan.chanWidth ← RTBasic.IRSize[channel].y};
EachChannel: SCChanUtil.EachRowChanProc ~ {
[chan: SCPrivate.MaxChanSr, rowChan: SCPrivate.RowChan] RETURNS [quit: BOOLFALSE]
route the channel specified by rowChan
LowerChannel: Route.EnumerateChannelNetsProc ~ {
PROC [channelData: REF, eachNet: EachChannelNetProc];
LowerChannelNet: SCNetUtil.EachNetProc ~ {
PROC [netIndex: NAT, net: SCPrivate.Net] RETURNS [quit: BOOLFALSE];
FOR segList: LIST OF REF ANY ← net.segsInChan, segList.rest WHILE segList # NIL DO
segInChan: SegInChan ← NARROW[segList.first];
eachNet[name: net.name,
enumeratePins: LowerChannelPins,
exitLeftOrBottom: segInChan.leftExit,
exitRightOrTop: segInChan.rightExit,
trunkSize: net.trunkWidth,
netData: segInChan];
ENDLOOP};
[] ← SCNetUtil.EnumerateNets[handle, LowerChannelNet]};
LowerChannelPins: Route.EnumerateChannelPinsProc ~ {
PROC [channelData, netData: REF, eachPin: EachChannelPinProc];
segInChan: SegInChan ← NARROW[netData];
net: SCPrivate.Net ← NARROW[structureData.nets.nets[segInChan.netNum]];
FOR pins: PinsInSeg ← segInChan.pinsInSeg, pins.rest UNTIL pins = NIL DO
pin: RoutePrivate.Pin ← pins.first;
bottomOrLeftSide: BOOL ← pin.side = bottom;
xfer: BOOLEAN ← net.externNet = externalNet AND SCNetUtil.ExitOnSide[handle, net, bottom] AND pin.side = top;
eachPin[bottomOrLeftSide: bottomOrLeftSide, min: pin.min, max: pin.max, depth: pin.depth, layer: pin.layer];
IF xfer THEN eachPin[bottomOrLeftSide: ~bottomOrLeftSide, min: pin.min, max: pin.max, depth: pin.depth, layer: pin.layer];
ENDLOOP};
InteriorChannel: Route.EnumerateChannelNetsProc ~ {
PROC [name: Label, enumeratePins: EnumerateChannelPinsProc, exitLeftOrBottom, exitRightOrTop: BOOLFALSE, mayExit: BOOLTRUE, trunkSize: CD.Number ← 0, channelData, netData: REFNIL];
InteriorChannelNet: SCNetUtil.EachNetProc ~ {
PROC [netIndex: NAT, net: SCPrivate.Net] RETURNS [quit: BOOLFALSE];
FOR segList: LIST OF REF ANY ← net.segsInChan, segList.rest WHILE segList # NIL DO
segInChan: SegInChan ← NARROW[segList.first];
eachNet[name: Rope.Cat[net.name, "-", Convert.RopeFromInt[segInChan.segNum]],
enumeratePins: InteriorChannelPins,
exitLeftOrBottom: segInChan.leftExit,
exitRightOrTop: segInChan.rightExit,
trunkSize: net.trunkWidth,
netData: segInChan];
ENDLOOP};
[] ← SCNetUtil.EnumerateNets[handle, InteriorChannelNet]};
InteriorChannelPins: Route.EnumerateChannelPinsProc ~ {
PROC [channelData, netData: REF, eachPin: EachChannelPinProc];
segInChan: SegInChan ← NARROW[netData];
net: SCPrivate.Net ← structureData.nets.nets[segInChan.netNum];
FOR pins: PinsInSeg ← segInChan.pinsInSeg, pins.rest UNTIL pins = NIL DO
pin: RoutePrivate.Pin ← pins.first;
bottomOrLeftSide: BOOL ← pin.side = bottom;
eachPin[bottomOrLeftSide: bottomOrLeftSide, min: pin.min, max: pin.max, depth: pin.depth, layer: pin.layer];
ENDLOOP};
GetGlobalRouteForChannel[handle: handle, rowChan: rowChan];
IF chan # 1 THEN { -- include the specified row in the object being constructed
[] ← RouteUtil.Include[cell: obj, ob: lgRows.rows[chan-1].cdOb, position: [0, offset]];
offset ← offset + lgRows.rows[chan-1].size.q};
IF chan = 1 AND rowChans.count = 2 THEN {
do the bottom channel if it is the only one
RouteChannel[LowerChannel, rowChan]};
IF chan # rowChans.count AND chan # 1 THEN {
do the interior channels
RouteChannel[InteriorChannel, rowChan]}};
layoutData: SCPrivate.LayoutData ← NARROW[handle.layoutData];
structureData: SCPrivate.StructureData ← NARROW[handle.structureData];
rowChans: SCPrivate.RowChans ← layoutData.rowChans;
lgRows: SCPrivate.LgRows ← layoutData.lgRows;
offset: SC.Number ← 0;
[] ← SCChanUtil.EnumerateRowChans[handle, EachChannel];
RTBasic.SetCDCellName[obj, handle.name];
RTBasic.RepositionCell[obj]};
GetGlobalRouteForChannel: PROC [handle: SC.Handle, rowChan: SCPrivate.RowChan] ~ {
collect the pins that are to be connected for this channel
InitNet: SCNetUtil.EachNetProc = {net.segsInChan ← NIL};
MakeNetSeg: SCNewRoutePinsUtil.SegProc = {
PROC [segNum: SC.Number, net: SCPrivate.Net];
seg: SegInChan ← NEW[SegInChanRec ← [segNum: segNum, netNum: net.num, leftExit: leftExit, rightExit: rightExit, pinsInSeg: pinList]];
net.segsInChan ← CONS[seg, net.segsInChan];
pinList ← NIL; leftExit ← rightExit ← FALSE};
MakeNetPin: SCNewRoutePinsUtil.PinProc = {
PROC [min, max, depth: SC.Number, side: SC.Side, layer: SC.Layer, net: SCPrivate.Net];
pin: RoutePrivate.Pin ← NEW[RoutePrivate.PinRec ← [min: min, max: max, depth: depth, layer: layer, side: side]];
pinList ← CONS[pin, pinList]};
MakeNetExit: SCNewRoutePinsUtil.ExitProc = {
PROC [side: SCPrivate.LRSide, layer: SC.Layer, net: SCPrivate.Net];
IF side = left THEN leftExit ← TRUE
ELSE IF side = right THEN rightExit ← TRUE
ELSE SC.Error[programmingError, "Not suppose to happen."]};
pinList: PinsInSeg ← NIL;
leftExit, rightExit: BOOLFALSE;
[] ← SCNetUtil.EnumerateNets[handle, InitNet];
SCNewRoutePinsUtil.GetAllNetSegInChan[handle, rowChan, MakeNetSeg, MakeNetPin, MakeNetExit]};
END.