Open
Description
Something like this:
from amaranth.lib import data
from amaranth import Signal, Module
from amaranth.asserts import AnyConst
class S(data.Struct):
a: Signal()
m = Module()
any_const = AnyConst(S)
signal = Signal(S)
out = Signal()
m.d.comb += out.eq(signal == any_const)
fails with
Traceback (most recent call last):
File "/tmp/a.py", line 16, in <module>
m.d.comb += out.eq(signal == any_const)
File "/data/projects/amaranth/amaranth/lib/data.py", line 888, in __eq__
raise TypeError(
TypeError: View with layout StructLayout({}) can only be compared to another view or constant with the same layout, not (anyconst 0')
It would be nice if such comparisons would be possible. (Its of course possible to work around this by creating a intermediate Signal
with the correct shape driven by the Any{Seq,Const}
and comparing to that)