From 8422fe8f832b1a5649a8f1506e0339dd5553ce03 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 18 May 2024 19:41:22 +0200 Subject: [PATCH] Implementing solution for issue #1701 (Feature request: strm2oas should report input unit differences) --- src/buddies/src/bd/bdReaderOptions.cc | 24 +++---------------- src/buddies/src/bd/bdReaderOptions.h | 2 -- .../lefdef/db_plugin/dbDEFImporter.cc | 4 ++++ .../lefdef/db_plugin/dbLEFDEFImporter.cc | 20 +++++++++++----- .../lefdef/db_plugin/dbLEFDEFImporter.h | 19 ++++++++------- .../lefdef/db_plugin/dbLEFDEFPlugin.cc | 5 ++++ 6 files changed, 36 insertions(+), 38 deletions(-) diff --git a/src/buddies/src/bd/bdReaderOptions.cc b/src/buddies/src/bd/bdReaderOptions.cc index ebeaaf870..62adc98eb 100644 --- a/src/buddies/src/bd/bdReaderOptions.cc +++ b/src/buddies/src/bd/bdReaderOptions.cc @@ -805,29 +805,11 @@ GenericReaderOptions::configure (db::LoadLayoutOptions &load_options) load_options.set_option_by_name ("lefdef_config.macro_resolution_mode", m_lefdef_macro_resolution_mode); load_options.set_option_by_name ("lefdef_config.paths_relative_to_cwd", true); - m_lef_layouts.clear (); - tl::Variant lef_layout_ptrs = tl::Variant::empty_list (); + tl::Variant lef_layout_files = 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 (); - } - + lef_layout_files.push (*l); } - - load_options.set_option_by_name ("lefdef_config.macro_layouts", lef_layout_ptrs); + load_options.set_option_by_name ("lefdef_config.macro_layout_files", lef_layout_files); } static std::string::size_type find_file_sep (const std::string &s, std::string::size_type from) diff --git a/src/buddies/src/bd/bdReaderOptions.h b/src/buddies/src/bd/bdReaderOptions.h index 62a4ac189..6d6414858 100644 --- a/src/buddies/src/bd/bdReaderOptions.h +++ b/src/buddies/src/bd/bdReaderOptions.h @@ -189,8 +189,6 @@ private: std::string m_lefdef_map_file; int m_lefdef_macro_resolution_mode; std::vector m_lefdef_lef_layout_files; - - tl::shared_collection m_lef_layouts; }; /** diff --git a/src/plugins/streamers/lefdef/db_plugin/dbDEFImporter.cc b/src/plugins/streamers/lefdef/db_plugin/dbDEFImporter.cc index 4a35ba4c9..28db90d8a 100644 --- a/src/plugins/streamers/lefdef/db_plugin/dbDEFImporter.cc +++ b/src/plugins/streamers/lefdef/db_plugin/dbDEFImporter.cc @@ -1704,6 +1704,10 @@ DEFImporter::do_read (db::Layout &layout) double units = get_double (); if (fabs (units) > 1e-6) { scale = 1.0 / (units * layout.dbu ()); + if (fabs (scale - 1.0) > db::epsilon) { + warn (tl::sprintf (tl::to_string (tr ("DEF UNITS not matching reader DBU (DEF UNITS is %.12g and corresponds to a DBU of %.12g, but reader unit is %.12g)")), + units, 1.0 / units, layout.dbu ())); + } } expect (";"); diff --git a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.cc b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.cc index 803cca456..ec404f7c8 100644 --- a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.cc +++ b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.cc @@ -2068,7 +2068,9 @@ LEFDEFImporter::read (tl::InputStream &stream, db::Layout &layout, LEFDEFReaderS void LEFDEFImporter::error (const std::string &msg) { - if (m_sections.empty ()) { + if (! mp_stream) { + throw LEFDEFReaderException (msg, -1, std::string (), m_fn); + } else if (m_sections.empty ()) { throw LEFDEFReaderException (msg, int (mp_stream->line_number ()), m_cellname, m_fn); } else { throw LEFDEFReaderException (msg + tl::sprintf (tl::to_string (tr (" (inside %s)")), tl::join (m_sections, "/")), int (mp_stream->line_number ()), m_cellname, m_fn); @@ -2082,11 +2084,17 @@ LEFDEFImporter::warn (const std::string &msg, int wl) return; } - tl::warn << msg - << tl::to_string (tr (" (line=")) << mp_stream->line_number () - << tl::to_string (tr (", cell=")) << m_cellname - << tl::to_string (tr (", file=")) << m_fn - << ")"; + if (! mp_stream) { + tl::warn << msg + << tl::to_string (tr (" (file=")) << m_fn + << ")"; + } else { + tl::warn << msg + << tl::to_string (tr (" (line=")) << mp_stream->line_number () + << tl::to_string (tr (", cell=")) << m_cellname + << tl::to_string (tr (", file=")) << m_fn + << ")"; + } } bool diff --git a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.h b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.h index 1a0cde661..647e3afd2 100644 --- a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.h +++ b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFImporter.h @@ -67,7 +67,8 @@ class DB_PLUGIN_PUBLIC LEFDEFReaderException { public: LEFDEFReaderException (const std::string &msg, int line, const std::string &cell, const std::string &fn) - : db::ReaderException (tl::sprintf (tl::to_string (tr ("%s (line=%d, cell=%s, file=%s)")), msg.c_str (), line, cell, fn)) + : db::ReaderException (line >= 0 ? tl::sprintf (tl::to_string (tr ("%s (line=%d, cell=%s, file=%s)")), msg.c_str (), line, cell, fn) : + tl::sprintf (tl::to_string (tr ("%s (file=%s)")), msg.c_str (), fn)) { } }; @@ -1517,14 +1518,6 @@ public: */ void read (tl::InputStream &stream, db::Layout &layout, LEFDEFReaderState &state); -protected: - /** - * @brief Actually does the reading - * - * Reimplement that method for the LEF and DEF implementation - */ - virtual void do_read (db::Layout &layout) = 0; - /** * @brief Issue an error at the current location */ @@ -1535,6 +1528,14 @@ protected: */ void warn (const std::string &msg, int wl = 1); +protected: + /** + * @brief Actually does the reading + * + * Reimplement that method for the LEF and DEF implementation + */ + virtual void do_read (db::Layout &layout) = 0; + /** * @brief Returns true if the reader is at the end of the file */ diff --git a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc index b9f1e9dcb..49bd9ffee 100644 --- a/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc +++ b/src/plugins/streamers/lefdef/db_plugin/dbLEFDEFPlugin.cc @@ -228,6 +228,11 @@ LEFDEFReader::read_lefdef (db::Layout &layout, const db::LoadLayoutOptions &opti db::Reader reader (macro_layout_stream); reader.read (*new_layout, options); + if (fabs (new_layout->dbu () / layout.dbu () - 1.0) > db::epsilon) { + importer.warn (tl::sprintf (tl::to_string (tr ("DBU of macro layout file '%s' is not compatible with reader DBU (layout DBU is %.12g, reader DBU is %.12g)")), + lp, new_layout->dbu (), layout.dbu ())); + } + } for (std::vector::const_iterator m = macro_layouts.begin (); m != macro_layouts.end (); ++m) {