In some FPGAs, floating-point numbers cannot be manipulated directly, and can only be numerically calculated using fixed-point numbers. For FPGAs, the book that participates in mathematics is the 16-bit integer number, but what if there are decimals in mathematical operations? You know, the FPGA is powerless for decimals, a solution is to use the calibration. The number of the calibration is to calculate the floating point number is enlarged very many times, and then take the whole, and then use this number to calculate, the result of the operation to reduce the corresponding multiples can be. Be sure not to forget the decimal point in the design. In the FPGA is not reflected in the decimal point, the location of the decimal point only the program apes know. Q Indicates the position of the decimal point, and Q15 indicates the decimal point in the 15th digit.
floating point (x) converted to fixed-point number (XQ): xq= (int) x*2^q
Fixed point (XQ) conversion floating point number (x): x= (float) xq*2^ (-Q)
For example, 16 binary number 2000H, expressed in Q0 is 8192; if Q15 is represented, it is 0.25.
The following is a description of Q-value determination in Q-format operations:
(1) Fixed-point addition and subtraction: need to convert to the same Q format talent plus minus
(2) fixed-point multiplication: data multiplication in different Q formats, equivalent to the Q value addition
(3) Fixed-point division: Divide the data in different Q formats, which is equivalent to the Q value subtraction
(4) Fixed-point left shift: equivalent to Q Value added
(5) Fixed-point right shift: equivalent to the Q value reduction
For example, Q15 represents the 4000H (floating point 0.5) multiplied by the Q15 represented by the 4000h,4000hx4000h=1000 0000H, after the end of the Q to 15+15=30, that is, the result is 0.01B, that is, floating point number 0.25.
Implementation method of floating-point arithmetic in FPGA--calibration