Implementation method of floating-point arithmetic in FPGA--calibration

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.