mirror of https://github.com/YosysHQ/yosys.git
rtlil: Bring back old selections but deprecated
abc9 is being a butt, so run new&old side by side while I figure it out.
This commit is contained in:
parent
d84c3a9eac
commit
08e849a651
103
kernel/rtlil.cc
103
kernel/rtlil.cc
|
@ -772,6 +772,17 @@ bool RTLIL::Selection::boxed_module(const RTLIL::IdString &mod_name) const
|
|||
}
|
||||
|
||||
bool RTLIL::Selection::selected_module(const RTLIL::IdString &mod_name) const
|
||||
{
|
||||
if (full_selection)
|
||||
return true;
|
||||
if (selected_modules.count(mod_name) > 0)
|
||||
return true;
|
||||
if (selected_members.count(mod_name) > 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RTLIL::Selection::is_selected_module(const RTLIL::IdString &mod_name) const
|
||||
{
|
||||
if (!selects_boxes && boxed_module(mod_name))
|
||||
return false;
|
||||
|
@ -785,6 +796,15 @@ bool RTLIL::Selection::selected_module(const RTLIL::IdString &mod_name) const
|
|||
}
|
||||
|
||||
bool RTLIL::Selection::selected_whole_module(const RTLIL::IdString &mod_name) const
|
||||
{
|
||||
if (full_selection)
|
||||
return true;
|
||||
if (selected_modules.count(mod_name) > 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RTLIL::Selection::is_selected_whole_module(const RTLIL::IdString &mod_name) const
|
||||
{
|
||||
if (!selects_boxes && boxed_module(mod_name))
|
||||
return false;
|
||||
|
@ -796,6 +816,18 @@ bool RTLIL::Selection::selected_whole_module(const RTLIL::IdString &mod_name) co
|
|||
}
|
||||
|
||||
bool RTLIL::Selection::selected_member(const RTLIL::IdString &mod_name, const RTLIL::IdString &memb_name) const
|
||||
{
|
||||
if (full_selection)
|
||||
return true;
|
||||
if (selected_modules.count(mod_name) > 0)
|
||||
return true;
|
||||
if (selected_members.count(mod_name) > 0)
|
||||
if (selected_members.at(mod_name).count(memb_name) > 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RTLIL::Selection::is_selected_member(const RTLIL::IdString &mod_name, const RTLIL::IdString &memb_name) const
|
||||
{
|
||||
if (!selects_boxes && boxed_module(mod_name))
|
||||
return false;
|
||||
|
@ -1118,6 +1150,15 @@ bool RTLIL::Design::selected_module(const RTLIL::IdString& mod_name) const
|
|||
return selection().selected_module(mod_name);
|
||||
}
|
||||
|
||||
bool RTLIL::Design::is_selected_module(const RTLIL::IdString& mod_name) const
|
||||
{
|
||||
if (!selected_active_module.empty() && mod_name != selected_active_module)
|
||||
return false;
|
||||
if (selection_stack.size() == 0)
|
||||
return true;
|
||||
return selection().is_selected_module(mod_name);
|
||||
}
|
||||
|
||||
bool RTLIL::Design::selected_whole_module(const RTLIL::IdString& mod_name) const
|
||||
{
|
||||
if (!selected_active_module.empty() && mod_name != selected_active_module)
|
||||
|
@ -1127,6 +1168,15 @@ bool RTLIL::Design::selected_whole_module(const RTLIL::IdString& mod_name) const
|
|||
return selection().selected_whole_module(mod_name);
|
||||
}
|
||||
|
||||
bool RTLIL::Design::is_selected_whole_module(const RTLIL::IdString& mod_name) const
|
||||
{
|
||||
if (!selected_active_module.empty() && mod_name != selected_active_module)
|
||||
return false;
|
||||
if (selection_stack.size() == 0)
|
||||
return true;
|
||||
return selection().is_selected_whole_module(mod_name);
|
||||
}
|
||||
|
||||
bool RTLIL::Design::selected_member(const RTLIL::IdString& mod_name, const RTLIL::IdString& memb_name) const
|
||||
{
|
||||
if (!selected_active_module.empty() && mod_name != selected_active_module)
|
||||
|
@ -1136,16 +1186,35 @@ bool RTLIL::Design::selected_member(const RTLIL::IdString& mod_name, const RTLIL
|
|||
return selection().selected_member(mod_name, memb_name);
|
||||
}
|
||||
|
||||
bool RTLIL::Design::is_selected_member(const RTLIL::IdString& mod_name, const RTLIL::IdString& memb_name) const
|
||||
{
|
||||
if (!selected_active_module.empty() && mod_name != selected_active_module)
|
||||
return false;
|
||||
if (selection_stack.size() == 0)
|
||||
return true;
|
||||
return selection().is_selected_member(mod_name, memb_name);
|
||||
}
|
||||
|
||||
bool RTLIL::Design::selected_module(RTLIL::Module *mod) const
|
||||
{
|
||||
return selected_module(mod->name);
|
||||
}
|
||||
|
||||
bool RTLIL::Design::is_selected_module(RTLIL::Module *mod) const
|
||||
{
|
||||
return is_selected_module(mod->name);
|
||||
}
|
||||
|
||||
bool RTLIL::Design::selected_whole_module(RTLIL::Module *mod) const
|
||||
{
|
||||
return selected_whole_module(mod->name);
|
||||
}
|
||||
|
||||
bool RTLIL::Design::is_selected_whole_module(RTLIL::Module *mod) const
|
||||
{
|
||||
return is_selected_whole_module(mod->name);
|
||||
}
|
||||
|
||||
void RTLIL::Design::push_selection(RTLIL::Selection sel)
|
||||
{
|
||||
sel.current_design = this;
|
||||
|
@ -1176,6 +1245,40 @@ void RTLIL::Design::pop_selection()
|
|||
selection_stack.pop_back();
|
||||
}
|
||||
|
||||
std::vector<RTLIL::Module*> RTLIL::Design::selected_modules() const
|
||||
{
|
||||
std::vector<RTLIL::Module*> result;
|
||||
result.reserve(modules_.size());
|
||||
for (auto &it : modules_)
|
||||
if (selected_module(it.first) && !it.second->get_blackbox_attribute())
|
||||
result.push_back(it.second);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<RTLIL::Module*> RTLIL::Design::selected_whole_modules() const
|
||||
{
|
||||
std::vector<RTLIL::Module*> result;
|
||||
result.reserve(modules_.size());
|
||||
for (auto &it : modules_)
|
||||
if (selected_whole_module(it.first) && !it.second->get_blackbox_attribute())
|
||||
result.push_back(it.second);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<RTLIL::Module*> RTLIL::Design::selected_whole_modules_warn(bool include_wb) const
|
||||
{
|
||||
std::vector<RTLIL::Module*> result;
|
||||
result.reserve(modules_.size());
|
||||
for (auto &it : modules_)
|
||||
if (it.second->get_blackbox_attribute(include_wb))
|
||||
continue;
|
||||
else if (selected_whole_module(it.first))
|
||||
result.push_back(it.second);
|
||||
else if (selected_module(it.first))
|
||||
log_warning("Ignoring partially selected module %s.\n", log_id(it.first));
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<RTLIL::Module*> RTLIL::Design::selected_modules(RTLIL::SelectPartials partials, RTLIL::SelectBoxes boxes) const
|
||||
{
|
||||
bool include_partials = partials == RTLIL::SELECT_ALL;
|
||||
|
|
|
@ -1132,9 +1132,15 @@ struct RTLIL::Selection
|
|||
Selection(bool full = true, bool boxes = false, RTLIL::Design *design = nullptr) : full_selection(full), selects_boxes(boxes), current_design(design) { }
|
||||
|
||||
bool boxed_module(const RTLIL::IdString &mod_name) const;
|
||||
[[deprecated("Use is_selected_module()")]]
|
||||
bool selected_module(const RTLIL::IdString &mod_name) const;
|
||||
bool is_selected_module(const RTLIL::IdString &mod_name) const;
|
||||
[[deprecated("Use is_selected_whole_module()")]]
|
||||
bool selected_whole_module(const RTLIL::IdString &mod_name) const;
|
||||
bool is_selected_whole_module(const RTLIL::IdString &mod_name) const;
|
||||
[[deprecated("Use is_selected_member()")]]
|
||||
bool selected_member(const RTLIL::IdString &mod_name, const RTLIL::IdString &memb_name) const;
|
||||
bool is_selected_member(const RTLIL::IdString &mod_name, const RTLIL::IdString &memb_name) const;
|
||||
void optimize(RTLIL::Design *design);
|
||||
|
||||
template<typename T1> void select(T1 *module) {
|
||||
|
@ -1232,12 +1238,22 @@ struct RTLIL::Design
|
|||
void check();
|
||||
void optimize();
|
||||
|
||||
[[deprecated("Use is_selected_module() instead.")]]
|
||||
bool selected_module(const RTLIL::IdString &mod_name) const;
|
||||
bool is_selected_module(const RTLIL::IdString &mod_name) const;
|
||||
[[deprecated("Use is_selected_whole_module() instead.")]]
|
||||
bool selected_whole_module(const RTLIL::IdString &mod_name) const;
|
||||
bool is_selected_whole_module(const RTLIL::IdString &mod_name) const;
|
||||
[[deprecated("Use is_selected_member() instead.")]]
|
||||
bool selected_member(const RTLIL::IdString &mod_name, const RTLIL::IdString &memb_name) const;
|
||||
bool is_selected_member(const RTLIL::IdString &mod_name, const RTLIL::IdString &memb_name) const;
|
||||
|
||||
[[deprecated("Use is_selected_module() instead.")]]
|
||||
bool selected_module(RTLIL::Module *mod) const;
|
||||
bool is_selected_module(RTLIL::Module *mod) const;
|
||||
[[deprecated("Use is_selected_whole_module() instead.")]]
|
||||
bool selected_whole_module(RTLIL::Module *mod) const;
|
||||
bool is_selected_whole_module(RTLIL::Module *mod) const;
|
||||
|
||||
void push_selection(RTLIL::Selection sel);
|
||||
void push_empty_selection();
|
||||
|
@ -1257,14 +1273,24 @@ struct RTLIL::Design
|
|||
return selection().full_selection;
|
||||
}
|
||||
|
||||
// [[deprecated("Use is_selected() instead.")]]
|
||||
template<typename T1> bool selected(T1 *module) const {
|
||||
return selected_module(module->name);
|
||||
}
|
||||
|
||||
bool is_selected(RTLIL::NamedObject *module) const {
|
||||
return is_selected_module(module->name);
|
||||
}
|
||||
|
||||
// [[deprecated("Use is_selected() instead.")]]
|
||||
template<typename T1, typename T2> bool selected(T1 *module, T2 *member) const {
|
||||
return selected_member(module->name, member->name);
|
||||
}
|
||||
|
||||
bool is_selected(RTLIL::NamedObject *module, RTLIL::NamedObject *member) const {
|
||||
return is_selected_member(module->name, member->name);
|
||||
}
|
||||
|
||||
template<typename T1> void select(T1 *module) {
|
||||
if (selection_stack.size() > 0) {
|
||||
RTLIL::Selection &sel = selection();
|
||||
|
@ -1280,20 +1306,27 @@ struct RTLIL::Design
|
|||
}
|
||||
|
||||
|
||||
[[deprecated("Use all_selected_modules() instead.")]]
|
||||
std::vector<RTLIL::Module*> selected_modules() const;
|
||||
|
||||
[[deprecated("Use all_selected_whole_modules() instead.")]]
|
||||
std::vector<RTLIL::Module*> selected_whole_modules() const;
|
||||
[[deprecated("Use selected_unboxed_whole_modules_warn() or selected_nonbb_whole_modules_warn() instead.")]]
|
||||
std::vector<RTLIL::Module*> selected_whole_modules_warn(bool include_wb = false) const;
|
||||
|
||||
// The new methods:
|
||||
std::vector<RTLIL::Module*> selected_modules(RTLIL::SelectPartials partials, RTLIL::SelectBoxes boxes = SB_ALL) const;
|
||||
|
||||
[[deprecated("Use selected_unboxed_modules() to maintain prior behaviour, or consider one of the other selected module helpers.")]]
|
||||
std::vector<RTLIL::Module*> selected_modules() const { return selected_modules(SELECT_ALL, SB_UNBOXED_WARN); }
|
||||
std::vector<RTLIL::Module*> all_selected_modules() const { return selected_modules(SELECT_ALL, SB_ALL); }
|
||||
std::vector<RTLIL::Module*> selected_unboxed_modules() const { return selected_modules(SELECT_ALL, SB_UNBOXED_ONLY); }
|
||||
std::vector<RTLIL::Module*> selected_unboxed_modules_warn() const { return selected_modules(SELECT_ALL, SB_UNBOXED_WARN); }
|
||||
|
||||
[[deprecated("Use select_unboxed_whole_modules() to maintain prior behaviour, or consider one of the other selected whole module helpers.")]]
|
||||
std::vector<RTLIL::Module*> selected_whole_modules() const { return selected_modules(SELECT_WHOLE_ONLY, SB_UNBOXED_WARN); }
|
||||
std::vector<RTLIL::Module*> all_selected_whole_modules() const { return selected_modules(SELECT_WHOLE_ONLY, SB_ALL); }
|
||||
std::vector<RTLIL::Module*> selected_whole_modules_warn(bool include_wb = false) const { return selected_modules(SELECT_WHOLE_WARN, include_wb ? SB_EXCL_BB_WARN : SB_UNBOXED_WARN); }
|
||||
std::vector<RTLIL::Module*> all_selected_whole_modules_warn() const { return selected_modules(SELECT_WHOLE_WARN, SB_ALL); }
|
||||
std::vector<RTLIL::Module*> selected_unboxed_whole_modules() const { return selected_modules(SELECT_WHOLE_ONLY, SB_UNBOXED_ONLY); }
|
||||
std::vector<RTLIL::Module*> selected_unboxed_whole_modules_warn() const { return selected_modules(SELECT_WHOLE_WARN, SB_UNBOXED_WARN); }
|
||||
std::vector<RTLIL::Module*> selected_nonbb_whole_modules_warn() const { return selected_modules(SELECT_WHOLE_WARN, SB_EXCL_BB_WARN); }
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
static std::map<unsigned int, RTLIL::Design*> *get_all_designs(void);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue