mirror of
https://github.com/YosysHQ/yosys
synced 2025-08-04 18:30:25 +00:00
publish: add pass for renaming private cell types to public
This commit is contained in:
parent
aa1daa7023
commit
4d8032ba01
2 changed files with 41 additions and 0 deletions
|
@ -57,3 +57,4 @@ OBJS += passes/cmds/abstract.o
|
|||
OBJS += passes/cmds/test_select.o
|
||||
OBJS += passes/cmds/timeest.o
|
||||
OBJS += passes/cmds/linecoverage.o
|
||||
OBJS += passes/cmds/publish.o
|
||||
|
|
40
passes/cmds/publish.cc
Normal file
40
passes/cmds/publish.cc
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include "kernel/register.h"
|
||||
#include "kernel/rtlil.h"
|
||||
#include "kernel/log.h"
|
||||
|
||||
USING_YOSYS_NAMESPACE
|
||||
PRIVATE_NAMESPACE_BEGIN
|
||||
|
||||
struct PublishPass : public Pass {
|
||||
private:
|
||||
static void publish(RTLIL::IdString& id) {
|
||||
if (id.begins_with("$")) {
|
||||
log_debug("publishing %s\n", id.c_str());
|
||||
id = "\\" + id.str();
|
||||
log_debug("published %s\n", id.c_str());
|
||||
}
|
||||
}
|
||||
public:
|
||||
PublishPass() : Pass("publish", "publish private cell types") { }
|
||||
void help() override
|
||||
{
|
||||
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
||||
log("\n");
|
||||
log(" publish\n");
|
||||
log("Makes all module names and cell types public by prefixing\n");
|
||||
log("%% with \\.\n");
|
||||
}
|
||||
void execute(std::vector<std::string> args, RTLIL::Design *design) override
|
||||
{
|
||||
log_header(design, "Executing PUBLISH pass. (make cell types public)\n");
|
||||
extra_args(args, 1, design);
|
||||
for (auto& [name, mod] : design->modules_) {
|
||||
publish(name);
|
||||
publish(mod->name);
|
||||
for (auto* cell : mod->cells())
|
||||
publish(cell->type);
|
||||
}
|
||||
}
|
||||
} PublishPass;
|
||||
|
||||
PRIVATE_NAMESPACE_END
|
Loading…
Add table
Add a link
Reference in a new issue