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 579a0bc45..4d8805a01 100644 Binary files a/testdata/lefdef/masks-1/au.oas.gz and b/testdata/lefdef/masks-1/au.oas.gz differ diff --git a/testdata/lefdef/masks-1/au_map.oas.gz b/testdata/lefdef/masks-1/au_map.oas.gz index 45638cae1..dd9c9bc00 100644 Binary files a/testdata/lefdef/masks-1/au_map.oas.gz and b/testdata/lefdef/masks-1/au_map.oas.gz differ 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 000000000..9f2f877cc Binary files /dev/null and b/testdata/lefdef/masks-1/au_plugin_alt_lef.oas.gz differ 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 000000000..dd9c9bc00 Binary files /dev/null and b/testdata/lefdef/masks-1/au_plugin_def.oas.gz differ 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