Feature glob expansion on LEF and GDS lists for LEF/DEF reader options.

This commit is contained in:
Matthias Koefferlein
2025-04-06 19:21:02 +02:00
parent 83e0c17291
commit 6b5268e5f7
6 changed files with 198 additions and 32 deletions
@@ -38,7 +38,7 @@ namespace db
// -----------------------------------------------------------------------------------
// Path resolution utility
std::string correct_path (const std::string &fn_in, const db::Layout &layout, const std::string &base_path)
std::vector<std::string> correct_path (const std::string &fn_in, const db::Layout &layout, const std::string &base_path, bool glob)
{
const db::Technology *tech = layout.technology ();
@@ -64,19 +64,28 @@ std::string correct_path (const std::string &fn_in, const db::Layout &layout, co
if (tech && ! tech->base_path ().empty ()) {
std::string new_fn = tl::combine_path (tech->base_path (), fn);
if (tl::file_exists (new_fn)) {
return new_fn;
std::vector<std::string> res;
res.push_back (new_fn);
return res;
} else if (glob) {
return tl::glob_expand (new_fn);
}
}
if (! base_path.empty ()) {
return tl::combine_path (base_path, fn);
} else {
return fn;
fn = tl::combine_path (base_path, fn);
}
} else {
return fn;
}
if (tl::file_exists (fn) || ! glob) {
std::vector<std::string> res;
res.push_back (fn);
return res;
} else {
return tl::glob_expand (fn);
}
}
// -----------------------------------------------------------------------------------
@@ -1059,7 +1068,7 @@ LEFDEFReaderState::read_map_file (const std::string &filename, db::Layout &layou
std::map<std::pair<std::string, LayerDetailsKey>, std::vector<db::LayerProperties> > layer_map;
for (std::vector<std::string>::const_iterator p = paths.begin (); p != paths.end (); ++p) {
read_single_map_file (correct_path (*p, layout, base_path), layer_map);
read_single_map_file (correct_path (*p, layout, base_path, false).front (), layer_map);
}
// build an explicit layer mapping now.
@@ -52,7 +52,7 @@ struct MacroDesc;
* @brief Correct a path relative to the stream and technology
*/
DB_PLUGIN_PUBLIC
std::string correct_path (const std::string &fn, const db::Layout &layout, const std::string &base_path);
std::vector<std::string> correct_path (const std::string &fn, const db::Layout &layout, const std::string &base_path, bool glob);
/**
* @brief Convers a string to a MASKSHIFT index list
@@ -141,11 +141,12 @@ LEFDEFReader::read_lefdef (db::Layout &layout, const db::LoadLayoutOptions &opti
for (std::vector<std::string>::const_iterator l = effective_options.begin_lef_files (); l != effective_options.end_lef_files (); ++l) {
std::string lp = correct_path (*l, layout, base_path);
tl::InputStream lef_stream (lp);
tl::log << tl::to_string (tr ("Reading")) << " " << lp;
importer.read (lef_stream, layout, state);
auto paths = correct_path (*l, layout, base_path, true);
for (auto lp = paths.begin (); lp != paths.end (); ++lp) {
tl::InputStream lef_stream (*lp);
tl::log << tl::to_string (tr ("Reading")) << " " << *lp;
importer.read (lef_stream, layout, state);
}
}
@@ -164,14 +165,20 @@ LEFDEFReader::read_lefdef (db::Layout &layout, const db::LoadLayoutOptions &opti
for (std::vector<std::string>::const_iterator l = effective_options.begin_lef_files (); l != effective_options.end_lef_files (); ++l) {
std::string lp = correct_path (*l, layout, base_path);
lef_files_read.insert (tl::normalize_path (lp));
auto paths = correct_path (*l, layout, base_path, true);
for (auto lp = paths.begin (); lp != paths.end (); ++lp) {
tl::SelfTimer timer (tl::verbosity () >= 21, tl::to_string (tr ("Reading LEF file: ")) + lp);
if (lef_files_read.insert (tl::normalize_path (*lp)).second) {
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);
}
}
}
@@ -223,22 +230,25 @@ LEFDEFReader::read_lefdef (db::Layout &layout, const db::LoadLayoutOptions &opti
tl::shared_collection<db::Layout> macro_layout_object_holder;
for (std::vector<std::string>::const_iterator l = effective_options.begin_macro_layout_files (); l != effective_options.end_macro_layout_files (); ++l) {
std::string lp = correct_path (*l, layout, base_path);
auto paths = correct_path (*l, layout, base_path, true);
for (auto lp = paths.begin (); lp != paths.end (); ++lp) {
tl::SelfTimer timer (tl::verbosity () >= 21, tl::to_string (tr ("Reading LEF macro layout file: ")) + lp);
tl::SelfTimer timer (tl::verbosity () >= 21, tl::to_string (tr ("Reading LEF macro layout file: ")) + *lp);
tl::InputStream macro_layout_stream (lp);
tl::log << tl::to_string (tr ("Reading")) << " " << lp;
db::Layout *new_layout = new db::Layout (false);
macro_layout_object_holder.push_back (new_layout);
macro_layouts.push_back (new_layout);
tl::InputStream macro_layout_stream (*lp);
tl::log << tl::to_string (tr ("Reading")) << " " << *lp;
db::Layout *new_layout = new db::Layout (false);
macro_layout_object_holder.push_back (new_layout);
macro_layouts.push_back (new_layout);
db::Reader reader (macro_layout_stream);
reader.read (*new_layout, options);
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' does not match reader DBU (layout DBU is %.12g, reader DBU is set to %.12g)")),
*lp, new_layout->dbu (), layout.dbu ()));
}
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' does not match reader DBU (layout DBU is %.12g, reader DBU is set to %.12g)")),
lp, new_layout->dbu (), layout.dbu ()));
}
}