DIRECTORY Core, CoreClasses, CoreOps, CoreProperties, HashTable, Sinix, SinixFlatten; SinixFlattenImpl: CEDAR PROGRAM IMPORTS CoreClasses, CoreOps, CoreProperties, HashTable, Sinix EXPORTS SinixFlatten = BEGIN OPEN SinixFlatten; Wire: TYPE = Core.Wire; CellType: TYPE = Core.CellType; Flatten: PUBLIC PROC [cellType: CellType, expand: ExpandProc] RETURNS [flat: CellType, isRecordCell: BOOL _ TRUE] = { WHILE (isRecordCell _ expand[cellType]) AND cellType.class#CoreClasses.recordCellClass DO cellType _ CoreOps.Recast[cellType]; IF cellType=NIL THEN ERROR; ENDLOOP; IF ~isRecordCell THEN RETURN[cellType, FALSE]; BEGIN data: CoreClasses.RecordCellType _ NARROW [cellType.data]; flatInterns: LIST OF Wire _ NIL; flatInstances: LIST OF CoreClasses.CellInstance _ NIL; correspondindFlatWires: HashTable.Table _ HashTable.Create[]; FOR i: NAT IN [0 .. data.internal.size) DO thisFlat: Wire _ CoreOps.CopyWire[data.internal[i]]; flatInterns _ CONS [thisFlat, flatInterns]; [] _ HashTable.Store[correspondindFlatWires, data.internal[i], thisFlat]; ENDLOOP; FOR i: NAT IN [0 .. data.size) DO instance: CoreClasses.CellInstance _ data[i]; subCell: CellType; isSubRecordCell: BOOL; [subCell, isSubRecordCell] _ Flatten[instance.type, expand]; IF ~isSubRecordCell THEN { thisInstance: CoreClasses.CellInstance _ NEW [CoreClasses.CellInstanceRec _ [ actual: MakeFlattenedWire[correspondindFlatWires, instance.actual], type: subCell, properties: CoreProperties.CopyProps[instance.properties]]]; flatInstances _ CONS [thisInstance, flatInstances]; } ELSE { subData: CoreClasses.RecordCellType _ NARROW [subCell.data]; subCorrespondingFlatWires: HashTable.Table _ HashTable.Create[]; FOR i: NAT IN [0 .. subCell.public.size) DO val: REF _ HashTable.Fetch[correspondindFlatWires, instance.actual[i]].value; IF val=NIL THEN ERROR; [] _ HashTable.Store[subCorrespondingFlatWires, subCell.public[i], val]; ENDLOOP; FOR i: NAT IN [0 .. subData.internal.size) DO IF HashTable.Fetch[subCorrespondingFlatWires, subData.internal[i]].value=NIL THEN { thisFlat: Wire _ CoreOps.CopyWire[subData.internal[i]]; flatInterns _ CONS [thisFlat, flatInterns]; [] _ HashTable.Store[subCorrespondingFlatWires, subData.internal[i], thisFlat]; Sinix.PutWireGeometryProp[ thisFlat, Sinix.TransformList[NARROW[CoreProperties.GetCellInstanceProp[instance, Sinix.instanceProp]], Sinix.GetWireGeometryProp[subData.internal[i]]]]; }; ENDLOOP; FOR i: NAT IN [0 .. subData.size) DO subInstance: CoreClasses.CellInstance _ subData[i]; thisInstance: CoreClasses.CellInstance _ NEW [CoreClasses.CellInstanceRec _ [ actual: MakeFlattenedWire[subCorrespondingFlatWires, subInstance.actual], type: subInstance.type, properties: CoreProperties.CopyProps[subInstance.properties]]]; CoreProperties.PutCellInstanceProp[ thisInstance, Sinix.instanceProp, Sinix.Transform[ NARROW [CoreProperties.GetCellInstanceProp[instance, Sinix.instanceProp]], NARROW [CoreProperties.GetCellInstanceProp[subInstance, Sinix.instanceProp]]]]; flatInstances _ CONS [thisInstance, flatInstances]; ENDLOOP; }; ENDLOOP; flat _ CoreClasses.CreateRecordCell[ public: MakeFlattenedWire[correspondindFlatWires, cellType.public], internal: CoreOps.CreateWire[flatInterns], instances: flatInstances, name: CoreOps.GetCellTypeName[cellType], props: CoreProperties.CopyProps[cellType.properties] ]; END; }; NonTransistorsExpand: PUBLIC ExpandProc = { expand _ cellType.class#CoreClasses.transistorCellClass; }; MakeFlattenedWire: PROC [table: HashTable.Table, oldWire: Wire] RETURNS [newWire: Wire] = { newWire _ CoreOps.CreateWires[size: oldWire.size]; FOR i: NAT IN [0 .. oldWire.size) DO newWire[i] _ NARROW [HashTable.Fetch[table, oldWire[i]].value]; IF newWire[i]=NIL THEN ERROR; ENDLOOP; }; END. <SinixFlattenImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reversed. Bertrand Serlet January 30, 1986 1:22:24 pm PST Barth, January 13, 1986 1:40:28 pm PST The game is now to mark each of the internal wires of the instance. Some are derived from the actual, others must be added to flatInterns; Κ˜code– "Cedar" stylešœ™Kšœ Οmœ1™Kšžœ˜Kšžœžœ˜K˜Kšœžœ ˜Kšœ žœ˜K˜š Οnœžœžœ*žœ žœžœ˜ušžœ#žœ,ž˜YKšœ%˜%Kšžœ žœžœžœ˜Kšžœ˜—Kšžœžœžœ žœ˜.šž˜Kšœ#žœ˜:Kšœ žœžœžœ˜ Jšœžœžœžœ˜6Jšœ=˜=šžœžœžœž˜*Jšœ4˜4Jšœžœ˜+JšœI˜IJšžœ˜—šžœžœžœž˜!Jšœ-˜-Jšœ$žœ˜)Jšœ<˜<šžœžœ˜šœ)žœ!˜MJšœD˜DJšœ˜Jšœ<˜<—Jšœžœ˜3Jšœžœ˜Jšœ‹™‹Jšœ&žœ˜