diff options
author | Clifford Wolf <clifford@clifford.at> | 2014-02-06 19:22:46 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2014-02-06 19:22:46 +0100 |
commit | fa295a4528513d6beeff638520d519faafd99324 (patch) | |
tree | b11afcff018bdb515596ec4b89dac9ff6a514931 /kernel/rtlil.cc | |
parent | d4b0f28881e361f53b61e67c4cb5cd04c196d204 (diff) |
Added generic RTLIL::SigSpec::parse_sel() with support for selection variables
Diffstat (limited to 'kernel/rtlil.cc')
-rw-r--r-- | kernel/rtlil.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 2ab3320b..95d62503 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -1649,6 +1649,24 @@ bool RTLIL::SigSpec::parse(RTLIL::SigSpec &sig, RTLIL::Module *module, std::stri return true; } +bool RTLIL::SigSpec::parse_sel(RTLIL::SigSpec &sig, RTLIL::Design *design, RTLIL::Module *module, std::string str) +{ + if (str.empty() || str[0] != '@') + return parse(sig, module, str); + + str = RTLIL::escape_id(str.substr(1)); + if (design->selection_vars.count(str) == 0) + return false; + + sig = RTLIL::SigSpec(); + RTLIL::Selection &sel = design->selection_vars.at(str); + for (auto &it : module->wires) + if (sel.selected_member(module->name, it.first)) + sig.append(it.second); + + return true; +} + bool RTLIL::SigSpec::parse_rhs(const RTLIL::SigSpec &lhs, RTLIL::SigSpec &sig, RTLIL::Module *module, std::string str) { if (str == "0") { |