aboutsummaryrefslogtreecommitdiffstats
path: root/passes/hierarchy/hierarchy.cc
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2018-03-27 14:10:39 +0200
committerGitHub <noreply@github.com>2018-03-27 14:10:39 +0200
commitc652774ca26416c4afeb4894b315814e20c42551 (patch)
tree8a18ca5f81134be0c4aa8cba4a1453804781b6d5 /passes/hierarchy/hierarchy.cc
parent77bd645c35225d4fa1a1c632457acfb47b7388eb (diff)
parentf93f8aaa114b06e046a107c9e1f77046a4b5b1fc (diff)
downloadyosys-c652774ca26416c4afeb4894b315814e20c42551.tar.gz
yosys-c652774ca26416c4afeb4894b315814e20c42551.tar.bz2
yosys-c652774ca26416c4afeb4894b315814e20c42551.zip
Merge pull request #518 from xerpi/master
passes/hierarchy: Reduce code duplication in expand_module
Diffstat (limited to 'passes/hierarchy/hierarchy.cc')
-rw-r--r--passes/hierarchy/hierarchy.cc28
1 files changed, 13 insertions, 15 deletions
diff --git a/passes/hierarchy/hierarchy.cc b/passes/hierarchy/hierarchy.cc
index 71b0cf622..21a232572 100644
--- a/passes/hierarchy/hierarchy.cc
+++ b/passes/hierarchy/hierarchy.cc
@@ -173,22 +173,20 @@ bool expand_module(RTLIL::Design *design, RTLIL::Module *module, bool flag_check
for (auto &dir : libdirs)
{
- filename = dir + "/" + RTLIL::unescape_id(cell->type) + ".v";
- if (check_file_exists(filename)) {
- Frontend::frontend_call(design, NULL, filename, "verilog");
- goto loaded_module;
- }
-
- filename = dir + "/" + RTLIL::unescape_id(cell->type) + ".sv";
- if (check_file_exists(filename)) {
- Frontend::frontend_call(design, NULL, filename, "verilog -sv");
- goto loaded_module;
- }
+ static const std::map<std::string, std::string> extensions_map =
+ {
+ {".v", "verilog"},
+ {".sv", "verilog -sv"},
+ {".il", "ilang"}
+ };
- filename = dir + "/" + RTLIL::unescape_id(cell->type) + ".il";
- if (check_file_exists(filename)) {
- Frontend::frontend_call(design, NULL, filename, "ilang");
- goto loaded_module;
+ for (auto &ext : extensions_map)
+ {
+ filename = dir + "/" + RTLIL::unescape_id(cell->type) + ext.first;
+ if (check_file_exists(filename)) {
+ Frontend::frontend_call(design, NULL, filename, ext.second);
+ goto loaded_module;
+ }
}
}