Skip to content

Commit 0139256

Browse files
authored
rtllib documentation cleanup (#491)
* Add AES doctest examples. * Make AES method names more consistent. Forward calls to the deprecated old method names to the new method names. * Convert PRNG examples to doctest examples. Also: * Update PRNGs to use State Registers. * Include `render_trace` output directly in examples. * `render_trace`: Remove trailing whitespace from output. * Always use the `pyrtl.` package prefix in examples. * Add more documentation links to specific `examples/`. * Improve documentation for functions with additional software requirements. * Make the main-page installation instructions consistent with the other `pip install` examples. * Stop publishing documentation for: * half_adder, one_bit_add, ripple_add, ripple_half_add (undocumented) * testingutils (nondeterministic tests are generally a bad idea)
1 parent 443e47e commit 0139256

19 files changed

Lines changed: 519 additions & 229 deletions

docs/basic.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ maps from :class:`.WireVector` to its default value for the
122122
:data:`.conditional_assignment` block. ``defaults`` are not supported for
123123
:class:`.MemBlock`. See :ref:`conditional_assignment_defaults` for more details.
124124

125-
See `the state machine example
126-
<https://github.com/UCSBarchlab/PyRTL/blob/development/examples/example3-statemachine.py>`_
127-
for more examples of :data:`.conditional_assignment`.
125+
.. note::
126+
127+
See `example3-statemachine
128+
<https://github.com/UCSBarchlab/PyRTL/blob/development/examples/example3-statemachine.py>`_
129+
for more :data:`.conditional_assignment` examples.
128130

129131
.. autodata:: pyrtl.otherwise
130132

docs/helpers.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ many operators such as addition and multiplication).
2323
Coercion to WireVector
2424
----------------------
2525

26-
In PyRTL there is only one function in charge of coercing values into
27-
:class:`WireVectors<.WireVector>`, and that is :func:`.as_wires`. This function
28-
is called in almost all helper functions and classes to manage the mixture of
29-
constants and :class:`WireVectors<.WireVector>` that naturally occur in
30-
hardware development.
26+
:func:`.as_wires` coerces values to :class:`WireVectors<.WireVector>`. Most
27+
PyRTL helper functions and classes call :func:`.as_wires` on their inputs, to
28+
manage the mixture of constants and :class:`WireVectors<.WireVector>` that
29+
naturally occur in hardware development.
3130

3231
See :ref:`wirevector_coercion` for examples and more details.
3332

docs/index.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ Quick links
2323
Installation
2424
============
2525

26-
**Automatic installation**::
26+
PyRTL is availble in `PyPI <http://pypi.python.org/pypi/pyrtl>`_ and can be
27+
installed with :program:`pip`::
2728

28-
pip install pyrtl
29-
30-
PyRTL is listed in `PyPI <http://pypi.python.org/pypi/pyrtl>`_ and can be
31-
installed with :program:`pip`.
29+
$ pip install pyrtl
3230

3331
Design, Simulate, and Inspect in 15 lines
3432
=========================================

docs/rtllib.rst

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Adders
1616
.. automodule:: pyrtl.rtllib.adders
1717
:members:
1818
:undoc-members:
19+
:exclude-members: half_adder, one_bit_add, ripple_add, ripple_half_add
1920

2021
Multipliers
2122
-----------
@@ -55,10 +56,3 @@ AES-128
5556

5657
.. autoclass:: pyrtl.rtllib.aes.AES
5758
:members:
58-
59-
Testing Utilities
60-
-----------------
61-
62-
.. automodule:: pyrtl.rtllib.testingutils
63-
:members:
64-
:exclude-members: generate_in_wire_and_values, sim_and_ret_out, sim_and_ret_outws, sim_multicycle, multi_sim_multicycle

docs/screenshots/render_trace.png

-13.5 KB
Binary file not shown.

pyrtl/analysis.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,11 @@ def yosys_area_delay(
344344
"""Synthesize with `Yosys <https://yosyshq.net/yosys/>`_ and return estimate of area
345345
and delay.
346346
347+
.. warning::
348+
349+
``yosys_area_delay`` requires ``yosys``, which must be `separately installed
350+
<https://yosyshq.readthedocs.io/projects/yosys/en/latest/getting_started/installation.html>`_.
351+
347352
If ``leave_in_dir`` is specified, that directory will be used to create any
348353
temporary files, and the resulting files will be left behind there (which can be
349354
useful for manual exploration or debugging)

pyrtl/core.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,12 @@ def set_debug_mode(debug: bool = True):
11821182
These call stacks can be inspected as :attr:`WireVector.init_call_stack`, and they
11831183
will appear in :meth:`Block.sanity_check` error messages.
11841184
1185+
.. note::
1186+
1187+
See `example4-debuggingtools
1188+
<https://github.com/UCSBarchlab/PyRTL/blob/development/examples/example4-debuggingtools.py>`_
1189+
for ``debug_mode`` examples.
1190+
11851191
:param debug: Optional boolean parameter to which the debug mode will be set.
11861192
"""
11871193
global debug_mode

pyrtl/corecircuits.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ def match_bitwidth(*args: WireVector, signed: bool = False) -> tuple[WireVector]
717717
>>> a = pyrtl.Const(-1, name="a_short", signed=True, bitwidth=2)
718718
>>> b = pyrtl.Const(-3, name="b", signed=True, bitwidth=4)
719719
720-
>>> a, b = match_bitwidth(a, b, signed=True)
720+
>>> a, b = pyrtl.match_bitwidth(a, b, signed=True)
721721
>>> a.name = "a_long"
722722
>>> a.bitwidth, b.bitwidth
723723
(4, 4)
@@ -768,8 +768,8 @@ def as_wires(
768768
:class:`Const` :class:`WireVector`). See :ref:`wirevector_coercion`. An example::
769769
770770
>>> def make_my_hardware(a, b):
771-
... a = as_wires(a)
772-
... b = as_wires(b)
771+
... a = pyrtl.as_wires(a)
772+
... b = pyrtl.as_wires(b)
773773
... return (a + b) & 0xf
774774
775775
>>> input = pyrtl.Input(name="input", bitwidth=8)

0 commit comments

Comments
 (0)