[Libre-soc-dev] Confusing nmigen assert error

Cole Poirier colepoirier at gmail.com
Wed Sep 23 18:55:33 BST 2020


On Wednesday, September 23, 2020, Luke Kenneth Casson Leighton <
lkcl at lkcl.net> wrote:

> 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.
>

Ok, that doesn’t give me any idea as to what I should be doing that would
succeed. Any tips)

Cole


More information about the Libre-soc-dev mailing list