-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cordic chapter: rounding requires corrections #21
Comments
I provide here a quick explanation (you are free to copy it if you wish). To avoid confusion I believe it is better to think that the output is an integer (the radix point is after the last digit), instead of a fixed-point number, so the difference is just a simple shift. First, there should be a distinction between directed rounding (i.e. towards or away from a reference value), and rounding to the nearest integer (or nearest representable number if we are dealing with fixed-point numbers). In directed rounding we have:
All of these methods introduce a bias (average error). For nearest integer rounding methods, the bias is a lot smaller than directed rounding. There are many variants, but all of them produce these example results: -1.3 → -1, -0.7 → -1, 1.6 → 2, 2.1 → 2. Some of them are:
Also, it would be interesting to explain the Quantization Modes in Vivado HLS. |
Hi, Thanks for the comment! It's not clear to me what exactly you're suggesting is incorrect? You're probably right that we should clarify that lrint() uses the currently set rounding mode, so we've assumed that the default rounding mode has not been changed. I see a few other things that could potentially be cleaned up here, but I think they are more clarity issues than anything else. One of the challenges in this section is to try to identify some correspondence with IEEE rounding modes (both directed rounding modes and round-to-nearest-even), while not suggesting that ap_fixed implements the IEEE standard. I think a few more examples might make it easier to see the patterns in how these different rounding modes work, but one of the key things I was trying to get across in this section is that rounding modes can be extended to work on fixed-point numbers. |
My apologies, I completely forgot to answer.
You are right, that's the default rounding mode for
Good point. What I think is misleading are the following parts:
This is presented as the opposite of And also:
Similar argument: this is a variant of Also, I believe that in
it should be more precise to say "average error" or "error bias" instead of just "error". |
I believe there is misleading or even factually incorrect info in "3.5.3 Overflow, Underflow, and Rounding". I think most of that is because in the examples only one bit is dropped and then half of the cases are ties.
In particular: the behaviour of
round()
andlrint()
(forlrint
we have to assumeFE_TONEAREST
mode is set, more info here) are actually rounding to the nearest integer and they only differ in the case of ties.All the variants are well explained in: https://en.wikipedia.org/wiki/Rounding#Rounding_to_integer
The text was updated successfully, but these errors were encountered: