Skip to content

exporter

PeakRDL cocotb_ralgen exporter.

Classes:

CocotbRALExporter

PeakRDL RAL exporter main class.

Methods:

  • export

    Interface stub required by peakrdl.

export

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

Interface stub required by peakrdl.

Source code in src/peakrdl_cocotb_ralgen/exporter.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
def export(
    self,
    top_node: Union[AddrmapNode, RootNode],
    outputpath: str,
    input_files: Optional[List[str]] = None,
    rename: Optional[str] = None,
    depth: int = 0,
    default_regwidth=None,
):
    """Interface stub required by peakrdl."""
    logger.info(
        f"Options {top_node=}, {outputpath=}, {input_files=}, {rename=}, {depth=}, {default_regwidth=}",
    )
    # print(f"{top_node.inst.inst_name} {input_files} {outputpath}")
    rdlc = RDLCompiler()
    try:
        for input_file in input_files:  # type: ignore
            rdlc.compile_file(input_file)
            root = rdlc.elaborate()
    except:
        sys.exit()
    with open(f"{outputpath}/{top_node.inst.inst_name}_RAL.py", "w") as file:
        walker = RDLWalker(unroll=True)
        listener = RALGEN(file, default_regwidth)
        walker.walk(root, listener)