Skip to content

regblock

regblock Callback.

Classes:

  • RegblockCallback

    Callback function for Peakrdl Generated Bluespec verilog code.

RegblockCallback

RegblockCallback(dut)

Bases: CallbackBase

Callback function for Peakrdl Generated Bluespec verilog code.

Peakrdl Regblock stores the signals in a struct called field_storage A signal Foo in register Bar can be accessed as field_storage.Bar.Foo.value;

Parameters:

  • dut (Any) –

    cocotb dut reference.

Methods:

  • read

    Finds the actual signal in RTL and returns its value.

  • sig

    Finds the signal in dut and returns a reference to it.

  • write

    Finds the actual signal in RTL and sets its value.

Source code in src/peakrdl_cocotb_ralgen/callbacks/callback_base.py
 9
10
11
12
13
14
15
def __init__(self, dut):
    """Initialize.

    params:
      dut (Any): cocotb dut reference.
    """
    self.dut = dut

read

read(sigHash)

Finds the actual signal in RTL and returns its value.

Parameters:

  • sigHash (dict) –

    A dictionary of signal parameters " {"reg": register, "sig": signal_name, "low": signal's low index in the register, "high": signal's high index in the register, }

Source code in src/peakrdl_cocotb_ralgen/callbacks/callback_base.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
def read(self, sigHash):
    """Finds the actual signal in RTL and returns its value.

    params:
        sigHash (dict): A dictionary of signal parameters "
            {"reg": register,
            "sig": signal_name,
            "low": signal's low index in the register,
            "high": signal's high index in the register,
             }
    """
    rv = self.sig(sigHash).value if self.sig(sigHash) is not None else None
    cocotb.log.debug(f"{sigHash} rv={rv}")
    return rv

sig

sig(sigHash) -> Any

Finds the signal in dut and returns a reference to it.

Parameters:

  • sigHash (dict) –

    A dictionary of signal parameters " {"reg": register, "sig": signal_name, "low": signal's low index in the register, "high": signal's high index in the register, }

Source code in src/peakrdl_cocotb_ralgen/callbacks/regblock.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
def sig(self, sigHash) -> Any:
    """Finds the signal in dut and returns a reference to it.

    params:
        sigHash (dict): A dictionary of signal parameters "
            {"reg": register,
            "sig": signal_name,
            "low": signal's low index in the register,
            "high": signal's high index in the register,
             }
    """
    # sig = f"field_storage.{sigHash['path'][-2]}.{sigHash['path'][-1]}"
    fs = self.dut.field_storage
    return self._walk_hier(fs, sigHash, -2)

write

write(sigHash, wr)

Finds the actual signal in RTL and sets its value.

Parameters:

  • sigHash (dict) –

    A dictionary of signal parameters " {"reg": register, "sig": signal_name, "low": signal's low index in the register, "high": signal's high index in the register, }

  • wr (int) –

    Integer value to write to the signal

Source code in src/peakrdl_cocotb_ralgen/callbacks/callback_base.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def write(self, sigHash, wr):
    """Finds the actual signal in RTL and sets its value.

    params:
        sigHash (dict): A dictionary of signal parameters "
            {"reg": register,
            "sig": signal_name,
            "low": signal's low index in the register,
            "high": signal's high index in the register,
             }
        wr (int): Integer value to write to the signal
    """
    if self.sig(sigHash):
        self.sig(sigHash).value = Force(wr)