[Libre-soc-dev] Confusing nmigen assert error

Luke Kenneth Casson Leighton lkcl at lkcl.net
Wed Sep 23 17:52:07 BST 2020


On Wed, Sep 23, 2020 at 5:48 PM Cole Poirier <colepoirier at gmail.com> wrote:
>
> Hi Luke,
>
> I'm working on icache.py and running into a TypeError in the icache_sim() test:
>
>   File "icache.py", line 1629, in icache_sim
>     assert i_in.valid
>   File "/home/colepoirier/src/nmigen/nmigen/hdl/ast.py", line 152, in __bool__
>     raise TypeError("Attempted to convert nMigen value to Python boolean")
> TypeError: Attempted to convert nMigen value to Python boolean
>
> I get the same error with the modifications:
> "assert i_in.valid == 1" and
> "assert i_in.valid == Const(1, 1)"
>
> Any ideas what I'm doing wrong?

you're trying to do python asserts.  l_in.valid is a nmigen AST object
of type "Signal".  "assert object of type Signal equal to 1" is 100%
guaranteed to fail.

l.



More information about the Libre-soc-dev mailing list