mirror of https://github.com/YosysHQ/yosys.git
Unify Design::selected_modules variants
Now uses two enums, one to control whether or not to include partially selected modules (and what to do if they are encountered), and one to control whether or not to include boxed modules (and what to do if they are encountered). Mark Design::selected{modules, whole_modules}() deprecated and make them provide warnings on boxes. There are a lot of places that use them and I can't always tell which ones support boxed modules and which don't.
This commit is contained in:
parent
5767da92d5
commit
39090affcd
|
@ -1146,37 +1146,58 @@ bool RTLIL::Design::selected_whole_module(RTLIL::Module *mod) const
|
||||||
return selected_whole_module(mod->name);
|
return selected_whole_module(mod->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<RTLIL::Module*> RTLIL::Design::selected_modules() const
|
|
||||||
|
std::vector<RTLIL::Module*> RTLIL::Design::selected_modules(RTLIL::SelectPartials partials, RTLIL::SelectBoxes boxes) const
|
||||||
{
|
{
|
||||||
|
bool include_partials = partials == RTLIL::SELECT_ALL;
|
||||||
|
bool exclude_boxes = (partials & RTLIL::SB_UNBOXED_ONLY) == 0;
|
||||||
|
bool ignore_wb = (partials & RTLIL::SB_INCL_WB) != 0;
|
||||||
std::vector<RTLIL::Module*> result;
|
std::vector<RTLIL::Module*> result;
|
||||||
result.reserve(modules_.size());
|
result.reserve(modules_.size());
|
||||||
for (auto &it : modules_)
|
for (auto &it : modules_)
|
||||||
if (selected_module(it.first))
|
if (selected_whole_module(it.first) || (include_partials && selected_module(it.first))) {
|
||||||
result.push_back(it.second);
|
if (!(exclude_boxes && it.second->get_blackbox_attribute(ignore_wb)))
|
||||||
return result;
|
result.push_back(it.second);
|
||||||
}
|
else
|
||||||
|
switch (boxes)
|
||||||
std::vector<RTLIL::Module*> RTLIL::Design::selected_whole_modules() const
|
{
|
||||||
{
|
case RTLIL::SB_UNBOXED_WARN:
|
||||||
std::vector<RTLIL::Module*> result;
|
log_warning("Ignoring boxed module %s.\n", log_id(it.first));
|
||||||
result.reserve(modules_.size());
|
break;
|
||||||
for (auto &it : modules_)
|
case RTLIL::SB_EXCL_BB_WARN:
|
||||||
if (selected_whole_module(it.first))
|
log_warning("Ignoring blackbox module %s.\n", log_id(it.first));
|
||||||
result.push_back(it.second);
|
break;
|
||||||
return result;
|
case RTLIL::SB_UNBOXED_ERR:
|
||||||
}
|
log_error("Unsupported boxed module %s.\n", log_id(it.first));
|
||||||
|
break;
|
||||||
std::vector<RTLIL::Module*> RTLIL::Design::selected_whole_modules_warn(bool include_wb) const
|
case RTLIL::SB_EXCL_BB_ERR:
|
||||||
{
|
log_error("Unsupported blackbox module %s.\n", log_id(it.first));
|
||||||
std::vector<RTLIL::Module*> result;
|
break;
|
||||||
result.reserve(modules_.size());
|
case RTLIL::SB_UNBOXED_CMDERR:
|
||||||
for (auto &it : modules_) {
|
log_cmd_error("Unsupported boxed module %s.\n", log_id(it.first));
|
||||||
log_assert(selection_stack.size() > 0 || !it.second->get_blackbox_attribute(include_wb));
|
break;
|
||||||
if (selected_whole_module(it.first))
|
case RTLIL::SB_EXCL_BB_CMDERR:
|
||||||
result.push_back(it.second);
|
log_cmd_error("Unsupported blackbox module %s.\n", log_id(it.first));
|
||||||
else if (selected_module(it.first))
|
break;
|
||||||
log_warning("Ignoring partially selected module %s.\n", log_id(it.first));
|
default:
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
} else if (!include_partials && selected_module(it.first)) {
|
||||||
|
switch(partials)
|
||||||
|
{
|
||||||
|
case RTLIL::SELECT_WHOLE_WARN:
|
||||||
|
log_warning("Ignoring partially selected module %s.\n", log_id(it.first));
|
||||||
|
break;
|
||||||
|
case RTLIL::SELECT_WHOLE_ERR:
|
||||||
|
log_error("Unsupported partially selected module %s.\n", log_id(it.first));
|
||||||
|
break;
|
||||||
|
case RTLIL::SELECT_WHOLE_CMDERR:
|
||||||
|
log_cmd_error("Unsupported partially selected module %s.\n", log_id(it.first));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,30 @@ namespace RTLIL
|
||||||
CONST_FLAG_REAL = 4 // only used for parameters
|
CONST_FLAG_REAL = 4 // only used for parameters
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum SelectPartials : unsigned char {
|
||||||
|
SELECT_ALL = 0, // include partial modules
|
||||||
|
SELECT_WHOLE_ONLY = 1, // ignore partial modules
|
||||||
|
SELECT_WHOLE_WARN = 2, // call log_warning on partial module
|
||||||
|
SELECT_WHOLE_ERR = 3, // call log_error on partial module
|
||||||
|
SELECT_WHOLE_CMDERR = 4 // call log_cmd_error on partial module
|
||||||
|
};
|
||||||
|
|
||||||
|
enum SelectBoxes : unsigned char {
|
||||||
|
SB_ALL = 0, // include boxed modules
|
||||||
|
SB_WARN = 1, // helper for log_warning
|
||||||
|
SB_ERR = 2, // helper for log_error
|
||||||
|
SB_CMDERR = 3, // helper for log_cmd_error
|
||||||
|
SB_UNBOXED_ONLY = 4, // ignore boxed modules
|
||||||
|
SB_UNBOXED_WARN = 5, // call log_warning on boxed module
|
||||||
|
SB_UNBOXED_ERR = 6, // call log_error on boxed module
|
||||||
|
SB_UNBOXED_CMDERR = 7, // call log_cmd_error on boxed module
|
||||||
|
SB_INCL_WB = 8, // helper for white boxes
|
||||||
|
SB_EXCL_BB_ONLY = 12, // ignore black boxes, but not white boxes
|
||||||
|
SB_EXCL_BB_WARN = 13, // call log_warning on black boxed module
|
||||||
|
SB_EXCL_BB_ERR = 14, // call log_error on black boxed module
|
||||||
|
SB_EXCL_BB_CMDERR = 15 // call log_cmd_error on black boxed module
|
||||||
|
};
|
||||||
|
|
||||||
struct Const;
|
struct Const;
|
||||||
struct AttrObject;
|
struct AttrObject;
|
||||||
struct NamedObject;
|
struct NamedObject;
|
||||||
|
@ -1250,9 +1274,20 @@ struct RTLIL::Design
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<RTLIL::Module*> selected_modules() const;
|
std::vector<RTLIL::Module*> selected_modules(RTLIL::SelectPartials partials, RTLIL::SelectBoxes boxes = SB_ALL) const;
|
||||||
std::vector<RTLIL::Module*> selected_whole_modules() const;
|
|
||||||
std::vector<RTLIL::Module*> selected_whole_modules_warn(bool include_wb = false) 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*> 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); }
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
static std::map<unsigned int, RTLIL::Design*> *get_all_designs(void);
|
static std::map<unsigned int, RTLIL::Design*> *get_all_designs(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue