From d7fab925a0b3b3dd6bee50fcf7d2a265fb43abd2 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 19 Aug 2020 23:06:46 +0200 Subject: [PATCH] Added an option for not reading all LEF files along with DEF files, but only selected ones. --- .../lefdef/db_plugin/dbLEFDEFImporter.cc | 4 +- .../lefdef/db_plugin/dbLEFDEFImporter.h | 11 +++++ .../lefdef/db_plugin/dbLEFDEFPlugin.cc | 25 ++++++---- .../lefdef/db_plugin/gsiDeclDbLEFDEF.cc | 14 ++++++ .../LEFDEFTechnologyComponentEditor.ui | 9 +++- .../lay_plugin/layLEFDEFImportDialogs.cc | 2 + .../lefdef/unit_tests/dbLEFDEFImportTests.cc | 46 ++++++++++++++++++ .../unit_tests/dbLEFDEFReaderOptionsTests.cc | 4 ++ testdata/lefdef/masks-1/au.oas.gz | Bin 1038 -> 1036 bytes testdata/lefdef/masks-1/au_map.oas.gz | Bin 1648 -> 1646 bytes .../lefdef/masks-1/au_plugin_alt_lef.oas.gz | Bin 0 -> 1652 bytes testdata/lefdef/masks-1/au_plugin_def.oas.gz | Bin 0 -> 1646 bytes testdata/lefdef/masks-1/hidden/in_tech.lef | 32 ++++++++++++ testdata/lefdef/masks-1/in_tech.lef | 2 +- testdata/ruby/dbReaders.rb | 4 ++ 15 files changed, 140 insertions(+), 13 deletions(-) create mode 100644 testdata/lefdef/masks-1/au_plugin_alt_lef.oas.gz create mode 100644 testdata/lefdef/masks-1/au_plugin_def.oas.gz create mode 100644 testdata/lefdef/masks-1/hidden/in_tech.lef diff --git a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.cc b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.cc index 06a1c4df5..63d4b2685 100644 --- a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.cc +++ b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.cc @@ -349,7 +349,8 @@ LEFDEFReaderOptions::LEFDEFReaderOptions () m_special_routing_datatype (0), m_separate_groups (false), m_map_file (), - m_macro_resolution_mode (0) + m_macro_resolution_mode (false), + m_read_lef_with_def (true) { // .. nothing yet .. } @@ -418,6 +419,7 @@ LEFDEFReaderOptions &LEFDEFReaderOptions::operator= (const LEFDEFReaderOptions & m_map_file = d.m_map_file; m_macro_resolution_mode = d.m_macro_resolution_mode; m_lef_files = d.m_lef_files; + m_read_lef_with_def = d.m_read_lef_with_def; } return *this; } diff --git a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.h b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.h index efa621b15..4009a7ad6 100644 --- a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.h +++ b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.h @@ -738,6 +738,16 @@ public: m_lef_files = lf; } + bool read_lef_with_def () const + { + return m_read_lef_with_def; + } + + void set_read_lef_with_def (bool f) + { + m_read_lef_with_def = f; + } + bool separate_groups () const { return m_separate_groups; @@ -829,6 +839,7 @@ private: bool m_separate_groups; std::string m_map_file; unsigned int m_macro_resolution_mode; + bool m_read_lef_with_def; std::vector m_lef_files; }; diff --git a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc index 468bc40e4..6ac19b03f 100644 --- a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc +++ b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc @@ -158,22 +158,26 @@ private: // Additionally read all LEF files next to the DEF file - std::string input_dir = tl::absolute_path (m_stream.absolute_path ()); + if (lefdef_options->read_lef_with_def ()) { - if (tl::file_exists (input_dir)) { + std::string input_dir = tl::absolute_path (m_stream.absolute_path ()); - std::vector entries = tl::dir_entries (input_dir); - for (std::vector::const_iterator e = entries.begin (); e != entries.end (); ++e) { + if (tl::file_exists (input_dir)) { - if (is_lef_format (*e)) { + std::vector entries = tl::dir_entries (input_dir); + for (std::vector::const_iterator e = entries.begin (); e != entries.end (); ++e) { - std::string lp = tl::combine_path (input_dir, *e); + if (is_lef_format (*e)) { - tl::SelfTimer timer (tl::verbosity () >= 21, tl::to_string (tr ("Reading LEF file: ")) + lp); + std::string lp = tl::combine_path (input_dir, *e); - tl::InputStream lef_stream (lp); - tl::log << tl::to_string (tr ("Reading")) << " " << lp; - importer.read_lef (lef_stream, layout, state); + tl::SelfTimer timer (tl::verbosity () >= 21, tl::to_string (tr ("Reading LEF file: ")) + lp); + + tl::InputStream lef_stream (lp); + tl::log << tl::to_string (tr ("Reading")) << " " << lp; + importer.read_lef (lef_stream, layout, state); + + } } @@ -323,6 +327,7 @@ class LEFDEFFormatDeclaration tl::make_member (&LEFDEFReaderOptions::special_routing_datatype_str, &LEFDEFReaderOptions::set_special_routing_datatype_str, "special-routing-datatype-string") + tl::make_member (&LEFDEFReaderOptions::via_cellname_prefix, &LEFDEFReaderOptions::set_via_cellname_prefix, "via-cellname-prefix") + tl::make_member (&LEFDEFReaderOptions::begin_lef_files, &LEFDEFReaderOptions::end_lef_files, &LEFDEFReaderOptions::push_lef_file, "lef-files") + + tl::make_member (&LEFDEFReaderOptions::read_lef_with_def, &LEFDEFReaderOptions::set_read_lef_with_def, "read-lef-with-def") + tl::make_member (&LEFDEFReaderOptions::macro_resolution_mode, &LEFDEFReaderOptions::set_macro_resolution_mode, "macro-resolution-mode", MacroResolutionModeConverter ()) + tl::make_member (&LEFDEFReaderOptions::separate_groups, &LEFDEFReaderOptions::set_separate_groups, "separate-groups") + tl::make_member (&LEFDEFReaderOptions::map_file, &LEFDEFReaderOptions::set_map_file, "map-file") diff --git a/src/plugins/streamers/lefdef/db_plugin/gsiDeclDbLEFDEF.cc b/src/plugins/streamers/lefdef/db_plugin/gsiDeclDbLEFDEF.cc index fe963515c..c8bcf3ea6 100644 --- a/src/plugins/streamers/lefdef/db_plugin/gsiDeclDbLEFDEF.cc +++ b/src/plugins/streamers/lefdef/db_plugin/gsiDeclDbLEFDEF.cc @@ -712,6 +712,20 @@ gsi::Class decl_lefdef_config ("db", "LEFDEFReaderConfi gsi::method ("lef_files=", &db::LEFDEFReaderOptions::set_lef_files, "@brief Sets the list technology LEF files to additionally import\n" "See \\lef_files for details." + ) + + gsi::method ("read_lef_with_def", &db::LEFDEFReaderOptions::read_lef_with_def, + "@brief Gets a value indicating whether to read all LEF files in the same directory than the DEF file.\n" + "If this property is set to true (the default), the DEF reader will automatically consume all LEF files " + "next to the DEF file in addition to the LEF files specified with \\lef_files. If set to false, only the " + "LEF files specified with \\lef_files will be read.\n" + "\n" + "This property has been added in version 0.27.\n" + ) + + gsi::method ("read_lef_with_def=", &db::LEFDEFReaderOptions::set_read_lef_with_def, gsi::arg ("flag"), + "@brief Sets a value indicating whether to read all LEF files in the same directory than the DEF file.\n" + "See \\read_lef_with_def for details about this property.\n" + "\n" + "This property has been added in version 0.27.\n" ), "@brief Detailed LEF/DEF reader options\n" "This class is a aggregate belonging to the \\LoadLayoutOptions class. It provides options for the LEF/DEF reader. " diff --git a/src/plugins/streamers/lefdef/lay_plugin/LEFDEFTechnologyComponentEditor.ui b/src/plugins/streamers/lefdef/lay_plugin/LEFDEFTechnologyComponentEditor.ui index bd6cf1950..9f3ed99f4 100644 --- a/src/plugins/streamers/lefdef/lay_plugin/LEFDEFTechnologyComponentEditor.ui +++ b/src/plugins/streamers/lefdef/lay_plugin/LEFDEFTechnologyComponentEditor.ui @@ -41,7 +41,7 @@ - LEF Files (specify what LEF files to use additionally) + LEF Files true @@ -189,6 +189,13 @@ + + + + for DEF: also read all LEF files in the same directory than the DEF file + + + diff --git a/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImportDialogs.cc b/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImportDialogs.cc index 94697f9c4..7693f38c7 100644 --- a/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImportDialogs.cc +++ b/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImportDialogs.cc @@ -452,6 +452,7 @@ LEFDEFReaderOptionsEditor::commit (db::FormatSpecificReaderOptions *options, con data->set_labels_suffix (tl::to_string (suffix_labels->text ())); data->set_labels_datatype (datatype_labels->text ().toInt ()); data->set_separate_groups (separate_groups->isChecked ()); + data->set_read_lef_with_def (read_lef_with_def->isChecked ()); data->set_map_file (tl::to_string (mapfile_path->text ())); data->set_macro_resolution_mode (produce_lef_geo->isChecked () ? 0 : 2); @@ -514,6 +515,7 @@ LEFDEFReaderOptionsEditor::setup (const db::FormatSpecificReaderOptions *options suffix_labels->setText (tl::to_qstring (data->labels_suffix ())); datatype_labels->setText (QString::number (data->labels_datatype ())); separate_groups->setChecked (data->separate_groups ()); + read_lef_with_def->setChecked (data->read_lef_with_def ()); mapfile_path->setText (tl::to_qstring (data->map_file ())); layer_map_mode->setCurrentIndex (data->map_file ().empty () ? 1 : 0); produce_lef_geo->setChecked (data->macro_resolution_mode () == 0); diff --git a/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFImportTests.cc b/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFImportTests.cc index dd60edf1c..b4c8a1f8e 100644 --- a/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFImportTests.cc +++ b/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFImportTests.cc @@ -27,6 +27,7 @@ #include "dbLEFImporter.h" #include "tlUnitTest.h" +#include "dbTestSupport.h" #include @@ -527,3 +528,48 @@ TEST(114_lef_skips_end_library) run_test (_this, "lef-skips-end-library", "lef:in.lef+def:in.def", "au.oas", opt, false); } +TEST(200_lefdef_plugin) +{ + db::Layout ly; + + std::string fn_path (tl::testsrc ()); + fn_path += "/testdata/lefdef/masks-1/"; + + db::LEFDEFReaderOptions lefdef_opt = default_options (); + lefdef_opt.set_map_file ("in.map"); + db::LoadLayoutOptions opt; + opt.set_options (lefdef_opt); + + { + tl::InputStream is (fn_path + "in.def"); + db::Reader reader (is); + reader.read (ly, opt); + } + + db::compare_layouts (_this, ly, fn_path + "au_plugin_def.oas.gz", db::WriteOAS); +} + +TEST(201_lefdef_plugin_explicit_lef) +{ + db::Layout ly; + + std::string fn_path (tl::testsrc ()); + fn_path += "/testdata/lefdef/masks-1/"; + + db::LEFDEFReaderOptions lefdef_opt = default_options (); + lefdef_opt.set_map_file ("in.map"); + std::vector lf; + lf.push_back ("hidden/in_tech.lef"); + lefdef_opt.set_lef_files (lf); + lefdef_opt.set_read_lef_with_def (false); + db::LoadLayoutOptions opt; + opt.set_options (lefdef_opt); + + { + tl::InputStream is (fn_path + "in.def"); + db::Reader reader (is); + reader.read (ly, opt); + } + + db::compare_layouts (_this, ly, fn_path + "au_plugin_alt_lef.oas.gz", db::WriteOAS); +} diff --git a/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFReaderOptionsTests.cc b/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFReaderOptionsTests.cc index 7862352bc..9018a98c8 100644 --- a/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFReaderOptionsTests.cc +++ b/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFReaderOptionsTests.cc @@ -312,6 +312,10 @@ TEST(1) EXPECT_EQ (options.lef_files ().size (), size_t (1)); EXPECT_EQ (*options.begin_lef_files (), "ABC.lef"); + EXPECT_EQ (options.read_lef_with_def (), true); + options.set_read_lef_with_def (false); + EXPECT_EQ (options.read_lef_with_def (), false); + options.set_map_file ("ABC.map"); EXPECT_EQ (options.map_file (), "ABC.map"); diff --git a/testdata/lefdef/masks-1/au.oas.gz b/testdata/lefdef/masks-1/au.oas.gz index 579a0bc453fbb049ac78be435ba6f347a924779e..4d8805a01800c5103809435b1407e25debe09012 100644 GIT binary patch delta 14 VcmeC<=;7G#l!=jR^9v?5MgS$$1d#v$ delta 16 XcmeC-=;PS%l!=*NN^0{nCN)L?Ebau# diff --git a/testdata/lefdef/masks-1/au_map.oas.gz b/testdata/lefdef/masks-1/au_map.oas.gz index 45638cae1ea3ad06a4b1e9a2162a0a3a8d214671..dd9c9bc008868577076f620e8a1ffa688c5d1963 100644 GIT binary patch delta 14 Vcmeys^NweO7AqsyW?fciMgS)S1PTBE delta 16 XcmaFI^MPlB7ArHql+4E=B}H diff --git a/testdata/lefdef/masks-1/au_plugin_alt_lef.oas.gz b/testdata/lefdef/masks-1/au_plugin_alt_lef.oas.gz new file mode 100644 index 0000000000000000000000000000000000000000..9f2f877ccb2d5553180ef5266897829db2dff9a8 GIT binary patch literal 1652 zcmd^9%Wl&^6rDSh)~W4~mc~Ir>4F79AQ8o0Mr;Bx!BSqT(*i52B94Rv5f8DZh%Mq9 z%3tsaX;)RZ{6K(Bmk2i8J7W)H${*lta$fgNjz_s3hr{UhxEn`t#RlQG+H7Sp^J#il z<7C);T$otB;D!^xls zobG2$3T(1~v=#_KE#{(vINNXK4GNLs?gBP+3SfJG42qERRZ~LD<#>&>MpkT%cB{?^ zN>w!^urU%fa@G-1TLRlMzRQeiMu>&XXrwjThAq)R)e%9*#?9@lB~JIPhz&guT;4Zr zP=w=3B5#XhTNjvuhhlW!jF_UbUC84b=h&J$i^hgd0lIH;1{oBQIaFVq?wd4d?35*@ z207g~6J=S|8^;z^R%1h_Wpv;2xZHjQ6<+%S^CS3#pW1soU+o>Q0CFdw$vJUs>ztof zf7n~+u(DQG?MVs$z&>B8|ALuq11y2W<_%VcD)TxiaB{KJYV#U0Q2%)hjWq^ekz83j z+iw{_@R2)gw&`^^@DDI!OYknA;h_3=dZi4G)^Q-ESv^<+lWTYC-_nM42M{nd+3Orb Xw(PL6vwc(C_iioJKz{f?KaBkbp{Jp& literal 0 HcmV?d00001 diff --git a/testdata/lefdef/masks-1/au_plugin_def.oas.gz b/testdata/lefdef/masks-1/au_plugin_def.oas.gz new file mode 100644 index 0000000000000000000000000000000000000000..dd9c9bc008868577076f620e8a1ffa688c5d1963 GIT binary patch literal 1646 zcmd^9%Wl&^6rDSh)~W4~mc~Iv?t%qEAW_9$Mr;Bx#Zq3X-2yACY7z+vDjq_jD~i}6 zzJbr+6Oyi~Zux-#n=TP-xOc`L#*{z6tDMKZXM8-$^(5-Yw}+i1PHHxYV5`Lz7Be5; zyP9PE&Z8`ew+B%-iw9}69qnWf<8Jz(TJdYXl6MFHGWedIWa)5}-HUoX*Lt@9eEQ_+ z#JZGZ+ubA^?F>iJPWpI7pk+nub-SXlh}FHglf8QJdjI7l3$q{#N=$%UxI`0H3spx19UGHdc}tw`TNxXAD7d_D z+Mo!>l|<1N$F?poB@d0!eKW=sm1iN3Uz}rW>MR-?It|c$lRL=oCixtr(Z-XHesfFED*`bkul{hikm!H9+D76f-4)t)27J z`VV{U92VBXY8+JXuj})b<}VoAHoy!>^lz{#)S1_w04Enat^3!If#%OSY%DSOisZuD zTz|^|!jIfx<5jQCfq#H8n}K)v3>P)O)5m1+X&D#NG;4-4U@~^I`E9ac-2ntlZT8x8 Y$it2|HrH>8``)cXwU8hG&ktk20XDXvwg3PC literal 0 HcmV?d00001 diff --git a/testdata/lefdef/masks-1/hidden/in_tech.lef b/testdata/lefdef/masks-1/hidden/in_tech.lef new file mode 100644 index 000000000..8a06777ad --- /dev/null +++ b/testdata/lefdef/masks-1/hidden/in_tech.lef @@ -0,0 +1,32 @@ +LAYER M0PO + TYPE MASTERSLICE ; + WIDTH 0.02 ; + MASKS 2 ; +END M0PO +LAYER VIA0 + TYPE CUT ; + MASKS 2 ; +END VIA0 +LAYER M1 + TYPE MASTERSLICE ; + WIDTH 0.024 ; + MASKS 2 ; +END M1 +LAYER VIA1 + TYPE CUT ; + MASKS 2 ; +END VIA1 +LAYER M2 + TYPE MASTERSLICE ; + WIDTH 0.03 ; + MASKS 2 ; +END M2 + +VIA square + LAYER M0PO ; + RECT -0.08 -0.08 0.08 0.08 ; + LAYER VIA0 ; + RECT -0.08 -0.08 0.08 0.08 ; + LAYER M1 ; + RECT -0.08 -0.08 0.08 0.08 ; +END square diff --git a/testdata/lefdef/masks-1/in_tech.lef b/testdata/lefdef/masks-1/in_tech.lef index c794d34d5..4d7c3fc47 100644 --- a/testdata/lefdef/masks-1/in_tech.lef +++ b/testdata/lefdef/masks-1/in_tech.lef @@ -9,7 +9,7 @@ LAYER VIA0 END VIA0 LAYER M1 TYPE MASTERSLICE ; - WIDTH 0.025 ; + WIDTH 0.024 ; MASKS 2 ; END M1 LAYER VIA1 diff --git a/testdata/ruby/dbReaders.rb b/testdata/ruby/dbReaders.rb index eb33d4c61..f96956f99 100644 --- a/testdata/ruby/dbReaders.rb +++ b/testdata/ruby/dbReaders.rb @@ -353,6 +353,10 @@ class DBReaders_TestClass < TestBase conf.lef_files = [ "u.lef", "v.lef" ] assert_equal(conf.lef_files.join(","), "u.lef,v.lef") + assert_equal(conf.read_lef_with_def, true) + conf.read_lef_with_def = false + assert_equal(conf.read_lef_with_def, false) + end # MAG Options