Skip to content

Instantly share code, notes, and snippets.

@povik
Last active December 7, 2023 15:58
Show Gist options
  • Save povik/138bb1a0cc7629715193b1bb81896fb1 to your computer and use it in GitHub Desktop.
Save povik/138bb1a0cc7629715193b1bb81896fb1 to your computer and use it in GitHub Desktop.
Example plugin (to demonstrate Python binding at YUG 4)
#!/usr/bin/python3
import libyosys as ys
class VisitallPass(ys.Pass):
def __init__(self):
super().__init__("visitall", "visit all selected cells across all modules")
def py_help(self):
ys.log("Hello YUG! TODO: write an actual help message...\n")
def py_execute(self, args, design):
ys.log_header(design, "Running pass\n")
for module in design.selected_modules():
ys.log(f"Visiting module {module.name.str()}\n")
for cell in module.selected_cells():
ys.log(f" Visiting cell {cell.name.str()} of type {cell.type.str()}\n")
for portname, sig in cell.connections().items():
ys.log(f" Visiting cell port {portname.str()} connected to {ys.log_signal(sig)}\n")
ys.log(f" Module has {len(module.selected_wires())} wires\n")
p = VisitallPass()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment