<> <> <> <> <> DIRECTORY CD USING [Design, Position, Rect], CDInstances USING [InstRectO], CDOrient USING [CreateTransform], CDProperties USING [GetProp], Convert USING [RopeFromRope], Core USING [CellType, CellTypeRec, Design, Properties, StructureError, Wire], CoreOps USING [CreateAtomWire, CreateRecordWire, FetchCellType, InsertCellType], CoreProperties USING [GetProp, propCompare, PropCompareProc, propCopy, PropCopyProc, propPrint, PropPrintProc, PutProp, RegisterProperty, StoreProperties], CoreClasses USING [CellInstance, CellInstanceRec, RecordCellType, recordCellClass], ImagerTransformation USING [Copy, Equal, Transformation], IO USING [atom, int, PutF, rope, STREAM], Rope USING [Compare, Equal, ROPE], SX USING [AreaPerimRec, NodeLocation, SpinifexLayerIndex, TechHandle, TechInfo, TechRec], SXAtoms USING [cdCellHint, cdDesignHint, crystalAttr, instanceTransf, locInfo, spinifex, strayInfo, techInfo], SXAccess, SXOutputPrivate USING [GetAName, PrintActualProc, PrintFormalProc, PrintHeadProc, PrintInstanceEndProc, PrintInstanceHeadProc, PrintLocalNodeProc, PrintStartBodyProc, PrintStrayProc, QuoteProc] ; SXOutputImplC: CEDAR PROGRAM IMPORTS CDInstances, CDOrient, CDProperties, Convert, Core, CoreProperties, CoreOps, CoreClasses, ImagerTransformation, IO, Rope, SXAtoms, SXAccess, SXOutputPrivate EXPORTS SXOutputPrivate = BEGIN OPEN SXOutputPrivate; <> coreDesign: PUBLIC Core.Design; coreCellBuffer: PUBLIC Core.CellType; coreCellInstance: PUBLIC CoreClasses.RecordCellType; coreInstanceBuffer: PUBLIC CoreClasses.CellInstance; corePortBuffer, coreNodeBuffer, corePortInstances: PUBLIC LIST OF Core.Wire _ NIL; strayBuffer: PUBLIC Core.Properties; QuoteCore: PUBLIC QuoteProc = <> BEGIN RETURN [Convert.RopeFromRope[from: name, quote: FALSE]] END; -- QuoteCore ComputeStray: PUBLIC PrintStrayProc = <> BEGIN stray: LIST OF SX.AreaPerimRec _ NIL; -- unordered ti: SX.TechInfo = NARROW [CoreProperties.GetProp [coreDesign.properties, SXAtoms.techInfo]]; strayBuffer _ NIL; FOR i: LIST OF SX.AreaPerimRec _ node.dim, i.rest WHILE i # NIL DO e: SX.AreaPerimRec; e.layer _ i.first.layer; e.area _ i.first.area/(SXAccess.design.technology.lambda*SXAccess.design.technology.lambda); e.perim _ i.first.perim/SXAccess.design.technology.lambda; <> <> <> stray _ CONS [e, stray] ENDLOOP; strayBuffer _ CoreProperties.PutProp [strayBuffer, SXAtoms.strayInfo, stray] <> END; -- ComputeStray InsertCell: PUBLIC PrintHeadProc = BEGIN coreCellBuffer _ NEW [Core.CellTypeRec]; coreCellBuffer.name _ name; coreCellBuffer.class _ CoreClasses.recordCellClass; CoreOps.InsertCellType [design: coreDesign, cellType: coreCellBuffer ! Core.StructureError => GOTO duplicate]; EXITS duplicate => ERROR END; -- InsertCell InsertPort: PUBLIC PrintFormalProc = BEGIN dummy: IO.STREAM; port: Core.Wire _ CoreOps.CreateAtomWire [name: qName]; internalNode: Core.Wire _ CoreOps.CreateAtomWire [name: qName]; ComputeStray [dummy, node]; port.properties _ internalNode.properties _ strayBuffer; corePortBuffer _ CONS [port, corePortBuffer]; coreNodeBuffer _ CONS [internalNode, coreNodeBuffer] END; -- InsertPort EndPortList: PUBLIC PrintStartBodyProc = <<[cellName: ROPE]>> BEGIN coreCellBuffer.public _ CoreOps.CreateRecordWire [name: "ports", components: corePortBuffer]; corePortBuffer _ NIL END; InsertNode: PUBLIC PrintLocalNodeProc = BEGIN dummy: IO.STREAM; internalNode: Core.Wire _ CoreOps.CreateAtomWire [name: GetAName[node]]; ComputeStray [dummy, node]; internalNode.properties _ strayBuffer; coreNodeBuffer _ CONS [internalNode, coreNodeBuffer] END; -- InsertNode CreateInstance: PUBLIC PrintInstanceHeadProc = BEGIN cell: Core.CellType = CoreOps.FetchCellType [coreDesign, defName]; t: ImagerTransformation.Transformation; pos, size: CD.Position; ir: CD.Rect; IF cell = NIL THEN ERROR; coreInstanceBuffer _ NEW [CoreClasses.CellInstanceRec]; coreInstanceBuffer.name _ QuoteCore [GetAName[inst]]; coreInstanceBuffer.actual _ NIL; coreInstanceBuffer.type _ cell; ir _ CDInstances.InstRectO [inst]; pos _ [x: ir.x1, y: ir.y1]; size _ [x: ir.x2 - ir.x1, y: ir.y2 - ir.y1]; t _ CDOrient.CreateTransform [cellSize: size, cellInstOrient: inst.orientation, cellInstPos: pos]; coreInstanceBuffer.properties _ CoreProperties.PutProp [on: coreInstanceBuffer.properties, prop: SXAtoms.cdCellHint, value: inst]; coreInstanceBuffer.properties _ CoreProperties.PutProp [on: coreInstanceBuffer.properties, prop: SXAtoms.instanceTransf, value: t] END; -- CreateInstance InsertPortInstance: PUBLIC PrintActualProc = BEGIN portInst: Core.Wire _ CoreOps.CreateAtomWire [name: qActualNode]; corePortInstances _ CONS [portInst, corePortInstances] END; -- InsertPortInstance EndPortInstanceList: PUBLIC PrintInstanceEndProc = BEGIN coreInstanceBuffer.actual _ CoreOps.CreateRecordWire [name: "port instances", components: corePortInstances]; coreCellInstance.instances _ CONS [coreInstanceBuffer, coreCellInstance.instances]; corePortInstances _ NIL END; -- EndPortInstanceList <> <> <> <> Compare: CoreProperties.PropCompareProc = <> BEGIN Stray: TYPE = REF SX.AreaPerimRec; WireLocation: TYPE = REF SX.NodeLocation; SELECT prop FROM SXAtoms.techInfo => { t1: SX.TechInfo = NARROW [value1]; t2: SX.TechInfo = NARROW [value2]; RETURN [(Rope.Compare[t1.name, t2.name]=equal)]}; SXAtoms.strayInfo => <> RETURN [TRUE]; SXAtoms.locInfo => { l1: WireLocation = NARROW [value1]; l2: WireLocation = NARROW [value2]; RETURN [(l1.xy.x=l2.xy.x)AND(l1.xy.y=l2.xy.y)AND(l1.layer=l2.layer)]}; SXAtoms.crystalAttr => RETURN [Rope.Equal[NARROW[value1, Rope.ROPE], NARROW[value2, Rope.ROPE], TRUE]]; SXAtoms.cdDesignHint, SXAtoms.cdCellHint => RETURN [(value1 = value2)]; SXAtoms.instanceTransf => RETURN [ImagerTransformation.Equal[NARROW[value1, ImagerTransformation.Transformation], NARROW[value2, ImagerTransformation.Transformation]]]; ENDCASE => [] _ SIGNAL Core.StructureError [InvariantFailed, "programming error"] END; -- Compare Copy: CoreProperties.PropCopyProc = <> BEGIN Stray: TYPE = LIST OF SX.AreaPerimRec; WireLocation: TYPE = REF SX.NodeLocation; SELECT prop FROM SXAtoms.techInfo => { oldT: SX.TechInfo = NARROW [value]; valCopy _ NEW [SX.TechRec _ oldT^]}; SXAtoms.strayInfo => { newS: Stray _ NIL; oldS: Stray = NARROW [value]; FOR s: Stray _ oldS, s.rest WHILE s # NIL DO newS _ CONS [s.first, newS] <> ENDLOOP; valCopy _ newS}; SXAtoms.locInfo => { oldL: WireLocation = NARROW [value]; valCopy _ NEW [SX.NodeLocation _ oldL^]}; SXAtoms.crystalAttr => { new: Rope.ROPE _ NARROW [value, Rope.ROPE]; valCopy _ new}; SXAtoms.cdDesignHint, SXAtoms.cdCellHint => valCopy _ value; SXAtoms.instanceTransf => valCopy _ ImagerTransformation.Copy [NARROW[value, ImagerTransformation.Transformation]]; ENDCASE => [] _ SIGNAL Core.StructureError [InvariantFailed, "programming error"] END; -- Copy Print: CoreProperties.PropPrintProc ~ BEGIN <> SELECT prop FROM SXAtoms.techInfo => { techProp: SX.TechInfo = NARROW [val, SX.TechInfo]; IO.PutF [stream: to, format: "The technology of the design is %l%g%l\n", v1: IO.rope ["b"], v2: IO.rope [techProp.name], v3: IO.rope ["B"]]; FOR i: SX.SpinifexLayerIndex IN SX.SpinifexLayerIndex DO IO.PutF [stream: to, format: "%g\t\t\t%g\t\t\t%g\n", v1: IO.int [i], v2: IO.atom [techProp.layers[i].id], v3: IO.rope [techProp.layers[i].thymeName]] ENDLOOP}; SXAtoms.strayInfo => { stray: LIST OF SX.AreaPerimRec = NARROW [val, LIST OF SX.AreaPerimRec]; FOR s: LIST OF SX.AreaPerimRec _ stray, s.rest WHILE s # NIL DO IO.PutF [stream: to, format: "(layer = %g, a = %g, p = %g) ", v1: IO.int [s.first.layer], v2: IO.int [s.first.area], v3: IO.int [s.first.perim]] ENDLOOP}; SXAtoms.locInfo => { loc: REF SX.NodeLocation = NARROW [val, REF SX.NodeLocation]; IO.PutF [stream: to, format: "(layer = %g, x = %g, y = %g) ", v1: IO.int [loc.layer], v2: IO.int [loc.xy.x], v3: IO.int [loc.xy.x]]}; SXAtoms.crystalAttr => IO.PutF [stream: to, format: "%g", v1: IO.rope [NARROW [val, Rope.ROPE]]]; SXAtoms.cdDesignHint, SXAtoms.cdCellHint => IO.PutF [stream: to, format: "CD hint %g", v1: IO.rope [IF val=NIL THEN "= NIL" ELSE "# NIL"]]; SXAtoms.instanceTransf => { t: ImagerTransformation.Transformation _ NARROW [val, ImagerTransformation.Transformation]; IF t.integerTrans THEN IO.PutF [stream: to, format: "Translation: (tx = %g, ty = %g)", v1: IO.int [t.tx], v2: IO.int [t.ty]] ELSE IO.PutF [stream: to, format: "Transformation looks insane"]}; ENDCASE => IO.PutF [stream: to, format: "Unknown property"]; END; -- Print <> <> <