mirror of
https://github.com/YosysHQ/yosys
synced 2026-05-25 19:36:21 +00:00
rtlil: add CellAdderMixin for shared Cell adder interface between Module and Patch
This commit is contained in:
parent
770d74cc9b
commit
dbc7e33908
4 changed files with 1283 additions and 1252 deletions
|
|
@ -5,40 +5,50 @@
|
|||
YOSYS_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* Notes
|
||||
*
|
||||
* If we want GC, we need more indices
|
||||
* namely user count (and users?). This should be optional
|
||||
*
|
||||
*
|
||||
* Notes
|
||||
*
|
||||
* If we want GC, we need more indices
|
||||
* namely user count (and users?). This should be optional
|
||||
*
|
||||
*
|
||||
*/
|
||||
using namespace RTLIL;
|
||||
|
||||
template class CellAdderMixin<Patch>;
|
||||
|
||||
Cell* Patch::addCell(IdString name, IdString type) {
|
||||
auto& cell = cells_.emplace_back(Cell::ConstructToken{});
|
||||
auto& cell = cells_.emplace_back(Cell::ConstructToken{});
|
||||
cell.name = std::move(name);
|
||||
cell.type = type;
|
||||
return &cell;
|
||||
return &cell;
|
||||
}
|
||||
|
||||
Wire* Patch::addWire(IdString name, int width) {
|
||||
(void)name;
|
||||
(void)width;
|
||||
log_assert(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Patch::patch() {
|
||||
for (auto& cell: cells_) {
|
||||
Cell* new_cell = mod->addCell(cell.name, &cell);
|
||||
for (auto [port_name, sig] : new_cell->connections()) {
|
||||
log_assert(yosys_celltypes.cell_known(cell.type));
|
||||
auto dir = cell.port_dir(port_name);
|
||||
if (dir == PD_OUTPUT || dir == PD_INOUT) {
|
||||
for (auto chunk : sig.chunks()) {
|
||||
log_assert(chunk.is_wire());
|
||||
auto* wire = chunk.wire;
|
||||
// Unwire old driver
|
||||
wire->driverCell_->setPort(wire->driverPort_, SigSpec());
|
||||
// Maintain bufnorm
|
||||
wire->driverCell_ = new_cell;
|
||||
wire->driverPort_ = port_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto& cell: cells_) {
|
||||
Cell* new_cell = mod->addCell(cell.name, &cell);
|
||||
for (auto [port_name, sig] : new_cell->connections()) {
|
||||
log_assert(yosys_celltypes.cell_known(cell.type));
|
||||
auto dir = cell.port_dir(port_name);
|
||||
if (dir == PD_OUTPUT || dir == PD_INOUT) {
|
||||
for (auto chunk : sig.chunks()) {
|
||||
log_assert(chunk.is_wire());
|
||||
auto* wire = chunk.wire;
|
||||
// Unwire old driver
|
||||
wire->driverCell_->setPort(wire->driverPort_, SigSpec());
|
||||
// Maintain bufnorm
|
||||
wire->driverCell_ = new_cell;
|
||||
wire->driverPort_ = port_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
YOSYS_NAMESPACE_BEGIN
|
||||
|
||||
struct RTLIL::Patch
|
||||
struct RTLIL::Patch final : public CellAdderMixin<RTLIL::Patch>
|
||||
{
|
||||
Hasher::hash_t hashidx_;
|
||||
[[nodiscard]] Hasher hash_into(Hasher h) const { h.eat(hashidx_); return h; }
|
||||
|
|
@ -34,6 +34,9 @@ public:
|
|||
|
||||
RTLIL::Cell *addCell(RTLIL::IdString name, RTLIL::IdString type);
|
||||
RTLIL::Cell *addCell(RTLIL::IdString name, const RTLIL::Cell *other);
|
||||
|
||||
RTLIL::Cell* addDffsr(RTLIL::IdString name, const RTLIL::SigSpec &sig_clk, const RTLIL::SigSpec &sig_set, const RTLIL::SigSpec &sig_clr,
|
||||
RTLIL::SigSpec sig_d, const RTLIL::SigSpec &sig_q, bool clk_polarity, bool set_polarity, bool clr_polarity, const std::string &src);
|
||||
};
|
||||
|
||||
YOSYS_NAMESPACE_END
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue