Skip to content

Commit

Permalink
Write DEF "VIAS" section
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateus Fogaça authored and Eder Monteiro committed Apr 10, 2019
1 parent c965b14 commit d16a1d3
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 17 deletions.
79 changes: 77 additions & 2 deletions rsyn/src/rsyn/io/parser/lef_def/DEFControlParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void DEFControlParser::parseDEF(const std::string &filename, DefDscp &defDscp) {

// register track call back
defrSetTrackCbk(defTrack);

// register special net call backs
defrSetSNetStartCbk(defSpecialNetStart);
defrSetSNetCbk(defSpecialNet);
Expand Down Expand Up @@ -963,7 +963,73 @@ void DEFControlParser::writeFullDEF(const string &filename, const DefDscp &defDs
status = defwNewLine();
CHECK_STATUS(status);


status = defwStartVias(defDscp.clsVias.size());
CHECK_STATUS(status);
for (const DefViaDscp & via : defDscp.clsVias) {
status = defwViaName(via.clsName.c_str());
CHECK_STATUS(status);
if (via.clsHasViaRule) {
status = defwViaViarule(
via.clsViaRuleName.c_str(),
via.clsXCutSize,
via.clsYCutSize,
via.clsBottomLayer.c_str(),
via.clsCutLayer.c_str(),
via.clsTopLayer.c_str(),
via.clsXCutSpacing,
via.clsYCutSpacing,
via.clsXBottomEnclosure,
via.clsYBottomEnclosure,
via.clsXTopEnclosure,
via.clsYTopEnclosure
);
CHECK_STATUS(status);

if (via.clsHasRowCol) {
status = defwViaViaruleRowCol(via.clsNumCutRows, via.clsNumCutCols);
CHECK_STATUS(status);
} // end if
if (via.clsHasOrigin) {
status = defwViaViaruleOrigin(via.clsXOffsetOrigin, via.clsYOffsetOrigin);
CHECK_STATUS(status);
} // end if
if (via.clsHasOffset) {
status = defwViaViaruleOffset(via.clsXBottomOffset, via.clsYBottomOffset, via.clsXTopOffset, via.clsYTopOffset);
CHECK_STATUS(status);
} // end if
} else {
const std::map<std::string, std::deque<DefViaGeometryDscp>> & mapGeos = via.clsGeometries;
for (auto& pair : mapGeos) {
const std::string layer = pair.first;
const std::deque<DefViaGeometryDscp>& geometries = pair.second;
for (size_t i = 0; i < geometries.size(); i++) {
const DefViaGeometryDscp & geo = geometries[i];
if (geo.clsHasMask) {
defwViaRect(
layer.c_str(),
geo.clsBounds[LOWER][X],
geo.clsBounds[LOWER][Y],
geo.clsBounds[UPPER][X],
geo.clsBounds[UPPER][Y],
geo.clsMask);
} else {
defwViaRect(
layer.c_str(),
geo.clsBounds[LOWER][X],
geo.clsBounds[LOWER][Y],
geo.clsBounds[UPPER][X],
geo.clsBounds[UPPER][Y]);
}
}
}
} // end if

status = defwOneViaEnd();
CHECK_STATUS(status);
} // end for
status = defwEndVias();
CHECK_STATUS(status);

// Write components
int numComponents = defDscp.clsComps.size();
if (numComponents > 0) {
Expand Down Expand Up @@ -1123,3 +1189,12 @@ std::string DEFControlParser::unescape(const std::string &str) {
} // end method

// -----------------------------------------------------------------------------

int defVia(defrCallbackType_e c, int num, void* ud) {
std::cout << "Entered here!\n";
DefDscp & defDscp = getDesignFromUserData(ud);
defDscp.clsVias.reserve(num);
return 0;
}// end method

// -----------------------------------------------------------------------------
91 changes: 78 additions & 13 deletions rsyn/src/rsyn/io/writer/WriterDEF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,19 +391,84 @@ void WriterDEF::loadDEFGCellGrid(DefDscp & def) {

// -----------------------------------------------------------------------------

void WriterDEF::loadDEFVias(DefDscp & def) {
// TODO
// std::vector<DefViaDscp> & defVias = def.clsVias;
// defVias.reserve(clsPhDesign.getNumPhysicalVias());
// for (Rsyn::PhysicalVia phVia : clsPhDesign.allPhysicalVias()) {
// if (!phVia.isDesignVia()) {
// continue;
// } // end if
// defVias.push_back(DefViaDscp());
// DefViaDscp & dscpVia = defVias.back();
// dscpVia.clsName = phVia.getName();
//
// } // end for
void WriterDEF::loadDEFVias(DefDscp & def) {
std::vector<DefViaDscp> & defVias = def.clsVias;
defVias.reserve(clsPhDesign.getNumPhysicalVias());
for (Rsyn::PhysicalVia phVia : clsPhDesign.allPhysicalVias()) {
if (!phVia.isViaDesign()) {
continue;
} // end if
defVias.push_back(DefViaDscp());
DefViaDscp & dscpVia = defVias.back();
dscpVia.clsName = phVia.getName();
if (phVia.isViaRule()) {
dscpVia.clsHasViaRule = true;
dscpVia.clsViaRuleName = phVia.getViaRule().getName();
dscpVia.clsXCutSize = phVia.getCutSize(X);
dscpVia.clsYCutSize = phVia.getCutSize(Y);
dscpVia.clsBottomLayer = phVia.getBottomLayer().getName();
dscpVia.clsCutLayer = phVia.getCutLayer().getName();
dscpVia.clsTopLayer = phVia.getTopLayer().getName();
dscpVia.clsXCutSpacing = phVia.getSpacing(X);
dscpVia.clsYCutSpacing = phVia.getSpacing(Y);
dscpVia.clsXBottomEnclosure = phVia.getEnclosure(BOTTOM_VIA_LEVEL, X);
dscpVia.clsYBottomEnclosure = phVia.getEnclosure(BOTTOM_VIA_LEVEL, Y);
dscpVia.clsXTopEnclosure = phVia.getEnclosure(TOP_VIA_LEVEL, X);
dscpVia.clsYTopEnclosure = phVia.getEnclosure(TOP_VIA_LEVEL, Y);
if (phVia.hasRowCol()) {
dscpVia.clsHasRowCol = true;
dscpVia.clsNumCutCols = phVia.getNumCols();
dscpVia.clsNumCutRows = phVia.getNumRows();
} // end if
if (phVia.hasOrigin()) {
dscpVia.clsHasOrigin = true;
dscpVia.clsXOffsetOrigin = phVia.getOrigin(X);
dscpVia.clsYOffsetOrigin = phVia.getOrigin(Y);
} // end if
if (phVia.hasoffset()) {
dscpVia.clsHasOffset = true;
dscpVia.clsXBottomOffset = phVia.getOffset(BOTTOM_VIA_LEVEL, X);
dscpVia.clsYBottomOffset = phVia.getOffset(BOTTOM_VIA_LEVEL, Y);
dscpVia.clsXTopOffset = phVia.getOffset(TOP_VIA_LEVEL, X);
dscpVia.clsYTopOffset = phVia.getOffset(TOP_VIA_LEVEL, Y);
} // end if
} else {
std::map<std::string, std::deque<DefViaGeometryDscp>> & mapGeos = dscpVia.clsGeometries;

const std::string bottomLayerName = phVia.getBottomLayer().getName();
for (Rsyn::PhysicalViaGeometry phGeometry: phVia.allBottomGeometries()) {
std::deque<DefViaGeometryDscp> & geos = mapGeos[bottomLayerName];
geos.push_back(DefViaGeometryDscp());
DefViaGeometryDscp & geoDscp = geos.back();
geoDscp.clsBounds = phGeometry.getBounds();
geoDscp.clsHasMask = phGeometry.getMaskNumber() != -1;
geoDscp.clsMask = phGeometry.getMaskNumber();
geoDscp.clsIsRect = true;
} // end for

const std::string cutLayerName = phVia.getCutLayer().getName();
for (Rsyn::PhysicalViaGeometry phGeometry: phVia.allCutGeometries()) {
std::deque<DefViaGeometryDscp> & geos = mapGeos[cutLayerName];
geos.push_back(DefViaGeometryDscp());
DefViaGeometryDscp & geoDscp = geos.back();
geoDscp.clsBounds = phGeometry.getBounds();
geoDscp.clsHasMask = phGeometry.getMaskNumber() != -1;
geoDscp.clsMask = phGeometry.getMaskNumber();
geoDscp.clsIsRect = true;
} // end for

const std::string topLayerName = phVia.getTopLayer().getName();
for (Rsyn::PhysicalViaGeometry phGeometry: phVia.allTopGeometries()) {
std::deque<DefViaGeometryDscp> & geos = mapGeos[topLayerName];
geos.push_back(DefViaGeometryDscp());
DefViaGeometryDscp & geoDscp = geos.back();
geoDscp.clsBounds = phGeometry.getBounds();
geoDscp.clsHasMask = phGeometry.getMaskNumber() != -1;
geoDscp.clsMask = phGeometry.getMaskNumber();
geoDscp.clsIsRect = true;
} // end for
} // end if
} // end for
} // end method

// -----------------------------------------------------------------------------
Expand Down
8 changes: 6 additions & 2 deletions rsyn/src/rsyn/phy/obj/impl/PhysicalDesign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1082,14 +1082,16 @@ void PhysicalDesign::addPhysicalDesignVia(const DefViaDscp & via) {

if (via.clsHasViaRule) {
Rsyn::PhysicalViaRuleBase phViaRuleBase = getPhysicalViaRuleBaseByName(via.clsViaRuleName);
phVia->clsHasViaRule = true;
phVia->clsType = VIA_RULE_TYPE;
phVia->clsViaRuleData = phViaRuleBase.data;
phVia->clsCutSize[X] = via.clsXCutSize;
phVia->clsCutSize[Y] = via.clsYCutSize;
phVia->clsSpacing[X] = via.clsXCutSpacing;
phVia->clsSpacing[Y] = via.clsYCutSpacing;
phVia->clsEnclosure[BOTTOM_VIA_LEVEL][X] = via.clsXBottomEnclosure;
phVia->clsEnclosure[TOP_VIA_LEVEL][Y] = via.clsYBottomEnclosure;
phVia->clsEnclosure[BOTTOM_VIA_LEVEL][X] = via.clsXTopEnclosure;
phVia->clsEnclosure[BOTTOM_VIA_LEVEL][Y] = via.clsYBottomEnclosure;
phVia->clsEnclosure[TOP_VIA_LEVEL][X] = via.clsXTopEnclosure;
phVia->clsEnclosure[TOP_VIA_LEVEL][Y] = via.clsYTopEnclosure;

Rsyn::PhysicalLayer bottom = getPhysicalLayerByName(via.clsBottomLayer);
Expand Down Expand Up @@ -1117,6 +1119,8 @@ void PhysicalDesign::addPhysicalDesignVia(const DefViaDscp & via) {
phVia->clsOffset[TOP_VIA_LEVEL][Y] = via.clsYTopOffset;
} // end if
} else {
phVia->clsHasViaRule = false;
phVia->clsType = VIA_GEOMETRY_TYPE;
std::vector<std::tuple<int, PhysicalLayerData *>> layers;
for (const std::pair < std::string, std::deque < DefViaGeometryDscp>> &geoPair : via.clsGeometries) {
const std::string & layerName = geoPair.first;
Expand Down

0 comments on commit d16a1d3

Please sign in to comment.