covsight-core 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. covsight/core/__init__.py +13 -0
  2. covsight/core/api/__init__.py +32 -0
  3. covsight/core/api/cov_scope.py +70 -0
  4. covsight/core/api/cover_data.py +88 -0
  5. covsight/core/api/cover_index.py +157 -0
  6. covsight/core/api/cover_instance.py +79 -0
  7. covsight/core/api/cover_item.py +99 -0
  8. covsight/core/api/cover_type.py +124 -0
  9. covsight/core/api/covergroup.py +350 -0
  10. covsight/core/api/coverpoint.py +181 -0
  11. covsight/core/api/cross.py +125 -0
  12. covsight/core/api/cvg_bin_scope.py +57 -0
  13. covsight/core/api/cvg_scope.py +319 -0
  14. covsight/core/api/du_name.py +103 -0
  15. covsight/core/api/du_scope.py +140 -0
  16. covsight/core/api/enums/__init__.py +13 -0
  17. covsight/core/api/enums/cover_flags.py +74 -0
  18. covsight/core/api/enums/cover_type.py +126 -0
  19. covsight/core/api/enums/flags.py +127 -0
  20. covsight/core/api/enums/formal_status.py +13 -0
  21. covsight/core/api/enums/handle_property.py +66 -0
  22. covsight/core/api/enums/history_node_kind.py +108 -0
  23. covsight/core/api/enums/int_property.py +160 -0
  24. covsight/core/api/enums/real_property.py +65 -0
  25. covsight/core/api/enums/scope_type.py +195 -0
  26. covsight/core/api/enums/source.py +85 -0
  27. covsight/core/api/enums/str_property.py +167 -0
  28. covsight/core/api/enums/test_status.py +118 -0
  29. covsight/core/api/enums/toggle.py +174 -0
  30. covsight/core/api/file_handle.py +88 -0
  31. covsight/core/api/func_cov_scope.py +61 -0
  32. covsight/core/api/history_node.py +274 -0
  33. covsight/core/api/ignore_bin_scope.py +69 -0
  34. covsight/core/api/illegal_bin_scope.py +75 -0
  35. covsight/core/api/instance_coverage.py +119 -0
  36. covsight/core/api/instance_scope.py +146 -0
  37. covsight/core/api/name_value.py +76 -0
  38. covsight/core/api/obj.py +422 -0
  39. covsight/core/api/scope.py +717 -0
  40. covsight/core/api/source_file.py +68 -0
  41. covsight/core/api/source_info.py +90 -0
  42. covsight/core/api/statement_id.py +92 -0
  43. covsight/core/api/test_data.py +124 -0
  44. covsight/core/api/ucis.py +699 -0
  45. covsight/core/api/unimpl_error.py +61 -0
  46. covsight/core/conversion/__init__.py +3 -0
  47. covsight/core/conversion/context.py +127 -0
  48. covsight/core/conversion/error.py +12 -0
  49. covsight/core/conversion/listener.py +95 -0
  50. covsight/core/ext/__init__.py +3 -0
  51. covsight/core/ext/format_db.py +76 -0
  52. covsight/core/ext/format_rpt.py +42 -0
  53. covsight/core/ext/registry.py +63 -0
  54. covsight/core/mem/__init__.py +2 -0
  55. covsight/core/mem/mem_code_scope.py +84 -0
  56. covsight/core/mem/mem_cover_index.py +62 -0
  57. covsight/core/mem/mem_cover_index_iterator.py +27 -0
  58. covsight/core/mem/mem_cover_item.py +24 -0
  59. covsight/core/mem/mem_cover_type.py +33 -0
  60. covsight/core/mem/mem_covergroup.py +124 -0
  61. covsight/core/mem/mem_coverpoint.py +24 -0
  62. covsight/core/mem/mem_cross.py +33 -0
  63. covsight/core/mem/mem_cvg_scope.py +59 -0
  64. covsight/core/mem/mem_du_scope.py +47 -0
  65. covsight/core/mem/mem_factory.py +49 -0
  66. covsight/core/mem/mem_file_handle.py +15 -0
  67. covsight/core/mem/mem_fsm_scope.py +217 -0
  68. covsight/core/mem/mem_history_node.py +273 -0
  69. covsight/core/mem/mem_history_node_iterator.py +37 -0
  70. covsight/core/mem/mem_instance_coverage.py +58 -0
  71. covsight/core/mem/mem_instance_scope.py +103 -0
  72. covsight/core/mem/mem_obj.py +53 -0
  73. covsight/core/mem/mem_scope.py +280 -0
  74. covsight/core/mem/mem_scope_iterator.py +29 -0
  75. covsight/core/mem/mem_source_file.py +35 -0
  76. covsight/core/mem/mem_statement_id.py +31 -0
  77. covsight/core/mem/mem_test_coverage.py +125 -0
  78. covsight/core/mem/mem_toggle_instance_scope.py +46 -0
  79. covsight/core/mem/mem_toggle_scope.py +151 -0
  80. covsight/core/mem/mem_ucis.py +243 -0
  81. covsight/core/merge/__init__.py +1 -0
  82. covsight/core/merge/db_merger.py +473 -0
  83. covsight/core/ncdb/__init__.py +6 -0
  84. covsight/core/ncdb/_accel/README.md +44 -0
  85. covsight/core/ncdb/_accel/__init__.py +135 -0
  86. covsight/core/ncdb/_accel/_ncdb_accel_build.py +63 -0
  87. covsight/core/ncdb/_accel/ncdb_accel.c +81 -0
  88. covsight/core/ncdb/attrs.py +264 -0
  89. covsight/core/ncdb/bucket_index.py +171 -0
  90. covsight/core/ncdb/constants.py +146 -0
  91. covsight/core/ncdb/contrib.py +86 -0
  92. covsight/core/ncdb/contrib_index.py +178 -0
  93. covsight/core/ncdb/counts.py +84 -0
  94. covsight/core/ncdb/coveritem_flags.py +93 -0
  95. covsight/core/ncdb/cross.py +94 -0
  96. covsight/core/ncdb/design_units.py +69 -0
  97. covsight/core/ncdb/dfs_util.py +51 -0
  98. covsight/core/ncdb/formal.py +81 -0
  99. covsight/core/ncdb/format_detect.py +43 -0
  100. covsight/core/ncdb/format_plugin.py +37 -0
  101. covsight/core/ncdb/fsm.py +144 -0
  102. covsight/core/ncdb/history.py +198 -0
  103. covsight/core/ncdb/history_buckets.py +328 -0
  104. covsight/core/ncdb/issues.py +625 -0
  105. covsight/core/ncdb/issues_history.py +342 -0
  106. covsight/core/ncdb/issues_meta.py +105 -0
  107. covsight/core/ncdb/manifest.py +166 -0
  108. covsight/core/ncdb/ncdb_merger.py +587 -0
  109. covsight/core/ncdb/ncdb_reader.py +294 -0
  110. covsight/core/ncdb/ncdb_ucis.py +735 -0
  111. covsight/core/ncdb/ncdb_writer.py +156 -0
  112. covsight/core/ncdb/properties.py +101 -0
  113. covsight/core/ncdb/reports.py +1192 -0
  114. covsight/core/ncdb/scope_tree.py +365 -0
  115. covsight/core/ncdb/sources.py +55 -0
  116. covsight/core/ncdb/squash_log.py +126 -0
  117. covsight/core/ncdb/string_table.py +72 -0
  118. covsight/core/ncdb/tags.py +52 -0
  119. covsight/core/ncdb/test_registry.py +217 -0
  120. covsight/core/ncdb/test_stats.py +316 -0
  121. covsight/core/ncdb/testplan.py +547 -0
  122. covsight/core/ncdb/testplan_closure.py +262 -0
  123. covsight/core/ncdb/testplan_export.py +301 -0
  124. covsight/core/ncdb/testplan_hjson.py +205 -0
  125. covsight/core/ncdb/testplan_imports.py +214 -0
  126. covsight/core/ncdb/testplan_questa.py +217 -0
  127. covsight/core/ncdb/testplan_vc_planner.py +222 -0
  128. covsight/core/ncdb/testplan_vpf.py +192 -0
  129. covsight/core/ncdb/testplan_yaml.py +284 -0
  130. covsight/core/ncdb/toggle.py +152 -0
  131. covsight/core/ncdb/varint.py +81 -0
  132. covsight/core/ncdb/waivers.py +195 -0
  133. covsight/core/schema/__init__.py +0 -0
  134. covsight/core/schema/cover.schema +0 -0
  135. covsight/core/schema/cover.yaml +20 -0
  136. covsight/core/schema/coverage.json +143 -0
  137. covsight/core/schema/covreport.json +156 -0
  138. covsight/core/schema/testplan.schema.json +168 -0
  139. covsight/core/schema/ucis.xsd +607 -0
  140. covsight/core/visitors/__init__.py +2 -0
  141. covsight/core/visitors/traverse.py +138 -0
  142. covsight/core/visitors/visitor.py +143 -0
  143. covsight_core-0.1.2.dist-info/METADATA +25 -0
  144. covsight_core-0.1.2.dist-info/RECORD +148 -0
  145. covsight_core-0.1.2.dist-info/WHEEL +5 -0
  146. covsight_core-0.1.2.dist-info/entry_points.txt +2 -0
  147. covsight_core-0.1.2.dist-info/licenses/LICENSE +201 -0
  148. covsight_core-0.1.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,13 @@
1
+ """
2
+ covsight-core: UCIS data-model API, in-memory backend, and NCDB format.
3
+
4
+ Quick-start::
5
+
6
+ from covsight.core.mem import MemFactory
7
+ from covsight.core.api import ScopeTypeT, SourceT, CoverData
8
+
9
+ db = MemFactory.create()
10
+ cg = db.createScope("my_cg", None, 1, SourceT.SV,
11
+ ScopeTypeT.COVERGROUP, 0)
12
+ db.close()
13
+ """
@@ -0,0 +1,32 @@
1
+ # Abstract interfaces
2
+ from covsight.core.api.obj import Obj
3
+ from covsight.core.api.scope import Scope
4
+ from covsight.core.api.ucis import UCIS
5
+ from covsight.core.api.history_node import HistoryNode
6
+ from covsight.core.api.cov_scope import CovScope
7
+ from covsight.core.api.cvg_scope import CvgScope
8
+ from covsight.core.api.du_scope import DUScope
9
+ from covsight.core.api.instance_scope import InstanceScope
10
+ from covsight.core.api.covergroup import Covergroup
11
+ from covsight.core.api.coverpoint import Coverpoint
12
+ from covsight.core.api.cross import Cross
13
+ from covsight.core.api.cover_item import CoverItem
14
+ from covsight.core.api.cover_type import CoverType
15
+ from covsight.core.api.instance_coverage import InstanceCoverage
16
+
17
+ # Data classes
18
+ from covsight.core.api.source_info import SourceInfo
19
+ from covsight.core.api.cover_data import CoverData
20
+ from covsight.core.api.cover_index import CoverIndex
21
+ from covsight.core.api.file_handle import FileHandle
22
+ from covsight.core.api.test_data import TestData
23
+ from covsight.core.api.source_file import SourceFile
24
+ from covsight.core.api.statement_id import StatementId
25
+
26
+ # All enums
27
+ from covsight.core.api.enums import (
28
+ ScopeTypeT, CoverTypeT, CoverFlagsT, FlagsT, SourceT,
29
+ ToggleMetricT, ToggleTypeT, ToggleDirT,
30
+ HistoryNodeKind, IntProperty, StrProperty, RealProperty,
31
+ HandleProperty, TestStatusT, FormalStatusT,
32
+ )
@@ -0,0 +1,70 @@
1
+
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+
19
+ '''
20
+ Created on Jan 8, 2020
21
+
22
+ @author: ballance
23
+ '''
24
+ from covsight.core.api.scope import Scope
25
+
26
+ class CovScope(Scope):
27
+ """Base class for generic coverage scopes.
28
+
29
+ CovScope is the base class for all coverage-related scopes in the UCIS
30
+ hierarchy. It sits between the generic Scope class and more specialized
31
+ coverage scope types like FuncCovScope (functional coverage) and code
32
+ coverage scopes.
33
+
34
+ CovScope provides common infrastructure for coverage scopes but adds
35
+ minimal functionality beyond the base Scope class. It serves primarily
36
+ as a structural marker in the type hierarchy to distinguish coverage
37
+ scopes from non-coverage scopes (like pure structural scopes).
38
+
39
+ Subclass hierarchy:
40
+ Scope
41
+ └── CovScope (this class)
42
+ ├── FuncCovScope (functional coverage)
43
+ │ └── CvgScope (covergroups/coverpoints)
44
+ └── (Code coverage scopes)
45
+
46
+ Note:
47
+ CovScope is rarely instantiated directly. Use specific subclasses
48
+ like Covergroup, Coverpoint, or code coverage scope types instead.
49
+
50
+ Example:
51
+ >>> # CovScope is not directly used; use subclasses instead
52
+ >>> # For functional coverage:
53
+ >>> cg = design.createCovergroup("cg_bus", src_info, 1, SourceT.SV)
54
+ >>>
55
+ >>> # For code coverage:
56
+ >>> instance = design.createInstance("u_core", src_info, 1, SourceT.SV, "core")
57
+
58
+ See Also:
59
+ Scope: Base scope class
60
+ FuncCovScope: Functional coverage base
61
+ CvgScope: Covergroup scope base
62
+ InstanceScope: Design instance scope
63
+ """
64
+
65
+ def __init__(self):
66
+
67
+ pass
68
+
69
+
70
+
@@ -0,0 +1,88 @@
1
+ '''
2
+ Created on Jan 11, 2020
3
+
4
+ @author: ballance
5
+ '''
6
+ from covsight.core.api.enums import CoverTypeT
7
+
8
+ class CoverData():
9
+ """Container for coverage measurement data.
10
+
11
+ CoverData encapsulates all measurement values associated with a coverage
12
+ item (bin), including the hit count, goal, weight, and limit. It serves as
13
+ a data transfer object when creating or querying cover items.
14
+
15
+ Coverage data consists of:
16
+ - **data**: The actual hit count (how many times the item was covered)
17
+ - **goal**: Target count for considering the item "covered"
18
+ - **weight**: Relative importance in coverage calculations
19
+ - **limit**: Maximum count before saturation (coverage stops incrementing)
20
+ - **type**: Coverage type (CVGBIN, BRANCHBIN, TOGGLEBIN, etc.)
21
+ - **flags**: Behavioral flags (data format, has_goal, has_weight, etc.)
22
+
23
+ The flags determine which fields are valid and how data is interpreted.
24
+ For example, HAS_GOAL flag indicates the goal field is meaningful.
25
+
26
+ Attributes:
27
+ type (CoverTypeT): Coverage type identifying the metric category.
28
+ flags (CoverFlagsT): Bitwise flags controlling data interpretation.
29
+ data (int): Hit count - number of times this coverage item was hit.
30
+ goal (int): Target count for coverage completion (if HAS_GOAL flag set).
31
+ weight (int): Relative weight for coverage computation (if HAS_WEIGHT flag set).
32
+ limit (int): Count saturation limit (if HAS_LIMIT flag set).
33
+ bitlen (int): Bit length for vector data (if IS_VECTOR flag set).
34
+
35
+ Example:
36
+ >>> from covsight.core.api.enums import CoverFlagsT
37
+ >>> # Simple bin with goal and weight
38
+ >>> data = CoverData(
39
+ ... type=CoverTypeT.CVGBIN,
40
+ ... flags=CoverFlagsT.HAS_GOAL | CoverFlagsT.HAS_WEIGHT)
41
+ >>> data.goal = 1
42
+ >>> data.weight = 1
43
+ >>> data.data = 0 # Not yet hit
44
+ >>>
45
+ >>> # Use when creating cover item
46
+ >>> idx = coverpoint.createNextCover("bin_low", data, src_info)
47
+
48
+ Note:
49
+ Default values (0) are set for all fields. Set flags appropriately to
50
+ indicate which fields contain valid data. Tools may ignore fields whose
51
+ corresponding flags are not set.
52
+
53
+ See Also:
54
+ Scope.createNextCover(): Create cover items with this data
55
+ CoverTypeT: Coverage type enumeration
56
+ CoverFlagsT: Coverage data flags
57
+ UCIS LRM Section 8.11.3 "ucis_GetCoverData"
58
+ UCIS LRM Section 8.11.4 "ucis_SetCoverData"
59
+ """
60
+
61
+ def __init__(self,
62
+ type : CoverTypeT,
63
+ flags):
64
+ """Create coverage data container.
65
+
66
+ Args:
67
+ type: Coverage type (CoverTypeT enum) indicating metric category.
68
+ flags: Bitwise OR of CoverFlagsT flags controlling data interpretation.
69
+ Common flags: HAS_GOAL, HAS_WEIGHT, HAS_LIMIT, IS_32BIT, IS_64BIT.
70
+
71
+ Example:
72
+ >>> # Covergroup bin with goal and weight
73
+ >>> data = CoverData(CoverTypeT.CVGBIN,
74
+ ... CoverFlagsT.HAS_GOAL | CoverFlagsT.HAS_WEIGHT)
75
+ >>> # Branch coverage with just count
76
+ >>> data = CoverData(CoverTypeT.BRANCHBIN, 0)
77
+ """
78
+ self.type = type
79
+ self.flags = flags
80
+ # TODO: determine default data based on flags
81
+ self.data = 0
82
+ self.goal = 0 # if UCIS_HAS_GOAL
83
+ self.weight = 0 # if UCIS_HAS_WEIGHT
84
+ self.limit = 0 # if UCIS_HAS_LIMIT
85
+ self.bitlen = 0 # if bytevector
86
+ self.at_least = 1 # Minimum count for coverage (default 1)
87
+
88
+
@@ -0,0 +1,157 @@
1
+ '''
2
+ Created on Mar 13, 2020
3
+
4
+ @author: ballance
5
+ '''
6
+ from covsight.core.api.cover_data import CoverData
7
+ from covsight.core.api.source_info import SourceInfo
8
+
9
+ class CoverIndex(object):
10
+ """Reference to a coverage item within a scope.
11
+
12
+ CoverIndex provides indexed access to coverage items (bins) within their
13
+ parent scope. Each cover item is identified by an integer index within
14
+ its scope, starting from 0.
15
+
16
+ Coverage items are the leaf nodes in the UCIS hierarchy, representing
17
+ individual bins, branches, toggle states, or other coverage points.
18
+ Unlike scopes which form the tree structure, cover items do not have
19
+ children.
20
+
21
+ A CoverIndex allows querying and modifying the coverage data (hit count)
22
+ and metadata (name, source location) for a specific coverage item.
23
+
24
+ Note:
25
+ CoverIndex objects are typically obtained by iterating over a scope's
26
+ cover items or by the index returned from createNextCover(). The index
27
+ value is only valid within the context of its parent scope.
28
+
29
+ Example:
30
+ >>> # Iterate cover items in a coverpoint
31
+ >>> for idx in coverpoint.coverItems():
32
+ ... name = idx.getName()
33
+ ... data = idx.getCoverData()
34
+ ... print(f"{name}: {data.data}/{data.goal} hits")
35
+ ...
36
+ >>> # Increment a specific item's count
37
+ >>> idx.incrementCover(5)
38
+
39
+ See Also:
40
+ Scope.coverItems(): Iterate cover items in a scope
41
+ Scope.createNextCover(): Create new cover item (returns index)
42
+ CoverData: Coverage measurement data
43
+ UCIS LRM Section 8.11.3 "ucis_GetCoverData"
44
+ UCIS LRM Section 8.11.5 "ucis_IncrementCover"
45
+ """
46
+
47
+ def __init__(self):
48
+ super().__init__()
49
+
50
+ def getName(self)->str:
51
+ """Get the name of this coverage item.
52
+
53
+ Returns the name assigned when the cover item was created. Names
54
+ are optional and may be None/empty for some coverage types.
55
+
56
+ Returns:
57
+ Name string, or None if no name was assigned.
58
+
59
+ Example:
60
+ >>> idx = coverpoint.coverItems().__next__()
61
+ >>> name = idx.getName()
62
+ >>> print(f"Bin name: {name}")
63
+
64
+ See Also:
65
+ Scope.createNextCover(): Set name when creating items
66
+ UCIS LRM Section 8.11.3 "ucis_GetCoverData"
67
+ """
68
+ raise NotImplementedError()
69
+
70
+ def getCoverData(self)->CoverData:
71
+ """Get the coverage measurement data for this item.
72
+
73
+ Retrieves the CoverData object containing hit count, goal, weight,
74
+ and other coverage metrics for this item. The returned data reflects
75
+ the current state and may be modified if the data structure is mutable.
76
+
77
+ Returns:
78
+ CoverData object with current coverage metrics.
79
+
80
+ Example:
81
+ >>> idx = coverpoint.coverItems().__next__()
82
+ >>> data = idx.getCoverData()
83
+ >>> print(f"Hits: {data.data}, Goal: {data.goal}")
84
+ >>> covered = (data.data >= data.goal)
85
+
86
+ Note:
87
+ The returned data should be treated as a snapshot. To modify
88
+ coverage data, use incrementCover() or scope-level methods.
89
+
90
+ See Also:
91
+ CoverData: Coverage data container
92
+ incrementCover(): Modify hit count
93
+ UCIS LRM Section 8.11.3 "ucis_GetCoverData"
94
+ """
95
+ raise NotImplementedError()
96
+
97
+ def getSourceInfo(self)->SourceInfo:
98
+ """Get source location information for this coverage item.
99
+
100
+ Returns the source file location where this coverage item was defined
101
+ or instantiated in the design. This links coverage results back to
102
+ source code.
103
+
104
+ Returns:
105
+ SourceInfo object with file, line, and token information.
106
+ May be None if source location was not recorded.
107
+
108
+ Example:
109
+ >>> idx = coverpoint.coverItems().__next__()
110
+ >>> src = idx.getSourceInfo()
111
+ >>> if src:
112
+ ... print(f"Defined at {src.filename}:{src.line}")
113
+
114
+ See Also:
115
+ SourceInfo: Source location data
116
+ FileHandle: File reference system
117
+ UCIS LRM Section 8.11.3 "ucis_GetCoverData"
118
+ """
119
+ raise NotImplementedError()
120
+
121
+ def incrementCover(self, amt=1):
122
+ """Increment this coverage item's hit count.
123
+
124
+ Adds the specified amount to the current hit count (data field)
125
+ of this coverage item. This is the primary method for recording
126
+ coverage events during simulation or when merging coverage databases.
127
+
128
+ Args:
129
+ amt: Amount to add to hit count. Default is 1. Can be negative
130
+ to decrement (though unusual). Must fit in int64_t range.
131
+
132
+ Example:
133
+ >>> # Record single hit
134
+ >>> idx.incrementCover()
135
+ >>>
136
+ >>> # Record multiple hits at once
137
+ >>> idx.incrementCover(10)
138
+ >>>
139
+ >>> # Verify increment
140
+ >>> before = idx.getCoverData().data
141
+ >>> idx.incrementCover(5)
142
+ >>> after = idx.getCoverData().data
143
+ >>> assert after == before + 5
144
+
145
+ Note:
146
+ Some coverage items may have a limit (HAS_LIMIT flag), causing
147
+ counts to saturate at the limit value rather than overflow.
148
+
149
+ See Also:
150
+ getCoverData(): Query current hit count
151
+ CoverData: Coverage data fields
152
+ UCIS LRM Section 8.11.5 "ucis_IncrementCover"
153
+ """
154
+ raise NotImplementedError()
155
+
156
+
157
+
@@ -0,0 +1,79 @@
1
+ from covsight.core.api.unimpl_error import UnimplError
2
+
3
+ # Licensed to the Apache Software Foundation (ASF) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The ASF licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ '''
21
+ Created on Jan 8, 2020
22
+
23
+ @author: ballance
24
+ '''
25
+ from covsight.core.api.cvg_scope import CvgScope
26
+
27
+ class CoverInstance(CvgScope):
28
+ """Covergroup instance scope.
29
+
30
+ CoverInstance represents a specific instance of a covergroup when
31
+ per-instance coverage is enabled. It extends CvgScope to inherit
32
+ covergroup options (at_least, auto_bin_max, etc.).
33
+
34
+ When a covergroup has per_instance=True, each instantiation creates
35
+ a COVERINSTANCE scope to track coverage separately. This enables
36
+ analysis of which instances are contributing to overall coverage.
37
+
38
+ Example:
39
+ >>> # Covergroup with per-instance mode
40
+ >>> cg = design.createCovergroup("cg_bus", src_info, 1, SourceT.SV)
41
+ >>> cg.setPerInstance(True)
42
+ >>>
43
+ >>> # Create instances (CoverInstance objects)
44
+ >>> inst1 = cg.createCoverInstance("inst_0", src_info, 1, SourceT.SV)
45
+ >>> inst2 = cg.createCoverInstance("inst_1", src_info, 1, SourceT.SV)
46
+ >>>
47
+ >>> # Each instance has separate coverage
48
+ >>> for cp in inst1.coverPoints():
49
+ ... data = cp.getCoverData()
50
+
51
+ See Also:
52
+ CvgScope: Base class with options
53
+ Covergroup: Container for covergroup instances
54
+ Covergroup.setPerInstance(): Enable per-instance mode
55
+ ScopeTypeT.COVERINSTANCE: Instance scope type
56
+ UCIS LRM Section 6.4.3.2 "Covergroup Instances"
57
+ """
58
+
59
+ def __init__(self):
60
+ super().__init__()
61
+
62
+ def getStmtIndex(self):
63
+ """Get statement index (if applicable).
64
+
65
+ Raises:
66
+ UnimplError: Not typically used for cover instances.
67
+ """
68
+ raise UnimplError()
69
+
70
+ def setStmtIndex(self, idx):
71
+ """Set statement index (if applicable).
72
+
73
+ Args:
74
+ idx: Statement index.
75
+
76
+ Raises:
77
+ UnimplError: Not typically used for cover instances.
78
+ """
79
+ raise UnimplError()
@@ -0,0 +1,99 @@
1
+ '''
2
+ Created on Jan 12, 2020
3
+
4
+ @author: ballance
5
+ '''
6
+ from covsight.core.api.obj import Obj
7
+ from covsight.core.api.unimpl_error import UnimplError
8
+
9
+ class CoverItem(Obj):
10
+ """Base class for coverage items (bins).
11
+
12
+ CoverItem is the base class for all coverage leaf nodes in the UCIS
13
+ hierarchy. Coverage items (also called "bins") represent individual
14
+ coverage points such as:
15
+ - Covergroup bins (CVGBIN)
16
+ - Branch outcomes (BRANCHBIN)
17
+ - Toggle states (TOGGLEBIN)
18
+ - Assertion outcomes (ASSERTBIN)
19
+ - FSM transitions (FSMBIN)
20
+
21
+ Unlike scopes which form the hierarchical tree structure, coverage items
22
+ are leaf nodes that contain measurement data (hit counts) but no children.
23
+
24
+ Coverage items are typically accessed via CoverIndex objects obtained by
25
+ iterating over a scope's cover items, rather than by direct instantiation
26
+ of CoverItem subclasses.
27
+
28
+ Note:
29
+ This class extends Obj, inheriting the property interface for
30
+ accessing integer, real, string, and handle properties. Properties
31
+ on cover items are accessed with coverindex ≥ 0, unlike scope-level
32
+ properties which use coverindex = -1.
33
+
34
+ Example:
35
+ >>> # Access cover items in a scope
36
+ >>> for cover_idx in coverpoint.coverItems():
37
+ ... # Each cover_idx provides access to a CoverItem
38
+ ... name = cover_idx.getName()
39
+ ... data = cover_idx.getCoverData()
40
+ ...
41
+ >>> # Get property from a cover item
42
+ >>> count = coverpoint.getIntProperty(
43
+ ... IntProperty.COUNT, coverindex=0)
44
+
45
+ See Also:
46
+ CoverIndex: Reference to coverage items
47
+ Scope.coverItems(): Iterate cover items
48
+ Scope.createNextCover(): Create new cover items
49
+ CoverData: Coverage measurement data
50
+ UCIS LRM Section 8.11 "Coveritem Creation and Manipulation"
51
+ """
52
+
53
+ def __init__(self):
54
+ super().__init__()
55
+
56
+ def getStmtIndex(self)->int:
57
+ """Get the statement index for code coverage items.
58
+
59
+ For code coverage types (statement, branch, condition, expression),
60
+ returns the index identifying which statement in the scope this
61
+ coverage item represents. This links coverage data to specific
62
+ statements in the source code.
63
+
64
+ Returns:
65
+ Statement index (non-negative integer), or implementation-specific
66
+ value if not applicable for this coverage type.
67
+
68
+ Raises:
69
+ UnimplError: Not implemented in base class or specific backend.
70
+
71
+ Note:
72
+ This method is primarily relevant for code coverage scopes
73
+ (STMTBIN, BRANCHBIN, CONDBIN, EXPRBIN). For other coverage types
74
+ like covergroups or toggles, the return value may not be meaningful.
75
+
76
+ See Also:
77
+ setStmtIndex(): Set statement index
78
+ CoverTypeT: Coverage type enumeration
79
+ """
80
+ raise UnimplError()
81
+
82
+ def setStmtIndex(self, i):
83
+ """Set the statement index for code coverage items.
84
+
85
+ Sets the statement index that links this coverage item to a specific
86
+ statement in the source code. Used primarily for code coverage types.
87
+
88
+ Args:
89
+ i: Statement index (non-negative integer).
90
+
91
+ Raises:
92
+ UnimplError: Not implemented in base class or specific backend.
93
+
94
+ See Also:
95
+ getStmtIndex(): Query statement index
96
+ """
97
+ raise UnimplError()
98
+
99
+
@@ -0,0 +1,124 @@
1
+
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+
19
+ '''
20
+ Created on Jan 8, 2020
21
+
22
+ @author: ballance
23
+ '''
24
+ from covsight.core.api.scope import Scope
25
+ from covsight.core.api.unimpl_error import UnimplError
26
+
27
+ class CoverType(Scope):
28
+ """Base class for coverage type scopes with goal/limit/weight management.
29
+
30
+ CoverType extends Scope to add coverage-specific attributes including
31
+ coverage goal, limit, and weight. These attributes control how coverage
32
+ is measured and reported.
33
+
34
+ - **Goal**: Target count for coverage completion
35
+ - **Limit**: Maximum count before saturation
36
+ - **Weight**: Relative importance in coverage calculations
37
+
38
+ This class serves as a base for coverage scopes that need these attributes,
39
+ providing getter/setter methods that can be overridden by subclasses.
40
+
41
+ Example:
42
+ >>> # CoverType is typically not used directly
43
+ >>> # Subclasses like Coverpoint inherit these methods
44
+ >>> cp = cg.createCoverpoint("cp_addr", src_info, 1, SourceT.SV)
45
+ >>> cp.setCoverGoal(100)
46
+ >>> cp.setCoverWeight(10)
47
+ >>> goal = cp.getCoverGoal()
48
+
49
+ See Also:
50
+ Scope: Base scope class
51
+ Coverpoint: Subclass using goal/weight
52
+ CoverData: Coverage data with goal/weight fields
53
+ """
54
+
55
+ def __init__(self):
56
+ super().__init__()
57
+
58
+ def setCoverGoal(self, goal : int):
59
+ """Set the coverage goal.
60
+
61
+ Args:
62
+ goal: Target count for coverage completion.
63
+
64
+ Raises:
65
+ UnimplError: Not implemented in base class or specific backend.
66
+ """
67
+ raise UnimplError()
68
+
69
+ def getCoverGoal(self)->int:
70
+ """Get the coverage goal.
71
+
72
+ Returns:
73
+ Goal value.
74
+
75
+ Raises:
76
+ UnimplError: Not implemented in base class or specific backend.
77
+ """
78
+ raise UnimplError()
79
+
80
+ def setCoverLimit(self, limit : int):
81
+ """Set the coverage count limit (saturation point).
82
+
83
+ Args:
84
+ limit: Maximum count value.
85
+
86
+ Raises:
87
+ NotImplementedError: Not implemented in base class or specific backend.
88
+ """
89
+ raise NotImplementedError()
90
+
91
+ def getCoverLimit(self) -> int:
92
+ """Get the coverage count limit.
93
+
94
+ Returns:
95
+ Limit value.
96
+
97
+ Raises:
98
+ NotImplementedError: Not implemented in base class or specific backend.
99
+ """
100
+ raise NotImplementedError()
101
+
102
+ def setCoverWeight(self, weight : int):
103
+ """Set the coverage weight.
104
+
105
+ Args:
106
+ weight: Relative weight value.
107
+
108
+ Raises:
109
+ NotImplementedError: Not implemented in base class or specific backend.
110
+ """
111
+ raise NotImplementedError()
112
+
113
+ def getCoverWeight(self) -> int:
114
+ """Get the coverage weight.
115
+
116
+ Returns:
117
+ Weight value.
118
+
119
+ Raises:
120
+ NotImplementedError: Not implemented in base class or specific backend.
121
+ """
122
+ raise NotImplementedError()
123
+
124
+