Skip to content

peakrdl_bsv

Top-level package for PeakRDL bsv.

Modules:

Classes:

BSVExporter

PeakRDL BSV exporter main class.

Methods:

  • export

    Writeout the BSV code.

export

export(
    top_node: Union[AddrmapNode, RootNode],
    outputpath: str,
    input_files: Optional[List[str]] = None,
    rename: Optional[str] = None,
    depth: int = 0,
    test: bool = False,
)

Writeout the BSV code.

Source code in src/peakrdl_bsv/exporter.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def export(
    self,
    top_node: Union[AddrmapNode, RootNode],
    outputpath: str,
    input_files: Optional[List[str]] = None,
    rename: Optional[str] = None,
    depth: int = 0,
    test: bool = False,
):
    """Writeout the BSV code."""
    rdlc = RDLCompiler()
    try:
        for input_file in input_files:
            rdlc.compile_file(input_file)
            root = rdlc.elaborate()
    except Exception:
        sys.exit()
    fname = f"{outputpath}/{top_node.inst.inst_name}"
    with open(fname + "_signal.bsv", "w") as file:
        walker = RDLWalker(unroll=True)
        walker.walk(root, PrintBSVSignal(file, test))
    with open(fname + "_reg.bsv", "w") as file:
        walker = RDLWalker(unroll=True)
        walker.walk(root, PrintBSVReg(file, test))
    with open(fname + "_csr.bsv", "w") as file:
        walker = RDLWalker(unroll=True)
        walker.walk(root, PrintBSVCSR(file, test))