Coverage for hdl_registers/test/test_register_mode.py: 100%
14 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-07 20:51 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-07 20:51 +0000
1# --------------------------------------------------------------------------------------------------
2# Copyright (c) Lukas Vik. All rights reserved.
3#
4# This file is part of the hdl-registers project, an HDL register generator fast enough to run
5# in real time.
6# https://hdl-registers.com
7# https://github.com/hdl-registers/hdl-registers
8# --------------------------------------------------------------------------------------------------
10# First party libraries
11from hdl_registers.register_mode import (
12 HardwareAccessDirection,
13 RegisterMode,
14 SoftwareAccessDirection,
15)
18def test_repr():
19 assert (
20 repr(
21 RegisterMode(
22 shorthand="a",
23 name="b",
24 description="c",
25 software_can_read=False,
26 software_can_write=False,
27 hardware_has_up=False,
28 )
29 )
30 == "RegisterMode(shorthand=a)"
31 )
34def test_software_access_direction():
35 register_mode = RegisterMode(
36 shorthand="a",
37 name="b",
38 description="c",
39 software_can_read=True,
40 software_can_write=False,
41 hardware_has_up=False,
42 )
44 assert register_mode.is_software_accessible(SoftwareAccessDirection.READ)
45 assert not register_mode.is_software_accessible(SoftwareAccessDirection.WRITE)
48def test_hardware_access_direction():
49 register_mode = RegisterMode(
50 shorthand="a",
51 name="b",
52 description="c",
53 software_can_read=True,
54 software_can_write=False,
55 hardware_has_up=True,
56 )
58 assert register_mode.is_hardware_accessible(HardwareAccessDirection.UP)
59 assert not register_mode.is_software_accessible(HardwareAccessDirection.DOWN)
61 register_mode = RegisterMode(
62 shorthand="a",
63 name="b",
64 description="c",
65 software_can_read=True,
66 software_can_write=True,
67 hardware_has_up=False,
68 )
70 assert not register_mode.is_hardware_accessible(HardwareAccessDirection.UP)
71 assert register_mode.is_software_accessible(HardwareAccessDirection.DOWN)