Repository navigation
en guides execution and backend
Place an existing DUT within a test scope and release resources afterwards.
These snippets assume a project-provided dut, registered dut.clock, and compatible xspcomm bindings.
For first-time integration, see native clocks and project DUTs.
Within an async test, create the backend, enter Execution, and close the backend in finally:
from toffee import Execution, RisingEdge, XCommClockBackend
backend = XCommClockBackend(dut.GetXClock())
try:
async with Execution(backend, default_sample=RisingEdge(dut.clock)):
await RisingEdge(dut.clock)
# 在稳定上升沿读取并检查 DUT 输出。
finally:
backend.close()Release the DUT after the backend. Inside Execution use Trigger waits; do not call dut.Step() or
run another clock task, even while paused. Execution cleans up its waits and components, while backend and DUT state persist.
import pytest
from toffee import Execution, XCommClockBackend
@pytest.fixture(scope="session")
def backend(dut):
backend = XCommClockBackend(dut.GetXClock())
try:
yield backend
finally:
backend.close()
@pytest.mark.asyncio
async def test_a(backend):
async with Execution(backend):
...
@pytest.mark.asyncio
async def test_b(backend):
async with Execution(backend):
...This requires a session-scoped DUT fixture as well. Match a function-scoped DUT with a function-scoped
backend; see the fixture tutorial.
Reusing the backend does not reset the clock or DUT. Run the project's reset sequence after entering Execution when needed.
Construct and connect Agents before registering them with Execution(backend, agents=[agent]).
Execution starts components and cleans them up in reverse order. Create fresh Agent instances after exit.
See Agent wiring.
Execution drains ready simulation work and its cascading wakeups before advancing the clock.
AsyncDriver manages background driving without sleep(0) handoffs:
async with Execution(backend), input_driver as driver:
inputs = [driver.send(request) for request in requests]
accepted = [await item for item in inputs]Here input_driver is an AsyncDriver subclass. Its completion contract depends on the Driver;
see pipeline examples.
Draining ready work does not complete external I/O. Explicitly await configuration or initialization.
Use Execution.paused() when the clock must remain frozen; do not await a simulation-dependent Trigger
inside that context, since it cannot complete until simulation resumes.
Start with default budgets. For SimulationNotSettledError, inspect tick, phase, and pending callbacks,
including possible endless sleep(0) loops. Use external_task for independent services as described in
asyncio integration. Increase max_settle_rounds only for a known finite callback chain.
See Execution reference and execution model.
内容由 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