This appendix contains examples of the Cadence® Library Exchange Format (LEF) reader and writer.
#pragma warning (disable : 4786)
int printing = 0; // Printing the output.
fprintf(fout, "ERROR: returned user data is not correct!\n");
void checkType(lefrCallbackType_e c) {
if (c >= 0 && c <= lefrLibraryEndCbkType) {
fprintf(fout, "ERROR: callback type is out of bounds!\n");
fprintf(fout, "VIA %s ", via->lefiVia::name());
if (via->lefiVia::hasDefault())
else if (via->lefiVia::hasGenerated())
if (via->lefiVia::hasTopOfStack())
fprintf(fout, " TOPOFSTACKONLY\n");
if (via->lefiVia::hasForeign()) {
fprintf(fout, " FOREIGN %s ", via->lefiVia::foreign());
if (via->lefiVia::hasForeignPnt()) {
fprintf(fout, "( %g %g ) ", via->lefiVia::foreignX(),
if (via->lefiVia::hasForeignOrient())
fprintf(fout, "%s ", orientStr(via->lefiVia::foreignOrient()));
if (via->lefiVia::hasProperties()) {
for (i = 0; i < via->lefiVia::numProperties(); i++) {
fprintf(fout, "%s ", via->lefiVia::propName(i));
if (via->lefiVia::propIsNumber(i))
fprintf(fout, "%g ", via->lefiVia::propNumber(i));
if (via->lefiVia::propIsString(i))
fprintf(fout, "%s ", via->lefiVia::propValue(i));
switch (via->lefiVia::propType(i)) {
case 'R': fprintf(fout, "REAL ");
case 'I': fprintf(fout, "INTEGER ");
case 'S': fprintf(fout, "STRING ");
case 'Q': fprintf(fout, "QUOTESTRING ");
case 'N': fprintf(fout, "NUMBER ");
if (via->lefiVia::hasResistance())
fprintf(fout, " RESISTANCE %g ;\n", via->lefiVia::resistance());
if (via->lefiVia::numLayers() > 0) {
for (i = 0; i < via->lefiVia::numLayers(); i++) {
fprintf(fout, " LAYER %s\n", via->lefiVia::layerName(i));
for (j = 0; j < via->lefiVia::numRects(i); j++)
fprintf(fout, " RECT ( %f %f ) ( %f %f ) ;\n",
via->lefiVia::xl(i, j), via->lefiVia::yl(i, j),
via->lefiVia::xh(i, j), via->lefiVia::yh(i, j));
for (j = 0; j < via->lefiVia::numPolygons(i); j++) {
poly = via->lefiVia::getPolygon(i, j);
for (int k = 0; k < poly.numPoints; k++)
fprintf(fout, " %g %g ", poly.x[k], poly.y[k]);
if (via->lefiVia::hasViaRule()) {
fprintf(fout, " VIARULE %s ;\n", via->lefiVia::viaRuleName());
fprintf(fout, " CUTSIZE %g %g ;\n", via->lefiVia::xCutSize(),
fprintf(fout, " LAYERS %s %s %s ;\n", via->lefiVia::botMetalLayer(),
via->lefiVia::cutLayer(), via->lefiVia::topMetalLayer());
fprintf(fout, " CUTSPACING %g %g ;\n", via->lefiVia::xCutSpacing(),
fprintf(fout, " ENCLOSURE %g %g %g %g ;\n", via->lefiVia::xBotEnc(),
via->lefiVia::yBotEnc(), via->lefiVia::xTopEnc(),
if (via->lefiVia::hasRowCol())
fprintf(fout, " ROWCOL %d %d ;\n", via->lefiVia::numCutRows(),
if (via->lefiVia::hasOrigin())
fprintf(fout, " ORIGIN %g %g ;\n", via->lefiVia::xOffset(),
if (via->lefiVia::hasOffset())
fprintf(fout, " OFFSET %g %g %g %g ;\n", via->lefiVia::xBotOffset(),
via->lefiVia::yBotOffset(), via->lefiVia::xTopOffset(),
if (via->lefiVia::hasCutPattern())
fprintf(fout, " PATTERN %s ;\n", via->lefiVia::cutPattern());
fprintf(fout, "END %s\n", via->lefiVia::name());
void lefSpacing(lefiSpacing* spacing) {
fprintf(fout, " SAMENET %s %s %g ", spacing->lefiSpacing::name1(),
spacing->lefiSpacing::name2(), spacing->lefiSpacing::distance());
if (spacing->lefiSpacing::hasStack())
void lefViaRuleLayer(lefiViaRuleLayer* vLayer) {
fprintf(fout, " LAYER %s ;\n", vLayer->lefiViaRuleLayer::name());
if (vLayer->lefiViaRuleLayer::hasDirection()) {
if (vLayer->lefiViaRuleLayer::isHorizontal())
fprintf(fout, " DIRECTION HORIZONTAL ;\n");
if (vLayer->lefiViaRuleLayer::isVertical())
fprintf(fout, " DIRECTION VERTICAL ;\n");
if (vLayer->lefiViaRuleLayer::hasEnclosure()) {
fprintf(fout, " ENCLOSURE %g %g ;\n",
vLayer->lefiViaRuleLayer::enclosureOverhang1(),
vLayer->lefiViaRuleLayer::enclosureOverhang2());
if (vLayer->lefiViaRuleLayer::hasWidth())
fprintf(fout, " WIDTH %g TO %g ;\n",
vLayer->lefiViaRuleLayer::widthMin(),
vLayer->lefiViaRuleLayer::widthMax());
if (vLayer->lefiViaRuleLayer::hasResistance())
fprintf(fout, " RESISTANCE %g ;\n",
vLayer->lefiViaRuleLayer::resistance());
if (vLayer->lefiViaRuleLayer::hasOverhang())
fprintf(fout, " OVERHANG %g ;\n",
vLayer->lefiViaRuleLayer::overhang());
if (vLayer->lefiViaRuleLayer::hasMetalOverhang())
fprintf(fout, " METALOVERHANG %g ;\n",
vLayer->lefiViaRuleLayer::metalOverhang());
if (vLayer->lefiViaRuleLayer::hasSpacing())
fprintf(fout, " SPACING %g BY %g ;\n",
vLayer->lefiViaRuleLayer::spacingStepX(),
vLayer->lefiViaRuleLayer::spacingStepY());
if (vLayer->lefiViaRuleLayer::hasRect())
fprintf(fout, " RECT ( %f %f ) ( %f %f ) ;\n",
vLayer->lefiViaRuleLayer::xl(), vLayer->lefiViaRuleLayer::yl(),
vLayer->lefiViaRuleLayer::xh(), vLayer->lefiViaRuleLayer::yh());
void prtGeometry(lefiGeometries* geometry) {
int numItems = geometry->lefiGeometries::numItems();
lefiGeomPolygonIter* polygonIter;
for (i = 0; i < numItems; i++) {
switch (geometry->lefiGeometries::itemType(i)) {
geometry->lefiGeometries::getClass(i));
fprintf(fout, " LAYER %s ;\n",
geometry->lefiGeometries::getLayer(i));
case lefiGeomLayerExceptPgNetE:
fprintf(fout, " EXCEPTPGNET ;\n");
case lefiGeomLayerMinSpacingE:
fprintf(fout, " SPACING %g ;\n",
geometry->lefiGeometries::getLayerMinSpacing(i));
fprintf(fout, " DESIGNRULEWIDTH %g ;\n",
geometry->lefiGeometries::getLayerRuleWidth(i));
fprintf(fout, " WIDTH %g ;\n",
geometry->lefiGeometries::getWidth(i));
path = geometry->lefiGeometries::getPath(i);
for (j = 0; j < path->numPoints; j++) {
if (j+1 == path->numPoints) // last one on the list
fprintf(fout, " ( %g %g ) ;\n", path->x[j], path->y[j]);
fprintf(fout, " ( %g %g )\n", path->x[j], path->y[j]);
pathIter = geometry->lefiGeometries::getPathIter(i);
fprintf(fout, " PATH ITERATED ");
for (j = 0; j < pathIter->numPoints; j++)
fprintf(fout, " ( %g %g )\n", pathIter->x[j],
fprintf(fout, " DO %g BY %g STEP %g %g ;\n", pathIter->xStart,
pathIter->yStart, pathIter->xStep, pathIter->yStep);
rect = geometry->lefiGeometries::getRect(i);
fprintf(fout, " RECT ( %f %f ) ( %f %f ) ;\n", rect->xl,
rect->yl, rect->xh, rect->yh);
rectIter = geometry->lefiGeometries::getRectIter(i);
fprintf(fout, " RECT ITERATE ( %f %f ) ( %f %f )\n",
rectIter->xl, rectIter->yl, rectIter->xh, rectIter->yh);
fprintf(fout, " DO %g BY %g STEP %g %g ;\n",
rectIter->xStart, rectIter->yStart, rectIter->xStep,
polygon = geometry->lefiGeometries::getPolygon(i);
for (j = 0; j < polygon->numPoints; j++) {
if (j+1 == polygon->numPoints) // last one on the list
fprintf(fout, " ( %g %g ) ;\n", polygon->x[j],
fprintf(fout, " ( %g %g )\n", polygon->x[j],
polygonIter = geometry->lefiGeometries::getPolygonIter(i);
fprintf(fout, " POLYGON ITERATE");
for (j = 0; j < polygonIter->numPoints; j++)
fprintf(fout, " ( %g %g )\n", polygonIter->x[j],
fprintf(fout, " DO %g BY %g STEP %g %g ;\n",
polygonIter->xStart, polygonIter->yStart,
polygonIter->xStep, polygonIter->yStep);
via = geometry->lefiGeometries::getVia(i);
fprintf(fout, " VIA ( %g %g ) %s ;\n", via->x, via->y,
viaIter = geometry->lefiGeometries::getViaIter(i);
fprintf(fout, " VIA ITERATE ( %g %g ) %s\n", viaIter->x,
fprintf(fout, " DO %g BY %g STEP %g %g ;\n",
viaIter->xStart, viaIter->yStart,
viaIter->xStep, viaIter->yStep);
fprintf(fout, "BOGUS geometries type.\n");
int antennaCB(lefrCallbackType_e c, double value, lefiUserData ud) {
fprintf(fout, "ANTENNAINPUTGATEAREA %g ;\n", value);
fprintf(fout, "ANTENNAINOUTDIFFAREA %g ;\n", value);
case lefrAntennaOutputCbkType:
fprintf(fout, "ANTENNAOUTPUTDIFFAREA %g ;\n", value);
fprintf(fout, "INPUTPINANTENNASIZE %g ;\n", value);
case lefrOutputAntennaCbkType:
fprintf(fout, "OUTPUTPINANTENNASIZE %g ;\n", value);
fprintf(fout, "INOUTPINANTENNASIZE %g ;\n", value);
fprintf(fout, "BOGUS antenna type.\n");
int arrayBeginCB(lefrCallbackType_e c, const char* name, lefiUserData ud) {
status = lefwStartArray(name);
int arrayCB(lefrCallbackType_e c, lefiArray* a, lefiUserData ud) {
if (a->lefiArray::numSitePattern() > 0) {
for (i = 0; i < a->lefiArray::numSitePattern(); i++) {
pattern = a->lefiArray::sitePattern(i);
status = lefwArraySite(pattern->lefiSitePattern::name(),
pattern->lefiSitePattern::x(),
pattern->lefiSitePattern::y(),
pattern->lefiSitePattern::orient(),
pattern->lefiSitePattern::xStart(),
pattern->lefiSitePattern::yStart(),
pattern->lefiSitePattern::xStep(),
pattern->lefiSitePattern::yStep());
if (a->lefiArray::numCanPlace() > 0) {
for (i = 0; i < a->lefiArray::numCanPlace(); i++) {
pattern = a->lefiArray::canPlace(i);
status = lefwArrayCanplace(pattern->lefiSitePattern::name(),
pattern->lefiSitePattern::x(),
pattern->lefiSitePattern::y(),
pattern->lefiSitePattern::orient(),
pattern->lefiSitePattern::xStart(),
pattern->lefiSitePattern::yStart(),
pattern->lefiSitePattern::xStep(),
pattern->lefiSitePattern::yStep());
if (a->lefiArray::numCannotOccupy() > 0) {
for (i = 0; i < a->lefiArray::numCannotOccupy(); i++) {
pattern = a->lefiArray::cannotOccupy(i);
status = lefwArrayCannotoccupy(pattern->lefiSitePattern::name(),
pattern->lefiSitePattern::x(),
pattern->lefiSitePattern::y(),
pattern->lefiSitePattern::orient(),
pattern->lefiSitePattern::xStart(),
pattern->lefiSitePattern::yStart(),
pattern->lefiSitePattern::xStep(),
pattern->lefiSitePattern::yStep());
if (a->lefiArray::numTrack() > 0) {
for (i = 0; i < a->lefiArray::numTrack(); i++) {
track = a->lefiArray::track(i);
fprintf(fout, " TRACKS %s, %g DO %d STEP %g\n",
track->lefiTrackPattern::name(),
track->lefiTrackPattern::start(),
track->lefiTrackPattern::numTracks(),
track->lefiTrackPattern::space());
if (track->lefiTrackPattern::numLayers() > 0) {
for (j = 0; j < track->lefiTrackPattern::numLayers(); j++)
fprintf(fout, "%s ", track->lefiTrackPattern::layerName(j));
if (a->lefiArray::numGcell() > 0) {
for (i = 0; i < a->lefiArray::numGcell(); i++) {
gcell = a->lefiArray::gcell(i);
fprintf(fout, " GCELLGRID %s, %g DO %d STEP %g\n",
gcell->lefiGcellPattern::name(),
gcell->lefiGcellPattern::start(),
gcell->lefiGcellPattern::numCRs(),
gcell->lefiGcellPattern::space());
if (a->lefiArray::numFloorPlans() > 0) {
for (i = 0; i < a->lefiArray::numFloorPlans(); i++) {
status = lefwStartArrayFloorplan(a->lefiArray::floorPlanName(i));
for (j = 0; j < a->lefiArray::numSites(i); j++) {
pattern = a->lefiArray::site(i, j);
status = lefwArrayFloorplan(a->lefiArray::siteType(i, j),
pattern->lefiSitePattern::name(),
pattern->lefiSitePattern::x(),
pattern->lefiSitePattern::y(),
pattern->lefiSitePattern::orient(),
(int)pattern->lefiSitePattern::xStart(),
(int)pattern->lefiSitePattern::yStart(),
pattern->lefiSitePattern::xStep(),
pattern->lefiSitePattern::yStep());
status = lefwEndArrayFloorplan(a->lefiArray::floorPlanName(i));
defCaps = a->lefiArray::numDefaultCaps();
status = lefwStartArrayDefaultCap(defCaps);
for (i = 0; i < defCaps; i++) {
status = lefwArrayDefaultCap(a->lefiArray::defaultCapMinPins(i),
status = lefwEndArrayDefaultCap();
int arrayEndCB(lefrCallbackType_e c, const char* name, lefiUserData ud) {
int busBitCharsCB(lefrCallbackType_e c, const char* busBit, lefiUserData ud)
status = lefwBusBitChars(busBit);
int caseSensCB(lefrCallbackType_e c, int caseSense, lefiUserData ud) {
fprintf(fout, "NAMESCASESENSITIVE ON ;\n");
fprintf(fout, "NAMESCASESENSITIVE OFF ;\n");
int clearanceCB(lefrCallbackType_e c, const char* name, lefiUserData ud) {
fprintf(fout, "CLEARANCEMEASURE %s ;\n", name);
int dividerCB(lefrCallbackType_e c, const char* name, lefiUserData ud) {
fprintf(fout, "DIVIDER %s ;\n", name);
int noWireExtCB(lefrCallbackType_e c, const char* name, lefiUserData ud) {
fprintf(fout, "NOWIREEXTENSION %s ;\n", name);
int edge1CB(lefrCallbackType_e c, double name, lefiUserData ud) {
fprintf(fout, "EDGERATETHRESHOLD1 %g ;\n", name);
int edge2CB(lefrCallbackType_e c, double name, lefiUserData ud) {
fprintf(fout, "EDGERATETHRESHOLD2 %g ;\n", name);
int edgeScaleCB(lefrCallbackType_e c, double name, lefiUserData ud) {
fprintf(fout, "EDGERATESCALEFACTORE %g ;\n", name);
int dielectricCB(lefrCallbackType_e c, double dielectric, lefiUserData ud) {
fprintf(fout, "DIELECTRIC %g ;\n", dielectric);
int irdropBeginCB(lefrCallbackType_e c, void* ptr, lefiUserData ud){
int irdropCB(lefrCallbackType_e c, lefiIRDrop* irdrop, lefiUserData ud) {
fprintf(fout, " TABLE %s ", irdrop->lefiIRDrop::name());
for (i = 0; i < irdrop->lefiIRDrop::numValues(); i++)
fprintf(fout, "%g %g ", irdrop->lefiIRDrop::value1(i),
irdrop->lefiIRDrop::value2(i));
int irdropEndCB(lefrCallbackType_e c, void* ptr, lefiUserData ud){
fprintf(fout, "END IRDROP\n");
int layerCB(lefrCallbackType_e c, lefiLayer* layer, lefiUserData ud) {
int numMinCut, numMinenclosed;
layer->lefiLayer::parse65nmRules();
fprintf(fout, "LAYER %s\n", layer->lefiLayer::name());
if (layer->lefiLayer::hasType())
fprintf(fout, " TYPE %s ;\n", layer->lefiLayer::type());
if (layer->lefiLayer::hasPitch())
fprintf(fout, " PITCH %g ;\n", layer->lefiLayer::pitch());
else if (layer->lefiLayer::hasXYPitch())
fprintf(fout, " PITCH %g %g ;\n", layer->lefiLayer::pitchX(),
if (layer->lefiLayer::hasOffset())
fprintf(fout, " OFFSET %g ;\n", layer->lefiLayer::offset());
else if (layer->lefiLayer::hasXYOffset())
fprintf(fout, " OFFSET %g %g ;\n", layer->lefiLayer::offsetX(),
if (layer->lefiLayer::hasDiagPitch())
fprintf(fout, " DIAGPITCH %g ;\n", layer->lefiLayer::diagPitch());
else if (layer->lefiLayer::hasXYDiagPitch())
fprintf(fout, " DIAGPITCH %g %g ;\n", layer->lefiLayer::diagPitchX(),
layer->lefiLayer::diagPitchY());
if (layer->lefiLayer::hasDiagWidth())
fprintf(fout, " DIAGWIDTH %g ;\n", layer->lefiLayer::diagWidth());
if (layer->lefiLayer::hasDiagSpacing())
fprintf(fout, " DIAGSPACING %g ;\n", layer->lefiLayer::diagSpacing());
if (layer->lefiLayer::hasWidth())
fprintf(fout, " WIDTH %g ;\n", layer->lefiLayer::width());
if (layer->lefiLayer::hasArea())
fprintf(fout, " AREA %g ;\n", layer->lefiLayer::area());
if (layer->lefiLayer::hasSlotWireWidth())
fprintf(fout, " SLOTWIREWIDTH %g ;\n", layer->lefiLayer::slotWireWidth());
if (layer->lefiLayer::hasSlotWireLength())
fprintf(fout, " SLOTWIRELENGTH %g ;\n",
layer->lefiLayer::slotWireLength());
if (layer->lefiLayer::hasSlotWidth())
fprintf(fout, " SLOTWIDTH %g ;\n", layer->lefiLayer::slotWidth());
if (layer->lefiLayer::hasSlotLength())
fprintf(fout, " SLOTLENGTH %g ;\n", layer->lefiLayer::slotLength());
if (layer->lefiLayer::hasMaxAdjacentSlotSpacing())
fprintf(fout, " MAXADJACENTSLOTSPACING %g ;\n",
layer->lefiLayer::maxAdjacentSlotSpacing());
if (layer->lefiLayer::hasMaxCoaxialSlotSpacing())
fprintf(fout, " MAXCOAXIALSLOTSPACING %g ;\n",
layer->lefiLayer::maxCoaxialSlotSpacing());
if (layer->lefiLayer::hasMaxEdgeSlotSpacing())
fprintf(fout, " MAXEDGESLOTSPACING %g ;\n",
layer->lefiLayer::maxEdgeSlotSpacing());
if (layer->lefiLayer::hasMaxFloatingArea()) // 5.7
fprintf(fout, " MAXFLOATINGAREA %g ;\n",
layer->lefiLayer::maxFloatingArea());
if (layer->lefiLayer::hasArraySpacing()) { // 5.7
fprintf(fout, " ARRAYSPACING ");
if (layer->lefiLayer::hasLongArray())
if (layer->lefiLayer::hasViaWidth())
fprintf(fout, "WIDTH %g ", layer->lefiLayer::viaWidth());
fprintf(fout, "CUTSPACING %g", layer->lefiLayer::cutSpacing());
for (i = 0; i < layer->lefiLayer::numArrayCuts(); i++)
fprintf(fout, "\n\tARRAYCUTS %g SPACING %g",
layer->lefiLayer::arrayCuts(i),
layer->lefiLayer::arraySpacing(i));
if (layer->lefiLayer::hasSplitWireWidth())
fprintf(fout, " SPLITWIREWIDTH %g ;\n",
layer->lefiLayer::splitWireWidth());
if (layer->lefiLayer::hasMinimumDensity())
fprintf(fout, " MINIMUMDENSITY %g ;\n",
layer->lefiLayer::minimumDensity());
if (layer->lefiLayer::hasMaximumDensity())
fprintf(fout, " MAXIMUMDENSITY %g ;\n",
layer->lefiLayer::maximumDensity());
if (layer->lefiLayer::hasDensityCheckWindow())
fprintf(fout, " DENSITYCHECKWINDOW %g %g ;\n",
layer->lefiLayer::densityCheckWindowLength(),
layer->lefiLayer::densityCheckWindowWidth());
if (layer->lefiLayer::hasDensityCheckStep())
fprintf(fout, " DENSITYCHECKSTEP %g ;\n",
layer->lefiLayer::densityCheckStep());
if (layer->lefiLayer::hasFillActiveSpacing())
fprintf(fout, " FILLACTIVESPACING %g ;\n",
layer->lefiLayer::fillActiveSpacing());
numMinCut = layer->lefiLayer::numMinimumcut();
for (i = 0; i < numMinCut; i++) {
fprintf(fout, " MINIMUMCUT %d WIDTH %g ",
layer->lefiLayer::minimumcut(i),
layer->lefiLayer::minimumcutWidth(i));
if (layer->lefiLayer::hasMinimumcutWithin(i))
fprintf(fout, "WITHIN %g ", layer->lefiLayer::minimumcutWithin(i));
if (layer->lefiLayer::hasMinimumcutConnection(i))
fprintf(fout, "%s ", layer->lefiLayer::minimumcutConnection(i));
if (layer->lefiLayer::hasMinimumcutNumCuts(i))
fprintf(fout, "LENGTH %g WITHIN %g ",
layer->lefiLayer::minimumcutLength(i),
layer->lefiLayer::minimumcutDistance(i));
if (layer->lefiLayer::hasMaxwidth()) {
fprintf(fout, " MAXWIDTH %g ;\n", layer->lefiLayer::maxwidth());
if (layer->lefiLayer::hasMinwidth()) {
fprintf(fout, " MINWIDTH %g ;\n", layer->lefiLayer::minwidth());
numMinenclosed = layer->lefiLayer::numMinenclosedarea();
for (i = 0; i < numMinenclosed; i++) {
fprintf(fout, " MINENCLOSEDAREA %g ",
layer->lefiLayer::minenclosedarea(i));
if (layer->lefiLayer::hasMinenclosedareaWidth(i))
fprintf(fout, "MINENCLOSEDAREAWIDTH %g ",
layer->lefiLayer::minenclosedareaWidth(i));
if (layer->lefiLayer::hasMinstep()) {
for (i = 0; i < layer->lefiLayer::numMinstep(); i++) {
fprintf(fout, " MINSTEP %g ", layer->lefiLayer::minstep(i));
if (layer->lefiLayer::hasMinstepType(i))
fprintf(fout, "%s ", layer->lefiLayer::minstepType(i));
if (layer->lefiLayer::hasMinstepLengthsum(i))
fprintf(fout, "LENGTHSUM %g ",
layer->lefiLayer::minstepLengthsum(i));
if (layer->lefiLayer::hasMinstepMaxedges(i))
fprintf(fout, "MAXEDGES %d ", layer->lefiLayer::minstepMaxedges(i));
if (layer->lefiLayer::hasProtrusion()) {
fprintf(fout, " PROTRUSIONWIDTH %g LENGTH %g WIDTH %g ;\n",
layer->lefiLayer::protrusionWidth1(),
layer->lefiLayer::protrusionLength(),
layer->lefiLayer::protrusionWidth2());
if (layer->lefiLayer::hasSpacingNumber()) {
for (i = 0; i < layer->lefiLayer::numSpacing(); i++) {
fprintf(fout, " SPACING %g ", layer->lefiLayer::spacing(i));
if (layer->lefiLayer::hasSpacingName(i))
fprintf(fout, "LAYER %s ", layer->lefiLayer::spacingName(i));
if (layer->lefiLayer::hasSpacingLayerStack(i))
fprintf(fout, "STACK "); // 5.7
if (layer->lefiLayer::hasSpacingAdjacent(i))
fprintf(fout, "ADJACENTCUTS %d WITHIN %g ",
layer->lefiLayer::spacingAdjacentCuts(i),
layer->lefiLayer::spacingAdjacentWithin(i));
if (layer->lefiLayer::hasSpacingAdjacentExcept(i)) // 5.7
fprintf(fout, "EXCEPTSAMEPGNET ");
if (layer->lefiLayer::hasSpacingCenterToCenter(i))
fprintf(fout, "CENTERTOCENTER ");
if (layer->lefiLayer::hasSpacingSamenet(i)) // 5.7
if (layer->lefiLayer::hasSpacingSamenetPGonly(i)) // 5.7
if (layer->lefiLayer::hasSpacingArea(i)) // 5.7
fprintf(fout, "AREA %g ", layer->lefiLayer::spacingArea(i));
if (layer->lefiLayer::hasSpacingRange(i)) {
fprintf(fout, "RANGE %g %g ", layer->lefiLayer::spacingRangeMin(i),
layer->lefiLayer::spacingRangeMax(i));
if (layer->lefiLayer::hasSpacingRangeUseLengthThreshold(i))
fprintf(fout, "USELENGTHTHRESHOLD ");
else if (layer->lefiLayer::hasSpacingRangeInfluence(i)) {
fprintf(fout, "INFLUENCE %g ",
layer->lefiLayer::spacingRangeInfluence(i));
if (layer->lefiLayer::hasSpacingRangeInfluenceRange(i))
layer->lefiLayer::spacingRangeInfluenceMin(i),
layer->lefiLayer::spacingRangeInfluenceMax(i));
} else if (layer->lefiLayer::hasSpacingRangeRange(i))
layer->lefiLayer::spacingRangeRangeMin(i),
layer->lefiLayer::spacingRangeRangeMax(i));
} else if (layer->lefiLayer::hasSpacingLengthThreshold(i)) {
fprintf(fout, "LENGTHTHRESHOLD %g ",
layer->lefiLayer::spacingLengthThreshold(i));
if (layer->lefiLayer::hasSpacingLengthThresholdRange(i))
layer->lefiLayer::spacingLengthThresholdRangeMin(i),
layer->lefiLayer::spacingLengthThresholdRangeMax(i));
} else if (layer->lefiLayer::hasSpacingNotchLength(i)) {// 5.7
fprintf(fout, "NOTCHLENGTH %g",
layer->lefiLayer::spacingNotchLength(i));
} else if (layer->lefiLayer::hasSpacingEndOfNotchWidth(i)) // 5.7
fprintf(fout, "ENDOFNOTCHWIDTH %g NOTCHSPACING %g, NOTCHLENGTH %g",
layer->lefiLayer::spacingEndOfNotchWidth(i),
layer->lefiLayer::spacingEndOfNotchSpacing(i),
layer->lefiLayer::spacingEndOfNotchLength(i));
if (layer->lefiLayer::hasSpacingParallelOverlap(i)) // 5.7
fprintf(fout, "PARALLELOVERLAP ");
if (layer->lefiLayer::hasSpacingEndOfLine(i)) { // 5.7
fprintf(fout, "ENDOFLINE %g WITHING %g ",
layer->lefiLayer::spacingEolWidth(i),
layer->lefiLayer::spacingEolWithin(i));
if (layer->lefiLayer::hasSpacingParellelEdge(i)) {
fprintf(fout, "PARALLELEDGE %g WITHING %g ",
layer->lefiLayer::spacingParSpace(i),
layer->lefiLayer::spacingParWithin(i));
if (layer->lefiLayer::hasSpacingTwoEdges(i)) {
if (layer->lefiLayer::hasSpacingTableOrtho()) { // 5.7
fprintf(fout, "SPACINGTABLE ORTHOGONAL");
ortho = layer->lefiLayer::orthogonal();
for (i = 0; i < ortho->lefiOrthogonal::numOrthogonal(); i++) {
fprintf(fout, "\n WITHIN %g SPACING %g",
ortho->lefiOrthogonal::cutWithin(i),
ortho->lefiOrthogonal::orthoSpacing(i));
for (i = 0; i < layer->lefiLayer::numEnclosure(); i++) {
if (layer->lefiLayer::hasEnclosureRule(i))
fprintf(fout, "%s ", layer->lefiLayer::enclosureRule(i));
fprintf(fout, "%g %g ", layer->lefiLayer::enclosureOverhang1(i),
layer->lefiLayer::enclosureOverhang2(i));
if (layer->lefiLayer::hasEnclosureWidth(i))
fprintf(fout, "WIDTH %g ", layer->lefiLayer::enclosureMinWidth(i));
if (layer->lefiLayer::hasEnclosureExceptExtraCut(i))
fprintf(fout, "EXCEPTEXTRACUT %g ",
layer->lefiLayer::enclosureExceptExtraCut(i));
if (layer->lefiLayer::hasEnclosureMinLength(i))
fprintf(fout, "LENGTH %g ", layer->lefiLayer::enclosureMinLength(i));
for (i = 0; i < layer->lefiLayer::numPreferEnclosure(); i++) {
fprintf(fout, "PREFERENCLOSURE ");
if (layer->lefiLayer::hasPreferEnclosureRule(i))
fprintf(fout, "%s ", layer->lefiLayer::preferEnclosureRule(i));
fprintf(fout, "%g %g ", layer->lefiLayer::preferEnclosureOverhang1(i),
layer->lefiLayer::preferEnclosureOverhang2(i));
if (layer->lefiLayer::hasPreferEnclosureWidth(i))
fprintf(fout, "WIDTH %g ",layer->lefiLayer::preferEnclosureMinWidth(i));
if (layer->lefiLayer::hasResistancePerCut())
fprintf(fout, " RESISTANCE %g ;\n",
layer->lefiLayer::resistancePerCut());
if (layer->lefiLayer::hasCurrentDensityPoint())
fprintf(fout, " CURRENTDEN %g ;\n",
layer->lefiLayer::currentDensityPoint());
if (layer->lefiLayer::hasCurrentDensityArray()) {
layer->lefiLayer::currentDensityArray(&numPoints, &widths, ¤t);
for (i = 0; i < numPoints; i++)
fprintf(fout, " CURRENTDEN ( %g %g ) ;\n", widths[i], current[i]);
if (layer->lefiLayer::hasDirection())
fprintf(fout, " DIRECTION %s ;\n", layer->lefiLayer::direction());
if (layer->lefiLayer::hasResistance())
fprintf(fout, " RESISTANCE RPERSQ %g ;\n",
layer->lefiLayer::resistance());
if (layer->lefiLayer::hasCapacitance())
fprintf(fout, " CAPACITANCE CPERSQDIST %g ;\n",
layer->lefiLayer::capacitance());
if (layer->lefiLayer::hasEdgeCap())
fprintf(fout, " EDGECAPACITANCE %g ;\n", layer->lefiLayer::edgeCap());
if (layer->lefiLayer::hasHeight())
fprintf(fout, " TYPE %g ;\n", layer->lefiLayer::height());
if (layer->lefiLayer::hasThickness())
fprintf(fout, " THICKNESS %g ;\n", layer->lefiLayer::thickness());
if (layer->lefiLayer::hasWireExtension())
fprintf(fout, " WIREEXTENSION %g ;\n", layer->lefiLayer::wireExtension());
if (layer->lefiLayer::hasShrinkage())
fprintf(fout, " SHRINKAGE %g ;\n", layer->lefiLayer::shrinkage());
if (layer->lefiLayer::hasCapMultiplier())
fprintf(fout, " CAPMULTIPLIER %g ;\n", layer->lefiLayer::capMultiplier());
if (layer->lefiLayer::hasAntennaArea())
fprintf(fout, " ANTENNAAREAFACTOR %g ;\n",
layer->lefiLayer::antennaArea());
if (layer->lefiLayer::hasAntennaLength())
fprintf(fout, " ANTENNALENGTHFACTOR %g ;\n",
layer->lefiLayer::antennaLength());
for (i = 0; i < layer->lefiLayer::numAntennaModel(); i++) {
aModel = layer->lefiLayer::antennaModel(i);
fprintf(fout, " ANTENNAMODEL %s ;\n",
aModel->lefiAntennaModel::antennaOxide());
if (aModel->lefiAntennaModel::hasAntennaAreaRatio())
fprintf(fout, " ANTENNAAREARATIO %g ;\n",
aModel->lefiAntennaModel::antennaAreaRatio());
if (aModel->lefiAntennaModel::hasAntennaDiffAreaRatio())
fprintf(fout, " ANTENNADIFFAREARATIO %g ;\n",
aModel->lefiAntennaModel::antennaDiffAreaRatio());
else if (aModel->lefiAntennaModel::hasAntennaDiffAreaRatioPWL()) {
pwl = aModel->lefiAntennaModel::antennaDiffAreaRatioPWL();
fprintf(fout, " ANTENNADIFFAREARATIO PWL ( ");
for (j = 0; j < pwl->lefiAntennaPWL::numPWL(); j++)
fprintf(fout, "( %g %g ) ", pwl->lefiAntennaPWL::PWLdiffusion(j),
pwl->lefiAntennaPWL::PWLratio(j));
if (aModel->lefiAntennaModel::hasAntennaCumAreaRatio())
fprintf(fout, " ANTENNACUMAREARATIO %g ;\n",
aModel->lefiAntennaModel::antennaCumAreaRatio());
if (aModel->lefiAntennaModel::hasAntennaCumDiffAreaRatio())
fprintf(fout, " ANTENNACUMDIFFAREARATIO %g\n",
aModel->lefiAntennaModel::antennaCumDiffAreaRatio());
if (aModel->lefiAntennaModel::hasAntennaCumDiffAreaRatioPWL()) {
pwl = aModel->lefiAntennaModel::antennaCumDiffAreaRatioPWL();
fprintf(fout, " ANTENNACUMDIFFAREARATIO PWL ( ");
for (j = 0; j < pwl->lefiAntennaPWL::numPWL(); j++)
fprintf(fout, "( %g %g ) ", pwl->lefiAntennaPWL::PWLdiffusion(j),
pwl->lefiAntennaPWL::PWLratio(j));
if (aModel->lefiAntennaModel::hasAntennaAreaFactor()) {
fprintf(fout, " ANTENNAAREAFACTOR %g ",
aModel->lefiAntennaModel::antennaAreaFactor());
if (aModel->lefiAntennaModel::hasAntennaAreaFactorDUO())
fprintf(fout, " DIFFUSEONLY ");
if (aModel->lefiAntennaModel::hasAntennaSideAreaRatio())
fprintf(fout, " ANTENNASIDEAREARATIO %g ;\n",
aModel->lefiAntennaModel::antennaSideAreaRatio());
if (aModel->lefiAntennaModel::hasAntennaDiffSideAreaRatio())
fprintf(fout, " ANTENNADIFFSIDEAREARATIO %g\n",
aModel->lefiAntennaModel::antennaDiffSideAreaRatio());
else if (aModel->lefiAntennaModel::hasAntennaDiffSideAreaRatioPWL()) {
pwl = aModel->lefiAntennaModel::antennaDiffSideAreaRatioPWL();
fprintf(fout, " ANTENNADIFFSIDEAREARATIO PWL ( ");
for (j = 0; j < pwl->lefiAntennaPWL::numPWL(); j++)
fprintf(fout, "( %g %g ) ", pwl->lefiAntennaPWL::PWLdiffusion(j),
pwl->lefiAntennaPWL::PWLratio(j));
if (aModel->lefiAntennaModel::hasAntennaCumSideAreaRatio())
fprintf(fout, " ANTENNACUMSIDEAREARATIO %g ;\n",
aModel->lefiAntennaModel::antennaCumSideAreaRatio());
if (aModel->lefiAntennaModel::hasAntennaCumDiffSideAreaRatio())
fprintf(fout, " ANTENNACUMDIFFSIDEAREARATIO %g\n",
aModel->lefiAntennaModel::antennaCumDiffSideAreaRatio());
else if (aModel->lefiAntennaModel::hasAntennaCumDiffSideAreaRatioPWL()) {
pwl = aModel->lefiAntennaModel::antennaCumDiffSideAreaRatioPWL();
fprintf(fout, " ANTENNACUMDIFFSIDEAREARATIO PWL ( ");
for (j = 0; j < pwl->lefiAntennaPWL::numPWL(); j++)
fprintf(fout, "( %g %g ) ", pwl->lefiAntennaPWL::PWLdiffusion(j),
pwl->lefiAntennaPWL::PWLratio(j));
if (aModel->lefiAntennaModel::hasAntennaSideAreaFactor()) {
fprintf(fout, " ANTENNASIDEAREAFACTOR %g ",
aModel->lefiAntennaModel::antennaSideAreaFactor());
if (aModel->lefiAntennaModel::hasAntennaSideAreaFactorDUO())
fprintf(fout, " DIFFUSEONLY ");
if (aModel->lefiAntennaModel::hasAntennaCumRoutingPlusCut())
fprintf(fout, " ANTENNACUMROUTINGPLUSCUT ;\n");
if (aModel->lefiAntennaModel::hasAntennaGatePlusDiff())
fprintf(fout, " ANTENNAGATEPLUSDIFF %g ;\n",
aModel->lefiAntennaModel::antennaGatePlusDiff());
if (aModel->lefiAntennaModel::hasAntennaAreaMinusDiff())
fprintf(fout, " ANTENNAAREAMINUSDIFF %g ;\n",
aModel->lefiAntennaModel::antennaAreaMinusDiff());
if (aModel->lefiAntennaModel::hasAntennaAreaDiffReducePWL()) {
pwl = aModel->lefiAntennaModel::antennaAreaDiffReducePWL();
fprintf(fout, " ANTENNAAREADIFFREDUCEPWL ( ");
for (j = 0; j < pwl->lefiAntennaPWL::numPWL(); j++)
fprintf(fout, "( %g %g ) ", pwl->lefiAntennaPWL::PWLdiffusion(j),
pwl->lefiAntennaPWL::PWLratio(j));
if (layer->lefiLayer::numAccurrentDensity()) {
for (i = 0; i < layer->lefiLayer::numAccurrentDensity(); i++) {
density = layer->lefiLayer::accurrent(i);
fprintf(fout, " ACCURRENTDENSITY %s", density->type());
fprintf(fout, " %g ;\n", density->oneEntry());
if (density->numFrequency()) {
for (j = 0; j < density->numFrequency(); j++)
fprintf(fout, " %g", density->frequency(j));
for (j = 0; j < density->numCutareas(); j++)
fprintf(fout, " %g", density->cutArea(j));
for (j = 0; j < density->numWidths(); j++)
fprintf(fout, " %g", density->width(j));
if (density->numTableEntries()) {
fprintf(fout, " TABLEENTRIES");
for (j = 0; j < density->numTableEntries(); j++)
fprintf(fout, "\n %g", density->tableEntry(j));
fprintf(fout, " %g", density->tableEntry(j));
if (layer->lefiLayer::numDccurrentDensity()) {
for (i = 0; i < layer->lefiLayer::numDccurrentDensity(); i++) {
density = layer->lefiLayer::dccurrent(i);
fprintf(fout, " DCCURRENTDENSITY %s", density->type());
fprintf(fout, " %g ;\n", density->oneEntry());
for (j = 0; j < density->numCutareas(); j++)
fprintf(fout, " %g", density->cutArea(j));
for (j = 0; j < density->numWidths(); j++)
fprintf(fout, " %g", density->width(j));
if (density->numTableEntries()) {
fprintf(fout, " TABLEENTRIES");
for (j = 0; j < density->numTableEntries(); j++)
fprintf(fout, " %g", density->tableEntry(j));
for (i = 0; i < layer->lefiLayer::numSpacingTable(); i++) {
spTable = layer->lefiLayer::spacingTable(i);
fprintf(fout, " SPACINGTABLE\n");
if (spTable->lefiSpacingTable::isInfluence()) {
influence = spTable->lefiSpacingTable::influence();
for (j = 0; j < influence->lefiInfluence::numInfluenceEntry(); j++) {
fprintf(fout, "\n WIDTH %g WITHIN %g SPACING %g",
influence->lefiInfluence::width(j),
influence->lefiInfluence::distance(j),
influence->lefiInfluence::spacing(j));
} else if (spTable->lefiSpacingTable::isParallel()){
parallel = spTable->lefiSpacingTable::parallel();
fprintf(fout, " PARALLELRUNLENGTH");
for (j = 0; j < parallel->lefiParallel::numLength(); j++) {
fprintf(fout, " %g", parallel->lefiParallel::length(j));
for (j = 0; j < parallel->lefiParallel::numWidth(); j++) {
parallel->lefiParallel::width(j));
for (k = 0; k < parallel->lefiParallel::numLength(); k++) {
fprintf(fout, " %g", parallel->lefiParallel::widthSpacing(j, k));
twoWidths = spTable->lefiSpacingTable::twoWidths();
for (j = 0; j < twoWidths->lefiTwoWidths::numWidth(); j++) {
twoWidths->lefiTwoWidths::width(j));
if (twoWidths->lefiTwoWidths::hasWidthPRL(j))
fprintf(fout, "PRL %g ", twoWidths->lefiTwoWidths::widthPRL(j));
for (k = 0; k < twoWidths->lefiTwoWidths::numWidthSpacing(j); k++)
fprintf(fout, "%g ",twoWidths->lefiTwoWidths::widthSpacing(j, k));
propNum = layer->lefiLayer::numProps();
for (i = 0; i < propNum; i++) {
// value can either be a string or number
fprintf(fout, "%s ", layer->lefiLayer::propName(i));
if (layer->lefiLayer::propIsNumber(i))
fprintf(fout, "%g ", layer->lefiLayer::propNumber(i));
if (layer->lefiLayer::propIsString(i))
fprintf(fout, "%s ", layer->lefiLayer::propValue(i));
pType = layer->lefiLayer::propType(i);
case 'R': fprintf(fout, "REAL ");
case 'I': fprintf(fout, "INTEGER ");
case 'S': fprintf(fout, "STRING ");
case 'Q': fprintf(fout, "QUOTESTRING ");
case 'N': fprintf(fout, "NUMBER ");
if (layer->lefiLayer::hasDiagMinEdgeLength())
fprintf(fout, " DIAGMINEDGELENGTH %g ;\n",
layer->lefiLayer::diagMinEdgeLength());
if (layer->lefiLayer::numMinSize()) {
for (i = 0; i < layer->lefiLayer::numMinSize(); i++) {
fprintf(fout, "%g %g ", layer->lefiLayer::minSizeWidth(i),
layer->lefiLayer::minSizeLength(i));
fprintf(fout, "END %s\n", layer->lefiLayer::name());
// Set it to case sensitive from here on
int macroBeginCB(lefrCallbackType_e c, const char* macroName, lefiUserData ud) {
fprintf(fout, "MACRO %s\n", macroName);
int macroClassTypeCB(lefrCallbackType_e c, const char* macroClassType,
fprintf(fout, "MACRO CLASS %s\n", macroClassType);
int macroCB(lefrCallbackType_e c, lefiMacro* macro, lefiUserData ud) {
int propNum, i, hasPrtSym = 0;
if (macro->lefiMacro::hasClass())
fprintf(fout, " CLASS %s ;\n", macro->lefiMacro::macroClass());
if (macro->lefiMacro::hasEEQ())
fprintf(fout, " EEQ %s ;\n", macro->lefiMacro::EEQ());
if (macro->lefiMacro::hasLEQ())
fprintf(fout, " LEQ %s ;\n", macro->lefiMacro::LEQ());
if (macro->lefiMacro::hasSource())
fprintf(fout, " SOURCE %s ;\n", macro->lefiMacro::source());
if (macro->lefiMacro::hasXSymmetry()) {
fprintf(fout, " SYMMETRY X ");
if (macro->lefiMacro::hasYSymmetry()) { // print X Y & R90 in one line
fprintf(fout, " SYMMETRY Y ");
if (macro->lefiMacro::has90Symmetry()) {
fprintf(fout, " SYMMETRY R90 ");
if (macro->lefiMacro::hasSiteName())
fprintf(fout, " SITE %s ;\n", macro->lefiMacro::siteName());
if (macro->lefiMacro::hasSitePattern()) {
for (i = 0; i < macro->lefiMacro::numSitePattern(); i++ ) {
pattern = macro->lefiMacro::sitePattern(i);
if (pattern->lefiSitePattern::hasStepPattern()) {
fprintf(fout, " SITE %s %g %g %s DO %g BY %g STEP %g %g ;\n",
pattern->lefiSitePattern::name(), pattern->lefiSitePattern::x(),
pattern->lefiSitePattern::y(),
orientStr(pattern->lefiSitePattern::orient()),
pattern->lefiSitePattern::xStart(),
pattern->lefiSitePattern::yStart(),
pattern->lefiSitePattern::xStep(),
pattern->lefiSitePattern::yStep());
fprintf(fout, " SITE %s %g %g %s ;\n",
pattern->lefiSitePattern::name(), pattern->lefiSitePattern::x(),
pattern->lefiSitePattern::y(),
orientStr(pattern->lefiSitePattern::orient()));
if (macro->lefiMacro::hasSize())
fprintf(fout, " SIZE %g BY %g ;\n", macro->lefiMacro::sizeX(),
if (macro->lefiMacro::hasForeign()) {
for (i = 0; i < macro->lefiMacro::numForeigns(); i++) {
fprintf(fout, " FOREIGN %s ", macro->lefiMacro::foreignName(i));
if (macro->lefiMacro::hasForeignPoint(i)) {
fprintf(fout, "( %g %g ) ", macro->lefiMacro::foreignX(i),
macro->lefiMacro::foreignY(i));
if (macro->lefiMacro::hasForeignOrient(i))
fprintf(fout, "%s ", macro->lefiMacro::foreignOrientStr(i));
if (macro->lefiMacro::hasOrigin())
fprintf(fout, " ORIGIN ( %g %g ) ;\n", macro->lefiMacro::originX(),
if (macro->lefiMacro::hasPower())
fprintf(fout, " POWER %g ;\n", macro->lefiMacro::power());
propNum = macro->lefiMacro::numProperties();
for (i = 0; i < propNum; i++) {
// value can either be a string or number
if (macro->lefiMacro::propValue(i)) {
fprintf(fout, "%s %s ", macro->lefiMacro::propName(i),
macro->lefiMacro::propValue(i));
fprintf(fout, "%s %g ", macro->lefiMacro::propName(i),
macro->lefiMacro::propNum(i));
switch (macro->lefiMacro::propType(i)) {
case 'R': fprintf(fout, "REAL ");
case 'I': fprintf(fout, "INTEGER ");
case 'S': fprintf(fout, "STRING ");
case 'Q': fprintf(fout, "QUOTESTRING ");
case 'N': fprintf(fout, "NUMBER ");
int macroEndCB(lefrCallbackType_e c, const char* macroName, lefiUserData ud) {
fprintf(fout, "END %s\n", macroName);
int manufacturingCB(lefrCallbackType_e c, double num, lefiUserData ud) {
fprintf(fout, "MANUFACTURINGGRID %g ;\n", num);
int maxStackViaCB(lefrCallbackType_e c, lefiMaxStackVia* maxStack,
fprintf(fout, "MAXVIASTACK %d ", maxStack->lefiMaxStackVia::maxStackVia());
if (maxStack->lefiMaxStackVia::hasMaxStackViaRange())
maxStack->lefiMaxStackVia::maxStackViaBottomLayer(),
maxStack->lefiMaxStackVia::maxStackViaTopLayer());
int minFeatureCB(lefrCallbackType_e c, lefiMinFeature* min, lefiUserData ud) {
fprintf(fout, "MINFEATURE %g %g ;\n", min->lefiMinFeature::one(),
int nonDefaultCB(lefrCallbackType_e c, lefiNonDefault* def, lefiUserData ud) {
fprintf(fout, "NONDEFAULTRULE %s\n", def->lefiNonDefault::name());
if (def->lefiNonDefault::hasHardspacing())
fprintf(fout, " HARDSPACING ;\n");
for (i = 0; i < def->lefiNonDefault::numLayers(); i++) {
fprintf(fout, " LAYER %s\n", def->lefiNonDefault::layerName(i));
if (def->lefiNonDefault::hasLayerWidth(i))
fprintf(fout, " WIDTH %g ;\n", def->lefiNonDefault::layerWidth(i));
if (def->lefiNonDefault::hasLayerSpacing(i))
fprintf(fout, " SPACING %g ;\n",
def->lefiNonDefault::layerSpacing(i));
if (def->lefiNonDefault::hasLayerDiagWidth(i))
fprintf(fout, " DIAGWIDTH %g ;\n",
def->lefiNonDefault::layerDiagWidth(i));
if (def->lefiNonDefault::hasLayerWireExtension(i))
fprintf(fout, " WIREEXTENSION %g ;\n",
def->lefiNonDefault::layerWireExtension(i));
if (def->lefiNonDefault::hasLayerResistance(i))
fprintf(fout, " RESISTANCE RPERSQ %g ;\n",
def->lefiNonDefault::layerResistance(i));
if (def->lefiNonDefault::hasLayerCapacitance(i))
fprintf(fout, " CAPACITANCE CPERSQDIST %g ;\n",
def->lefiNonDefault::layerCapacitance(i));
if (def->lefiNonDefault::hasLayerEdgeCap(i))
fprintf(fout, " EDGECAPACITANCE %g ;\n",
def->lefiNonDefault::layerEdgeCap(i));
fprintf(fout, " END %s\n", def->lefiNonDefault::layerName(i));
// handle via in nondefaultrule
for (i = 0; i < def->lefiNonDefault::numVias(); i++) {
via = def->lefiNonDefault::viaRule(i);
// handle spacing in nondefaultrule
for (i = 0; i < def->lefiNonDefault::numSpacingRules(); i++) {
spacing = def->lefiNonDefault::spacingRule(i);
for (i = 0; i < def->lefiNonDefault::numUseVia(); i++)
fprintf(fout, " USEVIA %s ;\n", def->lefiNonDefault::viaName(i));
for (i = 0; i < def->lefiNonDefault::numUseViaRule(); i++)
fprintf(fout, " USEVIARULE %s ;\n",
def->lefiNonDefault::viaRuleName(i));
for (i = 0; i < def->lefiNonDefault::numMinCuts(); i++) {
fprintf(fout, " MINCUTS %s %d ;\n", def->lefiNonDefault::cutLayerName(i),
def->lefiNonDefault::numCuts(i));
// handle property in nondefaultrule
if (def->lefiNonDefault::numProps() > 0) {
for (i = 0; i < def->lefiNonDefault::numProps(); i++) {
fprintf(fout, "%s ", def->lefiNonDefault::propName(i));
if (def->lefiNonDefault::propIsNumber(i))
fprintf(fout, "%g ", def->lefiNonDefault::propNumber(i));
if (def->lefiNonDefault::propIsString(i))
fprintf(fout, "%s ", def->lefiNonDefault::propValue(i));
switch(def->lefiNonDefault::propType(i)) {
case 'R': fprintf(fout, "REAL ");
case 'I': fprintf(fout, "INTEGER ");
case 'S': fprintf(fout, "STRING ");
case 'Q': fprintf(fout, "QUOTESTRING ");
case 'N': fprintf(fout, "NUMBER ");
fprintf(fout, "END %s ;\n", def->lefiNonDefault::name());
int obstructionCB(lefrCallbackType_e c, lefiObstruction* obs,
geometry = obs->lefiObstruction::geometries();
int pinCB(lefrCallbackType_e c, lefiPin* pin, lefiUserData ud) {
fprintf(fout, " PIN %s\n", pin->lefiPin::name());
if (pin->lefiPin::hasForeign()) {
for (i = 0; i < pin->lefiPin::numForeigns(); i++) {
if (pin->lefiPin::hasForeignOrient(i))
fprintf(fout, " FOREIGN %s STRUCTURE ( %g %g ) %s ;\n",
pin->lefiPin::foreignName(i), pin->lefiPin::foreignX(i),
pin->lefiPin::foreignOrientStr(i));
else if (pin->lefiPin::hasForeignPoint(i))
fprintf(fout, " FOREIGN %s STRUCTURE ( %g %g ) ;\n",
pin->lefiPin::foreignName(i), pin->lefiPin::foreignX(i),
fprintf(fout, " FOREIGN %s ;\n", pin->lefiPin::foreignName(i));
fprintf(fout, " LEQ %s ;\n", pin->lefiPin::LEQ());
if (pin->lefiPin::hasDirection())
fprintf(fout, " DIRECTION %s ;\n", pin->lefiPin::direction());
fprintf(fout, " USE %s ;\n", pin->lefiPin::use());
fprintf(fout, " SHAPE %s ;\n", pin->lefiPin::shape());
if (pin->lefiPin::hasMustjoin())
fprintf(fout, " MUSTJOIN %s ;\n", pin->lefiPin::mustjoin());
if (pin->lefiPin::hasOutMargin())
fprintf(fout, " OUTPUTNOISEMARGIN %g %g ;\n",
pin->lefiPin::outMarginHigh(), pin->lefiPin::outMarginLow());
if (pin->lefiPin::hasOutResistance())
fprintf(fout, " OUTPUTRESISTANCE %g %g ;\n",
pin->lefiPin::outResistanceHigh(),
pin->lefiPin::outResistanceLow());
if (pin->lefiPin::hasInMargin())
fprintf(fout, " INPUTNOISEMARGIN %g %g ;\n",
pin->lefiPin::inMarginHigh(), pin->lefiPin::inMarginLow());
fprintf(fout, " POWER %g ;\n", pin->lefiPin::power());
if (pin->lefiPin::hasLeakage())
fprintf(fout, " LEAKAGE %g ;\n", pin->lefiPin::leakage());
if (pin->lefiPin::hasMaxload())
fprintf(fout, " MAXLOAD %g ;\n", pin->lefiPin::maxload());
if (pin->lefiPin::hasCapacitance())
fprintf(fout, " CAPACITANCE %g ;\n", pin->lefiPin::capacitance());
if (pin->lefiPin::hasResistance())
fprintf(fout, " RESISTANCE %g ;\n", pin->lefiPin::resistance());
if (pin->lefiPin::hasPulldownres())
fprintf(fout, " PULLDOWNRES %g ;\n", pin->lefiPin::pulldownres());
if (pin->lefiPin::hasTieoffr())
fprintf(fout, " TIEOFFR %g ;\n", pin->lefiPin::tieoffr());
fprintf(fout, " VHI %g ;\n", pin->lefiPin::VHI());
fprintf(fout, " VLO %g ;\n", pin->lefiPin::VLO());
if (pin->lefiPin::hasRiseVoltage())
fprintf(fout, " RISEVOLTAGETHRESHOLD %g ;\n",
if (pin->lefiPin::hasFallVoltage())
fprintf(fout, " FALLVOLTAGETHRESHOLD %g ;\n",
if (pin->lefiPin::hasRiseThresh())
fprintf(fout, " RISETHRESH %g ;\n", pin->lefiPin::riseThresh());
if (pin->lefiPin::hasFallThresh())
fprintf(fout, " FALLTHRESH %g ;\n", pin->lefiPin::fallThresh());
if (pin->lefiPin::hasRiseSatcur())
fprintf(fout, " RISESATCUR %g ;\n", pin->lefiPin::riseSatcur());
if (pin->lefiPin::hasFallSatcur())
fprintf(fout, " FALLSATCUR %g ;\n", pin->lefiPin::fallSatcur());
if (pin->lefiPin::hasRiseSlewLimit())
fprintf(fout, " RISESLEWLIMIT %g ;\n", pin->lefiPin::riseSlewLimit());
if (pin->lefiPin::hasFallSlewLimit())
fprintf(fout, " FALLSLEWLIMIT %g ;\n", pin->lefiPin::fallSlewLimit());
if (pin->lefiPin::hasCurrentSource())
fprintf(fout, " CURRENTSOURCE %s ;\n", pin->lefiPin::currentSource());
if (pin->lefiPin::hasTables())
fprintf(fout, " IV_TABLES %s %s ;\n", pin->lefiPin::tableHighName(),
pin->lefiPin::tableLowName());
if (pin->lefiPin::hasTaperRule())
fprintf(fout, " TAPERRULE %s ;\n", pin->lefiPin::taperRule());
if (pin->lefiPin::hasNetExpr())
fprintf(fout, " NETEXPR \"%s\" ;\n", pin->lefiPin::netExpr());
if (pin->lefiPin::hasSupplySensitivity())
fprintf(fout, " SUPPLYSENSITIVITY %s ;\n",
pin->lefiPin::supplySensitivity());
if (pin->lefiPin::hasGroundSensitivity())
fprintf(fout, " GROUNDSENSITIVITY %s ;\n",
pin->lefiPin::groundSensitivity());
if (pin->lefiPin::hasAntennaSize()) {
for (i = 0; i < pin->lefiPin::numAntennaSize(); i++) {
fprintf(fout, " ANTENNASIZE %g ", pin->lefiPin::antennaSize(i));
if (pin->lefiPin::antennaSizeLayer(i))
fprintf(fout, "LAYER %s ", pin->lefiPin::antennaSizeLayer(i));
if (pin->lefiPin::hasAntennaMetalArea()) {
for (i = 0; i < pin->lefiPin::numAntennaMetalArea(); i++) {
fprintf(fout, " ANTENNAMETALAREA %g ",
pin->lefiPin::antennaMetalArea(i));
if (pin->lefiPin::antennaMetalAreaLayer(i))
fprintf(fout, "LAYER %s ", pin->lefiPin::antennaMetalAreaLayer(i));
if (pin->lefiPin::hasAntennaMetalLength()) {
for (i = 0; i < pin->lefiPin::numAntennaMetalLength(); i++) {
fprintf(fout, " ANTENNAMETALLENGTH %g ",
pin->lefiPin::antennaMetalLength(i));
if (pin->lefiPin::antennaMetalLengthLayer(i))
fprintf(fout, "LAYER %s ", pin->lefiPin::antennaMetalLengthLayer(i));
if (pin->lefiPin::hasAntennaPartialMetalArea()) {
for (i = 0; i < pin->lefiPin::numAntennaPartialMetalArea(); i++) {
fprintf(fout, " ANTENNAPARTIALMETALAREA %g ",
pin->lefiPin::antennaPartialMetalArea(i));
if (pin->lefiPin::antennaPartialMetalAreaLayer(i))
pin->lefiPin::antennaPartialMetalAreaLayer(i));
if (pin->lefiPin::hasAntennaPartialMetalSideArea()) {
for (i = 0; i < pin->lefiPin::numAntennaPartialMetalSideArea(); i++) {
fprintf(fout, " ANTENNAPARTIALMETALSIDEAREA %g ",
pin->lefiPin::antennaPartialMetalSideArea(i));
if (pin->lefiPin::antennaPartialMetalSideAreaLayer(i))
pin->lefiPin::antennaPartialMetalSideAreaLayer(i));
if (pin->lefiPin::hasAntennaPartialCutArea()) {
for (i = 0; i < pin->lefiPin::numAntennaPartialCutArea(); i++) {
fprintf(fout, " ANTENNAPARTIALCUTAREA %g ",
pin->lefiPin::antennaPartialCutArea(i));
if (pin->lefiPin::antennaPartialCutAreaLayer(i))
pin->lefiPin::antennaPartialCutAreaLayer(i));
if (pin->lefiPin::hasAntennaDiffArea()) {
for (i = 0; i < pin->lefiPin::numAntennaDiffArea(); i++) {
fprintf(fout, " ANTENNADIFFAREA %g ",
pin->lefiPin::antennaDiffArea(i));
if (pin->lefiPin::antennaDiffAreaLayer(i))
fprintf(fout, "LAYER %s ", pin->lefiPin::antennaDiffAreaLayer(i));
for (j = 0; j < pin->lefiPin::numAntennaModel(); j++) {
aModel = pin->lefiPin::antennaModel(j);
fprintf(fout, " ANTENNAMODEL %s ;\n",
aModel->lefiPinAntennaModel::antennaOxide());
if (aModel->lefiPinAntennaModel::hasAntennaGateArea()) {
for (i = 0; i < aModel->lefiPinAntennaModel::numAntennaGateArea(); i++)
fprintf(fout, " ANTENNAGATEAREA %g ",
aModel->lefiPinAntennaModel::antennaGateArea(i));
if (aModel->lefiPinAntennaModel::antennaGateAreaLayer(i))
aModel->lefiPinAntennaModel::antennaGateAreaLayer(i));
if (aModel->lefiPinAntennaModel::hasAntennaMaxAreaCar()) {
for (i = 0; i < aModel->lefiPinAntennaModel::numAntennaMaxAreaCar();
fprintf(fout, " ANTENNAMAXAREACAR %g ",
aModel->lefiPinAntennaModel::antennaMaxAreaCar(i));
if (aModel->lefiPinAntennaModel::antennaMaxAreaCarLayer(i))
aModel->lefiPinAntennaModel::antennaMaxAreaCarLayer(i));
if (aModel->lefiPinAntennaModel::hasAntennaMaxSideAreaCar()) {
for (i = 0; i < aModel->lefiPinAntennaModel::numAntennaMaxSideAreaCar();
fprintf(fout, " ANTENNAMAXSIDEAREACAR %g ",
aModel->lefiPinAntennaModel::antennaMaxSideAreaCar(i));
if (aModel->lefiPinAntennaModel::antennaMaxSideAreaCarLayer(i))
aModel->lefiPinAntennaModel::antennaMaxSideAreaCarLayer(i));
if (aModel->lefiPinAntennaModel::hasAntennaMaxCutCar()) {
for (i = 0; i < aModel->lefiPinAntennaModel::numAntennaMaxCutCar(); i++)
fprintf(fout, " ANTENNAMAXCUTCAR %g ",
aModel->lefiPinAntennaModel::antennaMaxCutCar(i));
if (aModel->lefiPinAntennaModel::antennaMaxCutCarLayer(i))
aModel->lefiPinAntennaModel::antennaMaxCutCarLayer(i));
if (pin->lefiPin::numProperties() > 0) {
for (i = 0; i < pin->lefiPin::numProperties(); i++) {
// value can either be a string or number
if (pin->lefiPin::propValue(i)) {
fprintf(fout, "%s %s ", pin->lefiPin::propName(i),
fprintf(fout, "%s %g ", pin->lefiPin::propName(i),
switch (pin->lefiPin::propType(i)) {
case 'R': fprintf(fout, "REAL ");
case 'I': fprintf(fout, "INTEGER ");
case 'S': fprintf(fout, "STRING ");
case 'Q': fprintf(fout, "QUOTESTRING ");
case 'N': fprintf(fout, "NUMBER ");
numPorts = pin->lefiPin::numPorts();
for (i = 0; i < numPorts; i++) {
geometry = pin->lefiPin::port(i);
fprintf(fout, " END %s\n", pin->lefiPin::name());
int densityCB(lefrCallbackType_e c, lefiDensity* density,
for (int i = 0; i < density->lefiDensity::numLayer(); i++) {
fprintf(fout, " LAYER %s ;\n", density->lefiDensity::layerName(i));
for (int j = 0; j < density->lefiDensity::numRects(i); j++) {
rect = density->lefiDensity::getRect(i,j);
fprintf(fout, " RECT %g %g %g %g ", rect.xl, rect.yl, rect.xh,
fprintf(fout, "%g ;\n", density->lefiDensity::densityValue(i,j));
int propDefBeginCB(lefrCallbackType_e c, void* ptr, lefiUserData ud) {
fprintf(fout, "PROPERTYDEFINITIONS\n");
int propDefCB(lefrCallbackType_e c, lefiProp* prop, lefiUserData ud) {
fprintf(fout, " %s %s", prop->lefiProp::propType(),
switch(prop->lefiProp::dataType()) {
if (prop->lefiProp::hasNumber())
fprintf(fout, " %g", prop->lefiProp::number());
if (prop->lefiProp::hasRange())
fprintf(fout, " RANGE %g %g", prop->lefiProp::left(),
if (prop->lefiProp::hasString())
fprintf(fout, " %s", prop->lefiProp::string());
int propDefEndCB(lefrCallbackType_e c, void* ptr, lefiUserData ud) {
fprintf(fout, "END PROPERTYDEFINITIONS\n");
int siteCB(lefrCallbackType_e c, lefiSite* site, lefiUserData ud) {
fprintf(fout, "SITE %s\n", site->lefiSite::name());
if (site->lefiSite::hasClass())
fprintf(fout, " CLASS %s ;\n", site->lefiSite::siteClass());
if (site->lefiSite::hasXSymmetry()) {
fprintf(fout, " SYMMETRY X ");
if (site->lefiSite::hasYSymmetry()) {
fprintf(fout, " SYMMETRY Y ");
if (site->lefiSite::has90Symmetry()) {
fprintf(fout, " SYMMETRY R90 ");
if (site->lefiSite::hasSize())
fprintf(fout, " SIZE %g BY %g ;\n", site->lefiSite::sizeX(),
fprintf(fout, " ROWPATTERN ");
for (i = 0; i < site->lefiSite::numSites(); i++)
fprintf(fout, " %s %s ", site->lefiSite::siteName(i),
site->lefiSite::siteOrientStr(i));
fprintf(fout, "END %s\n", site->lefiSite::name());
int spacingBeginCB(lefrCallbackType_e c, void* ptr, lefiUserData ud){
int spacingCB(lefrCallbackType_e c, lefiSpacing* spacing, lefiUserData ud) {
int spacingEndCB(lefrCallbackType_e c, void* ptr, lefiUserData ud){
fprintf(fout, "END SPACING\n");
int timingCB(lefrCallbackType_e c, lefiTiming* timing, lefiUserData ud) {
for (i = 0; i < timing->numFromPins(); i++)
fprintf(fout, " FROMPIN %s ;\n", timing->fromPin(i));
for (i = 0; i < timing->numToPins(); i++)
fprintf(fout, " TOPIN %s ;\n", timing->toPin(i));
fprintf(fout, " RISE SLEW1 %g %g %g %g ;\n", timing->riseSlewOne(),
timing->riseSlewTwo(), timing->riseSlewThree(),
fprintf(fout, " RISE SLEW2 %g %g %g ;\n", timing->riseSlewFive(),
timing->riseSlewSix(), timing->riseSlewSeven());
fprintf(fout, " FALL SLEW1 %g %g %g %g ;\n", timing->fallSlewOne(),
timing->fallSlewTwo(), timing->fallSlewThree(),
fprintf(fout, " FALL SLEW2 %g %g %g ;\n", timing->fallSlewFive(),
timing->fallSlewSix(), timing->riseSlewSeven());
if (timing->hasRiseIntrinsic()) {
fprintf(fout, "TIMING RISE INTRINSIC %g %g ;\n",
timing->riseIntrinsicOne(), timing->riseIntrinsicTwo());
fprintf(fout, "TIMING RISE VARIABLE %g %g ;\n",
timing->riseIntrinsicThree(), timing->riseIntrinsicFour());
if (timing->hasFallIntrinsic()) {
fprintf(fout, "TIMING FALL INTRINSIC %g %g ;\n",
timing->fallIntrinsicOne(), timing->fallIntrinsicTwo());
fprintf(fout, "TIMING RISE VARIABLE %g %g ;\n",
timing->fallIntrinsicThree(), timing->fallIntrinsicFour());
fprintf(fout, "TIMING RISERS %g %g ;\n",
timing->riseRSOne(), timing->riseRSTwo());
fprintf(fout, "TIMING RISECS %g %g ;\n",
timing->riseCSOne(), timing->riseCSTwo());
fprintf(fout, "TIMING FALLRS %g %g ;\n",
timing->fallRSOne(), timing->fallRSTwo());
fprintf(fout, "TIMING FALLCS %g %g ;\n",
timing->fallCSOne(), timing->fallCSTwo());
fprintf(fout, "TIMING UNATENESS %s ;\n", timing->unateness());
fprintf(fout, "TIMING RISESATT1 %g %g ;\n", timing->riseAtt1One(),
fprintf(fout, "TIMING FALLSATT1 %g %g ;\n", timing->fallAtt1One(),
fprintf(fout, "TIMING RISET0 %g %g ;\n", timing->riseToOne(),
fprintf(fout, "TIMING FALLT0 %g %g ;\n", timing->fallToOne(),
if (timing->hasSDFonePinTrigger())
fprintf(fout, " %s TABLEDIMENSION %g %g %g ;\n",
timing->SDFonePinTriggerType(), timing->SDFtriggerOne(),
timing->SDFtriggerTwo(), timing->SDFtriggerThree());
if (timing->hasSDFtwoPinTrigger())
fprintf(fout, " %s %s %s TABLEDIMENSION %g %g %g ;\n",
timing->SDFtwoPinTriggerType(), timing->SDFfromTrigger(),
timing->SDFtoTrigger(), timing->SDFtriggerOne(),
timing->SDFtriggerTwo(), timing->SDFtriggerThree());
fprintf(fout, "END TIMING\n");
int unitsCB(lefrCallbackType_e c, lefiUnits* unit, lefiUserData ud) {
if (unit->lefiUnits::hasDatabase())
fprintf(fout, " DATABASE %s %g ;\n", unit->lefiUnits::databaseName(),
unit->lefiUnits::databaseNumber());
if (unit->lefiUnits::hasCapacitance())
fprintf(fout, " CAPACITANCE PICOFARADS %g ;\n",
unit->lefiUnits::capacitance());
if (unit->lefiUnits::hasResistance())
fprintf(fout, " RESISTANCE OHMS %g ;\n", unit->lefiUnits::resistance());
if (unit->lefiUnits::hasPower())
fprintf(fout, " POWER MILLIWATTS %g ;\n", unit->lefiUnits::power());
if (unit->lefiUnits::hasCurrent())
fprintf(fout, " CURRENT MILLIAMPS %g ;\n", unit->lefiUnits::current());
if (unit->lefiUnits::hasVoltage())
fprintf(fout, " VOLTAGE VOLTS %g ;\n", unit->lefiUnits::voltage());
if (unit->lefiUnits::hasFrequency())
fprintf(fout, " FREQUENCY MEGAHERTZ %g ;\n",
unit->lefiUnits::frequency());
int useMinSpacingCB(lefrCallbackType_e c, lefiUseMinSpacing* spacing,
fprintf(fout, "USEMINSPACING %s ", spacing->lefiUseMinSpacing::name());
if (spacing->lefiUseMinSpacing::value())
int versionCB(lefrCallbackType_e c, double num, lefiUserData ud) {
fprintf(fout, "VERSION %g ;\n", num);
int versionStrCB(lefrCallbackType_e c, const char* versionName, lefiUserData ud) {
fprintf(fout, "VERSION %s ;\n", versionName);
int viaCB(lefrCallbackType_e c, lefiVia* via, lefiUserData ud) {
int viaRuleCB(lefrCallbackType_e c, lefiViaRule* viaRule, lefiUserData ud) {
fprintf(fout, "VIARULE %s", viaRule->lefiViaRule::name());
if (viaRule->lefiViaRule::hasGenerate())
if (viaRule->lefiViaRule::hasDefault())
numLayers = viaRule->lefiViaRule::numLayers();
for (i = 0; i < numLayers; i++) {
vLayer = viaRule->lefiViaRule::layer(i);
if (numLayers == 2 && !(viaRule->lefiViaRule::hasGenerate())) {
numVias = viaRule->lefiViaRule::numVias();
fprintf(fout, "Should have via names in VIARULE.\n");
fprintf(fout, " VIA %s ;\n", viaRule->lefiViaRule::viaName(i));
if (viaRule->lefiViaRule::numProps() > 0) {
for (i = 0; i < viaRule->lefiViaRule::numProps(); i++) {
fprintf(fout, "%s ", viaRule->lefiViaRule::propName(i));
if (viaRule->lefiViaRule::propValue(i))
fprintf(fout, "%s ", viaRule->lefiViaRule::propValue(i));
switch (viaRule->lefiViaRule::propType(i)) {
case 'R': fprintf(fout, "REAL ");
case 'I': fprintf(fout, "INTEGER ");
case 'S': fprintf(fout, "STRING ");
case 'Q': fprintf(fout, "QUOTESTRING ");
case 'N': fprintf(fout, "NUMBER ");
fprintf(fout, "END %s\n", viaRule->lefiViaRule::name());
int extensionCB(lefrCallbackType_e c, const char* extsn, lefiUserData ud) {
fprintf(fout, "BEGINEXT %s ;\n", extsn);
int doneCB(lefrCallbackType_e c, void* ptr, lefiUserData ud) {
fprintf(fout, "END LIBRARY\n");
void errorCB(const char* msg) {
printf ("%s : %s\n", lefrGetUserData(), msg);
void warningCB(const char* msg) {
printf ("%s : %s\n", lefrGetUserData(), msg);
void* reallocCB(void* name, int size) {
void lineNumberCB(int lineNo) {
fprintf(fout, "Parsed %d number of lines!!\n", lineNo);
userData = strdup ("(lefrw-5100)");
if (strcmp(*argv, "-d") == 0) {
} else if (strcmp(*argv, "-nc") == 0) {
} else if (strcmp(*argv, "-p") == 0) {
} else if (strcmp(*argv, "-m") == 0) { // use the user error/warning CB
} else if (strcmp(*argv, "-o") == 0) {
if ((fout = fopen(outFile, "w")) == 0) {
fprintf(stderr, "ERROR: could not open output file\n");
} else if (strcmp(*argv, "-verStr") == 0) {
/* New to set the version callback routine to return a string */
} else if (strcmp(*argv, "-relax") == 0) {
} else if (strcmp(*argv, "-65nm") == 0) {
} else if (strcmp(*argv, "-ver") == 0) {
} else if (argv[0][0] != '-') {
fprintf(stderr, "ERROR: too many input files, max = 3.\n");
fprintf(stderr, "ERROR: Illegal command line option: '%s'\n", *argv);
lefrSetAntennaInputCbk(antennaCB);
lefrSetAntennaInoutCbk(antennaCB);
lefrSetAntennaOutputCbk(antennaCB);
lefrSetArrayBeginCbk(arrayBeginCB);
lefrSetArrayEndCbk(arrayEndCB);
lefrSetBusBitCharsCbk(busBitCharsCB);
lefrSetCaseSensitiveCbk(caseSensCB);
lefrSetClearanceMeasureCbk(clearanceCB);
lefrSetDividerCharCbk(dividerCB);
lefrSetNoWireExtensionCbk(noWireExtCB);
lefrSetEdgeRateThreshold1Cbk(edge1CB);
lefrSetEdgeRateThreshold2Cbk(edge2CB);
lefrSetEdgeRateScaleFactorCbk(edgeScaleCB);
lefrSetExtensionCbk(extensionCB);
lefrSetDielectricCbk(dielectricCB);
lefrSetIRDropBeginCbk(irdropBeginCB);
lefrSetIRDropEndCbk(irdropEndCB);
lefrSetMacroBeginCbk(macroBeginCB);
lefrSetMacroClassTypeCbk(macroClassTypeCB);
lefrSetMacroEndCbk(macroEndCB);
lefrSetManufacturingCbk(manufacturingCB);
lefrSetMaxStackViaCbk(maxStackViaCB);
lefrSetMinFeatureCbk(minFeatureCB);
lefrSetNonDefaultCbk(nonDefaultCB);
lefrSetObstructionCbk(obstructionCB);
lefrSetPropBeginCbk(propDefBeginCB);
lefrSetPropEndCbk(propDefEndCB);
lefrSetSpacingBeginCbk(spacingBeginCB);
lefrSetSpacingEndCbk(spacingEndCB);
lefrSetUseMinSpacingCbk(useMinSpacingCB);
lefrSetVersionStrCbk(versionStrCB);
lefrSetInputAntennaCbk(antennaCB);
lefrSetOutputAntennaCbk(antennaCB);
lefrSetInoutAntennaCbk(antennaCB);
lefrSetWarningLogFunction(warningCB);
lefrSetMallocFunction(mallocCB);
lefrSetReallocFunction(reallocCB);
lefrSetLineNumberFunction(lineNumberCB);
lefrSetRegisterUnusedCallbacks();
(void)lefrSetVersionValue(version);
lefrSetAntennaInoutWarnings(30);
lefrSetAntennaInputWarnings(30);
lefrSetAntennaOutputWarnings(30);
lefrSetCaseSensitiveWarnings(30);
lefrSetCorrectionTableWarnings(30);
lefrSetDielectricWarnings(30);
lefrSetEdgeRateThreshold1Warnings(30);
lefrSetEdgeRateThreshold2Warnings(30);
lefrSetEdgeRateScaleFactorWarnings(30);
lefrSetInoutAntennaWarnings(30);
lefrSetInputAntennaWarnings(30);
lefrSetMaxStackViaWarnings(30);
lefrSetMinFeatureWarnings(30);
lefrSetNoiseMarginWarnings(30);
lefrSetNoiseTableWarnings(30);
lefrSetNonDefaultWarnings(30);
lefrSetNoWireExtensionWarnings(30);
lefrSetOutputAntennaWarnings(30);
lefrSetUseMinSpacingWarnings(30);
(void) lefrSetShiftCase(); // will shift name to uppercase if caseinsensitive
for (fileCt = 0; fileCt < numInFile; fileCt++) {
if ((f = fopen(inFile[fileCt],"r")) == 0) {
fprintf(stderr,"Couldn't open input file '%s'\n", inFile[fileCt]);
(void)lefrEnableReadEncrypted();
status = lefwInit(fout); // initialize the lef writer, need to be called 1st
res = lefrRead(f, inFile[fileCt], (void*)userData);
fprintf(stderr, "Reader returns bad status.\n", inFile[fileCt]);
(void)lefrPrintUnusedCallbacks(fout);
(void)lefrReleaseNResetMemory();
#define CHECK_STATUS(status) \
int main(int argc, char** argv) {
int status; // return code, if none 0 means error
if (strcmp(*argv, "-o") == 0) { // output filename
if ((fout = fopen(outfile, "w")) == 0) {
fprintf(stderr, "ERROR: could not open output file\n");
} else if (strncmp(*argv, "-h", 2) == 0) { // compare with -h[elp]
fprintf(stderr, "Usage: lefwrite [-o <filename>] [-help]\n");
fprintf(stderr, "ERROR: Illegal command line option: '%s'\n", *argv);
status = lefwBusBitChars("<>");
status = lefwDividerChar(":");
status = lefwManufacturingGrid(3.5);
status = lefwUseMinSpacing("OBS", "OFF");
status = lefwClearanceMeasure("EUCLIDEAN");
status = lefwAntennaInputGateArea(45);
status = lefwAntennaInOutDiffArea(65);
status = lefwAntennaOutputDiffArea(55);
status = lefwUnits(100, 10, 10000, 10000, 10000, 1000, 20000);
status = lefwUnitsFrequency(10);
status = lefwStringPropDef("LIBRARY", "NAME", 0, 0, "Cadence96");
status = lefwIntPropDef("LIBRARY", "intNum", 0, 0, 20);
status = lefwRealPropDef("LIBRARY", "realNum", 0, 0, 21.22);
status = lefwStringPropDef("PIN", "TYPE", 0, 0, 0);
status = lefwIntPropDef("PIN", "intProp", 0, 0, 0);
status = lefwRealPropDef("PIN", "realProp", 0, 0, 0);
status = lefwStringPropDef("MACRO", "stringProp", 0, 0, 0);
status = lefwIntPropDef("MACRO", "integerProp", 0, 0, 0);
status = lefwRealPropDef("MACRO", "WEIGHT", 1.0, 100.0, 0);
status = lefwStringPropDef("VIA", "stringProperty", 0, 0, 0);
status = lefwRealPropDef("VIA", "realProp", 0, 0, 0);
status = lefwIntPropDef("VIA", "COUNT", 1, 100, 0);
status = lefwStringPropDef("LAYER", "lsp", 0, 0, 0);
status = lefwIntPropDef("LAYER", "lip", 0, 0, 0);
status = lefwRealPropDef("LAYER", "lrp", 0, 0, 0);
status = lefwStringPropDef("VIARULE", "vrsp", 0, 0, 0);
status = lefwRealPropDef("VIARULE", "vrip", 0, 0, 0);
status = lefwIntPropDef("VIARULE", "vrrp", 0, 0, 0);
status = lefwStringPropDef("NONDEFAULTRULE", "ndrsp", 0, 0, 0);
status = lefwIntPropDef("NONDEFAULTRULE", "ndrip", 0, 0, 0);
status = lefwRealPropDef("NONDEFAULTRULE", "ndrrp", 0, 0, 0);
current = (double*)malloc(sizeof(double)*15);
diffs = (double*)malloc(sizeof(double)*15);
ratios = (double*)malloc(sizeof(double)*15);
status = lefwStartLayer("POLYS", "MASTERSLICE");
status = lefwStringProperty("lsp", "top");
status = lefwIntProperty("lip", 1);
status = lefwRealProperty("lrp", 2.3);
status = lefwEndLayer("POLYS");
status = lefwStartLayer("CUT01", "CUT");
status = lefwLayerDCCurrentDensity("AVERAGE", 0);
status = lefwLayerDCCutarea(3, current);
status = lefwLayerDCTableEntries(3, current);
status = lefwEndLayer("CUT01");
status = lefwStartLayerRouting("RX");
status = lefwLayerRouting("HORIZONTAL", 1);
status = lefwLayerRoutingPitch(1.8);
status = lefwLayerRoutingDiagPitch(1.5);
status = lefwLayerRoutingDiagWidth(1.0);
status = lefwLayerRoutingDiagSpacing(0.05);
status = lefwLayerRoutingDiagMinEdgeLength(0.07);
status = lefwLayerRoutingArea(34.1);
xl = (double*)malloc(sizeof(double)*2);
yl = (double*)malloc(sizeof(double)*2);
status = lefwLayerRoutingMinsize(2, xl, yl);
status = lefwLayerRoutingWireExtension(0.75);
status = lefwLayerRoutingOffset(0.9);
status = lefwLayerRoutingSpacing(0.6);
status = lefwLayerRoutingSpacingRange(0.1, 9);
status = lefwLayerRoutingResistance("0.103");
status = lefwLayerRoutingCapacitance("0.000156");
status = lefwLayerRoutingHeight(9);
status = lefwLayerRoutingThickness(1);
status = lefwLayerRoutingShrinkage(0.1);
status = lefwLayerRoutingEdgeCap(0.00005);
status = lefwLayerRoutingCapMultiplier(1);
status = lefwLayerRoutingMinwidth(0.15);
status = lefwLayerRoutingAntennaArea(1);
status = lefwLayerAntennaCumAreaRatio(6.7); // 5.7
status = lefwLayerAntennaCumRoutingPlusCut(); // 5.7
status = lefwLayerAntennaAreaMinusDiff(100.0); // 5.7
status = lefwLayerAntennaGatePlusDiff(2.0); // 5.7
status = lefwLayerAntennaCumDiffAreaRatio(1000); // 5.7
xl = (double*)malloc(sizeof(double)*5);
yl = (double*)malloc(sizeof(double)*5);
status = lefwLayerAntennaAreaDiffReducePwl(5, xl, yl); // 5.7
status = lefwLayerAntennaCumDiffAreaRatio(1000); // 5.7
status = lefwLayerRoutingAntennaLength(1);
status = lefwLayerACCurrentDensity("PEAK", 0);
status = lefwLayerACFrequency(3, current);
status = lefwLayerACCutarea(4, current);
status = lefwLayerACWidth(5, current);
status = lefwLayerACTableEntries(15, current);
status = lefwLayerACCurrentDensity("AVERAGE", 0);
status = lefwLayerACFrequency(3, current);
status = lefwLayerACTableEntries(3, current);
status = lefwLayerACCurrentDensity("RMS", 0);
status = lefwLayerACFrequency(3, current);
status = lefwLayerACWidth(5, current);
status = lefwLayerACTableEntries(15, current);
status = lefwEndLayerRouting("RX");
status = lefwStartLayer("CUT12", "CUT");
status = lefwLayerCutSpacing(0.7);
status = lefwLayerCutSpacingLayer("RX", 0);
status = lefwLayerCutSpacingEnd();
status = lefwLayerResistancePerCut(8.0);
status = lefwLayerCutSpacing(0.22); // 5.7
status = lefwLayerCutSpacingAdjacent(3, 0.25, 0); // 5.7
status = lefwLayerCutSpacingEnd(); // 5.7
status = lefwLayerCutSpacing(1.5); // 5.7
status = lefwLayerCutSpacingParallel(); // 5.7
status = lefwLayerCutSpacingEnd(); // 5.7
status = lefwLayerCutSpacing(1.2); // 5.7
status = lefwLayerCutSpacingAdjacent(2, 1.5, 0); // 5.7
status = lefwLayerCutSpacingEnd(); // 5.7
status = lefwLayerAntennaModel("OXIDE1");
status = lefwLayerAntennaAreaRatio(5.6);
status = lefwLayerAntennaDiffAreaRatio(6.5);
status = lefwLayerAntennaAreaFactor(5.4, 0);
status = lefwLayerAntennaCumDiffAreaRatio(4.5);
status = lefwLayerAntennaCumDiffAreaRatioPwl(3, diffs, ratios);
status = lefwLayerAntennaCumAreaRatio(6.7);
status = lefwLayerAntennaModel("OXIDE2");
status = lefwLayerAntennaCumAreaRatio(300);
status = lefwLayerAntennaCumRoutingPlusCut(); // 5.7
status = lefwLayerAntennaAreaMinusDiff(100.0); // 5.7
status = lefwLayerAntennaGatePlusDiff(2.0); // 5.7
status = lefwLayerAntennaDiffAreaRatio(1000); // 5.7
status = lefwLayerAntennaCumDiffAreaRatio(5000); // 5.7
xl = (double*)malloc(sizeof(double)*5);
yl = (double*)malloc(sizeof(double)*5);
status = lefwLayerAntennaAreaDiffReducePwl(5, xl, yl); // 5.7
status = lefwLayerAntennaCumDiffAreaRatioPwl(2, diffs, ratios);
status = lefwLayerACCurrentDensity("PEAK", 0);
status = lefwLayerACFrequency(2, current);
status = lefwLayerACTableEntries(2, current);
status = lefwLayerACCurrentDensity("AVERAGE", 0);
status = lefwLayerACFrequency(2, current);
status = lefwLayerACTableEntries(2, current);
status = lefwLayerACCurrentDensity("RMS", 0);
status = lefwLayerACFrequency(2, current);
status = lefwLayerACTableEntries(2, current);
status = lefwEndLayer("CUT12");
status = lefwStartLayerRouting("PC");
status = lefwLayerRouting("DIAG45", 1);
status = lefwLayerRoutingPitch(1.8);
status = lefwLayerRoutingWireExtension(0.4);
status = lefwLayerRoutingSpacing(0.6);
status = lefwLayerRoutingSpacing(1.2); // 5.7
status = lefwLayerRoutingSpacingEndOfLine(1.3, 0.6); // 5.7
status = lefwLayerRoutingSpacing(1.3); // 5.7
status = lefwLayerRoutingSpacingEndOfLine(1.4, 0.7); // 5.7
status = lefwLayerRoutingSpacingEOLParallel(1.1, 0.5, 1); // 5.7
status = lefwLayerRoutingSpacing(1.4); // 5.7
status = lefwLayerRoutingSpacingEndOfLine(1.5, 0.8); // 5.7
status = lefwLayerRoutingSpacingEOLParallel(1.2, 0.6, 0); // 5.7
status = lefwLayerRoutingOffsetXYDistance(0.9, 0.7);
status = lefwLayerRoutingResistance("PWL ( ( 1 0.103 ) )");
status = lefwLayerRoutingCapacitance("PWL ( ( 1 0.000156 ) ( 10 0.001 ) )");
status = lefwLayerAntennaAreaRatio(5.4);
status = lefwLayerAntennaDiffAreaRatio(6.5);
status = lefwLayerAntennaDiffAreaRatioPwl(2, diffs, ratios);
status = lefwLayerAntennaCumAreaRatio(7.5);
status = lefwLayerAntennaCumDiffAreaRatioPwl(2, diffs, ratios);
status = lefwLayerAntennaAreaFactor(4.5, 0);
status = lefwLayerAntennaSideAreaRatio(6.5);
status = lefwLayerAntennaCumDiffSideAreaRatio(4.6);
status = lefwLayerAntennaCumDiffSideAreaRatioPwl(4, diffs, ratios);
status = lefwLayerAntennaCumSideAreaRatio(7.4);
status = lefwLayerAntennaDiffSideAreaRatioPwl(2, diffs, ratios);
status = lefwLayerAntennaSideAreaFactor(9.0, "DIFFUSEONLY");
status = lefwLayerDCCurrentDensity("AVERAGE", 0);
status = lefwLayerDCWidth(3, current);
status = lefwLayerDCTableEntries(3, current);
status = lefwEndLayerRouting("PC");
status = lefwStartLayer("CA", "CUT");
status = lefwLayerCutSpacing(0.15); // 5.7
status = lefwLayerCutSpacingCenterToCenter(); // 5.7
status = lefwLayerCutSpacingEnd(); // 5.7
status = lefwLayerEnclosure("BELOW", 0.3, 0.01, 0);
status = lefwLayerEnclosure("ABOVE", 0.5, 0.01, 0);
status = lefwLayerPreferEnclosure("BELOW", 0.06, 0.01, 0);
status = lefwLayerPreferEnclosure("ABOVE", 0.08, 0.02, 0);
status = lefwLayerEnclosure("", 0.02, 0.02, 1.0);
status = lefwLayerEnclosure(NULL, 0.05, 0.05, 2.0);
status = lefwLayerEnclosure("BELOW", 0.07, 0.07, 1.0);
status = lefwLayerEnclosure("ABOVE", 0.09, 0.09, 1.0);
status = lefwLayerResistancePerCut(10.0);
status = lefwLayerDCCurrentDensity("AVERAGE", 0);
status = lefwLayerDCWidth(3, current);
status = lefwLayerDCTableEntries(3, current);
status = lefwStartLayerRouting("M1");
status = lefwLayerRouting("DIAG135", 1);
status = lefwLayerRoutingPitch(1.8);
status = lefwLayerRoutingSpacing(0.6);
status = lefwLayerRoutingSpacingRange(1.1, 100.1);
status = lefwLayerRoutingSpacingRangeUseLengthThreshold();
status = lefwLayerRoutingSpacing(0.61);
status = lefwLayerRoutingSpacingRange(1.1, 100.1);
status = lefwLayerRoutingSpacingRangeInfluence(2.01, 2.0, 1000.0);
status = lefwLayerRoutingSpacing(0.62);
status = lefwLayerRoutingSpacingRange(1.1, 100.1);
status = lefwLayerRoutingSpacingRangeRange(4.1, 6.5);
status = lefwLayerRoutingSpacing(0.63);
status = lefwLayerRoutingSpacingLengthThreshold(1.34, 4.5, 6.5);
status = lefwLayerRoutingWireExtension(7);
status = lefwLayerRoutingResistance("0.103");
status = lefwLayerRoutingCapacitance("0.000156");
status = lefwLayerRoutingStartSpacingtableParallel(4, current);
status = lefwLayerRoutingSpacingtableParallelWidth(0.00, 4, current);
status = lefwLayerRoutingSpacingtableParallelWidth(0.25, 4, current);
status = lefwLayerRoutingSpacingtableParallelWidth(1.50, 4, current);
status = lefwLayerRoutingSpacingtableParallelWidth(3.00, 4, current);
status = lefwLayerRoutingSpacingtableParallelWidth(5.00, 4, current);
status = lefwLayerRoutineEndSpacingtable();
status = lefwLayerRoutingStartSpacingtableInfluence();
status = lefwLayerRoutingSpacingInfluenceWidth(1.5, 0.5, 0.5);
status = lefwLayerRoutingSpacingInfluenceWidth(3.0, 1.0, 1.0);
status = lefwLayerRoutingSpacingInfluenceWidth(5.0, 2.0, 2.0);
status = lefwLayerRoutineEndSpacingtable();
status = lefwLayerRoutingStartSpacingtableInfluence();
status = lefwLayerRoutingSpacingInfluenceWidth(1.5, 0.5, 0.5);
status = lefwLayerRoutingSpacingInfluenceWidth(5.0, 2.0, 2.0);
status = lefwLayerRoutineEndSpacingtable();
status = lefwLayerRoutingStartSpacingtableParallel(3, current);
status = lefwLayerRoutingSpacingtableParallelWidth(0.00, 3, current);
status = lefwLayerRoutingSpacingtableParallelWidth(0.25, 3, current);
status = lefwLayerRoutingSpacingtableParallelWidth(3.00, 3, current);
status = lefwLayerRoutingSpacingtableParallelWidth(5.00, 3, current);
status = lefwLayerRoutineEndSpacingtable();
status = lefwLayerAntennaGatePlusDiff(2.0); // 5.7
status = lefwLayerAntennaDiffAreaRatio(1000); // 5.7
status = lefwLayerAntennaCumDiffAreaRatio(5000); // 5.7
status = lefwEndLayerRouting("M1");
status = lefwStartLayer("V1", "CUT");
status = lefwLayerCutSpacing(0.6);
status = lefwLayerCutSpacingLayer("CA", 0);
status = lefwLayerCutSpacingEnd();
status = lefwStartLayerRouting("M2");
status = lefwLayerRouting("VERTICAL", 0.9);
status = lefwLayerRoutingPitch(1.8);
status = lefwLayerRoutingWireExtension(8);
status = lefwLayerRoutingSpacing(0.9);
status = lefwLayerRoutingSpacingLengthThreshold(100.9, 0, 0);
status = lefwLayerRoutingSpacing(0.5);
status = lefwLayerRoutingSpacingLengthThreshold(0.9, 0, 0.1);
status = lefwLayerRoutingSpacing(0.6);
status = lefwLayerRoutingSpacingLengthThreshold(1.9, 0, 0);
status = lefwLayerRoutingSpacing(1.0); // 5.7
status = lefwLayerRoutingSpacingSameNet(1); // 5.7
status = lefwLayerRoutingSpacing(1.1); // 5.7
status = lefwLayerRoutingSpacingSameNet(0); // 5.7
status = lefwLayerRoutingResistance("0.0608");
status = lefwLayerRoutingCapacitance("0.000184");
status = lefwEndLayerRouting("M2");
status = lefwStartLayer("V2", "CUT");
status = lefwStartLayerRouting("M3");
status = lefwLayerRouting("HORIZONTAL", 0.9);
status = lefwLayerRoutingPitchXYDistance(1.8, 1.5);
status = lefwLayerRoutingDiagPitchXYDistance(1.5, 1.8);
status = lefwLayerRoutingWireExtension(8);
status = lefwLayerRoutingSpacing(0.9);
status = lefwLayerRoutingResistance("0.0608");
status = lefwLayerRoutingCapacitance("0.000184");
status = lefwEndLayerRouting("M3");
area = (double*)malloc(sizeof(double)*3);
width = (double*)malloc(sizeof(double)*3);
status = lefwStartLayerRouting("M4");
status = lefwLayerRouting("HORIZONTAL", 0.9);
status = lefwLayerRoutingMinimumcut(2, 0.50);
status = lefwLayerRoutingMinimumcut(2, 0.70);
status = lefwLayerRoutingMinimumcutConnections("FROMBELOW");
status = lefwLayerRoutingMinimumcut(4, 1.0);
status = lefwLayerRoutingMinimumcutConnections("FROMABOVE");
status = lefwLayerRoutingMinimumcut(2, 1.1);
status = lefwLayerRoutingMinimumcutLengthWithin(20.0, 5.0);
status = lefwLayerRoutingMinenclosedarea(3, area, width);
status = lefwLayerRoutingMaxwidth(10.0);
status = lefwLayerRoutingProtrusion(0.30, 0.60, 1.20);
status = lefwLayerRoutingMinstep(0.20);
status = lefwLayerRoutingMinstep(0.05);
status = lefwLayerRoutingMinstepWithOptions(0.05, NULL, 0.08);
status = lefwLayerRoutingMinstepWithOptions(0.05, NULL, 0.16);
status = lefwLayerRoutingMinstepWithOptions(0.05, "INSDECORNER", 0);
status = lefwLayerRoutingMinstepWithOptions(0.05, "INSIDECORNER", 0.15);
status = lefwLayerRoutingMinstepWithOptions(0.05, "STEP", 0);
status = lefwLayerRoutingMinstepWithOptions(0.05, "STEP", 0.08);
status = lefwLayerRoutingMinstepWithOptions(0.04, "STEP", 0);
status = lefwLayerRoutingMinstepMaxEdges(1.0, 2); // 5.7
status = lefwEndLayerRouting("M4");
status = lefwStartLayer("implant1", "IMPLANT");
status = lefwLayerWidth(0.50);
status = lefwLayerCutSpacing(0.50);
status = lefwLayerCutSpacingEnd();
status = lefwEndLayer("implant1");
status = lefwStartLayer("implant2", "IMPLANT");
status = lefwLayerWidth(0.50);
status = lefwLayerCutSpacing(0.50);
status = lefwLayerCutSpacingEnd();
status = lefwEndLayer("implant2");
status = lefwStartLayer("V3", "CUT");
status = lefwLayerWidth(0.60);
status = lefwStartLayerRouting("MT");
status = lefwLayerRouting("VERTICAL", 0.9);
status = lefwLayerRoutingPitch(1.8);
status = lefwLayerRoutingSpacing(0.9);
status = lefwLayerRoutingResistance("0.0608");
status = lefwLayerRoutingCapacitance("0.000184");
status = lefwEndLayerRouting("MT");
status = lefwStartLayer("OVERLAP", "OVERLAP");
status = lefwEndLayer("OVERLAP");
status = lefwStartLayerRouting("MET2");
status = lefwLayerRouting("VERTICAL", 0.9);
status = lefwMinimumDensity(20.2);
status = lefwMaximumDensity(80.0);
status = lefwDensityCheckWindow(200.0, 200.0);
status = lefwDensityCheckStep(100.0);
status = lefwFillActiveSpacing(3.0);
status = lefwEndLayerRouting("MET2");
status = lefwStartLayer("via34", "CUT"); // 5.7
status = lefwLayerWidth(0.25); // 5.7
status = lefwLayerCutSpacing(0.1); // 5.7
status = lefwLayerCutSpacingCenterToCenter(); // 5.7
status = lefwLayerCutSpacingEnd(); // 5.7
status = lefwLayerEnclosure(0, .05, .01, 0); // 5.7
status = lefwLayerEnclosureLength(0, .05, 0, 0.7); // 5.7
status = lefwLayerEnclosure("BELOW", .07, .07, 1.0); // 5.7
status = lefwLayerEnclosure("ABOVE", .09, .09, 1.0); // 5.7
status = lefwLayerEnclosureWidth(0, .03, .03, 1.0, 0.2); // 5.7
status = lefwEndLayer("via34"); // 5.7
status = lefwStartLayer("cut23", "CUT"); // 5.7
status = lefwLayerCutSpacing(0.20); // 5.7
status = lefwLayerCutSpacingSameNet(); // 5.7
status = lefwLayerCutSpacingLayer("cut12", 1); // 5.7
status = lefwLayerCutSpacingEnd(); // 5.7
status = lefwLayerCutSpacing(0.30); // 5.7
status = lefwLayerCutSpacingCenterToCenter(); // 5.7
status = lefwLayerCutSpacingSameNet(); // 5.7
status = lefwLayerCutSpacingArea(0.02); // 5.7
status = lefwLayerCutSpacingEnd(); // 5.7
status = lefwLayerCutSpacing(0.40); // 5.7
status = lefwLayerCutSpacingArea(0.5); // 5.7
status = lefwLayerCutSpacingEnd(); // 5.7
status = lefwLayerCutSpacing(0.10); // 5.7
status = lefwLayerCutSpacingEnd(); // 5.7
wthn = (double*)malloc(sizeof(double)*3); // 5.7
spng = (double*)malloc(sizeof(double)*3);
status = lefwLayerCutSpacingTableOrtho(3, wthn, spng);
status = lefwLayerArraySpacing(0, 2.0, 0.2, 1, wthn, spng);
status = lefwLayerArraySpacing(1, 2.0, 0.2, 3, wthn, spng);
status = lefwEndLayer("cut23");
status = lefwStartLayerRouting("cut24"); // 5.7
status = lefwLayerRouting("HORIZONTAL", 1); // 5.7
status = lefwLayerRoutingPitch(1.2); // 5.7
status = lefwLayerRoutingSpacing(0.10); // 5.7
status = lefwLayerRoutingSpacing(0.12); // 5.7
status = lefwLayerRoutingSpacingNotchLength(0.15); // 5.7
status = lefwLayerRoutingSpacing(0.14); // 5.7
status = lefwLayerRoutingSpacingEndOfNotchWidth(0.15, 0.16, 0.08); // 5.7
status = lefwEndLayerRouting("cut24"); // 5.7
status = lefwStartLayerRouting("cut25"); // 5.7
status = lefwLayerRoutingPitch(1.2); // 5.7
status = lefwLayerRouting("HORIZONTAL", 1); // 5.7
status = lefwLayerRoutingWireExtension(7); // 5.7
status = lefwLayerRoutingStartSpacingtableTwoWidths(); // 5.7
wthn = (double*)malloc(sizeof(double)*4); // 5.7
status = lefwLayerRoutingSpacingtableTwoWidthsWidth(0.0, 0, 4, wthn); // 5.7
status = lefwLayerRoutingSpacingtableTwoWidthsWidth(0.25, 0.1, 4, wthn);// 5.7
status = lefwLayerRoutingSpacingtableTwoWidthsWidth(1.5, 1.5, 4, wthn);// 5.7
status = lefwLayerRoutingSpacingtableTwoWidthsWidth(3.0, 3.0, 4, wthn);// 5.7
status = lefwLayerRoutineEndSpacingtable();
status = lefwEndLayerRouting("cut25"); // 5.7
status = lefwMaxviastack(4, "m1", "m7");
status = lefwStartVia("RX_PC", "DEFAULT");
status = lefwViaResistance(2);
status = lefwViaLayerRect(-0.7, -0.7, 0.7, 0.7);
status = lefwViaLayer("CUT12");
status = lefwViaLayerRect(-0.25, -0.25, 0.25, 0.25);
status = lefwViaLayerRect(-0.6, -0.6, 0.6, 0.6);
status = lefwStringProperty("stringProperty", "DEFAULT");
status = lefwRealProperty("realProperty", 32.33);
status = lefwIntProperty("COUNT", 34);
status = lefwStartVia("M2_M3_PWR", NULL);
status = lefwViaResistance(0.4);
status = lefwViaLayerRect(-1.35, -1.35, 1.35, 1.35);
status = lefwViaLayerRect(-1.35, -1.35, -0.45, 1.35);
status = lefwViaLayerRect(0.45, -1.35, 1.35, -0.45);
status = lefwViaLayerRect(0.45, 0.45, 1.35, 1.35);
status = lefwViaLayerRect(-1.35, -1.35, 1.35, 1.35);
status = lefwEndVia("M2_M3_PWR");
xl = (double*)malloc(sizeof(double)*6);
yl = (double*)malloc(sizeof(double)*6);
status = lefwStartVia("IN1X", 0);
status = lefwViaLayer("metal2");
status = lefwViaLayerPolygon(6, xl, yl);
status = lefwViaLayerPolygon(4, xl, yl);
status = lefwViaLayerPolygon(4, xl, yl);
status = lefwViaLayerPolygon(4, xl, yl);
status = lefwViaLayer("cut23");
status = lefwViaLayerRect(-0.4, -0.4, 0.4, 0.4);
status = lefwViaLayerPolygon(4, xl, yl);
status = lefwStartVia("myBlockVia", NULL);
status = lefwViaViarule("DEFAULT", 0.1, 0.1, "metal1", "via12", "metal2",
0.1, 0.1, 0.05, 0.01, 0.01, 0.05);
status = lefwViaViaruleRowCol(1, 2);
status = lefwViaViaruleOrigin(1.5, 2.5);
status = lefwViaViaruleOffset(1.5, 2.5, 3.5, 4.5);
status = lefwViaViarulePattern("2_1RF1RF1R71R0_3_R1FFFF");
status = lefwEndVia("myBlockVia");
status = lefwStartVia("myVia23", NULL);
status = lefwViaLayer("metal2");
status = lefwViaLayerPolygon(6, xl, yl);
status = lefwViaLayer("cut23");
status = lefwViaLayerRect(-0.4, -0.4, 0.4, 0.4);
status = lefwViaLayer("metal3");
status = lefwViaLayerPolygon(5, xl, yl);
status = lefwEndVia("myVia23");
status = lefwStartViaRule("VIALIST12");
lefwAddComment("Break up the old lefwViaRule into 2 routines");
lefwAddComment("lefwViaRuleLayer and lefwViaRuleVia");
status = lefwViaRuleLayer("M1", NULL, 9.0, 9.6, 0, 0);
status = lefwViaRuleLayer("M2", NULL, 3.0, 3.0, 0, 0);
status = lefwViaRuleVia("VIACENTER12");
status = lefwStringProperty("vrsp", "new");
status = lefwIntProperty("vrip", 1);
status = lefwRealProperty("vrrp", 4.5);
status = lefwEndViaRule("VIALIST12");
lefwAddComment("Break up the old lefwViaRuleGenearte into 4 routines");
lefwAddComment("lefwStartViaRuleGen, lefwViaRuleGenLayer,");
lefwAddComment("lefwViaRuleGenLayer3, and lefwEndViaRuleGen");
status = lefwStartViaRuleGen("VIAGEN12");
status = lefwViaRuleGenLayer("M1", NULL, 0.1, 19, 0, 0);
status = lefwViaRuleGenLayer("M2", NULL, 0, 0, 0, 0);
status = lefwViaRuleGenLayer3("V1", -0.8, -0.8, 0.8, 0.8, 5.6, 6.0, 0.2);
status = lefwEndViaRuleGen("VIAGEN12");
// VIARULE with GENERATE & ENCLOSURE & DEFAULT
status = lefwStartViaRuleGen("via12");
status = lefwViaRuleGenDefault();
status = lefwViaRuleGenLayerEnclosure("m1", 0.05, 0.005, 1.0, 100.0);
status = lefwViaRuleGenLayerEnclosure("m2", 0.05, 0.005, 1.0, 100.0);
status = lefwViaRuleGenLayer3("cut12", -0.07, -0.07, 0.07, 0.07, 0.16, 0.16, 0);
status = lefwEndViaRuleGen("via12");
status = lefwStartNonDefaultRule("RULE1");
status = lefwNonDefaultRuleHardspacing();
status = lefwNonDefaultRuleLayer("RX", 10.0, 2.2, 6, 0, 0, 0);
status = lefwNonDefaultRuleLayer("PC", 10.0, 2.2, 0, 0, 0, 0);
status = lefwNonDefaultRuleLayer("M1", 10.0, 2.2, 0, 0, 0, 0);
status = lefwStartVia("nd1VARX0", NULL);
status = lefwViaResistance(0.2);
status = lefwViaLayerRect(-3, -3, 3, 3);
status = lefwViaLayer("CUT12");
status = lefwViaLayerRect(-1.0, -1.0, 1.0, 1.0);
status = lefwViaLayerRect(-3, -3, 3, 3);
status = lefwEndVia("nd1VARX0");
status = lefwSpacing("CUT01", "RX", 0.1, "STACK");
status = lefwEndNonDefaultRule("RULE1");
status = lefwStartNonDefaultRule("wide1_5x");
status = lefwNonDefaultRuleLayer("fw", 4.8, 4.8, 0, 0, 0, 0);
status = lefwNonDefaultRuleStartVia("nd1VIARX0", "DEFAULT");
status = lefwViaResistance(0.2);
status = lefwViaLayerRect(-3, -3, 3, 3);
status = lefwViaLayer("CUT12");
status = lefwViaLayerRect(-1.0, -1.0, 1.0, 1.0);
status = lefwViaLayerRect(-3, -3, 3, 3);
status = lefwNonDefaultRuleEndVia("nd1VIARX0");
status = lefwNonDefaultRuleUseVia("via12_fixed_analog_via");
status = lefwNonDefaultRuleMinCuts("cut12", 2);
status = lefwNonDefaultRuleUseVia("via23_fixed_analog_via");
status = lefwNonDefaultRuleMinCuts("cut23", 2);
status = lefwNonDefaultRuleUseViaRule("viaRule23_fixed_analog_via");
status = lefwEndNonDefaultRule("wide1_5x");
status = lefwSpacing("CUT01", "CA", 1.5, NULL);
status = lefwSpacing("CA", "V1", 1.5, "STACK");
status = lefwSpacing("M1", "M1", 3.5, "STACK");
status = lefwSpacing("V1", "V2", 1.5, "STACK");
status = lefwSpacing("M2", "M2", 3.5, "STACK");
status = lefwSpacing("V2", "V3", 1.5, "STACK");
status = lefwMinFeature(0.1, 0.1);
status = lefwSite("CORE1", "CORE", "X", 67.2, 6);
status = lefwSiteRowPattern("Fsite", 0);
status = lefwSiteRowPatternStr("Lsite", "N");
status = lefwSiteRowPatternStr("Lsite", "FS");
status = lefwSite("CORE", "CORE", "Y", 3.6, 28.8);
status = lefwSite("MRCORE", "CORE", "Y", 3.6, 28.8);
status = lefwSite("IOWIRED", "PAD", NULL, 57.6, 432);
status = lefwStartArray("M7E4XXX");
status = lefwArraySite("CORE", -5021.450, -4998.000, 0, 14346, 595, 0.700,
status = lefwArraySiteStr("CORE", -5021.450, -4998.600, "FS", 14346, 595,
status = lefwArraySite("IO", 6148.800, 5800.000, 3, 1, 1, 0.000, 0.000);
status = lefwArraySiteStr("IO", 6148.800, 5240.000, "E", 1, 1, 0.000, 0.000);
status = lefwArraySite("COVER", -7315.0, -7315.000, 1, 1, 1, 0.000, 0.000);
status = lefwArraySiteStr("COVER", 7315.0, 7315.000, "FN", 1, 1, 0.000, 0.000);
status = lefwArrayCanplace("COVER", -7315.000, -7315.000, 0, 1, 1, 0.000,
status = lefwArrayCanplaceStr("COVER", -7250.000, -7250.000, "N", 5, 1,
status = lefwArrayCannotoccupy("CORE", -5021.450, -4989.600, 6, 100, 595,
status = lefwArrayCannotoccupyStr("CORE", -5021.450, -4989.600, "N", 100, 595,
status = lefwArrayTracks("X", -6148.800, 17569, 0.700, "RX");
status = lefwArrayTracks("Y", -6148.800, 20497, 0.600, "RX");
status = lefwStartArrayFloorplan("100%");
status = lefwArrayFloorplan("CANPLACE", "COVER", -7315.000, -7315.000, 1, 1,
status = lefwArrayFloorplanStr("CANPLACE", "COVER", -7250.000, -7250.000,
status = lefwArrayFloorplan("CANPLACE", "CORE", -5021.000, -4998.000, 1,
status = lefwArrayFloorplanStr("CANPLACE", "CORE", -5021.000, -4998.000, "FS",
status = lefwArrayFloorplan("CANNOTOCCUPY", "CORE", -5021.000, -4998.000, 7,
status = lefwArrayFloorplanStr("CANNOTOCCUPY", "CORE", -5021.000, -4998.000,
"E", 100, 595, 0.700, 16.800);
status = lefwEndArrayFloorplan("100%");
status = lefwArrayGcellgrid("X", -6157.200, 1467, 8.400);
status = lefwArrayGcellgrid("Y", -6157.200, 1467, 8.400);
status = lefwEndArray("M7E4XXX");
status = lefwStartMacro("CHK3A");
status = lefwMacroClass("RING", NULL);
status = lefwMacroOrigin(0.9, 0.9);
status = lefwMacroSize(10.8, 28.8);
status = lefwMacroSymmetry("X Y R90");
status = lefwMacroSite("CORE");
status = lefwStartMacroPin("GND");
status = lefwMacroPinDirection("INOUT");
status = lefwMacroPinMustjoin("PA3");
status = lefwMacroPinTaperRule("RULE1");
status = lefwMacroPinUse("GROUND");
status = lefwMacroPinShape("ABUTMENT");
status = lefwMacroPinSupplySensitivity("vddpin1");
status = lefwMacroPinNetExpr("power1 VDD1");
status = lefwMacroPinAntennaMetalArea(3, "M1");
status = lefwStartMacroPinPort(NULL);
status = lefwMacroPinPortLayer("M1", 0.05);
status = lefwMacroPinPortLayerRect(-0.9, 3, 9.9, 6, 0, 0, 0, 0);
status = lefwEndMacroPinPort();
status = lefwStringProperty("TYPE", "special");
status = lefwIntProperty("intProp", 23);
status = lefwRealProperty("realProp", 24.25);
status = lefwMacroPinAntennaModel("OXIDE1");
status = lefwEndMacroPin("GND");
status = lefwStartMacroPin("VDD");
status = lefwMacroPinDirection("INOUT");
status = lefwMacroPinUse("POWER");
status = lefwMacroPinShape("ABUTMENT");
status = lefwMacroPinNetExpr("power2 VDD2");
status = lefwStartMacroPinPort(NULL);
status = lefwMacroPinPortLayer("M1", 0);
status = lefwMacroPinPortLayerRect(-0.9, 21, 9.9, 24, 0, 0, 0, 0);
status = lefwMacroPinPortVia(100, 300, "nd1VIA12", 1, 2, 1, 2);
status = lefwEndMacroPinPort();
status = lefwStartMacroPinPort("BUMP");
status = lefwMacroPinPortLayer("M2", 0.06);
status = lefwEndMacroPinPort();
xl = (double*)malloc(sizeof(double)*5);
yl = (double*)malloc(sizeof(double)*5);
status = lefwStartMacroPinPort("CORE");
status = lefwMacroPinPortLayer("P1", 0);
status = lefwMacroPinPortLayerPolygon(5, xl, yl, 5, 6, 454.6, 345.6);
status = lefwMacroPinPortLayerPolygon(5, xl, yl, 0, 0, 0, 0);
status = lefwEndMacroPinPort();
status = lefwEndMacroPin("VDD");
status = lefwStartMacroPin("PA3");
status = lefwMacroPinDirection("INPUT");
status = lefwMacroPinNetExpr("gnd1 GND");
status = lefwMacroPinAntennaPartialMetalArea(4, "M1");
status = lefwMacroPinAntennaPartialMetalArea(5, "M2");
status = lefwMacroPinAntennaPartialMetalSideArea(5, "M2");
status = lefwMacroPinAntennaGateArea(1, "M1");
status = lefwMacroPinAntennaGateArea(2, 0);
status = lefwMacroPinAntennaGateArea(3, "M3");
status = lefwMacroPinAntennaDiffArea(1, "M1");
status = lefwMacroPinAntennaMaxAreaCar(1, "L1");
status = lefwMacroPinAntennaMaxSideAreaCar(1, 0);
status = lefwMacroPinAntennaPartialCutArea(1, 0);
status = lefwMacroPinAntennaPartialCutArea(2, "M2");
status = lefwMacroPinAntennaPartialCutArea(3, 0);
status = lefwMacroPinAntennaPartialCutArea(4, "M4");
status = lefwMacroPinAntennaMaxCutCar(1, 0);
status = lefwStartMacroPinPort("CORE");
status = lefwMacroPinPortLayer("M1", 0.02);
status = lefwMacroPinPortLayerRect(1.35, -0.45, 2.25, 0.45, 0, 0, 0, 0);
status = lefwMacroPinPortLayerRect(-0.45, -0.45, 0.45, 0.45, 0, 0, 0, 0);
status = lefwEndMacroPinPort();
status = lefwStartMacroPinPort(NULL);
status = lefwMacroPinPortLayer("PC", 0);
status = lefwMacroPinPortLayerRect(-0.45, 12.15, 0.45, 13.05, 0, 0, 0, 0);
status = lefwEndMacroPinPort();
status = lefwStartMacroPinPort(NULL);
status = lefwMacroPinPortDesignRuleWidth("PC", 2);
status = lefwMacroPinPortLayerRect(8.55, 8.55, 9.45, 9.45, 0, 0, 0, 0);
status = lefwMacroPinPortLayerRect(6.75, 6.75, 7.65, 7.65, 0, 0, 0, 0);
status = lefwMacroPinPortLayerRect(6.75, 8.75, 7.65, 9.65, 0, 0, 0, 0);
status = lefwMacroPinPortLayerRect(6.75, 10.35, 7.65, 11.25, 0, 0, 0, 0);
status = lefwEndMacroPinPort();
status = lefwEndMacroPin("PA3");
status = lefwMacroObsLayer("M1", 5.6);
status = lefwMacroObsLayerWidth(5.4);
status = lefwMacroObsLayerRect(6.6, -0.6, 9.6, 0.6, 0, 0, 0, 0);
status = lefwMacroObsLayerRect(4.8, 12.9, 9.6, 13.2, 0, 0, 0, 0);
status = lefwMacroObsLayerRect(3, 13.8, 7.8, 16.8, 0, 0, 0, 0);
status = lefwMacroObsLayerRect(3, -0.6, 6, 0.6, 0, 0, 0, 0);
status = lefwStringProperty("stringProp", "first");
status = lefwIntProperty("integerProp", 1);
status = lefwRealProperty("WEIGHT", 30.31);
status = lefwEndMacro("CHK3A");
status = lefwStartMacro("INV");
status = lefwMacroEEQ("CHK1");
status = lefwMacroClass("CORE", "SPACER");
status = lefwMacroForeign("INVS", 0, 0, -1);
status = lefwMacroSize(67.2, 24);
status = lefwMacroSymmetry("X Y R90");
status = lefwMacroSite("CORE1");
status = lefwStartMacroDensity("metal1");
status = lefwMacroDensityLayerRect(0, 0, 100, 100, 45.5);
status = lefwMacroDensityLayerRect(100, 0, 200, 100, 42.2);
status = lefwEndMacroDensity();
status = lefwStartMacroDensity("metal2");
status = lefwMacroDensityLayerRect(200, 1, 300, 200, 43.3);
status = lefwEndMacroDensity();
status = lefwStartMacroPin("Z");
status = lefwMacroPinDirection("OUTPUT");
status = lefwMacroPinUse("SIGNAL");
status = lefwMacroPinShape("ABUTMENT");
status = lefwMacroPinAntennaModel("OXIDE1");
status = lefwStartMacroPinPort(NULL);
status = lefwMacroPinPortLayer("M2", 0);
status = lefwMacroPinPortLayerWidth(5.6);
xpath = (double*)malloc(sizeof(double)*7);
ypath = (double*)malloc(sizeof(double)*7);
status = lefwMacroPinPortLayerPath(7, xpath, ypath, 0, 0, 0, 0);
status = lefwEndMacroPinPort();
status = lefwEndMacroPin("Z");
status = lefwMacroObsDesignRuleWidth("M1", 2);
status = lefwMacroObsLayerRect(24.1, 1.5, 43.5, 208.5, 0, 0, 0, 0);
xpath = (double*)malloc(sizeof(double)*2);
ypath = (double*)malloc(sizeof(double)*2);
status = lefwMacroObsLayerPath(2, xpath, ypath, 0, 0, 0, 0);
status = lefwMacroObsLayerPath(2, xpath, ypath, 0, 0, 0, 0);
status = lefwMacroObsLayerPath(2, xpath, ypath, 0, 0, 0, 0);
xl = (double*)malloc(sizeof(double)*5);
yl = (double*)malloc(sizeof(double)*5);
status = lefwMacroObsLayerPolygon(5, xl, yl, 0, 0, 0, 0);
status = lefwStartMacro("DFF3");
status = lefwMacroClass("CORE", "ANTENNACELL");
status = lefwMacroForeignStr("DFF3S", 0, 0, "N");
status = lefwMacroSize(67.2, 210);
status = lefwMacroSymmetry("X Y R90");
status = lefwMacroSitePattern("CORE", 34, 54, 7, 30, 3, 1, 1);
status = lefwMacroSitePatternStr("CORE1", 21, 68, "S", 30, 3, 2, 2);
status = lefwEndMacro("DFF3");
status = lefwStartMacro("DFF4");
status = lefwMacroClass("COVER", "BUMP");
status = lefwMacroForeignStr("DFF3S", 0, 0, "");
status = lefwEndMacro("DFF4");
status = lefwStartMacro("DFF5");
status = lefwMacroClass("COVER", NULL);
status = lefwMacroForeignStr("DFF3S", 0, 0, "");
status = lefwEndMacro("DFF5");
status = lefwStartMacro("DFF6");
status = lefwMacroClass("BLOCK", "BLACKBOX");
status = lefwMacroForeignStr("DFF3S", 0, 0, "");
status = lefwEndMacro("DFF6");
status = lefwStartMacro("DFF7");
status = lefwMacroClass("PAD", "AREAIO");
status = lefwMacroForeignStr("DFF3S", 0, 0, "");
status = lefwEndMacro("DFF7");
status = lefwStartMacro("DFF8");
status = lefwMacroClass("BLOCK", "SOFT");
status = lefwEndMacro("DFF8");
status = lefwStartMacro("DFF9");
status = lefwMacroClass("CORE", "WELLTAP");
status = lefwEndMacro("DFF9");
status = lefwStartMacro("myTest");
status = lefwMacroClass("CORE", NULL);
status = lefwMacroSize(10.0, 14.0);
status = lefwMacroSymmetry("X");
status = lefwMacroSitePatternStr("Fsite", 0, 0, "N", 0, 0, 0, 0);
status = lefwMacroSitePatternStr("Fsite", 0, 7.0, "FS", 30, 3, 2, 2);
status = lefwMacroSitePatternStr("Fsite", 4.0, 0, "N", 0, 0, 0, 0);
status = lefwEndMacro("myTest");
// ANTENNA, this will generate error for 5.4 since I already have ANTENNA
status = lefwAntenna("INPUTPINANTENNASIZE", 1);
status = lefwAntenna("OUTPUTPINANTENNASIZE", -1);
status = lefwAntenna("INOUTPINANTENNASIZE", -1);
status = lefwStartBeginext("SIGNATURE");
status = lefwBeginextCreator("CADENCE");
lineNum = lefwCurrentLineNumber();