3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-06-07 06:33:24 +00:00

cxxrtl: provide a way to perform unobtrusive power-on reset.

Although it is always possible to destroy and recreate the design to
simulate a power-on reset, this has two drawbacks:
  * Black boxes are also destroyed and recreated, which causes them
    to reacquire their resources, which might be costly and/or erase
    important state.
  * Pointers into the design are invalidated and have to be acquired
    again, which is costly and might be very inconvenient if they are
    captured elsewhere (especially through the C API).
This commit is contained in:
whitequark 2020-12-02 08:25:27 +00:00
parent 7b0cfd5c36
commit 5beab5bc17
4 changed files with 78 additions and 3 deletions

View file

@ -1869,6 +1869,46 @@ struct CxxrtlWorker {
}
if (has_cells)
f << "\n";
f << indent << mangle(module) << "() {}\n";
if (has_cells) {
f << indent << mangle(module) << "(adopt, " << mangle(module) << " other) :\n";
bool first = true;
for (auto cell : module->cells()) {
if (is_internal_cell(cell->type))
continue;
if (first) {
first = false;
} else {
f << ",\n";
}
RTLIL::Module *cell_module = module->design->module(cell->type);
if (cell_module->get_bool_attribute(ID(cxxrtl_blackbox))) {
f << indent << " " << mangle(cell) << "(std::move(other." << mangle(cell) << "))";
} else {
f << indent << " " << mangle(cell) << "(adopt {}, std::move(other." << mangle(cell) << "))";
}
}
f << " {\n";
inc_indent();
for (auto cell : module->cells()) {
if (is_internal_cell(cell->type))
continue;
RTLIL::Module *cell_module = module->design->module(cell->type);
if (cell_module->get_bool_attribute(ID(cxxrtl_blackbox)))
f << indent << mangle(cell) << "->reset();\n";
}
dec_indent();
f << indent << "}\n";
} else {
f << indent << mangle(module) << "(adopt, " << mangle(module) << " other) {}\n";
}
f << "\n";
f << indent << "void reset() override {\n";
inc_indent();
f << indent << "*this = " << mangle(module) << "(adopt {}, std::move(*this));\n";
dec_indent();
f << indent << "}\n";
f << "\n";
f << indent << "bool eval() override;\n";
f << indent << "bool commit() override;\n";
if (debug_info)