Coverage for pyVHDLModel/PSLModel.py: 87%
39 statements
« prev ^ index » next coverage.py v7.17.0, created at 2026-10-25 10:05 +0000
« prev ^ index » next coverage.py v7.17.0, created at 2026-10-25 10:05 +0000
1# ==================================================================================================================== #
2# __ ___ _ ____ _ __ __ _ _ #
3# _ __ _ \ \ / / | | | _ \| | | \/ | ___ __| | ___| | #
4# | '_ \| | | \ \ / /| |_| | | | | | | |\/| |/ _ \ / _` |/ _ \ | #
5# | |_) | |_| |\ V / | _ | |_| | |___| | | | (_) | (_| | __/ | #
6# | .__/ \__, | \_/ |_| |_|____/|_____|_| |_|\___/ \__,_|\___|_| #
7# |_| |___/ #
8# ==================================================================================================================== #
9# Authors: #
10# Patrick Lehmann #
11# #
12# License: #
13# ==================================================================================================================== #
14# Copyright 2017-2026 Patrick Lehmann - Boetzingen, Germany #
15# Copyright 2016-2017 Patrick Lehmann - Dresden, Germany #
16# #
17# Licensed under the Apache License, Version 2.0 (the "License"); #
18# you may not use this file except in compliance with the License. #
19# You may obtain a copy of the License at #
20# #
21# http://www.apache.org/licenses/LICENSE-2.0 #
22# #
23# Unless required by applicable law or agreed to in writing, software #
24# distributed under the License is distributed on an "AS IS" BASIS, #
25# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
26# See the License for the specific language governing permissions and #
27# limitations under the License. #
28# #
29# SPDX-License-Identifier: Apache-2.0 #
30# ==================================================================================================================== #
31#
32"""
33This module contains an abstract document language model for PSL in VHDL.
34"""
35from pyTooling.Decorators import export
36from pyTooling.MetaClasses import abstractclass
38from typing import Optional as Nullable
40from pyVHDLModel.Base import ModelEntity, NamedEntityMixin, DocumentedEntityMixin
41from pyVHDLModel.DesignUnit import PrimaryUnit
44@export
45@abstractclass
46class PSLEntity(ModelEntity):
47 """
48 Represents the base-class of all PSL entities.
50 PSL (Property Specification Language) support is rudimentary: verification units are recognised
51 and named, but their contents are not modelled.
53 .. seealso::
55 * :class:`Default clock <pyVHDLModel.PSLModel.DefaultClock>`
56 """
57 pass
60@export
61@abstractclass
62class PSLPrimaryUnit(PrimaryUnit):
63 """
64 Represents the base-class of all PSL primary units.
66 .. seealso::
68 * :class:`Verification unit <pyVHDLModel.PSLModel.VerificationUnit>`
69 * :class:`Verification property <pyVHDLModel.PSLModel.VerificationProperty>`
70 * :class:`Verification mode <pyVHDLModel.PSLModel.VerificationMode>`
71 """
72 pass
75@export
76class VerificationUnit(PSLPrimaryUnit):
77 """
78 Represents a PSL verification unit (``vunit``).
79 """
80 def __init__(self, identifier: str) -> None:
81 """
82 Initializes a PSL verification unit (``vunit``).
84 :param identifier: The identifier of a model entity.
85 """
86 super().__init__(identifier, parent=None)
88 def __str__(self) -> str:
89 """
90 Formats the verification unit declaration.
92 **Format:** ``vunit myUnit``
94 :returns: Formatted verification unit declaration.
95 """
96 return f"vunit {self._identifier}"
99@export
100class VerificationProperty(PSLPrimaryUnit):
101 """
102 Represents a PSL verification property (``vprop``).
103 """
104 def __init__(self, identifier: str) -> None:
105 """
106 Initializes a PSL verification property (``vprop``).
108 :param identifier: The identifier of a model entity.
109 """
110 super().__init__(identifier, parent=None)
112 def __str__(self) -> str:
113 """
114 Formats the verification property declaration.
116 **Format:** ``vprop myUnit``
118 :returns: Formatted verification property declaration.
119 """
120 return f"vprop {self._identifier}"
123@export
124class VerificationMode(PSLPrimaryUnit):
125 """
126 Represents a PSL verification mode (``vmode``).
127 """
128 def __init__(self, identifier: str) -> None:
129 """
130 Initializes a PSL verification mode (``vmode``).
132 :param identifier: The identifier of a model entity.
133 """
134 super().__init__(identifier, parent=None)
136 def __str__(self) -> str:
137 """
138 Formats the verification mode declaration.
140 **Format:** ``vmode myUnit``
142 :returns: Formatted verification mode declaration.
143 """
144 return f"vmode {self._identifier}"
147@export
148class DefaultClock(PSLEntity, NamedEntityMixin, DocumentedEntityMixin):
149 """
150 Represents a PSL default clock declaration.
152 It names the clock expression used by PSL directives that do not state one themselves.
153 """
154 def __init__(self, identifier: str, documentation: Nullable[str] = None) -> None:
155 """
156 Initializes a PSL default clock declaration.
158 :param identifier: The identifier of a model entity.
159 :param documentation: The documentation comment associated with this declaration.
160 """
161 super().__init__()
162 NamedEntityMixin.__init__(self, identifier)
163 DocumentedEntityMixin.__init__(self, documentation)
165 def __str__(self) -> str:
166 """
167 Formats the default clock declaration.
169 **Format:** ``default clock myClock``
171 :returns: Formatted default clock declaration.
172 """
173 return f"default clock {self._identifier}"