interchange: Track the macros that cells have been expanded from
Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
parent
78c965141f
commit
2476f116bb
@ -1152,6 +1152,7 @@ struct Arch : ArchAPI<ArchRanges>
|
|||||||
const DefaultCellConnsPOD *get_default_conns(IdString cell_type) const;
|
const DefaultCellConnsPOD *get_default_conns(IdString cell_type) const;
|
||||||
void pack_default_conns();
|
void pack_default_conns();
|
||||||
|
|
||||||
|
dict<IdString, std::vector<CellInfo *>> macro_to_cells;
|
||||||
void expand_macros();
|
void expand_macros();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -120,6 +120,7 @@ struct ArchCellInfo
|
|||||||
dict<IdString, std::vector<IdString>> cell_bel_pins;
|
dict<IdString, std::vector<IdString>> cell_bel_pins;
|
||||||
dict<IdString, std::vector<IdString>> masked_cell_bel_pins;
|
dict<IdString, std::vector<IdString>> masked_cell_bel_pins;
|
||||||
pool<IdString> const_ports;
|
pool<IdString> const_ports;
|
||||||
|
IdString macro_parent = IdString();
|
||||||
LutCell lut_cell;
|
LutCell lut_cell;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -66,6 +66,8 @@ void Arch::expand_macros()
|
|||||||
const MacroPOD *macro = lookup_macro(chip_info, exp ? IdString(exp->macro_name) : cell->type);
|
const MacroPOD *macro = lookup_macro(chip_info, exp ? IdString(exp->macro_name) : cell->type);
|
||||||
if (macro == nullptr)
|
if (macro == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
// Get the ultimate root of this macro expansion
|
||||||
|
IdString parent = (cell->macro_parent == IdString()) ? cell->name : cell->macro_parent;
|
||||||
// Create child instances
|
// Create child instances
|
||||||
for (const auto &inst : macro->cell_insts) {
|
for (const auto &inst : macro->cell_insts) {
|
||||||
CellInfo *inst_cell =
|
CellInfo *inst_cell =
|
||||||
@ -73,6 +75,7 @@ void Arch::expand_macros()
|
|||||||
for (const auto ¶m : inst.parameters) {
|
for (const auto ¶m : inst.parameters) {
|
||||||
inst_cell->params[IdString(param.key)] = IdString(param.value).str(ctx);
|
inst_cell->params[IdString(param.key)] = IdString(param.value).str(ctx);
|
||||||
}
|
}
|
||||||
|
inst_cell->macro_parent = parent;
|
||||||
next_cells.push_back(inst_cell);
|
next_cells.push_back(inst_cell);
|
||||||
}
|
}
|
||||||
// Create and connect nets
|
// Create and connect nets
|
||||||
@ -156,6 +159,9 @@ void Arch::expand_macros()
|
|||||||
std::swap(next_cells, cells);
|
std::swap(next_cells, cells);
|
||||||
next_cells.clear();
|
next_cells.clear();
|
||||||
} while (!cells.empty());
|
} while (!cells.empty());
|
||||||
|
// Do this at the end, otherwise we might add cells that are later destroyed
|
||||||
|
for (auto &cell : ctx->cells)
|
||||||
|
macro_to_cells[cell.second->macro_parent].push_back(cell.second.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
Loading…
Reference in New Issue
Block a user