yosys/passes/cmds/test_patch.cc

38 lines
1021 B
C++
Raw Normal View History

2025-12-31 17:46:27 +01:00
#include "kernel/rtlil.h"
#include "kernel/yosys.h"
#include "kernel/unstable/patch.h"
USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN
struct TestPatchPass : public Pass {
TestPatchPass() : Pass("test_patch", "test patcher") { }
void help() override
{
}
void execute(std::vector<std::string> args, RTLIL::Design *design) override
{
(void) args;
2026-05-19 12:36:41 +02:00
design->sigNormalize();
2025-12-31 17:46:27 +01:00
for (auto module : design->selected_modules()) {
for (auto cell : module->selected_cells()) {
if (cell->type == ID($add)) {
2026-05-14 17:43:46 +02:00
RTLIL::Patch patcher;
patcher.mod = module;
patcher.map = SigMap(module);
2025-12-31 17:46:27 +01:00
RTLIL::Cell* sub = patcher.addCell(NEW_ID, ID($sub));
2026-05-19 12:36:41 +02:00
// sub->connections_ = cell->connections();
2025-12-31 17:46:27 +01:00
sub->parameters = cell->parameters;
2026-05-19 12:36:41 +02:00
sub->connections_[ID::A] = cell->getPort(ID::A);
sub->connections_[ID::B] = cell->getPort(ID::B);
sub->connections_[ID::Y] = cell->getPort(ID::Y);
log_cell(sub);
patcher.patch(cell, sub);
2025-12-31 17:46:27 +01:00
}
}
}
}
} TestPatchPass;
PRIVATE_NAMESPACE_END