Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs/stdlib/data: view value-likes can't be used _anywhere_ values can #1472

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
14 changes: 13 additions & 1 deletion docs/stdlib/data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,24 @@ While this implementation works, it is repetitive, error-prone, hard to read, an

m.d.comb += o_gray.eq((i_color.red + i_color.green + i_color.blue) << 1)

The :class:`View` is :ref:`value-like <lang-valuelike>` and can be used anywhere a plain value can be used. For example, it can be assigned to in the usual way:
Signals with a layout based shape are automatically wrapped in the :class:`View` :ref:`value-like <lang-valuelike>` wrapper, and can be used in many places where a plain value can be used. For example, it can be assigned to in the usual way:

.. testcode::

m.d.comb += i_color.eq(0) # everything is black

They can be compared for equality with other value-like objects of the same layout, however they cannot be compared with value-like objects of other shapes, and most operators are also not supported:

.. testcode::

other_color = Signal(rgb565_layout)

i_color == other_color

# The following expressions would raise a TypeError:
# i_color == 0
# i_color | 1


Composing layouts
+++++++++++++++++
Expand Down