You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See amaranth-lang/rfcs#15 and #784.
Note that this RFC breaks the existing syntax for initializing a view
with a new signal. Instances of `View(layout)` *must* be changed to
`Signal(layout)`.
@@ -82,7 +82,7 @@ For example, consider a module that processes RGB pixels in groups of up to four
82
82
"valid": 4
83
83
})
84
84
85
-
i_stream = data.View(input_layout)
85
+
i_stream = Signal(input_layout)
86
86
r_accum = Signal(32)
87
87
88
88
m.d.sync += r_accum.eq(
@@ -120,7 +120,7 @@ In case the data has related operations or transformations, :class:`View` can be
120
120
121
121
.. testcode::
122
122
123
-
class RGBPixelLayout(data.StructLayout):
123
+
class RGBLayout(data.StructLayout):
124
124
def __init__(self, r_bits, g_bits, b_bits):
125
125
super().__init__({
126
126
"red": unsigned(r_bits),
@@ -129,20 +129,20 @@ In case the data has related operations or transformations, :class:`View` can be
129
129
})
130
130
131
131
def __call__(self, value):
132
-
return RGBPixelView(self, value)
132
+
return RGBView(self, value)
133
133
134
-
class RGBPixelView(data.View):
134
+
class RGBView(data.View):
135
135
def brightness(self):
136
136
return (self.red + self.green + self.blue)[-8:]
137
137
138
-
Here, the ``RGBLayout`` class itself is :ref:`shape-castable <lang-shapecasting>` and can be used anywhere a shape is accepted:
138
+
Here, the ``RGBLayout`` class itself is :ref:`shape-castable <lang-shapecasting>` and can be used anywhere a shape is accepted. When a :class:`Signal` is constructed with this layout, the returned value is wrapped in an ``RGBView``:
In case the data format is static, :class:`Struct` (or :class:`Union`) can be subclassed instead of :class:`View`, to reduce the amount of boilerplate needed:
@@ -189,7 +189,7 @@ One module could submit a command with:
0 commit comments