<<--File: IPToolBox.mesa>> <> <<>> <<--Intro: Contains a lot of the highly commonly used procedures>> DIRECTORY IO, Misc, Rope, CD, CDOrient, D2Basic, IP; IPToolBox: CEDAR DEFINITIONS IMPORTS CDOrient = BEGIN PhysicalPins: TYPE = LIST OF REF IP.PhysicalPinRep; IntVector: TYPE = IP.IntVector; IPPinsFromCDPins: PROC[cdObj: CD.Object] RETURNS [LIST OF REF IP.PinRep]; <<--Calls IPPinFromCDPin repeatedly.>> <<--Note: order of pins will be reveresed>> -- IPPinFromCDPin: PROC[cdPin: REF CDPins.Pin] RETURNS [REF IP.PinRep]; <<--Note: Order of physicalPins will be reversed>> MakeIPPins: PROC[ipPins: LIST OF REF IP.PinRep, origin: IntVector _ [0, 0], coShape: REF IP.ShapeRep _ NIL, cutOff: NAT _ 0] RETURNS [LIST OF REF IP.PinRep]; <<--Basically deep copy ipPins with coordinates of copy recomputed wrt >> <<-- origin, if coShape # NIL. Side of all physical pins in iPins >> <<-- will be assigned to the nearest side of the component when >> <<-- distance of pin from side is less then cutOff, else it will be an interior pin. >> <<-- If coShape = NIL then coordinates of (physical) pins is meaningless >> <<--Shape manipulation routines>> NearestSide: PROC [shape: REF IP.ShapeRep, point: IntVector, cutOff: NAT _ 0] RETURNS [inShape: BOOL, side: IP.PinSideType]; <<-- Compute the side closest to point. If (distance of point from closest side) > cutOff >> <<-- then side = interior (even though point may actually lie outside shape.) >> <<-- inShape = TRUE iff coord actually lies on the boundary or within shape>> DistFromSide: PROC[shape: REF IP.ShapeRep, point: IntVector, side: IP.PinSideType] RETURNS [INT]; <<-- returns perpendicular distance of point from side>> <<-- returns LAST[INT] for pathological/meaningless cases.>> GetCorner: PROC [shape: IP.ShapeRep, corner: IP.CornerTypes] RETURNS [REF IP.NatVector]; GetBRect: PROC[shape: REF IP.ShapeRep, origin: IntVector _ [0, 0]] RETURNS [Misc.Rect]; GetCornerRect: PROC[shape: REF IP.ShapeRep, corner: IP.CornerTypes, origin: IntVector _ [0, 0], crop: INT _ 1] RETURNS [Misc.Rect]; GetCornerRects: PROC[shape: REF IP.ShapeRep, origin: IntVector _ [0, 0], crop: INT _ 1] RETURNS [sw, se, ne, nw: Misc.Rect]; CopyShape: PROC[oShape: REF IP.ShapeRep, orient: IP.Orientation] RETURNS [nShape: REF IP.ShapeRep]; <<--doesn't modify oShape. nShape and oShape shares all REF IP.NatVector>> <<-- For examples, see IPCoTabImpl>> <<--Copy oShape and apply OrientShape>> OrientShape: PROC[shape: REF IP.ShapeRep, orient: IP.Orientation]; <<--modifies shape>> MirrorXShape: PROC[shape: REF IP.ShapeRep]; Rotate90Shape: PROC [shape: REF IP.ShapeRep, numberOfRot: INT _ 1]; <<--Some primitives for reading data from stream>> ParseError: ERROR [reason: ATOM, at: REF]; GetIdRope: PROC[stream: IO.STREAM] RETURNS [Rope.ROPE]; <<--read : from stream into "Id">> <<-- ! Raise ParseError[$syntaxError, char];>> GetIdAtom: PROC[stream: IO.STREAM] RETURNS [ATOM]; <<--read : from stream into $Id>> <<-- ! Raise ParseError[$syntaxError, char];>> <<>> EnterBlock: PROC [stream: IO.STREAM]; <<--Remove { from stream. If char read is not '{ then>> <<--! Raise ParseError[$noBegn, char];>> ExitBlock: PROC [stream: IO.STREAM] RETURNS [BOOL _ TRUE]; <<-- Return TRUE iff first non-blank char = }>> RemoveBlock: PROC [stream: IO.STREAM]; <<--Remove { } from stream>> GetNatVector: PROC[stream: IO.STREAM] RETURNS [REF IP.NatVector]; <<--Read ( , ) >> GetIntVector: PROC[stream: IO.STREAM] RETURNS [REF IntVector]; <<--Read ( , ) >> GetShape: PROC[stream: IO.STREAM] RETURNS [REF IP.ShapeRep]; <<--Read {( ) sw: () ...: (, ) }>> <<-- where xy IN {sw, se, ne, nw} and xx, yy are NAT's>> <<--! Raise ParseError[$badToken, $];>> GetPhysicalPins: PROC[stream: IO.STREAM] RETURNS [PhysicalPins]; <<>> <<--Some high level stream output routines:>> <<>> PutShape: PROC[stream: IO.STREAM, shape: REF IP.ShapeRep]; <<--inverse of GetShape>> <<>> PutPhysicalPins: PROC[stream: IO.STREAM, physicalPins: PhysicalPins]; <<-- inverse of GetPhysicalPins>> <<>> <<--Physical pins manipulation procedures>> OrientPhysicalPins: PROC [phyPins: PhysicalPins, cellDim: IP.NatVector, cellOrient: IP.Orientation, cellOrigin: IntVector _ [0, 0]]; MirrorXPhysicalPins: PROC [phyPins: PhysicalPins, cellDim: IP.NatVector, cellOrigin: IntVector _ [0, 0]]; Rotate90PhysicalPins: PROC [phyPins: PhysicalPins, cellDim: IP.NatVector, numberOfRot: INT _ 1, cellOrigin: IntVector _ [0, 0]]; OrientPinSide: PROC[side: IP.PinSideType, orient: IP.Orientation] RETURNS [IP.PinSideType]; MirrorXPinSide: PROC[side: IP.PinSideType] RETURNS [IP.PinSideType]; Rotate90PinSide: PROC [side: IP.PinSideType, numberOfRot: INT _ 1] RETURNS [IP.PinSideType]; <<--Some commonly used operation on Component>> CoChannels: PROC[co: REF IP.ComponentRep, action: PROC[REF IP.ChannelRep] RETURNS [quit: BOOL]]; <<--enumerate channels in co in the following order:>> <<-- (i) prinChannels: south, east, north, west, followed by>> <<-- (2) cornerChannels: sw.hor, sw.ver, se.hor, ...., nw.hor, hw.ver>> GetCoDim: PROC[co: REF IP.ComponentRep] RETURNS[x, y: NAT] = INLINE { IF CDOrient.IncludesOddRot90[co.orient] THEN [y, x] _ co.shape.dim^ ELSE [x, y] _ co.shape.dim^; }; --GetCoDim GetCoOrigin: PROC[co: REF IP.ComponentRep] RETURNS[IntVector] = INLINE {RETURN[co.origin]}; ConstructFileName: PROC[defaultDir, inputFile, defaultExt: Rope.ROPE] RETURNS[fullName: Rope.ROPE]; END.