RTStructure.mesa
Copyright (C) 1986 by Xerox Corporation. All rights reserved.
Created by Bryan Preas, August 21, 1986 6:23:51 pm PDT
DIRECTORY
CD, Core, CoreFlat, CoreGeometry, HashTable, Properties, PWPins, Rope, RTBasic, RTCoreUtil;
RTStructure: CEDAR DEFINITIONS
IMPORTS RTCoreUtil, HashTable =
BEGIN
Theory
This interface provides a simple way to describe the structure in a cell to be laid out. This includes the interconnections (public and private), the instances and their objects, Facilities are providesd to create this structure from a Core cellType as well as a collection of ChipNDale objects with pins ( binding by name in this case).
This is intended to be used as an interface to the routers as well as their internal data structure.
Errors
Error: ERROR [errorType: ErrorType ← callingError, explanation: Rope.ROPENIL];
Signal: SIGNAL [signalType: ErrorType ← callingError, explanation: Rope.ROPENIL];
ErrorType: TYPE = {programmingError, callingError, noResource, designRuleViolation, other};
Types
Instances, Objects, Nets, InstancePins, ObjectPins, NetPins: TYPE = HashTable.Table; -- A HashTable for the instances, interconnections and the pins
Key: TYPE = REF;
Structure: TYPE = REF StructureRec;
StructureRec: TYPE = RECORD [
name: Rope.ROPENIL,
instances: Instances ← NIL,  -- invocations of objects within the cell being laid out
objects: Objects ← NIL,   -- objects within the cell being laid out
nets: Nets ← NIL,   -- public and private wires for the cell being laid out
outerInstance: Instance ← NIL,  -- instance representing next level of heirarchy (if any)
netWidth: NetWidthProc ← NIL,
properties: Properties.PropList ← NIL
];
NetWidthProc: TYPE = PROC[net: Net, structure: Structure, direction: RTBasic.Direction, context: REF ANYNIL] RETURNS [wireWidth: INT];
WidestPinProc: NetWidthProc;
net width is same as width of widest pin
Instance: TYPE = REF InstanceRec;
InstanceRec: TYPE = RECORD [
name: Rope.ROPENIL,   -- should be unique among the instances
placed: BOOLEANFALSE,  -- indicates if instance has been placed
position: CD.Position ← [0, 0],  -- current position of instance
orientation: CD.Orientation ← original,  -- current orientation
object: Object ← NIL,   -- the object definition
iPins: InstancePins ← NIL,  -- bindings for pins for this instance
properties: Properties.PropList ← NIL,
any: REF ANYNIL   -- for use by client
];
InstancePin: TYPE = REF InstancePinRec;  -- specifies binding of pin to net
InstancePinRec: TYPE = RECORD [
oPin: ObjectPin ← NIL,
net: Net ← NIL
];
HeirarchyLevel: TYPE = {this, nextHigher}; -- next higher indicates a public
Object: TYPE = REF ObjectRec;
ObjectRec: TYPE = RECORD [
name: Rope.ROPENIL,   -- should be unique among the objects
cdObject: CD.Object ← NIL,  -- the base object definition
heirarchyLevel: HeirarchyLevel ← this, -- level of this object
oPins: ObjectPins ← NIL,   -- bindings for pins for this instance
properties: Properties.PropList ← NIL,
any: REF ANYNIL   -- for use by client
];
ObjectPin: TYPE = REF ObjectPinRec;
ObjectPinRec: TYPE = RECORD [
name: Rope.ROPENIL,   -- optional name of connection
heirarchyLevel: HeirarchyLevel ← this, -- level of this object
physicalPins: LIST OF PhysicalPin ← NIL, -- physical connections for this logical pin
properties: Properties.PropList ← NIL
];
PhysicalPin: TYPE = REF PhysicalPinRec;
PhysicalPinRec: TYPE = RECORD [
range: Range ← [0, 0],   -- in interest coordinate system
side: RTBasic.SideOrNone ← none,  -- side toward which routing should connect
layer: CD.Layer ← CD.undefLayer,
depth: INT ← 0,   -- depth of pin into object, 0 if on edge
properties: Properties.PropList ← NIL
];
Range: TYPE = RECORD [
min, max: INT   -- range of pin along side
];
Net: TYPE = REF NetRec;
NetRec: TYPE = RECORD [
name: Rope.ROPENIL,   -- should be unique among the nets
nPins: NetPins ← NIL,   -- pins for this net
properties: Properties.PropList ← NIL,
any: REF ANYNIL   -- for use by client
];
NetPin: TYPE = REF NetPinRec;  -- binding to instance and pin on object
NetPinRec: TYPE = RECORD [
oPin: ObjectPin ← NIL,   -- pin on defining object
instance: Instance ← NIL   -- the owning instance
];
Building and Using The Structure Table
Creating The Structure Table
CreateForRopes: PROC [name: Rope.ROPENIL, nInsts, nObjs, nNets, nPubs: HashTable.SeqIndex ← 17, netWidth: NetWidthProc ← WidestPinProc, properties: Properties.PropList ← NIL] RETURNS [Structure];
CreateForRefs: PROC [name: Rope.ROPENIL, nInsts, nObjs, nNets, nPubs: HashTable.SeqIndex ← 17, netWidth: NetWidthProc ← WidestPinProc, properties: Properties.PropList ← NIL] RETURNS [Structure];
creates new table, whose length is mod. They do the right thing for Rope and Ref tables.
Instance Manipulation
FetchInstance: PROC [structure: Structure, key: Key] RETURNS [found: BOOLEAN, instance: Instance];
looks up key in table, returns associated instance (if any)
if found is TRUE, net is value associated with given key
if found is FALSE, instance is NIL
StoreInstance: PROC [structure: Structure, key: Key, instance: Instance] RETURNS [BOOLEAN] = INLINE{RETURN[HashTable.Store[structure.instances, key, instance]]};
returns TRUE after inserting new instance
returns FALSE after overwriting old instance for existing key-instance pair
FetchInstancePin: PROC [instance: Instance, key: Key] RETURNS [found: BOOLEAN, iPin: InstancePin];
looks up key in table, returns associated iPin (if any)
if found is TRUE, net is value associated with given key
if found is FALSE, iPin is NIL
StoreInstancePin: PROC [instance: Instance, key: Key, iPin: InstancePin] RETURNS [BOOLEAN] = INLINE{RETURN[HashTable.Store[instance.iPins, key, iPin]]};
returns TRUE after inserting new iPin
returns FALSE after overwriting old instancePin for existing key-instance pair
EnumerateInstances: PROC [structure: Structure, action: EachInstanceAction] RETURNS [quit: BOOLEAN];
enumerates objects currently in symbol table in unspecified order
instances inserted/deleted during enumeration may or may not be seen
applies action to each object until action returns TRUE or no more pairs
returns TRUE if some action returns TRUE
EachInstanceAction: TYPE = PROC [key: Key, instance: Instance] RETURNS [quit: BOOLEANFALSE];
EnumerateInstancePins: PROC [instance: Instance, action: EachInstancePinAction] RETURNS [quit: BOOLEAN];
enumerates pins on instance in unspecified order
pins inserted/deleted during enumeration may or may not be seen
applies action to each pin until action returns TRUE or no more pins
returns TRUE if some action returns TRUE
EachInstancePinAction: TYPE = PROC [key: Key, instance: Instance, iPin: InstancePin] RETURNS [quit: BOOLEANFALSE];
Object Manipulation
FetchObject: PROC [structure: Structure, key: Key] RETURNS [found: BOOLEAN, object: Object];
looks up key in table, returns associated object (if any)
if found is TRUE, net is value associated with given key
if found is FALSE, net is NIL
StoreObject: PROC [structure: Structure, key: Key, object: Object] RETURNS [BOOLEAN] = INLINE{RETURN[HashTable.Store[structure.objects, key, object]]};
returns TRUE after inserting new object
returns FALSE after overwriting old net for existing key-net pair
FetchObjectPin: PROC [object: Object, key: Key] RETURNS [found: BOOLEAN, oPin: ObjectPin];
looks up key in table, returns associated objectPin (if any)
if found is TRUE, net is value associated with given key
if found is FALSE, objectPin is NIL
StoreObjectPin: PROC [object: Object, key: Key, oPin: ObjectPin] RETURNS [BOOLEAN] = INLINE{RETURN[HashTable.Store[object.oPins, key, oPin]]};
returns TRUE after inserting new objectPin
returns FALSE after overwriting old objectPin for existing key-objectPin pair
StorePhysicalPin: PROC [oPin: ObjectPin, pPin: PhysicalPin] = INLINE{oPin.physicalPins ← CONS[pPin, oPin.physicalPins]};
add a new physical pin to a logical pin
EnumerateObjects: PROC [structure: Structure, action: EachObjectAction] RETURNS [quit: BOOLEAN];
enumerates objects currently in symbol table in unspecified order
instances inserted/deleted during enumeration may or may not be seen
applies action to each object until action returns TRUE or no more pairs
returns TRUE if some action returns TRUE
EachObjectAction: TYPE = PROC [key: Key, object: Object] RETURNS [quit: BOOLEANFALSE];
EnumerateObjectPins: PROC [object: Object, action: EachObjectPinAction] RETURNS [quit: BOOLEAN];
enumerates pins on object in unspecified order
pins inserted/deleted during enumeration may or may not be seen
applies action to each segment until action returns TRUE or no more object pins
returns TRUE if some action returns TRUE
EachObjectPinAction: TYPE = PROC [key: Key, object: Object, oPin: ObjectPin] RETURNS [quit: BOOLEANFALSE];
EnumeratePhysicalPins: PROC [oPin: ObjectPin, action: EachPhysicalPinAction] RETURNS [quit: BOOLEAN];
enumerates physical pins on ObjectPin in unspecified order
pins inserted/deleted during enumeration may or may not be seen
applies action to each segment until action returns TRUE or no more object pins
returns TRUE if some action returns TRUE
EachPhysicalPinAction: TYPE = PROC [oPin: ObjectPin, pPin: PhysicalPin] RETURNS [quit: BOOLEANFALSE];
PosOfObjectPin: PROC [object: Object, pPin: PhysicalPin] RETURNS [position: CD.Position];
returns position of object Pin wrt the object
Net Manipulation
FetchNet: PROC [structure: Structure, key: Key] RETURNS [found: BOOLEAN, net: Net];
looks up key in table, returns associated net (if any)
if found is TRUE, net is value associated with given key
if found is FALSE, net is NIL
StoreNet: PROC [structure: Structure, key: Key, net: Net] RETURNS [BOOLEAN] = INLINE{RETURN[HashTable.Store[structure.nets, key, net]]};
returns TRUE after inserting new pair
returns FALSE after overwriting old net for existing key-net pair
FetchNetPin: PROC [net: Net, key: Key] RETURNS [found: BOOLEAN, nPin: NetPin];
looks up key in table, returns associated netPin (if any)
if found is TRUE, net is value associated with given key
if found is FALSE, netPin is NIL
StoreNetPin: PROC [net: Net, key: Key, nPin: NetPin] RETURNS [BOOLEAN] = INLINE{RETURN[HashTable.Store[net.nPins, key, nPin]]};
returns TRUE after inserting new netPin
returns FALSE after overwriting old net for existing key-netPin pair
EnumerateNets: PROC [structure: Structure, action: EachNetAction] RETURNS [quit: BOOLEAN];
enumerates nets currently in symbol table in unspecified order
nets inserted/deleted during enumeration may or may not be seen
applies action to each net until action returns TRUE or no more nets
returns TRUE if some action returns TRUE
EachNetAction: TYPE = PROC [key: Key, net: Net] RETURNS [quit: BOOLEANFALSE];
EnumerateNetPins: PROC [net: Net, action: EachNetPinAction] RETURNS [quit: BOOLEAN];
enumerates pins on net in unspecified order
pins inserted/deleted during enumeration may or may not be seen
applies action to each pin until action returns TRUE or no more pins
returns TRUE if some action returns TRUE
EachNetPinAction: TYPE = PROC [key: Key, net: Net, nPin: NetPin] RETURNS [quit: BOOLEANFALSE];
IsPublic: PROC [net: Net] RETURNS [isPublic: BOOLEAN];
TRUE iff this tet has a connection to the next higher level
Utilities
CreateFromCore: PROC [cellType: Core.CellType, flattenCellType: RTCoreUtil.FlattenCellTypeProc ← RTCoreUtil.defaultFlatten, pinFilter: CorePinFilterProc ← NIL, interestingProperties: RTCoreUtil.PropertyKeys ← NIL, userData: REF ANYNIL, decoration: CoreGeometry.Decoration, libDesign: CD.Design ← NIL, properties: Properties.PropList ← NIL] RETURNS [structure: Structure];
derive the interconnection requirements from a Core data structure.
instances: Core cellInstance of flattened object
instancePins: Core public wires on associated object
objects: Core cellType
objectPins: Rope name of defining pins
nets: Core actual wires of flattened object
netPins: publicWire of flattened object
pinFilter = NIL => keep all pins on objects
CorePinFilterProc: TYPE = PROC [wire: Core.Wire, range: Range, side: RTBasic.Side, layer: CD.Layer, userData: REF ANY] RETURNS [keepIt: BOOLEANTRUE];
provides client an opportunity to disregard some pins. This is useful when extractor returns some extra publics.
InsertPublic: PROC [structure: Structure, name: Rope.ROPE, cdObject: CD.Object, pinFilter: CDPinFilterProc ← NIL, userData: REF ANYNIL, makeHashKey: HashKeyProc ← NIL];
construct an instance, an object and put the pins on the interest rec of the object in the structure if pinFilter returns true. makeHashKey can be used to transform the pin names to net names.
Ropes are use for keys; this means that CreateForRopes must be used to create the structure used by theis procedure. In addition, the obhect and pins must be named. pinFilter = NIL => keep all pins on object.
InsertInstance: PROC [structure: Structure, name: Rope.ROPE, position: CD.Position, orientation: CD.Orientation, cdObject: CD.Object, pinFilter: CDPinFilterProc ← NIL, userData: REF ANYNIL, makeHashKey: HashKeyProc ← NIL];
construct an instance, an object and put the pins on the interest rec of the object in the structure if pinFilter returns true. makeHashKey can be used to transform the pin names to net names.
Ropes are use for keys; this means that CreateForRopes must be used to create the structure used by theis procedure. In addition, the obhect and pins must be named. pinFilter = NIL => keep all pins on object.
CDPinFilterProc: TYPE = PROC [inst: CD.Instance, obj: CD.Object, userData: REF ANY] RETURNS [keepIt: BOOLEANTRUE];
provides client an opportunity to disregard some pins.
HashKeyProc: TYPE = PROC [instance: CD.Instance] RETURNS [key: Rope.ROPE];
PrintStructure: PUBLIC PROC [structure: Structure];
print the given structure
CoordsAlongSide: PROC [instance: CD.Instance, object: CD.Object, side: RTBasic.Side] RETURNS [range: Range];
TranslateRange: PROC [instance: Instance, pPin: PhysicalPin] RETURNS [range: Range];
FromSideToSide: PROC [side: PWPins.Side] RETURNS [routeSide: RTBasic.Side];
END.