Re: Conversion error: Type mismatch with earlier assignment

Guy Eschemann <[email protected]>
Newsgroups gmane.comp.python.myhdl
Message-ID <CAK4OkACMoafyuTwRbt9ZTNw+35L7Lt79iJSFpybTqHosKCAKVw@mail.gmail.com>
Hi Josy,

I believe this has something to do with how name assignment works in
Python. There's a section about this in the manual at
http://docs.myhdl.org/en/stable/manual/conversion.html#intbv-objects

My only criticism is that if you do it wrong (e.g. forget the "[:]"), you
get an error message that is of little help to debug the issue.

Regards,
Guy.


On Mon, Sep 7, 2015 at 9:36 PM, Josy Boelen <[email protected]> wrote:

> Hi Guy,
>
> I studied this a bit deeper and went looking for some 'variable'
> examples in the MyHDL doc and found this one:
> def bin2gray(B, G, width):
>
>     """ Gray encoder.
>
>     B -- input intbv signal, binary encoded
>     G -- output intbv signal, gray encoded
>     width -- bit width
>
>     """
>
>     @always_comb
>     def logic():
>         Bext = intbv(0)[width+1:]
>         Bext[:] = B
>         for i in range(width):
>             G.next[i] = Bext[i+1] ^ Bext[i]
>
>     return logic
>
> And to my surprise it uses the [:] ...
> So it may not be a bug, as it is actually _documented_ behaviour ...
> But I maintain that it is inconsistent because e.g.:  if I change
>         count_v = count_v + 1
> into:
>         count_v += 1
> the conversion will pass without errors.
>
> Regards,
>
> Josy
>
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> myhdl-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/myhdl-list
>

------------------------------------------------------------------------------

_______________________________________________
myhdl-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/myhdl-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.