SaveCellType:
PUBLIC
PROC [cellType: Core.CellType, fileName:
ROPE ←
NIL] = {
WriteCellType: CoreFlat.BoundFlatCellProc = {
name: ROPE ← CoreOps.GetCellTypeName[cell];
primitive: Primitive ← NARROW[SymTab.Fetch[primitives, name].val];
IF primitive=NIL THEN CoreFlat.NextBoundCellType[cell, target, flatCell, instance, index, parent, flatParent, data, bindings, WriteCellType]
ELSE primitive.translate[stream, cellType, cell, name, flatCell, iomap, part2000, primitive.data];
};
WriteEXT:
PROC [wire: Core.Wire] = {
name: ROPE ← CoreOps.GetFullWireName[cellType.public, wire];
IF
NOT GlobalDelete[name]
THEN {
signalName: ROPE ← SignalName[cellType, CoreFlat.rootCellType, wire];
pin: REF INT ← NARROW[CoreProperties.InheritPublicProp[cellType, wire, $Pin], REF INT];
direction: ROPE ← NARROW[SymTab.Fetch[iomap, signalName].val];
IF direction=NIL THEN ERROR;
IO.PutF[stream, "EXT,%g,%g", IO.rope[signalName], IO.rope[direction]];
IF pin#NIL THEN IO.PutF[stream, ",,LOC=P%g", IO.int[pin^]];
IO.PutRope[stream, "\n"];
};
};
stream: IO.STREAM ← NIL;
iomap: SymTab.Ref ← SymTab.Create[];
partTypeName: ROPE ← NARROW[CoreProperties.InheritCellTypeProp[cellType, $XilinxPartType]];
part2000: BOOL ← FALSE;
IF fileName=NIL THEN fileName ← Rope.Cat[CoreOps.GetCellTypeName[cellType], ".xnf"];
stream ← FS.StreamOpen[fileName, $create];
IO.PutRope[stream, "LCANET,1\n"];
IO.PutF[stream, "PROG,Core2XNF,1,%g\n", IO.time[]];
IF partTypeName=NIL THEN partTypeName ← "2064PC68-33";
part2000 ← Rope.Fetch[partTypeName]='2;
IO.PutF[stream, "PART,%g\n", IO.rope[partTypeName]];
WriteCellType[cell: cellType, bindings: CoreFlat.InitialBindingTable[cellType]];
IO.PutRope[stream, "PWR,1,public-$Vdd\n"];
IO.PutRope[stream, "PWR,0,public-$Gnd\n"];
CoreOps.VisitRootAtomics[cellType.public, WriteEXT];
IO.PutRope[stream, "EOF\n"];
IO.Close[stream];
};
PrintCoreRecursive:
PUBLIC
PROC [cellType: Core.CellType] = {
WriteCellType:
PROC [cell: Core.CellType, indent:
NAT ← 0] = {
name: ROPE ← CoreOps.GetCellTypeName[cell];
IF name#
NIL
THEN {
FOR i: NAT IN [0..indent) DO IO.PutChar[stream, ' ] ENDLOOP;
IO.PutF[stream, "%g\n", IO.rope[name]];
};
IF RefTab.Fetch[iomap, cell].found THEN RETURN;
IF NOT RefTab.Insert[iomap, cell, $Printed] THEN ERROR;
cell ← CoreOps.ToBasic[cell];
IF cell.class=CoreClasses.recordCellClass
THEN {
rct: CoreClasses.RecordCellType ← NARROW[cell.data];
subMap: RefTab.Ref ← RefTab.Create[];
FOR index:
NAT
IN [0..rct.size)
DO
subType: Core.CellType ← rct[index].type;
IF
NOT RefTab.Fetch[subMap, subType].found
THEN {
IF NOT RefTab.Insert[subMap, subType, $Printed] THEN ERROR;
WriteCellType[subType, indent+2];
};
ENDLOOP;
};
};
stream: IO.STREAM ← TerminalIO.TOS[];
iomap: RefTab.Ref ← RefTab.Create[];
WriteCellType[cellType];
};