Skip to content

Commit 3df3313

Browse files
committed
Minor wire_struct improvements:
* The concatenated value can be set with the special `kwarg` "_value". This is useful when the `wire_struct`'s class name is not known. * Changes to make `wire_struct` instances documentable with Sphinx. The generated class copies its docstring from the decorated class (`__doc__`), and the generated class's name now matches the decorated class's name. Previously all `wire_struct` classes were named `_WireStruct`. * Add a new `class_name` argument to `wire_matrix`. This lets users set the name of the generated class. This is optional for backwards compatibility, but highly recommended to help with debugging. Previously all `wire_matrix` classes were named `_WireMatrix`.
1 parent 4ace6d3 commit 3df3313

5 files changed

Lines changed: 301 additions & 265 deletions

File tree

examples/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PYTHON=python
1+
PYTHON=uv run python3
22
PY_FILES=$(wildcard *.py)
33
IPYNB_FILES=$(addprefix ../ipynb-examples/, $(PY_FILES:.py=.ipynb))
44

examples/example1.2-wire-struct.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class Pixel:
154154
# `PixelPair` is a pair of two `Pixels`. This also shows how `wire_matrix()` and
155155
# `wire_struct` work together - `PixelPair` is a `wire_struct` nested in a
156156
# `wire_matrix()`.
157-
PixelPair = pyrtl.wire_matrix(component_schema=Pixel, size=2)
157+
PixelPair = pyrtl.wire_matrix(component_schema=Pixel, size=2, class_name="PixelPair")
158158

159159
# `wire_matrix()` returns a class!
160160
assert inspect.isclass(PixelPair)

ipynb-examples/example1.2-wire-struct.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@
384384
},
385385
"outputs": [],
386386
"source": [
387-
"PixelPair = pyrtl.wire_matrix(component_schema=Pixel, size=2)\n"
387+
"PixelPair = pyrtl.wire_matrix(component_schema=Pixel, size=2, class_name=\"PixelPair\")\n"
388388
]
389389
},
390390
{

0 commit comments

Comments
 (0)