Repository navigation
en guides coverage patterns
Ordinary bins inspect one sample. Temporal bins recognize events over time, such as a response
within four cycles of acceptance or a condition held for two samples. Reuse @xtrigger for these
patterns. If Sequence and FSM are new to you, start with compiled conditions and timing.
This definition comes from the complete example.
ProtocolBundle groups already-bound request, response, and clock signals; it is not a new signal wrapper.
from toffee import RisingEdge, Sequence, Wait, Within, xtrigger
from toffee.declarative import Bin, SignalCoverGroup, TemporalCoverPoint, covergroup
from toffee.ir import signal_expr
from examples.coverage.declarative_protocol import ProtocolBundle
@xtrigger(sample=RisingEdge("clock"))
def roundtrip(pins: ProtocolBundle, *, tag: int = 1, maximum: int = 4):
return Sequence(
Wait(signal_expr(pins.request.valid) & signal_expr(pins.request.ready)
& (signal_expr(pins.request.tag) == tag)),
Within(1, maximum,
signal_expr(pins.response.valid) & signal_expr(pins.response.ready)
& (signal_expr(pins.response.tag) == tag)),
)
class Completions(TemporalCoverPoint[ProtocolBundle]):
tag_one = roundtrip
tag_one_fast = Bin.pattern(roundtrip.with_args(maximum=2))
@covergroup(schema_id="protocol.completions", contract="roundtrip/v1")
class ProtocolCoverage(SignalCoverGroup[ProtocolBundle]):
completions = Completions()tag_one uses the default four-cycle window; tag_one_fast uses two cycles. A response arriving
three cycles later hits only the former. Counts use the declared class attributes, for example
coverage.completions.count(Completions.tag_one).
After instantiation, bind the project's pins and clock with
bind(pins=..., sample=RisingEdge(clock), strategy="native"), then give coverage.runtime to
Execution. For attributes calculated by a Monitor, such as latency or IDs, see
transaction coverage.
roundtrip(pins, maximum=3) creates an awaitable Trigger.
roundtrip.with_args(maximum=3) stores arguments for later signal binding. Required arguments
must be supplied this way when the definition is used before binding.
An FSM may have terminal states such as OK and BAD_DATA. Select outcomes with
Bin.pattern(definition, terminals=("OK",)), and wrap erroneous outcomes in Bin.illegal(...).
Reaching an unselected terminal still ends the match without incrementing that bin.
Within one coverpoint, terminal bins using the same process can share execution state while
keeping separate counts. Different windows or parameters execute separately.
compile().explain() shows this sharing.
The default tracks one active match. Enable concurrency with explicit capacity:
Bin.pattern(roundtrip, overlap=True, max_active=8)Three completions in one cycle count three times. Exhausting capacity raises an error and marks collection incomplete instead of silently dropping events. This does not associate arbitrary dynamic request IDs with their responses.
You cannot directly cross TemporalCoverPoint instances because their processes may finish at
different times. Form a completed transaction in the Monitor and cross its fields instead.
strategy="native" requires native support and fails if capabilities are insufficient.
"auto" allows Python fallback, recording the strategy and reason. See
expressions and resource management for native requirements and types.
Cancelling an ordinary await does not clear the covergroup's own matching history. Exit its Execution to stop sampling; use the group's history operations to clear history explicitly.
python3 -m examples.coverage.trigger_bins --engine memory --strategy python
python3 -m examples.coverage.trigger_bins --engine xcomm --strategy nativeThe example sends IDs 1, 2, 3 and receives responses in order 2, 1, 3.
| Coverage item | Count | Reason |
|---|---|---|
requests.handshake |
3 | Three requests accepted |
completions.tag_one |
1 | ID 1 returned within four cycles |
completions.tag_one_fast |
0 | ID 1 missed the two-cycle window |
completions.tag_two_ready |
1 | Ready stayed high for two samples after ID 2's response |
completions.correct_data |
1 | ID 1 returned correct data |
completions.bad_data |
0 | No bad data observed |
An uncovered item may simply mean its scenario did not occur in this run. Assertions and checkers still determine whether the design behaves correctly.
内容由 CI 自动同步;请编辑主仓库文档。 Automatically synced by CI; edit the source documentation.
- 首页
- 教程
- 操作指南
- 参考
- 原理说明
- Home
-
Tutorials
- Learning path
- 0. Prepare your environment
- 1. Your first PASS and FAIL
- 2. Inputs and clocks
- 3. More cases and boundaries
- 4. Extract a Driver
- 5. Delayed output and a Monitor
- 6. Assemble an Agent
- 7. Models and the test environment
- 8. Pipelines, batches, and cancellation
- 9. Understand failures
- 10. Functional coverage
- Optional: out-of-order responses
- Optional: native clocks and project DUTs
-
How-to guides
- Find your task
- Simulation and events
- Verification components
- Coverage and regressions
- Migration and maintenance
- Runnable examples
- Reference
- Explanation