Re: [myhdl-list] Conversion error: Type mismatch with earlier assignment
Brought to you by:
jandecaluwe
From: Guy E. <guy...@gm...> - 2015-09-08 07:13:17
|
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 <jos...@gm...> 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 > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list > |