SCNetUtilImpl.mesa
Copyright Ó 1986, 1987 by Xerox Corporation. All rights reserved.
Frank Bowers January 27, 1986 4:15:38 pm PST
Preas September 29, 1987 3:59:15 pm PDT
Cong, August 20, 1987 5:47:10 pm PDT
DIRECTORY
Core, Rope, Route, RTSets, SC, SCInstUtil, SCNetUtil, SCPrivate, SCRowUtil;
SCNetUtilImpl:
CEDAR
PROGRAM
IMPORTS SCInstUtil, SCNetUtil, SCRowUtil
EXPORTS SCNetUtil
SHARES SC =
BEGIN
find nets attached to component
NetsOnInst:
PUBLIC
PROCEDURE[insts: SCPrivate.InstanceList]
RETURNS [nets: SCPrivate.NetList ←
NIL] =
BEGIN
PinProc: SCInstUtil.EachPinProc = {
IF netPin.net #
NIL
THEN {
net: SCPrivate.Net ← NIL;
FOR netList: SCPrivate.NetList ← nets, netList.rest
WHILE netList #
NIL
AND net #
NIL
DO
IF netList.first = netPin.net THEN net ← netList.first;
ENDLOOP;
IF net # NIL THEN nets ← CONS[net, nets]}};
FOR instList: SCPrivate.InstanceList ← insts, instList.rest
WHILE instList #
NIL
DO
inst: SCPrivate.Instance ← instList.first;
[] ← SCInstUtil.EnumeratePinsOnInst[inst, PinProc];
ENDLOOP;
END;
determine components on net
InstsOnNets:
PUBLIC
PROCEDURE[nets: SCPrivate.NetList]
RETURNS [insts: SCPrivate.InstanceList ←
NIL] = {
InstProc: SCNetUtil.EachInstProc = {
IF instance #
NIL
THEN insts ←
CONS[instance, insts]};
[] ← SCNetUtil.EnumerateInstsOnNets[nets, InstProc]};
determine components on net
EnumerateInstsOnNets:
PUBLIC
PROCEDURE[nets: SCPrivate.NetList, eachInst: SCNetUtil.EachInstProc]
RETURNS [quit:
BOOL ←
FALSE] = {
PinProc: SCNetUtil.EachPinProc = {
instance: SCPrivate.Instance ← netPin.instance;
IF instance #
NIL
THEN {
found: BOOLEAN ← FALSE;
FOR instanceList: SCPrivate.InstanceList ← insts, instanceList.rest
WHILE instanceList #
NIL
AND ~found
DO
IF instanceList.first = instance THEN found ← TRUE;
ENDLOOP;
IF ~found
THEN
{insts ← CONS[instance, insts]; quit ← eachInst[instance]}}};
insts: SCPrivate.InstanceList ← NIL;
FOR netList: SCPrivate.NetList ← nets, netList.rest
WHILE netList #
NIL
AND ~quit
DO
[] ← SCNetUtil.EnumeratePinsOnNet[netList.first, PinProc];
ENDLOOP;
};
EnumerateNets:
PUBLIC
PROC [handle:
SC.Handle, eachNet: SCNetUtil.EachNetProc]
RETURNS [quit:
BOOL ←
FALSE] = {
structureData: SCPrivate.StructureData ← NARROW[handle.structureData];
nets: SCPrivate.Nets ← structureData.nets;
FOR n:
NAT
IN [1 .. nets.count]
WHILE ~quit
DO
IF nets.nets[n].pins.size > 0 THEN quit ← eachNet[n, nets.nets[n]];
ENDLOOP;
};
EnumeratePinsOnNet:
PUBLIC
PROC [net: SCPrivate.Net, eachPin: SCNetUtil.EachPinProc]
RETURNS [quit:
BOOL ←
FALSE] = {
FOR index:
NAT
IN [0 .. net.pins.size)
WHILE ~quit
DO
quit ← eachPin[net.pins.np[index]];
ENDLOOP};
AddConnection:
PUBLIC
PROCEDURE [handle:
SC.Handle, net: SCPrivate.Net, instance: SCPrivate.Instance, pin: SCPrivate.ObjectPin, pinIndex:
NAT, pinClass: SCPrivate.PinType] = {
netPin: SCPrivate.NetPin ← NEW[SCPrivate.NetPinRec ← [pinClass: pinClass, instance: instance, pin: pin]];
pins: SCPrivate.NetPinSeq ← NEW[SCPrivate.NetPinSeqRec[net.pins.size+1]];
FOR index:
NAT
IN [0 .. net.pins.size)
DO
pins[index] ← net.pins.np[index]
ENDLOOP;
pins[pins.size-1] ← netPin;
instance.pinNets.n[pinIndex] ← NEW[SCPrivate.PinNetRec ← [pin: pin, pinInChan: NIL, net: net]];
net.pins ← pins};
RemoveConnections:
PUBLIC
PROCEDURE [handle:
SC.Handle, instance: SCPrivate.Instance] = {
pinNets: SCPrivate.PinNets ← instance.pinNets;
FOR index:
NAT
IN [0 .. pinNets.size-1]
DO
pinNets.n[index] ← NIL;
ENDLOOP};
DefineNet:
PUBLIC
PROCEDURE [handle:
SC.Handle, name: Rope.
ROPE]
RETURNS [net: SCPrivate.Net ← NIL] = {
define a net
structureData: SCPrivate.StructureData ← NARROW[handle.structureData];
rules: Route.DesignRules ← handle.rules.rowRules;
nets: SCPrivate.Nets ← structureData.nets;
nets.count ← nets.count + 1;
net ← NEW[SCPrivate.NetRec ← [name: name, publicWire: NIL, num: nets.count, trunkWidth: rules.trunkWidth, branchWidth: rules.branchWidth, routeTopology: ALL[[none, none]], pins: NEW[SCPrivate.NetPinSeqRec[0]]]];
net.num ← nets.count;
nets.nets[nets.count] ← net;
net.ftsOnRow ← RTSets.RTLgSetEmpty;
net.chanExits[left] ← net.chanExits[right] ← RTSets.RTLgSetEmpty};
remove the fts on a net list
RemoveFtsOnNet:
PUBLIC
PROCEDURE[handle:
SC.Handle, net: SCPrivate.Net] = {
EachPin: SCNetUtil.EachPinProc = {
IF netPin.pinClass # ftPin THEN pins[countNew] ← netPin;
countNew ← countNew + 1};
CountPins: SCNetUtil.EachPinProc = {
IF netPin.pinClass # ftPin THEN countOld ← countOld + 1};
countOld, countNew: NAT ← 0;
pins: SCPrivate.NetPinSeq;
[] ← SCNetUtil.EnumeratePinsOnNet[net, CountPins];
pins ← NEW[SCPrivate.NetPinSeqRec[countOld]];
[] ← SCNetUtil.EnumeratePinsOnNet[net, EachPin];
net.pins ← pins};
ExitOnSide:
PUBLIC
PROC [handle:
SC.Handle, net: SCPrivate.Net, side:
SC.Side]
RETURNS [onThisSide:
BOOLEAN] ~ {
EachInstance: SCRowUtil.EachInstProc ~ {
CheckPin: SCInstUtil.EachPinProc = {
[instance: SCPrivate.Instance, pin: NAT, netPin: SCPrivate.PinNet]
IF netPin.net = net THEN quit ← TRUE};
quit ← SCInstUtil.EnumeratePinsOnInst[instance, CheckPin]};
onThisSide ← SCRowUtil.EnumerateAllInstsOnSide[handle, side, EachInstance]};
END.