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