diff options
author | Clifford Wolf <clifford@clifford.at> | 2014-02-02 16:47:17 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2014-02-02 16:47:17 +0100 |
commit | a9e2d86f86291e82e752dab5cec796f7263ad905 (patch) | |
tree | 4564f77b3437ac1d2bad3bc7877d704baf00f3ea /passes/cmds/select.cc | |
parent | 0f88e2869367966e6386cbe0b5e92ed028dae66c (diff) | |
download | yosys-a9e2d86f86291e82e752dab5cec796f7263ad905.tar.gz yosys-a9e2d86f86291e82e752dab5cec796f7263ad905.tar.bz2 yosys-a9e2d86f86291e82e752dab5cec796f7263ad905.zip |
Added suuport for module attribute matching with A:<pattern>[=<pattern>] syntax
Diffstat (limited to 'passes/cmds/select.cc')
-rw-r--r-- | passes/cmds/select.cc | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/passes/cmds/select.cc b/passes/cmds/select.cc index 550545384..9c0a39650 100644 --- a/passes/cmds/select.cc +++ b/passes/cmds/select.cc @@ -48,8 +48,11 @@ static bool match_ids(RTLIL::IdString id, std::string pattern) static bool match_attr_val(const RTLIL::Const &value, std::string pattern) { - if ((value.flags & RTLIL::CONST_FLAG_STRING) == 0) - return false; + if ((value.flags & RTLIL::CONST_FLAG_STRING) == 0) { + char *endp = NULL; + long int v = strtol(pattern.c_str(), &endp, 0); + return *endp == 0 && value.as_int() == v; + } if (!fnmatch(pattern.c_str(), value.decode_string().c_str(), FNM_NOESCAPE)) return true; return false; @@ -529,7 +532,7 @@ static void select_stmt(RTLIL::Design *design, std::string arg) } else { size_t pos = arg.find('/'); if (pos == std::string::npos) { - if (arg.find(':') == std::string::npos) + if (arg.find(':') == std::string::npos || arg.substr(0, 1) == "A") arg_mod = arg; else arg_mod = "*", arg_memb = arg; @@ -550,6 +553,17 @@ static void select_stmt(RTLIL::Design *design, std::string arg) sel.full_selection = false; for (auto &mod_it : design->modules) { + if (arg_mod.substr(0, 2) == "A:") { + bool use_value_pat = false; + std::string name_pat = arg_mod.substr(2), value_pat; + if (name_pat.find('=') != std::string::npos) { + value_pat = name_pat.substr(name_pat.find('=')+1); + name_pat = name_pat.substr(0, name_pat.find('=')); + use_value_pat = true; + } + if (!match_attr(mod_it.second->attributes, name_pat, value_pat, use_value_pat)) + continue; + } else if (!match_ids(mod_it.first, arg_mod)) continue; @@ -726,8 +740,11 @@ struct SelectPass : public Pass { log(" <obj_pattern>\n"); log(" select the specified object(s) from the current module\n"); log("\n"); - log("A <mod_pattern> can be a module name or wildcard expression (*, ?, [..])\n"); - log("matching module names.\n"); + log("A <mod_pattern> can be a module name, wildcard expression (*, ?, [..])\n"); + log("matching module names, or one of the following:\n"); + log("\n"); + log(" A:<pattern>, A:<pattern>=<pattern>\n"); + log(" all modules with an attribute matching the given pattern\n"); log("\n"); log("An <obj_pattern> can be an object name, wildcard expression, or one of\n"); log("the following:\n"); |