Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,30 @@ on:
- pull_request

jobs:
tests:
runs-on: ubuntu-latest
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
enable-cache: true
- name: Install apt dependencies
run: sudo apt install -y yosys
- name: Install dependencies
shell: bash
run: |
if [ "$RUNNER_OS" = "Linux" ]; then
sudo apt install -y yosys
elif [ "$RUNNER_OS" = "macOS" ]; then
brew install -y yosys
fi
- name: Run tests
run: uv run just tests
- name: Upload coverage to Codecov
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: codecov/codecov-action@v7
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ tests:
# Run `pytest` with the latest version of Python supported by PyRTL,
# which is the default for `uv`. The default is set with `uv python
# pin` and written to `.python_version`.
uv run pytest -n auto --cov=pyrtl --cov-report=xml
uv run pytest -rsx -n auto --cov=pyrtl --cov-report=xml

# Run `pytest` in an isolated virtual environment, with the earliest
# version of Python supported by PyRTL.
uv run --python=3.10 --isolated pytest -n auto
uv run --python=3.10 --isolated pytest -rsx -n auto

# Run `ruff format` to check that code is formatted properly.
#
Expand Down
4 changes: 2 additions & 2 deletions pyrtl/compilesim.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,12 +1122,12 @@ def _create_code(self, write):
"x86_64": '"mulq %q3":"=a"(pl),"=d"(ph):"%0"(t0),"r"(t1):"cc"',
"arm64": (
'"mul %0, %2, %3\\n\\t" \\\n'
'"umulh %1, %2, %3":"=&r"(pl),"=r"(ph):"r"(t0),"r"(t1):"cc"',
'"umulh %1, %2, %3":"=&r"(pl),"=r"(ph):"r"(t0),"r"(t1):"cc"'
),
"mips64": (
'"dmultu %2, %3\\n\\t" \\\n'
'"tmflo %0\\n\\t" \\\n'
'"mfhi %1":"=r"(pl),"=r"(ph):"r"(t0),"r"(t1)',
'"mfhi %1":"=r"(pl),"=r"(ph):"r"(t0),"r"(t1)'
),
}
if machine in mul_asm:
Expand Down
48 changes: 24 additions & 24 deletions pyrtl/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,29 +346,29 @@ def graphviz_detailed_namer(
Any additional information in these ``dicts`` will be displayed in parentheses in
the Graphviz graph.

.. doctest only::
.. doctest comment::

>>> import pyrtl
>>> pyrtl.reset_working_block()
This example is not a `doctest` because it depends on `graphviz`, which might
not be installed.

Example::

>>> a = pyrtl.WireVector(name="a", bitwidth=3)
>>> b = pyrtl.WireVector(name="b", bitwidth=3)
>>> sum = a + b
>>> sum.name = "sum"
a = pyrtl.WireVector(name="a", bitwidth=3)
b = pyrtl.WireVector(name="b", bitwidth=3)
sum = a + b
sum.name = "sum"

add_logicnets = pyrtl.working_block().logic_subset("+")
len(add_logicnets)

>>> add_logicnets = pyrtl.working_block().logic_subset("+")
>>> len(add_logicnets)
1
>>> add_logicnet = add_logicnets.pop()
add_logicnet = add_logicnets.pop()

>>> namer = pyrtl.graphviz_detailed_namer(
... extra_node_info={add_logicnet: "ADD NODE"},
... extra_edge_info={a: "EDGE A", b: "EDGE B"}
... )
namer = pyrtl.graphviz_detailed_namer(
extra_node_info={add_logicnet: "ADD NODE"},
extra_edge_info={a: "EDGE A", b: "EDGE B"}
)

>>> svg_data = pyrtl.block_to_svg(namer=namer)
svg_data = pyrtl.block_to_svg(namer=namer)

``svg_data`` is a :class:`str` containing the SVG data. This data can be written to
a file::
Expand Down Expand Up @@ -590,21 +590,21 @@ def block_to_svg(*args, **kwargs) -> str:

$ pip install pyrtl[svg]

.. doctest only::
.. doctest comment::

>>> import pyrtl
>>> pyrtl.reset_working_block()
This example is not a `doctest` because it depends on ``graphviz``, which might
not be installed.

This just calls :func:`block_to_graphviz_string` and renders the Graphviz string as
SVG, using the `graphviz <https://pypi.org/project/graphviz/>`_ ``pip`` package.
Example::

>>> a = pyrtl.WireVector(name="a", bitwidth=3)
>>> b = pyrtl.WireVector(name="b", bitwidth=3)
>>> sum = a + b
>>> sum.name = "sum"
a = pyrtl.WireVector(name="a", bitwidth=3)
b = pyrtl.WireVector(name="b", bitwidth=3)
sum = a + b
sum.name = "sum"

>>> svg_data = pyrtl.block_to_svg()
svg_data = pyrtl.block_to_svg()

``svg_data`` is a :class:`str` containing the SVG data. This data can be written to
a file::
Expand Down
Loading