2
<p><span class="h-card" translate="no"><a href="https://aus.social/@jpm" class="u-url mention">@<span>jpm</span></a></span> i think we can however add a diagnostic for this case; if you file an issue we&#39;ll take care of it (most likely checking in the Const.__eq__ implementation if you&#39;re comparing a constant with a non-Amaranth enum or something)</p>
<p><span class="h-card" translate="no"><a href="https://social.treehouse.systems/@mupuf" class="u-url mention">@<span>mupuf</span></a></span> <span class="h-card" translate="no"><a href="https://hachyderm.io/@emersion" class="u-url mention">@<span>emersion</span></a></span> (it was not a WSI patch, i was working on improving hardware driver support for hot-unplug. i don&#39;t remember the details anymore)</p>
<p><span class="h-card" translate="no"><a href="https://gts.mischief.expert/@arcayr" class="u-url mention">@<span>arcayr</span></a></span> <span class="h-card" translate="no"><a href="https://chaosfem.tw/@kookie" class="u-url mention">@<span>kookie</span></a></span> &quot;stable&quot; (not actually stable in practice on PC platforms) net interface names was the thing that prompted me to dig in. it was infuriating to learn that this was a breaking change for the sole reason that network interface aliases were added to the kernel after it shipped and not before</p><p>we could have had the &quot;stable&quot; interface names _and_ eth0, etc, but we didn&#39;t because the people involved don&#39;t give a shit about this</p>
<p><span class="h-card" translate="no"><a href="https://aus.social/@jpm" class="u-url mention">@<span>jpm</span></a></span> this isn&#39;t an Amaranth enum; those should have a `shape=` argument in the class declaration, like:</p><p>class RunState(enum.Enum, shape=range(6)):</p><p>for Amaranth enums, == is overridden the way you need here</p><p>see <a href="https://amaranth-lang.org/docs/amaranth/latest/stdlib/enum.html#view-classes" target="_blank" rel="nofollow noopener" translate="no"><span class="invisible">https://</span><span class="ellipsis">amaranth-lang.org/docs/amarant</span><span class="invisible">h/latest/stdlib/enum.html#view-classes</span></a></p>
<p><span class="h-card" translate="no"><a href="https://mastodon.social/@whitequark" class="u-url mention">@<span>whitequark</span></a></span> the one quirk I&#39;ve found so far with writing tests is that I can&#39;t compare a state to an enum member directly, I have to specify Enum.MEMBER.value, e.g.</p><p>...<br />from amaranth.lib import enum, wiring<br />...<br />class RunState(enum.Enum):<br /> NONE = 0<br /> STOP = 1<br /> LATCH = 2<br /> DATA = 3<br /> ONESHOT = 4<br /> CONTINUOUS = 5<br />...</p><p>async def testbench(ctx):<br /> # set initial state<br /> ctx.set(dut.reg_run_state, RunState.NONE)<br />...</p><p> assert ctx.get(dut.reg_run_state) == RunState.NONE.value # assertion ok<br /> assert ctx.get(dut.reg_run_state) == RunState.NONE # assertion fails</p><p>I&#39;m guessing this is a Python quirk, so a note in the testing docs about it would be very helpful!</p>
<p><span class="h-card" translate="no"><a href="https://mastodon.social/@whitequark" class="u-url mention">@<span>whitequark</span></a></span> it&#39;s obvious that just as much care and attention has been paid to testing as it has been to the language itself, and really encourages tests to be written during development (and not as an afterthought). Being able to sim the code to any arbitrary clock point and assert that its internal state should be &lt;this&gt; at that time given the previous inputs is absolutely how it should be.</p>
<p><span class="h-card" translate="no"><a href="https://aus.social/@jpm" class="u-url mention">@<span>jpm</span></a></span> i&#39;m incredibly pleased to hear that this is your experience! writing tests has always been a pain point for me in HDL, and i&#39;ve done a lot of independent research (with my collaborators) on how to make it nice and intuitive. glad it pays off!!</p>
<p>Again, many thanks to <span class="h-card" translate="no"><a href="https://mastodon.social/@whitequark" class="u-url mention">@<span>whitequark</span></a></span> for it&#39;s amazing work on Amaranth. Testing your code SHOULD be this easy!</p>
<p><span class="h-card" translate="no"><a href="https://hachyderm.io/@emersion" class="u-url mention">@<span>emersion</span></a></span> it&#39;s specifically the &quot;we, the xorg team, moved on to wayland&quot; (which is what i took away from that interaction) that made me come to that conclusion</p>