3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-07-07 13:16:26 +00:00
yosys/passes/cmds/publish.cc
2025-06-25 14:14:31 +02:00

40 lines
1 KiB
C++

#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