RecordX:
PUBLIC
PROC [obNames: Names, cx: Sisyph.Context, ctName:
ROPE]
RETURNS [ct: CellType] ~ {
count: NAT ← GList.Length[obNames];
Index: TYPE = {ComCell0, ComCell1, ComCellX, ComCellN, ComCellE};
baseCTs: CellTypes ← NIL;
public: Wire; -- public of cellType to be returned
tileRow: TilingClass.TileRow ← NEW [TilingClass.TileRowRec[count]];
tileArray: TilingClass.TileArray ← NEW [TilingClass.TileArrayRec[1]];
publicElements, arrayedWires, leftSideOnlyWires, rightSideOnlyWires, globalWires: Wires ← NIL;
EachWire: CoreOps.EachWireProc = {
sides: CoreGeometry.Sides = WireSide[wire, baseCTs.first];
vertical: BOOL = sides[top] OR sides[bottom];
IF vertical AND (sides[right] OR sides[left]) THEN WireSideProblem[wire, "touches adjacent sides", baseCTs.first];
IF vertical
THEN {
newPublic: Wire ← CoreOps.CreateWires[count, CoreOps.GetShortWireName[wire]];
arrayedWires ← CONS[wire, arrayedWires];
FOR i:
INT
IN [0..count)
DO
newPublic[i] ← CoreOps.SetShortWireName[CoreOps.CopyWire[wire], NIL];
ENDLOOP;
publicElements ← CONS[newPublic, publicElements];
}
ELSE {
IF sides=CoreGeometry.noSide
THEN {
IF IsGlobal[wire, cx]
THEN {
globalWires ← CONS [wire, globalWires];
publicElements ← CONS [wire, publicElements]
}
}
ELSE {
IF sides[left] THEN leftSideOnlyWires ← CONS[wire, leftSideOnlyWires];
IF sides[right] THEN rightSideOnlyWires ← CONS[wire, rightSideOnlyWires];
publicElements ← CONS [wire, publicElements]
}
}
};
Make the baseCellTypes
FOR l: Names ← obNames, l.rest
WHILE l#
NIL
DO
baseCTs ← CONS[Sisyph.ExtractSchematicByName[l.first, cx], baseCTs];
ENDLOOP;
baseCTs ← NARROW[GList.Reverse[baseCTs]];
Compute the public of the cellType to be returned
[] ← CoreOps.VisitWireSeq[baseCTs.first.public, EachWire];
public ← CoreOps.CreateWire[publicElements];
Fill in the cellTypes
FOR i:
INT
IN [0..count)
DO
tileRow[i] ← NEW [TilingClass.TileRec ← [type: baseCTs.first]];
baseCTs ← baseCTs.rest;
ENDLOOP;
Define the renaming for wires that touch the left side
FOR wl: Wires ← leftSideOnlyWires, wl.rest
WHILE wl#
NIL
DO
wireName: ROPE ← CoreOps.GetShortWireName[wl.first];
tileRow[0].renaming ← CONS[[wireName, wireName], tileRow[0].renaming];
ENDLOOP;
Define the renaming for wires that touch the right side
FOR wl: Wires ← rightSideOnlyWires, wl.rest
WHILE wl#
NIL
DO
wireName: ROPE ← CoreOps.GetShortWireName[wl.first];
tileRow[count-1].renaming ← CONS[[wireName, wireName], tileRow[count-1].renaming];
ENDLOOP;
Define the renaming for global wires
FOR wl: Wires ← globalWires, wl.rest
WHILE wl#
NIL
DO
wireName: ROPE ← CoreOps.GetShortWireName[wl.first];
FOR i:
NAT
IN [0..count)
DO
tileRow[i].renaming ← CONS[[wireName, wireName], tileRow[i].renaming];
ENDLOOP;
ENDLOOP;
Define the renaming for arrayed wires
FOR wl: Wires ← arrayedWires, wl.rest
WHILE wl#
NIL
DO
wireName: ROPE ← CoreOps.GetShortWireName[wl.first];
FOR i:
NAT
IN [0..count)
DO
tileRow[i].renaming ← CONS[[wireName, Rope.Cat[wireName, "[", Convert.RopeFromInt[i], "]"]], tileRow[i].renaming];
ENDLOOP;
ENDLOOP;
tileArray[0] ← tileRow;
Copying the public is necessary to avoid sharing of wires between cellTypes
ct ← TilingClass.CreateTiling[CoreOps.CopyWire[public], tileArray, TilingClass.SchematicsNeighborX, TilingClass.SchematicsNeighborY, Rope.Cat[ctName, ".RecordX"]];
};