Skip to content
Open
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
Binary file modified docs/screenshots/pyrtl-renderer-demo-ascii.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions examples/renderer-demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def make_counter(period: int, bitwidth: int = 2):
)

for name, (constants, notes) in renderers.items():
print(f"# {notes}")
print(f"export PYRTL_RENDERER={name}\n")
print(f"# {notes}\n")
print(f"$ export PYRTL_RENDERER={name}\n")
sim.tracer.render_trace(
renderer=pyrtl.simulation.WaveRenderer(constants), repr_func=int
)
Expand Down
43 changes: 23 additions & 20 deletions pyrtl/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1376,10 +1376,10 @@ class Utf8RendererConstants(RendererConstants):

This is the default renderer.

Enable this renderer by default by setting the ``PYRTL_RENDERER`` environment
variable to ``utf-8``::
Use this renderer by default by setting the ``PYRTL_RENDERER`` environment variable
to ``utf-8``::

export PYRTL_RENDERER=utf-8
$ export PYRTL_RENDERER=utf-8

.. image:: ../docs/screenshots/pyrtl-renderer-demo-utf-8.png
:width: 35em
Expand Down Expand Up @@ -1417,10 +1417,10 @@ class Utf8AltRendererConstants(RendererConstants):
Compared to :class:`Utf8RendererConstants`, this renderer is more compact because it
uses one character between cycles instead of two.

Enable this renderer by default by setting the ``PYRTL_RENDERER`` environment
variable to ``utf-8-alt``::
Use this renderer by default by setting the ``PYRTL_RENDERER`` environment variable
to ``utf-8-alt``::

export PYRTL_RENDERER=utf-8-alt
$ export PYRTL_RENDERER=utf-8-alt

.. image:: ../docs/screenshots/pyrtl-renderer-demo-utf-8-alt.png
:width: 25em
Expand Down Expand Up @@ -1456,10 +1456,10 @@ class PowerlineRendererConstants(Utf8RendererConstants):
This renderer requires a `terminal font that supports Powerline glyphs
<https://github.com/powerline/fonts>`_.

Enable this renderer by default by setting the ``PYRTL_RENDERER`` environment
variable to ``powerline``::
Use this renderer by default by setting the ``PYRTL_RENDERER`` environment variable
to ``powerline``::

export PYRTL_RENDERER=powerline
$ export PYRTL_RENDERER=powerline

.. image:: ../docs/screenshots/pyrtl-renderer-demo-powerline.png
:width: 35em
Expand Down Expand Up @@ -1487,10 +1487,10 @@ class Utf8BasicRendererConstants(RendererConstants):
codes <https://en.wikipedia.org/wiki/ANSI_escape_code>`_, which makes its output
suitable for inclusion in text files.

Enable this renderer by default by setting the ``PYRTL_RENDERER`` environment
variable to ``utf-8-basic``::
Use this renderer by default by setting the ``PYRTL_RENDERER`` environment variable
to ``utf-8-basic``::

export PYRTL_RENDERER=utf-8-basic
$ export PYRTL_RENDERER=utf-8-basic

.. image:: ../docs/screenshots/pyrtl-renderer-demo-utf-8-basic.png
:width: 25em
Expand All @@ -1515,23 +1515,26 @@ class Utf8BasicRendererConstants(RendererConstants):
class AsciiRendererConstants(RendererConstants):
"""7-bit ASCII renderer constants. These should work anywhere.

Single-bit :class:`WireVectors<WireVector>` are rendered as waveforms with sloped
rising and falling edges. Multi-bit :class:`WireVector` values are rendered between
vertical bars.
Single-bit :class:`WireVectors<WireVector>` are rendered as square waveforms with
vertical rising and falling edges. Multi-bit :class:`WireVector` values are rendered
between vertical bars.

Enable this renderer by default by setting the ``PYRTL_RENDERER`` environment
variable to ``ascii``::
Use this renderer by default by setting the ``PYRTL_RENDERER`` environment variable
to ``ascii``::

export PYRTL_RENDERER=ascii
$ export PYRTL_RENDERER=ascii

.. image:: ../docs/screenshots/pyrtl-renderer-demo-ascii.png
:width: 25em
"""

_tick = "|"

_up, _down = ",", "."
_low, _high = "_", "-"
_up, _down = "|", "|"
_low, _high = "_", " "

_prev_line_up, _prev_line_down = " ", " "
_prev_line_low, _prev_line_high = " ", "_"

_x = "|"
_zero_x = "|"
Expand Down
18 changes: 9 additions & 9 deletions tests/test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def check_rendered_trace(self, expected, **kwargs):
)
buff = io.StringIO()
sim.tracer.render_trace(file=buff, renderer=self.renderer, **kwargs)
self.assertEqual(buff.getvalue(), expected)
self.assertEqual(expected, buff.getvalue())

def test_hex_trace(self):
expected = (
Expand All @@ -195,8 +195,8 @@ def test_hex_trace(self):
"a 0x1 |0x4 |0x9 |0xb |0xc\n"
" \n"
"b 0x2 |0x17|0x2b|0x78|----\n"
" \n"
"c ____,---------.____,----\n"
" _________ ____\n"
"c ____| |____|\n"
)
self.check_rendered_trace(expected)

Expand All @@ -207,8 +207,8 @@ def test_oct_trace(self):
"a 0o1 |0o4 |0o11 |0o13 |0o14\n"
" \n"
"b 0o2 |0o27 |0o53 |0o170|-----\n"
" \n"
"c _____,-----------._____,-----\n"
" ___________ _____\n"
"c _____| |_____|\n"
)

self.check_rendered_trace(expected, repr_func=oct)
Expand All @@ -220,8 +220,8 @@ def test_bin_trace(self):
"a 0b1 |0b100 |0b1001 |0b1011 |0b1100\n"
" \n"
"b 0b10 |0b10111 |0b101011 |0b1111000|---------\n"
" \n"
"c _________,-------------------._________,---------\n"
" ___________________ _________\n"
"c _________| |_________|\n"
)

self.check_rendered_trace(expected, repr_func=bin)
Expand All @@ -233,8 +233,8 @@ def test_decimal_trace(self):
"a 1 |4 |9 |11 |12\n"
" \n"
"b 2 |23 |43 |120|---\n"
" \n"
"c ___,-------.___,---\n"
" _______ ___\n"
"c ___| |___|\n"
)
self.check_rendered_trace(expected, repr_func=str)

Expand Down
Loading