Re: [myhdl-list] intbv.wrap()
Brought to you by:
jandecaluwe
From: Tom D. <td...@di...> - 2011-04-19 02:32:20
|
On 04/18/2011 05:25 PM, Christopher Felton wrote: > 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 generally like keeping the low level details down in the class. I think it comes down to if we think it is a basic part of the intbv. To me it is since we are really modeling the behavior of the logic. Now if we were talking about something like saturation, then there would be a good case for a function call and not an attribute as it would be additional logic to implement as well. Although if we were talking about saturation I would also vote for an attribute. > 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? You could solve that with an attribute too. > But the attribute would solve the conversion implementation! I think it is fine either way, just like the discussion and hearing the different perspectives. |