Re: [myhdl-list] intbv.signed()
Brought to you by:
jandecaluwe
From: Jan D. <ja...@ja...> - 2008-07-25 14:57:50
|
Günter Dannoritzer wrote: > Hi, > > I was gonna try out implementing the signed() function to intbv. > > My first question is whether it should be a function or a property? What > would be the decision about what to take. For example with the min and > max values they are implemented as property. As there are no parameters > needed, could the signed by also implemented as property? To me, a property contains some static info about an existing object (even when it is implemented as a method behind the curtains), while a method returns some new object. So, it should be a method. The brackets indicate that "something is being done". > My next question is what signed() will return. Just the value as integer > or will it be an intbv instance with the range set based on the _nrbits, > but as +/- range? I would go for an integer to start with. That is what MyHDL does now for many operators. It is more efficient than constructing intbv's (although I dont' know how much more) and seems sufficient in many cases. Note that when we write: a[:] = <some expression> the range checking problem is transfered to the left-hand side. Some other (more bit-oriented) operators return an unconstrained intbv and we could do this also if there's a good reason. But I would avoid trying to infer ranges. Jan -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Kaboutermansstraat 97, B-3000 Leuven, Belgium From Python to silicon: http://myhdl.jandecaluwe.com |