Re: [myhdl-list] intbv.wrap()
Brought to you by:
jandecaluwe
From: Christopher F. <chr...@gm...> - 2011-04-18 22:25:57
|
On 4/18/2011 12:08 PM, Tom Dillon wrote: > Why not make it part of the intbv object? It seems like when you create > the intbv you should know if you want bounds checking or wrapping. > > So you would do this: > > x = intbv(0,min=-8,max=7,wrap=True) > x[:] = x + 5 > > The default would be wrap=False. > > > In the past the explicit stating of a wrap was preferred. In the case of an unsigned, x[:] = x % 8 was preferred over building in a attribute. Someone reading the code would not need to know if wrap attribute was set or not. I can't think of an example but if for some reason, you wanted to mix bound checking and wrapping. Maybe mixing would be a bad thing to allow? But the attribute would solve the conversion implementation! Chris Felton |