当前位置:网站首页>FPGA notes -- implementation of FPGA floating point operation
FPGA notes -- implementation of FPGA floating point operation
2022-06-26 00:51:00 【To, violet】
One 、IEEE-754 standard
IEEE-754 Standard numerical representations include : Floating point numbers , Special values ( zero , infinity , Non standard value ,nan), Single precision 、 Double precision 、 Floating point numbers in single precision extended format .
(1) Floating point format . stay IEEE-754 In the standard , All floating-point numbers are represented by binary templates :

among ,S The field represents the sign bit ,E The field represents the exponent ,M Fields represent mantissa ( A part or fraction of a logarithm ). For standard floating point numbers , The default always exists 1 An implied boot bit “1”. for example , Binary number 1.0011 Or decimal numbers 1.1875 use IEEE-754 When expressed in standard format, its M A value of the domain 0011, Do not save the implied pilot bit in the identification format “1”. For nonstandard floating point numbers , The boot bit can be “1” or “0”. For zero , Infinity and nan, M The field has no implied leading bits “1” Or there is no explicit boot bit .
(2) Single-precision floating-point . Single precision floating point numbers use 32 Bit binary number means , The highest of them ( Bit[31], MSB) Symbol bit , namely S Domain ; Bit[30:23] by E Domain , this 8 Bit data represents the index ; Lowest 23 position (Bit[22:0], LSB ) by M Domain , Used to represent the fractional part of a floating-point number .
(3) Double precision floating point . Double precision floating point numbers use 64 Bit binary number means , The highest of them ( Bit[63], MSB) Symbol bit , namely S Domain ; Bit[62:52] by E Domain , this 11 Bitwise index ; Lowest 52 position (Bit[51:0], LSB) by M Domain , Used to represent the fractional part of a floating-point number .
So it represents a floating point number y The values are as follows

Two 、 The addition and subtraction of floating-point numbers
The implementation of floating-point addition operation includes the following steps: symbol judgment 、: Antithetic order 、 Mantissa addition and subtraction operation 、 normalized 、 Rounding operation 、 Overflow judgment . The concrete implementation usually normalizes 、 Rounding operation 、 Overflow judgment is implemented as a step . The format of floating point numbers can obviously be divided into two parts , That is, the absolute value of symbols and data . If the symbols are the same, the symbols cannot be added to the absolute values ; If the symbols are different, the size of the two absolute values must be compared, and then the two absolute values are calculated by difference . When the symbol is different, the symbol that first judges and , Obviously, if the order of two floating-point numbers is different, the sign of the sum should be the same as the operand with large order ; If the order is different, continue to compare the opposite order operation. First, compare the order of the two floating-point numbers . Then we need two pairs of orders . The principle of order is small order to large order , The advantage of small order to large order is , When the small order is different from the large order , Just remove the lower part of the mantissa of the small order . The addition flow chart is shown in the figure below

3、 ... and 、 Multiplication of floating point numbers
The multiplication of floating-point numbers is relatively simple , You only need to XOR the sign bits of the two operands , Then sum the order code part 、 Product the mantissa . At the same time, it is necessary to check whether the result of operand operation has overflow problem . The multiplication process is shown in the following figure :

Four 、 Use Altera Of IP The kernel implements floating-point operations
The following figure for Altera Floating point addition operation provided IP Core setting interface .

IP The core is set to 64 Bit input and output 、 Delay 14 Clock cycle output results 、 Select speed optimization 、 Can make ‘ Add 、 reduce ’ Dynamic switching function . See the following table for module function pins
| Signal name | Signal direction | explain |
| dataa | I | The data input conforms to IEEE-754 standard |
| datab | I | The data input conforms to IEEE-754 standard |
| add_sub | I | Dynamic switching of addition and subtraction function , High level performs adding operation |
| clk | I | The system clock |
| result | O | Operation output |
| NaN | O | NaN Abnormal output |
| overflow | O | overflow Abnormal output , |
| underflow | O | underflow Abnormal output |
| zero | O | Zero output |
Next, instantiate the addition module , And then write a tb Functional simulation , The simulation results are shown in the figure below , among inNum1 and inNum2 Two addends ,outNum Is the number of operation results .

5、 ... and 、 summary
stay FPGA When doing operations, especially floating-point operations , comparison ARM and DSP Always seem unable to do what you want , but FPGA To realize floating-point operation with high speed 、 Low cost 、 Short development cycle and other advantages . And use IP Nuclear development FPGA Can greatly shorten the algorithm in FPGA Cycle implemented on .
This article is the author's study notes , The author is inexperienced , Limited ability , If there is any mistake, we hope to put it forward .
边栏推荐
- ASP.NET cache缓存的用法
- 从进程的角度来解释 输入URL后浏览器会发生什么?
- Spark log analysis
- react + router 框架下的路由跳转后缓存页面存初始参数
- Is camkiia the same as gcamp6f?
- Vscode shortcut
- Openresty chapter 01 introduction and installation configuration
- 1-10Vmware构建自定义的网络架构
- Methods of modifying elements in JS array
- . user. PHP website installation problems caused by INI files
猜你喜欢

Middle order clue binary tree

Law and self-regulation in the meta universe

DPVS fullnat mode management

【图像检测】基于高斯过程和Radon变换实现血管跟踪和直径估计附matlab代码

Qt优秀开源项目之九:qTox

ciscn_2019_en_2

Leetcode 513. Find the value in the lower left corner of the tree

【超能云终端创领先机】如何在48小时内交付一座方舱医院?

Apache foundation officially announced Apache inlong as a top-level project

C IO stream (II) extension class_ Packer
随机推荐
[TSP problem] solving traveling salesman problem based on Hopfield neural network with matlab code
1-11solutions to common problems of VMware virtual machine
鼠标拖拽围绕某个物体旋转展示
Unified gateway
【超能云终端创领先机】如何在48小时内交付一座方舱医院?
Web學習之TypeScript
What do SMT operators do? operating duty?
flink报错:No ExecutorFactory found to execute the application
每日一问:线程和进程的区别
What training brings happiness
Correct writing methods of case, number and punctuation in Chinese and English papers
What are the red lines of open source that should not be trodden on?
基于OpenVINOTM开发套件“无缝”部署PaddleNLP模型
Kylin
Data synchronization
Comprehensive introduction to Simulink solver
Atlas200dk brush machine
Mining pit record of modified field information in Dameng database
SVN
DPVS fullnat mode deployment