-- File: DJExtAlloc.mesa -- Allocation routines for the disjoint circuit extractor -- Written by Martin Newell/Dan Fitzpatrick June 1981 -- Last edited: August 27, 1981 5:50 PM DIRECTORY DisjointAllocDefs: FROM "DisjointAllocDefs" USING [Alloc, Free, EnumerateSymbols], DisjointPropDefs: FROM "DisjointPropDefs" USING [GetLongProp], DisjointTypes: FROM "DisjointTypes" USING [Symbol], DJExtDefs: FROM "DJExtDefs", DJExtractDefs: FROM "DJExtractDefs" USING [GetSegmentID, GetParamID, GetNodeLocID, GetExtCapID, GetIntCapID, GetExtTransID, GetIntTransID], DJExtAllocDefs: FROM "DJExtAllocDefs", DJExtUtilsDefs: FROM "DJExtUtilsDefs" USING [WriteLongDecimal], DJExtTypes: FROM "DJExtTypes" USING [Edge, EdgeRecord, Segment, SegmentRecord, Box, BoxRecord, NodeNumber, Position, Side, SideRecord, NodeLocation, NodeLocationRecord, NodeSegment, NodeSegmentRecord, ActualParameter, ActualParameterRecord, Node, NodeRecord, Diffusion, DiffusionRecord], IODefs: FROM "IODefs" USING [WriteString, WriteLine]; DJExtAlloc: PROGRAM IMPORTS DisjointAllocDefs, DisjointPropDefs, DJExtractDefs, DJExtUtilsDefs, IODefs EXPORTS DJExtDefs, DJExtAllocDefs = BEGIN OPEN DisjointAllocDefs, DisjointPropDefs, DisjointTypes, DJExtractDefs, DJExtUtilsDefs, DJExtTypes, IODefs; MakeHEdge: PUBLIC PROCEDURE [h, left, right: REAL] RETURNS[e:Edge] = BEGIN e _ AllocateEdge[]; e.by _ e.ty _ h; e.bx _ left; e.tx _ right; e.segment _ NIL; e.count _ 0; END; MakeVEdge: PUBLIC PROCEDURE [v, bottom, top: REAL] RETURNS[e:Edge] = BEGIN e _ AllocateEdge[]; e.bx _ e.tx _ v; e.by _ bottom; e.ty _ top; e.segment _ NIL; e.count _ 0; END; AllocateEdge: PUBLIC PROCEDURE RETURNS[e:Edge] = BEGIN AllocatedEdges _ AllocatedEdges + 1; e _ Alloc[SIZE[EdgeRecord]]; END; FreeEdge: PUBLIC PROCEDURE[e:Edge] = BEGIN Free[e,SIZE[EdgeRecord]]; AllocatedEdges _ AllocatedEdges - 1; END; AllocateSegment: PUBLIC PROCEDURE RETURNS[e:Segment] = BEGIN AllocatedSegments _ AllocatedSegments + 1; e _ Alloc[SIZE[SegmentRecord]]; END; FreeSegment: PUBLIC PROCEDURE[e:Segment] = BEGIN Free[e,SIZE[SegmentRecord]]; AllocatedSegments _ AllocatedSegments - 1; END; AllocateBox: PUBLIC PROCEDURE RETURNS[e:Box] = BEGIN AllocatedBoxes _ AllocatedBoxes + 1; e _ Alloc[SIZE[BoxRecord]]; END; FreeBox: PUBLIC PROCEDURE[e:Box] = BEGIN Free[e,SIZE[BoxRecord]]; AllocatedBoxes _ AllocatedBoxes - 1; END; MakeSide: PUBLIC PROCEDURE [x, bottom, top: REAL, node: NodeNumber, pos:Position, layer:INTEGER] RETURNS[s:Side] = BEGIN s _ AllocateSide[]; s^ _ [ next: NIL, layer: layer, node: node, pos: pos, x: x, b: bottom, t: top ]; END; AllocateSide: PUBLIC PROCEDURE RETURNS[s:Side] = BEGIN AllocatedSides _ AllocatedSides + 1; s _ Alloc[SIZE[SideRecord]]; END; FreeSide: PUBLIC PROCEDURE[s:Side] = BEGIN Free[s,SIZE[SideRecord]]; AllocatedSides _ AllocatedSides - 1; END; AllocateNodeSegment: PUBLIC PROCEDURE RETURNS[e:NodeSegment] = BEGIN AllocatedNodeSegments _ AllocatedNodeSegments + 1; e _ Alloc[SIZE[NodeSegmentRecord]]; END; FreeNodeSegment: PUBLIC PROCEDURE[e:NodeSegment] = BEGIN Free[e,SIZE[NodeSegmentRecord]]; AllocatedNodeSegments _ AllocatedNodeSegments - 1; END; AllocateActualParameter: PUBLIC PROCEDURE RETURNS[e:ActualParameter] = BEGIN AllocatedActualParameters _ AllocatedActualParameters + 1; e _ Alloc[SIZE[ActualParameterRecord]]; END; FreeActualParameter: PUBLIC PROCEDURE[e:ActualParameter] = BEGIN Free[e,SIZE[ActualParameterRecord]]; AllocatedActualParameters _ AllocatedActualParameters - 1; END; MakeNodeLocation: PUBLIC PROCEDURE[node:NodeNumber, x,y:REAL] RETURNS[e:NodeLocation] = BEGIN e _ AllocateNodeLocation[]; e^ _ [ next: NIL, node: node, x: x, y: y ]; END; AllocateNodeLocation: PUBLIC PROCEDURE RETURNS[e:NodeLocation] = BEGIN AllocatedNodeLocations _ AllocatedNodeLocations + 1; e _ Alloc[SIZE[NodeLocationRecord]]; END; FreeNodeLocation: PUBLIC PROCEDURE[e:NodeLocation] = BEGIN Free[e,SIZE[NodeLocationRecord]]; AllocatedNodeLocations _ AllocatedNodeLocations - 1; END; AllocateCap: PUBLIC PROCEDURE RETURNS[e:Node] = BEGIN AllocatedCapacitors _ AllocatedCapacitors + 1; e _ Alloc[SIZE[cap NodeRecord]]; END; FreeCap: PUBLIC PROCEDURE[e:Node] = BEGIN Free[e,SIZE[cap NodeRecord]]; AllocatedCapacitors _ AllocatedCapacitors - 1; END; AllocateTransistor: PUBLIC PROCEDURE RETURNS[e:Node] = BEGIN AllocatedTransistors _ AllocatedTransistors + 1; e _ Alloc[SIZE[trans NodeRecord]]; END; FreeTransistor: PUBLIC PROCEDURE[e:Node] = BEGIN Free[e,SIZE[trans NodeRecord]]; AllocatedTransistors _ AllocatedTransistors - 1; END; AllocateDiffusion: PUBLIC PROCEDURE RETURNS[e:Diffusion] = BEGIN AllocatedDiffusions _ AllocatedDiffusions + 1; e _ Alloc[SIZE[DiffusionRecord]]; END; FreeDiffusion: PUBLIC PROCEDURE[e:Diffusion] = BEGIN Free[e,SIZE[DiffusionRecord]]; AllocatedDiffusions _ AllocatedDiffusions - 1; END; PrintExtAlloc: PUBLIC PROCEDURE = BEGIN Print: PROC [str:STRING, alloc,used:LONG INTEGER] = BEGIN WriteString[""]; WriteString[str]; WriteString[": "]; WriteLongDecimal[alloc]; WriteString[" allocated, "]; WriteLongDecimal[used]; WriteLine[" used"]; END; Check[]; Print["Edges",AllocatedEdges,0]; Print["Segments",AllocatedSegments,uSeg]; Print["Sides",AllocatedSides,0]; Print["Boxes",AllocatedBoxes,0]; Print["NodeSegments",AllocatedNodeSegments,0]; Print["ActualParameters",AllocatedActualParameters,uParam]; Print["NodeLocations",AllocatedNodeLocations,uLoc]; Print["Capacitors",AllocatedCapacitors,uCap]; Print["Transistors",AllocatedTransistors,uTrans]; Print["Diffusions",AllocatedDiffusions,uDiff]; END; Check: PROCEDURE = BEGIN Count: PROC[s: Symbol] RETURNS [BOOLEAN] = BEGIN nSymbols _ nSymbols + 1; FOR i: Segment _ GetLongProp[s.prop,GetSegmentID[]],i.next UNTIL i = NIL DO uSeg _ uSeg + 1; ENDLOOP; FOR i: ActualParameter _ GetLongProp[s.prop,GetParamID[]],i.next UNTIL i = NIL DO uParam _ uParam + 1; ENDLOOP; FOR i: NodeLocation _ GetLongProp[s.prop,GetNodeLocID[]],i.next UNTIL i = NIL DO uLoc _ uLoc + 1; ENDLOOP; FOR i: Node _ GetLongProp[s.prop,GetExtCapID[]],i.next UNTIL i = NIL DO uCap _ uCap + 1; ENDLOOP; FOR i: Node _ GetLongProp[s.prop,GetIntCapID[]],i.next UNTIL i = NIL DO uCap _ uCap + 1; ENDLOOP; FOR i: Node _ GetLongProp[s.prop,GetExtTransID[]],i.next UNTIL i = NIL DO uTrans _ uTrans + 1; FOR d: Diffusion _ i.diff,d.next UNTIL d = NIL DO uDiff _ uDiff + 1; ENDLOOP; ENDLOOP; FOR i: Node _ GetLongProp[s.prop,GetIntTransID[]],i.next UNTIL i = NIL DO uTrans _ uTrans + 1; FOR d: Diffusion _ i.diff,d.next UNTIL d = NIL DO uDiff _ uDiff + 1; ENDLOOP; ENDLOOP; RETURN[FALSE]; END; uSeg _ 0; uParam _ 0; uLoc _ 0; uCap _ 0; uTrans _ 0; uDiff _ 0; nSymbols _ 0; [] _ EnumerateSymbols[Count]; WriteLongDecimal[nSymbols]; WriteLine[""]; END; nSymbols:LONG INTEGER; uSeg:LONG INTEGER; uParam:LONG INTEGER; uLoc:LONG INTEGER; uCap:LONG INTEGER; uTrans:LONG INTEGER; uDiff:LONG INTEGER; AllocatedEdges: LONG INTEGER _ 0; AllocatedSegments: LONG INTEGER _ 0; AllocatedBoxes: LONG INTEGER _ 0; AllocatedSides: LONG INTEGER _ 0; AllocatedNodeSegments: LONG INTEGER _ 0; AllocatedActualParameters: LONG INTEGER _ 0; AllocatedNodeLocations: LONG INTEGER _ 0; AllocatedCapacitors: LONG INTEGER _ 0; AllocatedTransistors: LONG INTEGER _ 0; AllocatedDiffusions: LONG INTEGER _ 0; END. (672)\178b10B816b10B243b10B173b9B173b12B118b8B107b15B130b11B119b11B116b7B105b8B243b12B118b8B107b19B146b15B135b23B162b19B151b16B174b20B150b16B139b11B132b7B121b18B136b14B125b17B138b13B127b13B723b5B22b5B