Coverage for hdl_registers/constant/constant.py: 100%
11 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-12 11:11 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-12 11:11 +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# --------------------------------------------------------------------------------------------------
10from abc import ABC, abstractmethod
11from typing import Any
14class Constant(ABC):
15 """
16 Meta class for all register constants (integer, boolean, ...).
17 Lists a few properties that must be available.
18 """
20 name: str
21 description: str
23 @property
24 @abstractmethod
25 def value(self) -> Any: # noqa: ANN401
26 """
27 The value of the constant. Return type depends on the subclass.
28 """
30 @value.setter
31 @abstractmethod
32 def value(self, value: Any) -> None: # noqa: ANN401
33 """
34 Setter to update the constant value.
35 Argument type depends on the subclass.
36 Subclasses should perform sanity checks.
37 """