Re: [myhdl-list] Wrap-around support in MyHDL
Brought to you by:
jandecaluwe
From: Christopher F. <chr...@gm...> - 2011-05-30 16:03:48
|
On 5/29/2011 4:55 PM, Jan Decaluwe wrote: > On 05/20/2011 05:25 PM, Jan Decaluwe wrote: >> As you like the proposal after putting the feature >> back on the map, and I hear no objections, I'd like >> to make some progress. >> >> This is definitely a 0.8 feature, so I will open >> a 0.8-dev branch for development. I will also turn >> the proposal into a MEP. > > http://myhdl.org/doku.php/meps:mep-106 > I didn't notice this in the previous draft but there is an error in the code examples; handling wrap using modulus (Wrap-around type proposals). """ if count == N: count.next = 0 some_decode_action() else: count.next = count + 1 ... if count == N: some_decode action() count.next = (count + 1) % N """ The code snippets should be count == 0 or count = N-1, count will never actually equal N in the "%" case. The first case will not act like a mod. To double check my sanity, here is a small capture from a python session: In [176]: N = 2**3 In [179]: count = intbv(0, min=0, max=N) In [180]: for ii in range(2*N): .....: if count == N: .....: print "Do some action" .....: count[:] = (count + 1) % N .....: print count 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 In [181]: N Out[181]: 8 Chris |