Skip to content
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

[Question] Ranges in fixed point representation. #15

Open
cgyurgyik opened this issue Mar 1, 2021 · 1 comment
Open

[Question] Ranges in fixed point representation. #15

cgyurgyik opened this issue Mar 1, 2021 · 1 comment

Comments

@cgyurgyik
Copy link

Hey! Awesome library. Can you explain what you mean by the range of a in this section:

In svreal, fixed-point formats are generally determined automatically from the range of the signals they represent. In this case, the range of a is set to +/- 5.0, and the range of b is set to +/- 10.0.

I'm far from a fixed point expert, and am only aware of the Q format to establish bits for integer and fractional widths.

@sgherbst
Copy link
Owner

sgherbst commented Mar 1, 2021

Glad that you're finding it useful. svreal has three properties associated with each fixed-point signal:

  1. Width: total number of bits for signal. For example, if the width is "8", then signal, when interpreted as a twos-complement integer, goes from -128 (10000000) to +127 (01111111).
  2. Exponent: implicit scale factor multiplied by the signal's integer interpretation to produce its real number interpretation. For example, if the exponent is "-5", and the integer interpretation of the signal is "123", then the real number represented is 123*(2^(-5))=3.84375.
  3. Range: real-number range of the signal. For example, if it is "3", then the real-number interpretation can range from -3 to +3. The upper bound of the range is set by the width and exponent, but it is worth keeping track of the range separately to prevent ranges from growing faster than necessary in computations.

In general, the ranges of inputs to a computation must be specified by the user (or passed in from a higher level of the design hierarchy; see "Passing real-number signals"). So in this case, since "a" and "b" are inputs to the computation, the user has to provide their ranges ("5", meaning +/- 5, and "10", meaning +/-10)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants