mirror of https://github.com/YosysHQ/yosys.git
Added copy-constructor-like module->addCell(name, other) method
This commit is contained in:
parent
2bec47a404
commit
4755e14e7b
|
@ -782,14 +782,8 @@ void RTLIL::Module::cloneInto(RTLIL::Module *new_mod) const
|
||||||
for (auto &it : memories)
|
for (auto &it : memories)
|
||||||
new_mod->memories[it.first] = new RTLIL::Memory(*it.second);
|
new_mod->memories[it.first] = new RTLIL::Memory(*it.second);
|
||||||
|
|
||||||
for (auto &it : cells) {
|
for (auto &it : cells)
|
||||||
new_mod->cells[it.first] = new RTLIL::Cell;
|
new_mod->addCell(it.first, it.second);
|
||||||
new_mod->cells[it.first]->name = it.second->name;
|
|
||||||
new_mod->cells[it.first]->type = it.second->type;
|
|
||||||
new_mod->cells[it.first]->connections = it.second->connections;
|
|
||||||
new_mod->cells[it.first]->parameters = it.second->parameters;
|
|
||||||
new_mod->cells[it.first]->attributes = it.second->attributes;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto &it : processes)
|
for (auto &it : processes)
|
||||||
new_mod->processes[it.first] = it.second->clone();
|
new_mod->processes[it.first] = it.second->clone();
|
||||||
|
@ -912,6 +906,15 @@ RTLIL::Cell *RTLIL::Module::addCell(RTLIL::IdString name, RTLIL::IdString type)
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RTLIL::Cell *RTLIL::Module::addCell(RTLIL::IdString name, const RTLIL::Cell *other)
|
||||||
|
{
|
||||||
|
RTLIL::Cell *cell = addCell(name, other->type);
|
||||||
|
cell->connections = other->connections;
|
||||||
|
cell->parameters = other->parameters;
|
||||||
|
cell->attributes = other->attributes;
|
||||||
|
return cell;
|
||||||
|
}
|
||||||
|
|
||||||
#define DEF_METHOD(_func, _y_size, _type) \
|
#define DEF_METHOD(_func, _y_size, _type) \
|
||||||
RTLIL::Cell* RTLIL::Module::add ## _func(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, bool is_signed) { \
|
RTLIL::Cell* RTLIL::Module::add ## _func(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_y, bool is_signed) { \
|
||||||
RTLIL::Cell *cell = new RTLIL::Cell; \
|
RTLIL::Cell *cell = new RTLIL::Cell; \
|
||||||
|
|
|
@ -302,6 +302,7 @@ struct RTLIL::Module
|
||||||
|
|
||||||
RTLIL::Wire *addWire(RTLIL::IdString name, int width = 1);
|
RTLIL::Wire *addWire(RTLIL::IdString name, int width = 1);
|
||||||
RTLIL::Cell *addCell(RTLIL::IdString name, RTLIL::IdString type);
|
RTLIL::Cell *addCell(RTLIL::IdString name, RTLIL::IdString type);
|
||||||
|
RTLIL::Cell *addCell(RTLIL::IdString name, const RTLIL::Cell *other);
|
||||||
|
|
||||||
// The add* methods create a cell and return the created cell. All signals must exist in advance.
|
// The add* methods create a cell and return the created cell. All signals must exist in advance.
|
||||||
|
|
||||||
|
|
|
@ -162,10 +162,7 @@ struct SubmodWorker
|
||||||
}
|
}
|
||||||
|
|
||||||
for (RTLIL::Cell *cell : submod.cells) {
|
for (RTLIL::Cell *cell : submod.cells) {
|
||||||
RTLIL::Cell *new_cell = new_mod->addCell(cell->name, cell->type);
|
RTLIL::Cell *new_cell = new_mod->addCell(cell->name, cell);
|
||||||
new_cell->connections = cell->connections;
|
|
||||||
new_cell->parameters = cell->parameters;
|
|
||||||
new_cell->attributes = cell->attributes;
|
|
||||||
for (auto &conn : new_cell->connections)
|
for (auto &conn : new_cell->connections)
|
||||||
for (auto &bit : conn.second)
|
for (auto &bit : conn.second)
|
||||||
if (bit.wire != NULL) {
|
if (bit.wire != NULL) {
|
||||||
|
|
|
@ -183,22 +183,18 @@ struct TechmapWorker
|
||||||
for (auto &it : tpl->cells)
|
for (auto &it : tpl->cells)
|
||||||
{
|
{
|
||||||
RTLIL::IdString c_name = it.second->name;
|
RTLIL::IdString c_name = it.second->name;
|
||||||
RTLIL::IdString c_type = it.second->type;
|
|
||||||
|
|
||||||
if (!flatten_mode && c_type.substr(0, 2) == "\\$")
|
|
||||||
c_type = c_type.substr(1);
|
|
||||||
|
|
||||||
if (!flatten_mode && c_name == "\\_TECHMAP_REPLACE_")
|
if (!flatten_mode && c_name == "\\_TECHMAP_REPLACE_")
|
||||||
c_name = orig_cell_name;
|
c_name = orig_cell_name;
|
||||||
else
|
else
|
||||||
apply_prefix(cell->name, c_name);
|
apply_prefix(cell->name, c_name);
|
||||||
|
|
||||||
RTLIL::Cell *c = module->addCell(c_name, c_type);
|
RTLIL::Cell *c = module->addCell(c_name, it.second);
|
||||||
c->connections = it.second->connections;
|
|
||||||
c->parameters = it.second->parameters;
|
|
||||||
c->attributes = it.second->attributes;
|
|
||||||
design->select(module, c);
|
design->select(module, c);
|
||||||
|
|
||||||
|
if (!flatten_mode && c->type.substr(0, 2) == "\\$")
|
||||||
|
c->type = c->type.substr(1);
|
||||||
|
|
||||||
for (auto &it2 : c->connections) {
|
for (auto &it2 : c->connections) {
|
||||||
apply_prefix(cell->name, it2.second, module);
|
apply_prefix(cell->name, it2.second, module);
|
||||||
port_signal_map.apply(it2.second);
|
port_signal_map.apply(it2.second);
|
||||||
|
|
Loading…
Reference in New Issue