mirror of
https://github.com/YosysHQ/yosys
synced 2026-05-25 11:26:22 +00:00
test_patch total basics
This commit is contained in:
parent
6f0be1b4e9
commit
89e5c4ccca
4 changed files with 62 additions and 3 deletions
|
|
@ -60,5 +60,6 @@ OBJS += passes/cmds/timeest.o
|
|||
OBJS += passes/cmds/linecoverage.o
|
||||
OBJS += passes/cmds/sort.o
|
||||
OBJS += passes/cmds/icell_liberty.o
|
||||
OBJS += passes/cmds/test_patch.o
|
||||
|
||||
include $(YOSYS_SRC)/passes/cmds/sdc/Makefile.inc
|
||||
|
|
|
|||
36
passes/cmds/test_patch.cc
Normal file
36
passes/cmds/test_patch.cc
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#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;
|
||||
RTLIL::Patch patcher;
|
||||
design->bufNormalize();
|
||||
for (auto module : design->selected_modules()) {
|
||||
patcher.mod = module;
|
||||
patcher.map = SigMap(module);
|
||||
for (auto cell : module->selected_cells()) {
|
||||
if (cell->type == ID($add)) {
|
||||
RTLIL::Cell* sub = patcher.addCell(NEW_ID, ID($sub));
|
||||
sub->connections_ = cell->connections();
|
||||
sub->parameters = cell->parameters;
|
||||
sub->setPort(ID::A, cell->getPort(ID::A));
|
||||
sub->setPort(ID::B, cell->getPort(ID::B));
|
||||
sub->setPort(ID::Y, cell->getPort(ID::Y));
|
||||
patcher.patch();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} TestPatchPass;
|
||||
|
||||
PRIVATE_NAMESPACE_END
|
||||
Loading…
Add table
Add a link
Reference in a new issue