Implementation of floating-point operations in FPGA-Calibration

Source: Internet
Author: User

In some FPGAs, floating point numbers cannot be operated directly, but only fixed points can be used for numerical operations. For FPGA, the book involved in mathematical operations is a 16-bit integer number. What if there is a decimal number in the mathematical operation? You must know that FPGA is powerless to decimal places. One solution is to adopt calibration. The number calibration is to increase the number of floating-point numbers to many times, then take an integer, and use this number for calculation. Then, the result of the calculation can be reduced to a specific multiple. Do not forget the decimal point during design. In FPGA, decimal points are not displayed. Only programmers know the decimal point. Q indicates the decimal place. q15 indicates that the decimal point is 15th digits.

Convert a floating point number (X) to a fixed point number (XQ): XQ = (INT) x * 2 ^ Q

X: x = (float) XQ * 2 ^ (-q)

For example, if the hexadecimal number is 2000 h, q0 is 8192. If q15 is used, it is 0.25.

The following describes how to determine the Q value in Q format calculation:

(1) fixed-point addition and subtraction: The addition and subtraction must be converted to the same Q format.

(2) Fixed-Point multiplication: data in different Q formats is multiplied, which is equivalent to the sum of Q values.

(3) fixed-point Division: Division of data in different Q formats, equivalent to subtraction of Q values

(4) shift left: equivalent to increasing the Q value

(5) shift right of a fixed point: equivalent to reducing the Q value

For example, q15 represents 4000 H (floating point number 0.5) multiplied by q15 represents 4000 H, 4000 H × 4000 H = 1000 0000 h, after which the Q value becomes 15 + 15 = 30, the result is 0.01b, indicating that the floating point number is 0.25.

Implementation of floating-point operations in FPGA-Calibration

Related Article

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.