Skip to content

callback_base

Base class for all callbacks.

Classes:

CallbackBase

CallbackBase(dut)

Base class for all callbacks.

Parameters:

  • dut (Any) –

    cocotb dut reference.

Methods:

  • read

    Finds the actual signal in RTL and returns its value.

  • 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

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)