From 05901d767e030d284ab5794145b71a8848be1906 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 22 Apr 2021 23:43:28 +0200 Subject: [PATCH] Generalized macro resolution mode options for LEF/DEF reader (UI, buddy tools). Added lefdef-lef-layouts for buddy scripts for providing external layouts for FOREIGN. --- src/buddies/src/bd/bdReaderOptions.cc | 54 ++++++-- src/buddies/src/bd/bdReaderOptions.h | 9 +- src/buddies/src/bd/strmclip.cc | 2 +- .../lefdef/db_plugin/gsiDeclDbLEFDEF.cc | 4 +- .../LEFDEFTechnologyComponentEditor.ui | 127 +++++++++++------- .../lay_plugin/layLEFDEFImportDialogs.cc | 4 +- 6 files changed, 139 insertions(+), 61 deletions(-) diff --git a/src/buddies/src/bd/bdReaderOptions.cc b/src/buddies/src/bd/bdReaderOptions.cc index 57c31cd95..f36b5d7ac 100644 --- a/src/buddies/src/bd/bdReaderOptions.cc +++ b/src/buddies/src/bd/bdReaderOptions.cc @@ -124,7 +124,7 @@ GenericReaderOptions::GenericReaderOptions () m_lefdef_read_lef_with_def = load_options.get_option_by_name ("lefdef_config.read_lef_with_def").to_bool (); m_lefdef_separate_groups = load_options.get_option_by_name ("lefdef_config.separate_groups").to_bool (); m_lefdef_map_file = load_options.get_option_by_name ("lefdef_config.map_file").to_string (); - m_lefdef_produce_lef_macros = (load_options.get_option_by_name ("lefdef_config.macro_resolution_mode").to_int () == 0); + m_lefdef_macro_resolution_mode = load_options.get_option_by_name ("lefdef_config.macro_resolution_mode").to_int (); } void @@ -615,13 +615,27 @@ GenericReaderOptions::add_options (tl::CommandLineOptions &cmd) "If a map file is used, only the layers present in the map file are generated. No other layers are produced." ) << tl::arg (group + - "!--" + m_long_prefix + "lefdef-no-lef-macros", &m_lefdef_produce_lef_macros, "Don't produce LEF macro geometry", + "!--" + m_long_prefix + "lefdef-macro-resolution-mode", &m_lefdef_macro_resolution_mode, "Specify how to generate layout from LEF macros", "This option applies when reading DEF files.\n" "\n" - "If this option is present, no geometry will be produced for LEF macros. Instead, a ghost cell with the name of the LEF " - "macro will be produced. If this option is not given, the LEF macros will be inserted in to these cells " - "unless a FOREIGN specification is present in the LEF macro. If a FOREIGN specification is given, LEF geometry is never " - "inserted into a DEF file. Instead ghost cells are created." + "The following values are accepted for this option:\n" + "\n" + "* 0: produce LEF geometry unless a FOREIGN cell is specified\n" + "* 1: produce LEF geometry always and ignore FOREIGN\n" + "* 2: Never produce LEF geometry and assume FOREIGN always\n" + "\n" + "In case of FOREIGN macros in mode 1 or always in mode 2, the '--" + m_long_prefix + "lefdef-lef-layouts' option is available to specify " + "external layout files for providing the LEF macro layouts.\n" + ) + << tl::arg (group + + "--" + m_long_prefix + "lefdef-lef-layouts", &m_lefdef_lef_layout_files, "Layout files for resolving FOREIGN LEF cells from", + "This option applies when reading DEF files.\n" + "\n" + "Use a comma-separated list of file names here to specify which layout files to use for resolving LEF macros. " + "This applies when LEF macros are specified with FOREIGN. By using '--" + m_long_prefix + "lefdef-macro-resolution-mode' you " + "can force external resolution (assume FOREIGN always) or turn it off (ignore FOREIGN).\n" + "\n" + "Relative paths are resolved based on the location of the DEF file which is read." ) << tl::arg (group + "!--" + m_long_prefix + "lefdef-no-implicit-lef", &m_lefdef_read_lef_with_def, "Disables reading all LEF files together with DEF files", @@ -678,7 +692,7 @@ void GenericReaderOptions::set_dbu (double dbu) } void -GenericReaderOptions::configure (db::LoadLayoutOptions &load_options) const +GenericReaderOptions::configure (db::LoadLayoutOptions &load_options) { load_options.set_option_by_name ("layer_map", tl::Variant::make_variant (m_layer_map)); load_options.set_option_by_name ("create_other_layers", m_create_other_layers); @@ -763,7 +777,31 @@ GenericReaderOptions::configure (db::LoadLayoutOptions &load_options) const load_options.set_option_by_name ("lefdef_config.read_lef_with_def", m_lefdef_read_lef_with_def); load_options.set_option_by_name ("lefdef_config.separate_groups", m_lefdef_separate_groups); load_options.set_option_by_name ("lefdef_config.map_file", m_lefdef_map_file); - load_options.set_option_by_name ("lefdef_config.macro_resolution_mode", m_lefdef_produce_lef_macros ? 0 : 2); + load_options.set_option_by_name ("lefdef_config.macro_resolution_mode", m_lefdef_macro_resolution_mode); + + m_lef_layouts.clear (); + tl::Variant lef_layout_ptrs = tl::Variant::empty_list (); + for (std::vector::const_iterator l = m_lefdef_lef_layout_files.begin (); l != m_lefdef_lef_layout_files.end (); ++l) { + + try { + + std::unique_ptr ly (new db::Layout ()); + + tl::InputStream stream (*l); + db::Reader reader (stream); + db::LoadLayoutOptions load_options; + reader.read (*ly, load_options); + + lef_layout_ptrs.push (tl::Variant::make_variant_ref (ly.get ())); + m_lef_layouts.push_back (ly.release ()); + + } catch (tl::Exception &ex) { + tl::warn << ex.msg (); + } + + } + + load_options.set_option_by_name ("lefdef_config.macro_layouts", lef_layout_ptrs); } } diff --git a/src/buddies/src/bd/bdReaderOptions.h b/src/buddies/src/bd/bdReaderOptions.h index 2f877dc00..0a035d793 100644 --- a/src/buddies/src/bd/bdReaderOptions.h +++ b/src/buddies/src/bd/bdReaderOptions.h @@ -25,6 +25,7 @@ #include "bdCommon.h" #include "dbCommonReader.h" +#include "tlObject.h" #include @@ -36,6 +37,7 @@ namespace tl namespace db { class LoadLayoutOptions; + class Layout; } namespace bd @@ -61,7 +63,7 @@ public: /** * @brief Configures the reader options object with the options stored in this object */ - void configure (db::LoadLayoutOptions &load_options) const; + void configure (db::LoadLayoutOptions &load_options); /** * @brief Sets the option prefix for the short option name @@ -183,7 +185,10 @@ private: bool m_lefdef_read_lef_with_def; bool m_lefdef_separate_groups; std::string m_lefdef_map_file; - bool m_lefdef_produce_lef_macros; + int m_lefdef_macro_resolution_mode; + std::vector m_lefdef_lef_layout_files; + + tl::shared_collection m_lef_layouts; }; } diff --git a/src/buddies/src/bd/strmclip.cc b/src/buddies/src/bd/strmclip.cc index 6af528e21..b83c588ac 100644 --- a/src/buddies/src/bd/strmclip.cc +++ b/src/buddies/src/bd/strmclip.cc @@ -63,7 +63,7 @@ struct ClipData }; -void clip (const ClipData &data) +void clip (ClipData &data) { db::Layout layout; db::Layout target_layout; diff --git a/src/plugins/streamers/lefdef/db_plugin/gsiDeclDbLEFDEF.cc b/src/plugins/streamers/lefdef/db_plugin/gsiDeclDbLEFDEF.cc index 44b1279e7..18d0dba1e 100644 --- a/src/plugins/streamers/lefdef/db_plugin/gsiDeclDbLEFDEF.cc +++ b/src/plugins/streamers/lefdef/db_plugin/gsiDeclDbLEFDEF.cc @@ -863,9 +863,9 @@ gsi::Class decl_lefdef_config ("db", "LEFDEFReaderConfi "are three modes available:\n" "\n" "@ul\n" - " @li 0: produce LEF geometry unless a FOREIGN cell is specified (default) @/li\n" + " @li 0: produce LEF geometry unless a FOREIGN cell is specified @/li\n" " @li 1: produce LEF geometry always and ignore FOREIGN @/li\n" - " @li 2: Never produce LEF geometry @/li\n" + " @li 2: Never produce LEF geometry and assume FOREIGN always @/li\n" "@/ul\n" "\n" "If substitution layouts are specified with \\macro_layouts, these are used to provide " diff --git a/src/plugins/streamers/lefdef/lay_plugin/LEFDEFTechnologyComponentEditor.ui b/src/plugins/streamers/lefdef/lay_plugin/LEFDEFTechnologyComponentEditor.ui index 0db23b7f8..43b5a4bcc 100644 --- a/src/plugins/streamers/lefdef/lay_plugin/LEFDEFTechnologyComponentEditor.ui +++ b/src/plugins/streamers/lefdef/lay_plugin/LEFDEFTechnologyComponentEditor.ui @@ -35,7 +35,7 @@ - 2 + 1 @@ -255,6 +255,37 @@ + + + + + 0 + 0 + + + + + + + + Produce a parent cell per group + + + + + + + Via cell name prefix + + + + + + + LEF import into DEF + + + @@ -278,7 +309,38 @@ - + + + + Groups + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal @@ -291,49 +353,23 @@ - - - - Groups - - - - - - - Produce a parent cell per group - - - - - - - Via cell name prefix - - - - - - - - 0 - 0 - - - - - - - - LEF import into DEF - - - - - - - Produce LEF geometry - + + + + + Produce LEF geometry unless FOREIGN is used + + + + + Always produce LEF geometry and ignore FOREIGN + + + + + Never produce LEF geometry and assume FOREIGN always + + @@ -1362,7 +1398,6 @@ type ... dbu separate_groups prefix_via_cellname - produce_lef_geo produce_net_names net_prop_name produce_inst_names diff --git a/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImportDialogs.cc b/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImportDialogs.cc index 1ebe6c8b8..2d4676fd4 100644 --- a/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImportDialogs.cc +++ b/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImportDialogs.cc @@ -515,7 +515,7 @@ LEFDEFReaderOptionsEditor::commit (db::FormatSpecificReaderOptions *options, con 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); + data->set_macro_resolution_mode (macro_resolution_mode->currentIndex ()); data->clear_lef_files (); for (int i = 0; i < lef_files->count (); ++i) { @@ -582,7 +582,7 @@ LEFDEFReaderOptionsEditor::setup (const db::FormatSpecificReaderOptions *options 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); + macro_resolution_mode->setCurrentIndex (data->macro_resolution_mode ()); checkbox_changed ();