Skip to content

reset_test

Reset Testcase.

Functions:

reset_test

reset_test(RAL, *, verbose=False, expected_error=0)

Reset Testcase.

This testcase reads the value of all fields during reset and checks for match with the defined reset value.

Source code in src/peakrdl_cocotb_ralgen/testcases/reset_test.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
def reset_test(RAL, *, verbose=False, expected_error=0):
    """Reset Testcase.

    This testcase reads the value of all fields during reset and checks for match with the defined reset value.
    """
    error_count = 0
    for key, val in RAL.masks.items():
        if "reset" in val["disable"]:
            continue
        rv = 0
        for hsh in val["signals"]:
            hshval = RAL.background.read(hsh)
            if hshval is not None:
                rv |= int(hshval) << hsh["low"]
                try:
                    actual = rv & val["reset_mask"]
                    expected = val["reset_value"]
                    assert (
                        actual == expected
                    ), f"{key} Resetvalue mismatch Actual {actual:x},Expected {expected:x},"
                except:
                    cocotb.log.error(
                        f"Reset Read Reg:{key}, actual {rv:x} expected {expected:x}",
                    )
                    error_count += 1
            else:
                logger.info(f"Error: Unable to access {hsh}")
                error_count += 1
            if verbose:
                logger.info(f"Reset Read Reg:{key}, Value {rv:x}")
        assert (
            error_count == expected_error
        ), f"Test exited with {error_count} Error, expected {expected_error}"