Reading LEF/DEF map files such that MASK is applied to previous entries too.

This commit is contained in:
Matthias Koefferlein 2020-08-19 23:47:25 +02:00
parent d7fab925a0
commit 35249ef0b5
5 changed files with 32 additions and 29 deletions

View File

@ -729,6 +729,11 @@ LEFDEFReaderState::read_map_file (const std::string &path, db::Layout &layout)
purpose_translation ["VIA"] = ViaGeometry; purpose_translation ["VIA"] = ViaGeometry;
purpose_translation ["BLOCKAGE"] = Blockage; purpose_translation ["BLOCKAGE"] = Blockage;
std::map<LayerPurpose, std::string> purpose_translation_rev;
for (std::map<std::string, LayerPurpose>::const_iterator i = purpose_translation.begin (); i != purpose_translation.end (); ++i) {
purpose_translation_rev.insert (std::make_pair (i->second, i->first));
}
std::map<std::pair<std::string, std::pair<LayerPurpose, unsigned int> >, db::LayerProperties> layer_map; std::map<std::pair<std::string, std::pair<LayerPurpose, unsigned int> >, db::LayerProperties> layer_map;
while (! ts.at_end ()) { while (! ts.at_end ()) {
@ -745,7 +750,6 @@ LEFDEFReaderState::read_map_file (const std::string &path, db::Layout &layout)
std::string w1, w2; std::string w1, w2;
int layer = 0, datatype = 0; int layer = 0, datatype = 0;
size_t max_purpose_str = 10; size_t max_purpose_str = 10;
bool purpose_abbreviated = false;
if (ex.try_read_word (w1) && ex.try_read_word (w2, "._$,/:") && ex.try_read (layer) && ex.try_read (datatype)) { if (ex.try_read_word (w1) && ex.try_read_word (w2, "._$,/:") && ex.try_read (layer) && ex.try_read (datatype)) {
@ -790,9 +794,12 @@ LEFDEFReaderState::read_map_file (const std::string &path, db::Layout &layout)
// (separating, translating and recombing the purposes) // (separating, translating and recombing the purposes)
std::set<std::pair<LayerPurpose, unsigned int> > translated_purposes; std::set<std::pair<LayerPurpose, unsigned int> > translated_purposes;
std::string purpose_str;
std::vector<std::string> purposes = tl::split (w2, ","); std::vector<std::string> purposes = tl::split (w2, ",");
std::reverse (purposes.begin (), purposes.end ());
unsigned int mask = 0;
for (std::vector<std::string>::const_iterator p = purposes.begin (); p != purposes.end (); ++p) { for (std::vector<std::string>::const_iterator p = purposes.begin (); p != purposes.end (); ++p) {
std::string p_uc = tl::to_upper_case (*p); std::string p_uc = tl::to_upper_case (*p);
@ -801,8 +808,6 @@ LEFDEFReaderState::read_map_file (const std::string &path, db::Layout &layout)
std::string ps; std::string ps;
ex.read_word_or_quoted (ps); ex.read_word_or_quoted (ps);
unsigned int mask = 0;
if (ex.test (":")) { if (ex.test (":")) {
if (ex.test ("MASK") && ex.test (":")) { if (ex.test ("MASK") && ex.test (":")) {
ex.read (mask); ex.read (mask);
@ -811,33 +816,31 @@ LEFDEFReaderState::read_map_file (const std::string &path, db::Layout &layout)
std::map<std::string, LayerPurpose>::const_iterator i = purpose_translation.find (ps); std::map<std::string, LayerPurpose>::const_iterator i = purpose_translation.find (ps);
if (i != purpose_translation.end ()) { if (i != purpose_translation.end ()) {
translated_purposes.insert (std::make_pair (i->second, mask)); translated_purposes.insert (std::make_pair (i->second, mask));
}
if (! purpose_abbreviated) { }
if (! purpose_str.empty ()) { // create a visual description string for the combined purposes
purpose_str += "/"; std::string purpose_str;
}
if (purpose_str.size () > max_purpose_str) { for (std::set<std::pair<LayerPurpose, unsigned int> >::const_iterator p = translated_purposes.begin (); p != translated_purposes.end (); ++p) {
purpose_abbreviated = true; if (p != translated_purposes.begin ()) {
purpose_str += "..."; purpose_str += "/";
}
} else { std::string ps = purpose_translation_rev [p->first];
if (p->second > 0) {
purpose_str += i->first; ps += ":";
ps += tl::to_string (p->second);
if (mask > 0) { }
purpose_str += ":";
purpose_str += tl::to_string (mask);
}
}
}
if ((purpose_str + ps).size () > max_purpose_str) {
purpose_str += "...";
break;
} else {
purpose_str += ps;
} }
} }

View File

@ -851,9 +851,9 @@ enum LayerPurpose
Routing = 0, // from DEF only Routing = 0, // from DEF only
SpecialRouting, // from DEF only SpecialRouting, // from DEF only
ViaGeometry, // from LEF+DEF ViaGeometry, // from LEF+DEF
Label, // from LEF+DEF
Pins, // from DEF Pins, // from DEF
LEFPins, // from LEF LEFPins, // from LEF
Label, // from LEF+DEF
Obstructions, // from LEF only Obstructions, // from LEF only
Outline, // from LEF+DEF Outline, // from LEF+DEF
Blockage, // from DEF only Blockage, // from DEF only

View File

@ -164,7 +164,7 @@ private:
if (tl::file_exists (input_dir)) { if (tl::file_exists (input_dir)) {
std::vector<std::string> entries = tl::dir_entries (input_dir); std::vector<std::string> entries = tl::dir_entries (input_dir, true, false, true);
for (std::vector<std::string>::const_iterator e = entries.begin (); e != entries.end (); ++e) { for (std::vector<std::string>::const_iterator e = entries.begin (); e != entries.end (); ++e) {
if (is_lef_format (*e)) { if (is_lef_format (*e)) {

View File

@ -492,30 +492,30 @@ TEST(113_masks_1)
"'M0PO.SPNET:2' : 'M0PO.SPNET:2' (1/201)\n" "'M0PO.SPNET:2' : 'M0PO.SPNET:2' (1/201)\n"
"'M0PO.VIA:1' : 'M0PO.VIA:1' (1/102)\n" "'M0PO.VIA:1' : 'M0PO.VIA:1' (1/102)\n"
"'M0PO.VIA:2' : 'M0PO.VIA:2' (1/202)\n" "'M0PO.VIA:2' : 'M0PO.VIA:2' (1/202)\n"
"M0PO.LABEL : M0PO.LABEL (1/1)\n"
"M0PO.PIN : M0PO.PIN (1/2)\n" "M0PO.PIN : M0PO.PIN (1/2)\n"
"'M0PO.PIN:1' : 'M0PO.PIN:1' (1/110)\n" "'M0PO.PIN:1' : 'M0PO.PIN:1' (1/110)\n"
"'M0PO.PIN:2' : 'M0PO.PIN:2' (1/210)\n" "'M0PO.PIN:2' : 'M0PO.PIN:2' (1/210)\n"
"M0PO.LABEL : M0PO.LABEL (1/1)\n"
"'M1.NET:1' : 'M1.NET:1' (3/100)\n" "'M1.NET:1' : 'M1.NET:1' (3/100)\n"
"'M1.NET:2' : 'M1.NET:2' (3/200)\n" "'M1.NET:2' : 'M1.NET:2' (3/200)\n"
"'M1.SPNET:1' : 'M1.SPNET:1' (3/101)\n" "'M1.SPNET:1' : 'M1.SPNET:1' (3/101)\n"
"'M1.SPNET:2' : 'M1.SPNET:2' (3/201)\n" "'M1.SPNET:2' : 'M1.SPNET:2' (3/201)\n"
"'M1.VIA:1' : 'M1.VIA:1' (3/102)\n" "'M1.VIA:1' : 'M1.VIA:1' (3/102)\n"
"'M1.VIA:2' : 'M1.VIA:2' (3/202)\n" "'M1.VIA:2' : 'M1.VIA:2' (3/202)\n"
"M1.LABEL : M1.LABEL (3/1)\n"
"M1.PIN : M1.PIN (3/2)\n" "M1.PIN : M1.PIN (3/2)\n"
"'M1.PIN:1' : 'M1.PIN:1' (3/110)\n" "'M1.PIN:1' : 'M1.PIN:1' (3/110)\n"
"'M1.PIN:2' : 'M1.PIN:2' (3/210)\n" "'M1.PIN:2' : 'M1.PIN:2' (3/210)\n"
"M1.LABEL : M1.LABEL (3/1)\n"
"'VIA0.NET:1' : 'VIA0.NET:1' (2/100)\n" "'VIA0.NET:1' : 'VIA0.NET:1' (2/100)\n"
"'VIA0.NET:2' : 'VIA0.NET:2' (2/200)\n" "'VIA0.NET:2' : 'VIA0.NET:2' (2/200)\n"
"'VIA0.SPNET:1' : 'VIA0.SPNET:1' (2/101)\n" "'VIA0.SPNET:1' : 'VIA0.SPNET:1' (2/101)\n"
"'VIA0.SPNET:2' : 'VIA0.SPNET:2' (2/201)\n" "'VIA0.SPNET:2' : 'VIA0.SPNET:2' (2/201)\n"
"'VIA0.VIA:1' : 'VIA0.VIA:1' (2/102)\n" "'VIA0.VIA:1' : 'VIA0.VIA:1' (2/102)\n"
"'VIA0.VIA:2' : 'VIA0.VIA:2' (2/202)\n" "'VIA0.VIA:2' : 'VIA0.VIA:2' (2/202)\n"
"VIA0.LABEL : VIA0.LABEL (2/1)\n"
"VIA0.PIN : VIA0.PIN (2/2)\n" "VIA0.PIN : VIA0.PIN (2/2)\n"
"'VIA0.PIN:1' : 'VIA0.PIN:1' (2/110)\n" "'VIA0.PIN:1' : 'VIA0.PIN:1' (2/110)\n"
"'VIA0.PIN:2' : 'VIA0.PIN:2' (2/210)\n" "'VIA0.PIN:2' : 'VIA0.PIN:2' (2/210)\n"
"VIA0.LABEL : VIA0.LABEL (2/1)\n"
) )
} }

Binary file not shown.