3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-05-10 17:25:49 +00:00
This commit is contained in:
Catherine 2025-05-08 16:07:26 +00:00 committed by GitHub
commit 7fb21c17f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 40 additions and 18 deletions

View file

@ -93,6 +93,22 @@ Pass::~Pass()
Pass::pre_post_exec_state_t Pass::pre_execute() Pass::pre_post_exec_state_t Pass::pre_execute()
{ {
if (!abstract_modules_ok) {
bool has_top = false;
bool has_abstract = false;
for (auto mod : yosys_design->modules()) {
if (mod->get_bool_attribute(ID::top))
has_top = true;
if (mod->name.begins_with("$abstract"))
has_abstract = true;
}
if (has_abstract) {
std::string command = has_top ? "hierarchy" : "hierarchy -auto-top";
log_warning("Pass `%s` does not accept abstract modules; running `%s` first!\n", pass_name.c_str(), command.c_str());
run_pass(command);
}
}
pre_post_exec_state_t state; pre_post_exec_state_t state;
call_counter++; call_counter++;
state.begin_ns = PerformanceTimer::query(); state.begin_ns = PerformanceTimer::query();
@ -385,6 +401,7 @@ Frontend::Frontend(std::string name, std::string short_help) :
Pass(name.rfind("=", 0) == 0 ? name.substr(1) : "read_" + name, short_help), Pass(name.rfind("=", 0) == 0 ? name.substr(1) : "read_" + name, short_help),
frontend_name(name.rfind("=", 0) == 0 ? name.substr(1) : name) frontend_name(name.rfind("=", 0) == 0 ? name.substr(1) : name)
{ {
abstract_modules_ok = true;
} }
void Frontend::run_register() void Frontend::run_register()

View file

@ -38,6 +38,7 @@ struct Pass
int call_counter; int call_counter;
int64_t runtime_ns; int64_t runtime_ns;
bool experimental_flag = false; bool experimental_flag = false;
bool abstract_modules_ok = false;
void experimental() { void experimental() {
experimental_flag = true; experimental_flag = true;
@ -80,7 +81,11 @@ struct ScriptPass : Pass
RTLIL::Design *active_design; RTLIL::Design *active_design;
std::string active_run_from, active_run_to; std::string active_run_from, active_run_to;
ScriptPass(std::string name, std::string short_help = "** document me **") : Pass(name, short_help) { } ScriptPass(std::string name, std::string short_help = "** document me **") : Pass(name, short_help) {
// Either the script pass will include an explicit `hierarchy` invocation or one of the passes called inside will
// trigger the check for abstract modules.
abstract_modules_ok = true;
}
virtual void script() = 0; virtual void script() = 0;

View file

@ -23,7 +23,7 @@ USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN PRIVATE_NAMESPACE_BEGIN
struct BlackboxPass : public Pass { struct BlackboxPass : public Pass {
BlackboxPass() : Pass("blackbox", "convert modules into blackbox modules") { } BlackboxPass() : Pass("blackbox", "convert modules into blackbox modules") { abstract_modules_ok = true; }
void help() override void help() override
{ {
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|

View file

@ -27,7 +27,7 @@ std::map<std::string, RTLIL::Design*> saved_designs;
std::vector<RTLIL::Design*> pushed_designs; std::vector<RTLIL::Design*> pushed_designs;
struct DesignPass : public Pass { struct DesignPass : public Pass {
DesignPass() : Pass("design", "save, restore and reset current design") { } DesignPass() : Pass("design", "save, restore and reset current design") { abstract_modules_ok = true; }
~DesignPass() override { ~DesignPass() override {
for (auto &it : saved_designs) for (auto &it : saved_designs)
delete it.second; delete it.second;

View file

@ -37,7 +37,7 @@ USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN PRIVATE_NAMESPACE_BEGIN
struct ExecPass : public Pass { struct ExecPass : public Pass {
ExecPass() : Pass("exec", "execute commands in the operating system shell") { } ExecPass() : Pass("exec", "execute commands in the operating system shell") { abstract_modules_ok = true; }
void help() override void help() override
{ {
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|

View file

@ -26,7 +26,7 @@ USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN PRIVATE_NAMESPACE_BEGIN
struct LogPass : public Pass { struct LogPass : public Pass {
LogPass() : Pass("log", "print text and log files") { } LogPass() : Pass("log", "print text and log files") { abstract_modules_ok = true; }
void help() override void help() override
{ {
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|

View file

@ -24,7 +24,7 @@ USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN PRIVATE_NAMESPACE_BEGIN
struct LoggerPass : public Pass { struct LoggerPass : public Pass {
LoggerPass() : Pass("logger", "set logger properties") { } LoggerPass() : Pass("logger", "set logger properties") { abstract_modules_ok = true; }
void help() override void help() override
{ {
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|

View file

@ -121,7 +121,7 @@ void load_plugin(std::string, std::vector<std::string>)
#endif #endif
struct PluginPass : public Pass { struct PluginPass : public Pass {
PluginPass() : Pass("plugin", "load and list loaded plugins") { } PluginPass() : Pass("plugin", "load and list loaded plugins") { abstract_modules_ok = true; }
void help() override void help() override
{ {
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|

View file

@ -26,7 +26,7 @@ USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN PRIVATE_NAMESPACE_BEGIN
struct ScratchpadPass : public Pass { struct ScratchpadPass : public Pass {
ScratchpadPass() : Pass("scratchpad", "get/set values in the scratchpad") { } ScratchpadPass() : Pass("scratchpad", "get/set values in the scratchpad") { abstract_modules_ok = true; }
void help() override void help() override
{ {
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|

View file

@ -111,7 +111,7 @@ struct SetattrPass : public Pass {
} SetattrPass; } SetattrPass;
struct WbflipPass : public Pass { struct WbflipPass : public Pass {
WbflipPass() : Pass("wbflip", "flip the whitebox attribute") { } WbflipPass() : Pass("wbflip", "flip the whitebox attribute") { abstract_modules_ok = true; }
void help() override void help() override
{ {
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
@ -142,7 +142,7 @@ struct WbflipPass : public Pass {
} WbflipPass; } WbflipPass;
struct SetparamPass : public Pass { struct SetparamPass : public Pass {
SetparamPass() : Pass("setparam", "set/unset parameters on objects") { } SetparamPass() : Pass("setparam", "set/unset parameters on objects") { abstract_modules_ok = true; }
void help() override void help() override
{ {
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
@ -194,7 +194,7 @@ struct SetparamPass : public Pass {
} SetparamPass; } SetparamPass;
struct ChparamPass : public Pass { struct ChparamPass : public Pass {
ChparamPass() : Pass("chparam", "re-evaluate modules with new parameters") { } ChparamPass() : Pass("chparam", "re-evaluate modules with new parameters") { abstract_modules_ok = true; }
void help() override void help() override
{ {
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|

View file

@ -26,7 +26,7 @@ USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN PRIVATE_NAMESPACE_BEGIN
struct TeePass : public Pass { struct TeePass : public Pass {
TeePass() : Pass("tee", "redirect command output to file") { } TeePass() : Pass("tee", "redirect command output to file") { abstract_modules_ok = true; }
void help() override void help() override
{ {
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|

View file

@ -59,7 +59,7 @@ struct TraceMonitor : public RTLIL::Monitor
}; };
struct TracePass : public Pass { struct TracePass : public Pass {
TracePass() : Pass("trace", "redirect command output to file") { } TracePass() : Pass("trace", "redirect command output to file") { abstract_modules_ok = true; }
void help() override void help() override
{ {
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|

View file

@ -727,7 +727,7 @@ RTLIL::Wire *find_implicit_port_wire(Module *module, Cell *cell, const std::stri
} }
struct HierarchyPass : public Pass { struct HierarchyPass : public Pass {
HierarchyPass() : Pass("hierarchy", "check, expand and clean up design hierarchy") { } HierarchyPass() : Pass("hierarchy", "check, expand and clean up design hierarchy") { abstract_modules_ok = true; }
void help() override void help() override
{ {
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|