Re: [myhdl-list] fixed-point thoughts : part two
Brought to you by:
jandecaluwe
From: Christopher F. <chr...@gm...> - 2013-09-13 10:25:24
|
<snip> >>> The same turned, what about: >>> >>> fixedbv(1.25,min=-8,max=8,res=1/16.) + 1 >>> To be consistent with the suggestion, this would result in 1.3125. Not >>> something I would expect. >> >> Currently, it would throw an error. > > Ah. It seems to me like this could be interesting when adding a > constant; but it needs careful thought on what the effect on the min/max > values of a returned fixedbv is (assuming a fixedbv is returned). > Throwing an error would not block adding such a feature later on. > In my head, a constant has an implied format, and the resolution is /res = 1/, the constant format would be (assuming only integer constants for now): cc = fixbv(1, min=1, max=1+1, res=1) When doing the operation above siii.iiii + si ----------- The constant and the /fixbv/ are not aligned, so it needs to throw an error. To add a constant to an existing /fixbv/ the /resize/ function would need to be used or added to a /fixbv/ with a /res = 1/ >>> x = fixbv(1.25, min=-8, max=8, res=1/16) >>> x = x + resize(1,x) # <-- resize to "x" format For a complicated expression this gets a little unwieldy. > Thanks for looking into this, > Benjamin Thanks for keeping me honest :) |