Skip to content

Commit 414ad62

Browse files
robtaylorclaude
andcommitted
Convert strategic examples to testable doctests
Phase 3 of doctest improvements: - Convert complete MySoC examples to testcode blocks with assertions - Two examples converted: using-pin-signatures.rst and architecture.rst - Examples now validate that classes can be instantiated correctly - All doctests pass (3 tests total) Strategy: Convert only complete, self-contained examples that use documented public APIs. Keep illustrative fragments as code-block for readability. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 9a44d35 commit 414ad62

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

docs/architecture.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,9 @@ Design Flow in Detail
5858

5959
You write your design in Python using Amaranth HDL and ChipFlow signatures:
6060

61-
.. code-block:: python
62-
63-
from chipflow_lib.platforms import UARTSignature, GPIOSignature
64-
from amaranth import Module
65-
from amaranth.lib.wiring import Component, Out
61+
.. testcode::
6662

67-
class MySoC(Component):
63+
class MySoC(wiring.Component):
6864
def __init__(self):
6965
super().__init__({
7066
"uart": Out(UARTSignature()),
@@ -76,6 +72,11 @@ You write your design in Python using Amaranth HDL and ChipFlow signatures:
7672
# Your design logic here
7773
return m
7874

75+
# Verify the design can be instantiated
76+
design = MySoC()
77+
assert hasattr(design, 'uart')
78+
assert hasattr(design, 'gpio')
79+
7980
2. Signatures Add Metadata
8081
~~~~~~~~~~~~~~~~~~~~~~~~~~~
8182

docs/using-pin-signatures.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ Using Pin Signatures in Your Top-Level Design
3434

3535
Pin signatures are used when defining your top-level component's interface:
3636

37-
.. code-block:: python
38-
39-
from amaranth.lib.wiring import Out
40-
from chipflow_lib.platforms import UARTSignature, GPIOSignature, QSPIFlashSignature
37+
.. testcode::
4138

39+
# Define a simple SoC with external interfaces
4240
class MySoC(wiring.Component):
4341
def __init__(self):
4442
super().__init__({
@@ -47,6 +45,12 @@ Pin signatures are used when defining your top-level component's interface:
4745
"flash": Out(QSPIFlashSignature()),
4846
})
4947

48+
# Verify the component can be instantiated
49+
soc = MySoC()
50+
assert hasattr(soc, 'uart')
51+
assert hasattr(soc, 'gpio')
52+
assert hasattr(soc, 'flash')
53+
5054
These signatures tell ChipFlow:
5155

5256
- How to connect your design to the physical pins of your chip

0 commit comments

Comments
 (0)