3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-05-25 19:36:21 +00:00
yosys/passes/cmds/test_patch.cc
2026-05-23 00:09:17 +02:00

37 lines
1,021 B
C++

#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;
design->sigNormalize();
for (auto module : design->selected_modules()) {
for (auto cell : module->selected_cells()) {
if (cell->type == ID($add)) {
RTLIL::Patch patcher;
patcher.mod = module;
patcher.map = SigMap(module);
RTLIL::Cell* sub = patcher.addCell(NEW_ID, ID($sub));
// sub->connections_ = cell->connections();
sub->parameters = cell->parameters;
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);
}
}
}
}
} TestPatchPass;
PRIVATE_NAMESPACE_END