Repository navigation
en getting started native and next
Complete the main tutorial and prepare xcomm's Python bindings. This lesson checks that the same verification components work with native XClock.
Toffee depends on uc-xcomm, which provides xspcomm. The backend requires APIs including
XClock.StepHalf, GetHalfTick, GetPhase, XData, and XTriggerEngine.
Use the commit, package, ABI, and protocol versions from the
dependency manifest, not the package name alone.
python3 examples/getting_started/check_native.pyFor a binding built locally, add the parent of the xspcomm package directory to the search path. Replace the placeholder with your build directory:
export PYTHONPATH="/实际路径/xcomm/python${PYTHONPATH:+:$PYTHONPATH}"
python3 examples/getting_started/check_native.pyThe script prints the loaded binding's path and should end with:
native clock: tick=2, phase=RISING_STABLE
| Symptom | Action |
|---|---|
No module named xspcomm |
Check installation in the selected interpreter or PYTHONPATH |
| Path points at an old build | Select the intended binding |
| Missing half-step APIs or XTriggerEngine | Update or rebuild xcomm with those APIs |
Repository tests attempt to discover a sibling Picker build. Ordinary scripts and example-only runs
do not use tests/conftest.py, so xspcomm must be directly importable here.
File: examples/getting_started/native_lab.py.
"""Optional native-clock exercise, run explicitly after installing xspcomm."""
import pytest
from examples.getting_started.test_accumulator import AccumulatorModel, make_pipeline_agent
from examples.getting_started.toy_dut import TutorialDut
from toffee import Execution
@pytest.mark.asyncio
async def test_accumulator_with_native_clock():
dut = TutorialDut(backend="native")
agent = make_pipeline_agent(dut)
agent.connect(AccumulatorModel())
try:
async with Execution(dut.backend, agents=[agent]):
first = agent.submit(250)
second = agent.submit(10)
await agent.finish(timeout_cycles=10, observe_cycles=1)
assert await first == 250
assert await second == 4
finally:
dut.close()python3 -m pytest -q examples/getting_started/native_lab.pyExpect 1 passed. The environment changes to TutorialDut(backend="native"), using native XClock and XData.
The accumulator behavior is still implemented in Python: this verifies backend integration, not an RTL accumulator.
This optional file is run explicitly; the basic tutorial does not require native bindings to execute its teaching model.
DUT generation, ports, and initialization are project-specific. Implement these mappings in the project environment:
| Teaching component | Project responsibility |
|---|---|
TutorialDut() |
Build/create the generated DUT and initialize it |
dut.clock / dut.backend
|
Actual XClock and XCommClockBackend(clock)
|
Bundle(enable=..., operand=...) |
Ports, widths, and idle values |
| SingleCycleDriver | Real acceptance condition and input timing, or a custom Driver |
dut.response is not None |
Response validity and sampling point |
| Integer snapshot | Immutable project response record |
AccumulatorModel.accept() |
Functional specification, initial state, and updates |
| Three-cycle response budget | Allowed timing from the specification |
dut.close() |
Actual resource cleanup |
Keep the input/wait/check structure, but define protocol, reset, and flush rules explicitly. Do not copy the tutorial's one-cycle enable rule to unrelated interfaces.
| Task | Example or guide |
|---|---|
| Multicycle inputs and overlapping stages | Pipeline examples |
| Passive observation | Monitors and Agents |
| Conditions and timeouts | Triggers |
| Fixed-latency output association | Scoreboards |
| Seeds, coverage, and pytest reports | Verification flow |
| Existing generated cache DUT | Cache environment, with extra dependencies |
| Full e203 RTL and coverage flow | e203 environment |
For the repository's complete checks:
python3 -m pytest -q --require-xspcomm
python3 -m pip install -e '.[docs]'
mkdocs build --strict--require-xspcomm fails when native bindings are unavailable, preventing skipped native tests from
being mistaken for passing coverage. It is a repository test option, not required by the earlier tutorial commands.
Return to the tutorial or feature map.
内容由 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