[go: up one dir, main page]

CN111538473A - A Posit floating point processor - Google Patents

A Posit floating point processor Download PDF

Info

Publication number
CN111538473A
CN111538473A CN202010348464.7A CN202010348464A CN111538473A CN 111538473 A CN111538473 A CN 111538473A CN 202010348464 A CN202010348464 A CN 202010348464A CN 111538473 A CN111538473 A CN 111538473A
Authority
CN
China
Prior art keywords
field
posit
point number
bit
floating point
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010348464.7A
Other languages
Chinese (zh)
Other versions
CN111538473B (en
Inventor
梁峰
赵科芃
吴斌
张国和
孙齐伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xian Jiaotong University
Original Assignee
Xian Jiaotong University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xian Jiaotong University filed Critical Xian Jiaotong University
Priority to CN202010348464.7A priority Critical patent/CN111538473B/en
Publication of CN111538473A publication Critical patent/CN111538473A/en
Application granted granted Critical
Publication of CN111538473B publication Critical patent/CN111538473B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
    • G06F7/48Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
    • G06F7/483Computations with numbers represented by a non-linear combination of denominational numbers, e.g. rational numbers, logarithmic number system or floating-point numbers
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Mathematical Optimization (AREA)
  • Computing Systems (AREA)
  • Mathematical Analysis (AREA)
  • Computational Mathematics (AREA)
  • Pure & Applied Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Nonlinear Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Complex Calculations (AREA)
  • Advance Control (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

本申请提供了一种Posit浮点数处理器,涉及计算机技术领域。为用户提供了满足Posit标准的浮点数处理器。所述Posit浮点数处理器包括:解码电路、运算电路以及编码电路;所述解码电路用于根据CPU的计算指令,获取参与运算的多个目标Posit浮点数,并将所述多个目标Posit浮点数转换为各自对应的补码形式的中间数据;所述中间数据包括多个字段:符号字段、真实指数字段、第一尾数字段以及保护位字段;所述运算电路,用于根据所述计算指令,对接收的所述解码电路输出的多个中间数据进行运算,得到以补码形式的中间数据表示的运算结果;所述编码电路,用于根据所述计算指令中的指定格式,将所述运算结果转换为所述指定格式的Posit浮点数。

Figure 202010348464

The present application provides a Posit floating point number processor, which relates to the field of computer technology. Provide users with a floating-point processor that meets the Posit standard. The Posit floating-point number processor includes: a decoding circuit, an arithmetic circuit and an encoding circuit; the decoding circuit is used to obtain a plurality of target Posit floating-point numbers participating in the operation according to a calculation instruction of the CPU, and float the plurality of target Posit numbers. Points are converted into corresponding intermediate data in complement form; the intermediate data includes a plurality of fields: a sign field, a real exponent field, a first mantissa field and a protection bit field; the operation circuit is used for calculating the instruction according to the calculation instruction , perform operations on the received intermediate data output by the decoding circuit to obtain an operation result represented by the intermediate data in complement form; the encoding circuit is used for converting the The operation result is converted into a Position floating-point number in the specified format.

Figure 202010348464

Description

一种Posit浮点数处理器A Posit floating point processor

技术领域technical field

本申请涉及计算机技术领域,特别是涉及一种Posit浮点数处理器。The present application relates to the field of computer technology, and in particular to a Posit floating point number processor.

背景技术Background technique

浮点数是科学计算领域和高性能计算领域常用的数据表示方法,特别地,在对计算结果的精度要求较高的场合,大量运用浮点数进行数据处理,例如自动驾驶、航空航天、力学计算领域。Floating-point numbers are a common data representation method in the field of scientific computing and high-performance computing. In particular, in the occasions where the precision of calculation results is required, a large number of floating-point numbers are used for data processing, such as autonomous driving, aerospace, and mechanical computing. .

Posit标准的浮点数相较于IEEE 754标准的浮点数,灵活性更高,并且Posit浮点数在实数上的采样分布与sigmoid函数相关,而sigmoid函数是机器学习里常用的一种激活函数,因此将Posit浮点数用于机器学习,计算机进行数据处理的效率更高。Compared with IEEE 754 standard floating-point numbers, the Posit standard floating-point numbers are more flexible, and the sampling distribution of Posit floating-point numbers on real numbers is related to the sigmoid function, which is a commonly used activation function in machine learning, so Using Posit floating point numbers for machine learning, the computer is more efficient in data processing.

但目前商用计算机的浮点数处理器,大都是基于IEEE 754标准的浮点数处理器,并没有完全满足Posit标准的浮点数处理器。However, at present, most of the floating-point number processors of commercial computers are based on the IEEE 754 standard, and there are no floating-point number processors that fully meet the Posit standard.

发明内容SUMMARY OF THE INVENTION

为解决上述问题,本申请实施例提供一种Posit浮点数处理器,为用户提供了满足Posit标准的浮点数处理器。To solve the above problem, an embodiment of the present application provides a Posit floating-point number processor, which provides users with a floating-point number processor that satisfies the Posit standard.

本申请实施例提供的Posit浮点数处理器包括:解码电路、运算电路以及编码电路;The Posit floating-point number processor provided by the embodiments of the present application includes: a decoding circuit, an arithmetic circuit, and an encoding circuit;

所述解码电路用于根据CPU的计算指令,获取参与运算的多个目标Posit浮点数,并将所述多个目标Posit浮点数转换为各自对应的补码形式的中间数据;所述中间数据包括多个字段:符号字段、真实指数字段、第一尾数字段以及保护位字段;The decoding circuit is used to obtain a plurality of target Posit floating-point numbers participating in the operation according to a calculation instruction of the CPU, and convert the plurality of target Posit floating-point numbers into respective corresponding intermediate data in complement form; the intermediate data includes Multiple fields: sign field, real exponent field, first mantissa field and protection bit field;

所述运算电路,用于根据所述计算指令,对接收的所述解码电路输出的多个中间数据进行运算,得到以补码形式的中间数据表示的运算结果;The operation circuit is configured to perform operation on the received multiple intermediate data output by the decoding circuit according to the calculation instruction, to obtain an operation result represented by the intermediate data in complement form;

所述编码电路,用于根据所述计算指令中的指定格式,将所述运算结果转换为所述指定格式的Posit浮点数。The encoding circuit is configured to convert the operation result into a Posit floating point number of the specified format according to the specified format in the calculation instruction.

可选地,所述解码电路包括:第一异或器件、第二异或器件、反向前导零检测电路器件、第一移位电路器件、第一拼接电路器件、第一提取电路器件以及以下模块:Optionally, the decoding circuit includes: a first XOR device, a second XOR device, a reverse leading zero detection circuit device, a first shift circuit device, a first splicing circuit device, a first extraction circuit device, and the following Module:

regime真实符号确定模块,用于通过所述第一异或器件对目标Posit浮点数的最高位与所述目标Posit浮点数的次高位进行异或操作,得到所述目标Posit浮点数的regime字段的真实符号;The real symbol determination module of the regime is used to perform an XOR operation on the highest bit of the target Posit floating-point number and the second highest bit of the target Posit floating-point number by the first XOR device, to obtain the regime field of the target Posit floating-point number. real symbols;

regime字段统一模块,用于第一次除去所述目标Posit浮点数的最高位和次高位,第二次除去所述目标Posit浮点数的最高位和最低位,再通过所述第二异或器件对所述第一次除去的结果和所述第二次除去的结果进行异或操作,得到regime统一字段;The unified module of the regime field is used to remove the highest bit and the second highest bit of the target Posit floating point number for the first time, remove the highest bit and the lowest bit of the target Posit floating point number for the second time, and then pass the second XOR device The XOR operation is performed on the result of the first removal and the result of the second removal to obtain the uniform field of the regime;

regime值计算模块,用于通过所述反向前导零检测电路器件对所述regime统一字段进行检测,并根据所述反向前导零检测电路器件的输出得到所述regime字段的取值字段;The regime value calculation module is used to detect the unified field of the regime by the reverse leading zero detection circuit device, and obtain the value field of the regime field according to the output of the reverse leading zero detection circuit device;

提取模块,用于通过所述第一移位电路器件,将所述目标Posit浮点数的最高三位移出,并将移出最高三位后的所述目标Posit浮点数的剩余字段左移指定位数;所述指定位数是根据所述反向前导零检测电路器件的输出得到的;an extraction module, configured to shift out the highest three bits of the target Posit floating-point number through the first shifting circuit device, and shift the remaining fields of the target Posit floating-point number after the highest three bits are shifted left by a specified number of bits ; The specified number of digits is obtained according to the output of the reverse leading zero detection circuit device;

所述提取模块,还用于根据所述目标Posit浮点数的指数字段的位宽,在左移后的目标Posit浮点数中,提取得到所述目标Posit浮点数的指数字段和第二尾数字段;The extraction module is further configured to extract the exponent field and the second mantissa field of the target Posit floating-point number from the left-shifted target Posit floating-point number according to the bit width of the exponent field of the target Posit floating-point number;

真实指数确定模块,用于在所述目标Posit浮点数是负数时,对所述指数字段进行取反,再通过所述第一拼接电路器件,将所述指数字段或取反后的所述指数字段与所述regime字段的取值字段进行拼接,得到并输出所述目标Posit浮点数对应的中间数据中的真实指数字段;The true exponent determination module is used to invert the exponent field when the target Posit floating point number is a negative number, and then use the first splicing circuit device to convert the exponent field or the inverted exponent The field is spliced with the value field of the regime field to obtain and output the real index field in the intermediate data corresponding to the target Posit floating point number;

第一尾数字段确定模块,用于按照所述第一尾数字段的最大位宽,对所述第二尾数字段的低位补零得到所述第一尾数字段,输出所述第一尾数字段;所述第一尾数字段的最大位宽是所述目标Posit浮点数的总位宽减去所述目标Posit浮点数的符号位的位宽、所述指数字段的位宽,和所述regime字段的最小位宽得到的;a first mantissa field determining module, configured to fill the lower bits of the second mantissa field with zeros according to the maximum bit width of the first mantissa field to obtain the first mantissa field, and output the first mantissa field; the The maximum bit width of the first mantissa field is the total bit width of the target Posit floating point number minus the bit width of the sign bit of the target Posit floating point number, the bit width of the exponent field, and the minimum bit of the regime field. wide available;

保护位输出模块,用于将每一位的值都为0的字段作为所述保护位字段,并输出所述保护位字段;所述保护位字段的位宽为3。A protection bit output module, configured to use a field whose value of each bit is 0 as the protection bit field, and output the protection bit field; the bit width of the protection bit field is 3.

可选地,所述中间数据还包括无穷数字段和零值字段;所述解码电路还包括:无穷数确定模块和零值判断模块;Optionally, the intermediate data further includes an infinite number field and a zero value field; the decoding circuit further includes: an infinite number determination module and a zero value judgment module;

所述无穷数确定模块,用于在所述目标Posit浮点数是无穷数时,将所述目标Posit浮点数对应的中间数据的无穷数字段置为真;The infinite number determination module is used to set the infinite number field of the intermediate data corresponding to the target Posit floating point number to true when the target Posit floating point number is an infinite number;

所述零值判断模块,用于在所述目标Posit浮点数是零时,将所述目标Posit浮点数对应的中间数据的零值字段置为真。The zero value judgment module is configured to set the zero value field of the intermediate data corresponding to the target Posit floating point number to true when the target Posit floating point number is zero.

可选地,所述中间数据还包括符号字段;所述解码电路还包括:符号判断模块;Optionally, the intermediate data further includes a symbol field; the decoding circuit further includes: a symbol judgment module;

所述符号判断模块,用于根据所述目标Posit浮点数的最高位,确定该目标Posit浮点数的符号,再以该目标Posit浮点数的符号作为该目标Posit浮点数对应的中间数据的符号,并输出该目标Posit浮点数对应的中间数据的符号字段为所述中间数据的符号。The symbol judgment module is used to determine the symbol of the target Posit floating point number according to the highest bit of the target Posit floating point number, and then use the symbol of the target Posit floating point number as the symbol of the intermediate data corresponding to the target Posit floating point number, And output the symbol field of the intermediate data corresponding to the target Posit floating point number as the symbol of the intermediate data.

可选地,所述编码电路包括:第二提取电路器件、第二移位电路器件、第二拼接电路器件以及以下模块:Optionally, the encoding circuit includes: a second extraction circuit device, a second shift circuit device, a second splicing circuit device, and the following modules:

指数字段编码模块,用于以所述第二提取电路器件,在所述运算结果的真实指数字段中,按照最低位到最高位的顺序,提取得到位宽与指数编码字段的位宽相同的字段,根据所述位宽与指数编码字段的位宽相同的字段得到所述指数编码字段,并以提取所述位宽与指数编码字段的位宽相同的字段后的所述真实指数字段,作为所述regime编码字段对应的数值;The exponent field encoding module is used for extracting a field whose bit width is the same as that of the exponent encoding field in the real exponent field of the operation result by the second extraction circuit device in the order of the lowest bit to the highest bit , obtain the exponent encoding field according to the field whose bit width is the same as that of the exponent encoding field, and extract the real exponent field after the field whose bit width is the same as that of the exponent encoding field is used as the The value corresponding to the above-mentioned regular code field;

regime格式确定模块,根据所述运算结果的符号字段和所述regime编码字段的符号,确定所述regime编码字段的填充格式;Regime format determination module, according to the symbol field of described operation result and the symbol of described regime coding field, determine the filling format of described regime coding field;

regime字段编码模块,用于以所述第二拼接电路器件,将所述填充格式、所述指数编码字段、所述运算结果的第一尾数字段以及所述运算结果的保护位字段依次拼接,得到拼接字段,并以所述第二移位电路器件,依据所述regime编码字段对应的数值,将所述拼接字段算术右移,得到所述regime编码字段;The regime field encoding module is used for sequentially splicing the padding format, the exponent encoding field, the first mantissa field of the operation result, and the protection bit field of the operation result with the second splicing circuit device to obtain The splicing field, and with the second shift circuit device, according to the numerical value corresponding to the regular coding field, the splicing field is arithmetically shifted to the right to obtain the regular coding field;

浮点数结果确定模块,用于利用所述保护位字段对向右移位后的所述拼接字段进行舍入操作,并对进行舍入操作后的所述拼接字段的最高位添加所述运算结果的符号字段,得到所述指定格式的Posit浮点数。A floating-point number result determination module, configured to use the protection bit field to perform a rounding operation on the splicing field shifted to the right, and add the operation result to the highest bit of the splicing field after the rounding operation of the sign field, to get the Position floating point number in the specified format.

可选地,所述编码电路还包括输出模块:Optionally, the encoding circuit further includes an output module:

所述输出模块用于在所述中间数据的无穷数字段真时,直接输出所述指定格式的Posit浮点数为表示无穷数的无穷数编码字段;The output module is used to directly output the Posit floating point number of the specified format as an infinite number encoding field representing an infinite number when the infinite number field of the intermediate data is true;

所述输出模块还用于在所述中间数据的零值字段为真时,直接输出所述指定格式的Posit浮点数为表示零值的无穷数编码字段。The output module is further configured to directly output the Posit floating point number in the specified format as an infinite number encoded field representing a zero value when the zero value field of the intermediate data is true.

可选地,所述反向前导零检测电路器件包括或器件,第一取反器件,第二取反器件;Optionally, the reverse leading zero detection circuit device includes an OR device, a first inversion device, and a second inversion device;

所述反向前导零检测电路器件,用于以所述第一取反器件分别对多个位宽为2的输入字段的第0位进行取反运算,再以所述或器件,分别对多个取反结果和所述多个位宽为2的输入字段的第1位进行或运算,得到多个输出字段的第0位;所述位宽为2的输入字段是所述regime统一字段通过二分法处理后得到的;The reverse leading zero detection circuit device is used to use the first inversion device to respectively invert the 0th bit of a plurality of input fields with a bit width of 2, and then use the OR device to respectively invert multiple bits. The inversion results are ORed with the first bits of the input fields with a bit width of 2 to obtain the 0th bit of the output fields; the input fields with a bit width of 2 are the unified obtained after dichotomous processing;

所述反向前导零检测电路器件,还用于以所述或器件分别对所述多个位宽为2的输入字段的第0位和所述多个位宽为2的输入字段的第1位进行或运算,得到所述多个输出字段的第1位;The reverse leading zero detection circuit device is further configured to use the OR device to detect the 0th bit of the plurality of input fields with a bit width of 2 and the first bit of the plurality of input fields with a bit width of 2 respectively. performing an OR operation on the bits to obtain the first bit of the plurality of output fields;

所述反向前导零检测电路器件,还用将所述多个输出字段拼接,得到所述regime统一字段的取值的反码。The reverse leading zero detection circuit device is also used for splicing the multiple output fields to obtain the inverse code of the value of the regular uniform field.

可选地,所述regime值计算模块包括:Optionally, the regime value calculation module includes:

regime取值计算子模块,用于在所述regime字段的真实符号为正时,对所述反向前导零检测电路器件输出的反码取反,再对取反后的所述反向前导零检测电路器件输出的反码的最高位添加所述regime字段的真实符号,得到所述regime字段的取值字段;The regime value calculation sub-module is used to invert the inverse code output by the reverse leading zero detection circuit device when the real symbol of the regime field is positive, and then invert the reversed leading zero The highest bit of the inverse code output by the detection circuit device adds the real symbol of the regime field to obtain the value field of the regime field;

regime取值计算子模块,还用于在所述regime字段的真实符号为负时,对所述反向前导零检测电路器件输出的反码的最高位添加所述regime字段的真实符号,得到所述regime字段的取值字段。The regime value calculation submodule is also used to add the real symbol of the regime field to the highest bit of the complement code output by the reverse leading zero detection circuit device when the real symbol of the regime field is negative, to obtain the Describe the value field of the regime field.

可选地,所述浮点数结果确定模块包括:Optionally, the floating-point number result determination module includes:

保护位子模块,用于在向右移位后的所述拼接字段的每一位都为0时,在向右移位后的所述拼接字段的最低位加1,在向右移位后的所述拼接字段的所有值都为1时,保持向右移位后的所述拼接字段不变;The protection bit submodule is used to add 1 to the lowest bit of the splicing field after shifting to the right when each bit of the splicing field after shifting to the right is 0, and When all the values of the splicing field are 1, keep the splicing field after shifting to the right unchanged;

所述保护位子模块,还用于在向右移位后的所述拼接字段中的任意两位的取值不相同,并且所述保护位的值大于4时,在向右移位后的所述拼接字段的最低位加1,或在向右移位后的所述拼接字段中的任意两位不相同,所述保护位的值等于4时,且向右移位后的所述拼接字段的最低位是1时,在向右移位后的所述拼接字段的最低位加1。The protection bit submodule is further configured to, when the values of any two bits in the splicing field shifted to the right are not the same, and the value of the protection bit is greater than 4, when the value of the protection bit shifted to the right is greater than 4. The lowest bit of the splicing field is added by 1, or any two bits in the splicing field after shifting to the right are not the same, when the value of the protection bit is equal to 4, and the splicing field after shifting to the right When the lowest bit of is 1, add 1 to the lowest bit of the spliced field after shifting to the right.

可选地,所述指数字段编码模块,还用于在所述中间数据的符号字段表示负数时,对所述位宽与指数编码字段的位宽相同的字段取反,得到所述指数编码字段;Optionally, the exponent field encoding module is further configured to invert a field whose bit width is the same as that of the exponent encoding field when the symbol field of the intermediate data represents a negative number, to obtain the exponent encoding field. ;

在所述中间数据的符号字段表示正数时,将所述位宽与指数编码字段的位宽相同的字段作为所述指数编码字段。When the sign field of the intermediate data represents a positive number, a field with the same bit width as that of the exponent encoding field is used as the exponent encoding field.

本申请实施例提出的Posit浮点数处理器,利用解码电路,将根据计算指令得到的Posit浮点数转换为补码形式的中间数据,中间数据包含了表示特殊Posit浮点数的无穷数字段和零值字段,以使运算电路和编码电路在计算参数或计算结果是特殊Posit浮点数时,可以直接输出表示特殊Posit浮点数的无穷数编码字段或零值编码字段,提高了Posit浮点数处理器的输出效率。The Posit floating-point number processor proposed by the embodiment of the present application uses a decoding circuit to convert the Posit floating-point number obtained according to the calculation instruction into intermediate data in complement form, where the intermediate data includes an infinite number field and a zero value representing a special Posit floating-point number field, so that when the calculation parameter or the calculation result is a special Posit floating point number, the arithmetic circuit and the encoding circuit can directly output the infinite number encoding field or zero value encoding field representing the special Posit floating point number, which improves the output of the Posit floating point number processor efficiency.

运算电路可以直接使用中间数据中的真实指数字段、第一尾数字段进行运算,并且对Posit浮点数的组成字段进行提取和拼接后,就可得到真实指数字段和第一尾数字段,真实指数字段和第一尾数字段为补码形式的定点数,多个中间数据根据计算指令进行运算后,得到的中间数据表示的运算结果,仍然是补码形式的定点数,编码电路只需按照CPU处理器指定的格式,将补码形式的定点数转换为Posit浮点数的编码格式,就可以完成Posit浮点数的编码。上述过程不需要多次的原码到补码的相互转化的过程,简化了Posit浮点数的处理操作。The arithmetic circuit can directly use the real exponent field and the first mantissa field in the intermediate data for operation, and after extracting and splicing the constituent fields of the Posit floating point number, the real exponent field and the first mantissa field, the real exponent field and the The first mantissa field is a fixed-point number in complement form. After multiple intermediate data are operated according to the calculation instructions, the operation result represented by the intermediate data is still a fixed-point number in complement form. The encoding circuit only needs to be specified by the CPU processor. The encoding format of the Posit floating-point number can be completed by converting the fixed-point number in the complement form to the encoding format of the Posit floating-point number. The above process does not require multiple processes of mutual conversion from original code to complement code, which simplifies the processing operation of the Posit floating point number.

中间数据中的符号字段可以直接用于运算电路中,对得到运算结果的符号,还可以用于编码电路中,得到regime编码字段,并直接作为最终表示运算结果的Posit浮点数的最高位,不用再考虑补码时,正负Posit浮点数的编码形式的差异,简化了Posit浮点数的处理操作。The symbol field in the intermediate data can be directly used in the operation circuit, and the symbol of the operation result can also be used in the encoding circuit to obtain the regular encoding field, which is directly used as the highest bit of the Posit floating-point number that finally represents the operation result. When considering complement, the difference in the encoding form of positive and negative Posit floating-point numbers simplifies the processing of Posit floating-point numbers.

中间数据中的保护位字段,用于运算电路中,对运算结果进行舍入操作,还可以用于编码电路中,对编码过程进行舍入操作,使Posit浮点数处理器的工作符合Posit浮点数的规范。The protection bit field in the intermediate data is used in the operation circuit to round the operation result, and it can also be used in the encoding circuit to round the encoding process, so that the work of the Posit floating point number processor conforms to the Posit floating point number. specification.

附图说明Description of drawings

为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例的描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions of the embodiments of the present application more clearly, the following briefly introduces the drawings that are used in the description of the embodiments of the present application. Obviously, the drawings in the following description are only some embodiments of the present application. , for those of ordinary skill in the art, other drawings can also be obtained from these drawings without creative labor.

图1是本申请实施例解码电路的结构示意图;1 is a schematic structural diagram of a decoding circuit according to an embodiment of the present application;

图2是本申请实施例提出的反向前导零检测电路器件的结构示意图;2 is a schematic structural diagram of a reverse leading zero detection circuit device proposed in an embodiment of the present application;

图3是本申请实施例提出的Posit浮点数处理器的结构示意图;3 is a schematic structural diagram of a Posit floating-point number processor proposed by an embodiment of the present application;

图4是本申请实施例提出的编码电路的结构示意图。FIG. 4 is a schematic structural diagram of an encoding circuit proposed in an embodiment of the present application.

具体实施方式Detailed ways

下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请的一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.

Posit浮点数是由新加坡国立大学的教授John L.Gustafson提出的一种新型浮点数标准(也叫Unum浮点标准,Posit是第三版Unum标准),该标准定义了与IEEE 754不同的数据格式和算术规则。Posit与IEEE 754相比,具有数据格式灵活、动态范围大、异常格式少、精度高等优势。具体不限于以下列举的优势:Posit floating point number is a new floating point number standard (also called Unum floating point standard, Posit is the third edition Unum standard) proposed by John L. Gustafson, a professor at the National University of Singapore, which defines a different data format from IEEE 754 and arithmetic rules. Compared with IEEE 754, Posit has the advantages of flexible data format, large dynamic range, less abnormal format and high precision. It is not limited to the advantages listed below:

Posit浮点数在实数上的采样分布与sigmoid函数相关,而sigmoid函数是当前流行的机器学习里常用的一种激活函数。经过实践得到,Posit浮点数在拟合sigmoid函数时非常方便,因此将Posit浮点数应用在机器学习领域,可以简化相关的硬件设计。The sampling distribution of Posit floating-point numbers on real numbers is related to the sigmoid function, which is an activation function commonly used in popular machine learning. After practice, Posit floating-point numbers are very convenient when fitting sigmoid functions. Therefore, applying Posit floating-point numbers in the field of machine learning can simplify the related hardware design.

相比于IEEE 754浮点数在约定浮点数的总位宽时,需要满足IEEE 754-2008中规定的位宽格式,即16bit的半精度、32bit的单精度、64bit的双精度和128bit四精度四种位宽。Posit浮点数在满足应用的需求的情况下,可以选择任意格式的位宽,既可以选择32bit,也可以选择31bit、33bit、30bit等等,体现了Posit浮点数的灵活性。相比于IEEE754浮点数为了利用更多的编码空间,规定了隐藏位为0的非常规数,而Posit浮点数的隐藏位永远是1,减小了硬件的复杂性。Compared with IEEE 754 floating-point numbers, when agreeing on the total bit width of floating-point numbers, it needs to meet the bit width format specified in IEEE 754-2008, that is, 16-bit half-precision, 32-bit single-precision, 64-bit double-precision and 128-bit quad-precision four. Seed width. Posit floating-point numbers can choose the bit width of any format if they meet the needs of the application, either 32bit, 31bit, 33bit, 30bit, etc., which reflects the flexibility of Posit floating-point numbers. Compared with IEEE754 floating-point numbers, in order to utilize more coding space, an unconventional number whose hidden bit is 0 is specified, while the hidden bit of Posit floating-point number is always 1, which reduces the complexity of the hardware.

现有技术下,对Posit浮点数的处理仍处于理论研究阶段,没有能够投入商业应用的Posit处理器。并且,目前对Posit浮点数的处理方法的研究方向是,先利用解码电路将Posit浮点数转换为原码,输入运算电路,运算电路为方便运算,将原码转换为补码,得到补码的运算结果后,再转换为原码的运算结果,输入编码电路,编码边路最后将原码的运算结果转换为Posit浮点数。整个处理过程需要反复地进行原码到补码,以及补码到原码的转换,逻辑复杂,导致大量额外的操作,造成整体的Posit浮点数处理电路面积大。In the prior art, the processing of Posit floating point numbers is still in the theoretical research stage, and there is no Posit processor that can be put into commercial applications. Moreover, the current research direction of the processing method of Posit floating-point numbers is to first use the decoding circuit to convert the Posit floating-point numbers into the original code, and then input the operation circuit. After the operation result, it is converted into the operation result of the original code, input to the encoding circuit, and the encoding side finally converts the operation result of the original code into a Posit floating point number. The entire processing process requires repeated conversion from original code to complement code and complement code to original code. The logic is complex, resulting in a large number of additional operations, resulting in a large overall Posit floating-point number processing circuit area.

鉴于上述问题,本申请实施例提出一种Posit浮点数处理器,用于将Posit浮点数解码为补码形式的中间数据,以中间数据进行运算,再将运算结果编码,得到Posit浮点数的运算结果。本申请实施例提出的Posit浮点数处理器,能够将Posit浮点数解码为能够直接参与运算的中间数据,解决了现有方案中必须将Posit浮点数转换为其取值的二进制编码才能进行运算的缺陷,以及整个Posit浮点数的处理过程中,需要大量的从原码到补码,和从补码到原码的转换计算的缺陷。In view of the above problems, an embodiment of the present application proposes a Posit floating-point number processor, which is used to decode the Posit floating-point number into intermediate data in complement form, perform operations on the intermediate data, and then encode the operation result to obtain the operation of the Posit floating-point number. result. The Posit floating-point number processor proposed by the embodiments of the present application can decode the Posit floating-point number into intermediate data that can directly participate in the operation, and solves the problem in the existing solution that the Posit floating-point number must be converted into the binary code of its value before the operation can be performed. Defects, as well as the entire processing of Posit floating point numbers, require a large number of defects in conversion calculations from the original code to the complement, and from the complement to the original code.

浮点数是在计算机技术中,用以近似表示任意某个实数的科学计数法。以实数M×2e为例,M是尾数,2是基数,e是指数。计算机中参与运算的数据都用二进制表示,因此无论是IEEE 754浮点数还是Posit浮点数,基数都是2。Floating point number is a scientific notation method used to approximately represent any real number in computer technology. Take the real number M×2 e as an example, M is the mantissa, 2 is the base, and e is the exponent. The data involved in the operation in the computer are all represented in binary, so whether it is an IEEE 754 floating point number or a Posit floating point number, the base is 2.

Posit浮点数在约定总位宽后,还会对指数的位宽进行约定。一般地,对于总位宽是32bit的Posit浮点数,通常约定2-4bit的位宽作为Posit浮点数的指数位宽,对于总位宽是8bit的Posit浮点数,通常约定1-2bit的位宽作为Posit浮点数的指数字段的位宽。包括指数字段在内,Posit浮点数标准规定了Posit浮点数具有以下字段:After the total bit width of the Posit floating-point number is agreed, the bit width of the exponent is also agreed. Generally, for a Posit floating point number with a total bit width of 32 bits, a bit width of 2-4 bits is usually agreed as the exponent bit width of the Posit floating point number. For a Posit floating point number with a total bit width of 8 bits, a bit width of 1-2 bits is usually agreed. The bit width of the exponent field as a floating-point number for Position. Including the exponent field, the Posit floating point standard specifies that Posit floating point numbers have the following fields:

一:符号字段。符号字段通常是Posit浮点数的最高位。One: Symbol field. The sign field is usually the most significant bit of a Position floating-point number.

二、regime字段,位于符号字段后,regime字段由从最高位到次低位的一串连续的1和最低位的0组成,最低位的0是翻转位,或由最从高位到次低位的一串连续的0和最低位的1组成。在regime字段为正时,regime字段的取值为连续的1的个数减1,在连regime字段为负时,regime字段的取值为0的个数取负。regime字段的宽度可以是任意的。例如:在regime字段是1110时,其取值为3-1=2;在regime字段是0001时,其取值为-3。2. The regime field, located after the symbol field, the regime field consists of a series of consecutive 1s from the highest bit to the next lowest bit and the lowest bit 0, the lowest bit 0 is the flip bit, or from the highest bit to the next lowest bit one The string consists of consecutive 0s and the least significant 1. When the regime field is positive, the value of the regime field is minus 1 for the number of consecutive 1s, and when the consecutive regime field is negative, the value of the regime field is negative for the number of 0s. The width of the regime field can be arbitrary. For example: when the regime field is 1110, its value is 3-1=2; when the regime field is 0001, its value is -3.

三、指数字段,若regime字段没有用完事先约定的总位宽,regime字段后紧跟指数字段,位指数字段宽为事先约定的位宽。指数字段是无符号整数,其取值一定大于零。3. Exponent field, if the Regime field does not use up the pre-agreed total bit width, the Regime field is followed by the exponent field, and the bit exponent field width is the pre-agreed bit width. The exponent field is an unsigned integer whose value must be greater than zero.

四、尾数字段,即第二尾数字段,若指数字段和regime字段没有用完事先约定的总位宽,剩余的全部位宽为尾数字段的位宽。可以理解的是,在十进制中,由于尾数是一个大于等于1.0、小于10的小数,其整数部分取1至9中任意一个整数。二进制中,尾数的整数部分只可能是1,为了减少不必要的编码,Posit浮点数标准将整数位作为隐藏位,只在Posit浮点数的尾数字段记录小数位。例如:如果尾数字段是1001,那么它加上隐藏位就是11001,对应的十进制取值是1×20+1×2-1+0×2-2+0×2-3+1×2-4=1.5625。在Posit浮点数标准中,还定义了useed的概念,useed用于在数值上统一regime字段和指数字段。useed的值与事先约定的Posit浮点数的指数字段的位宽有关,对于任意的格式固定的Posit浮点数,useed的值也是固定的。假设指数字段的位宽是es,则useed的取值为

Figure BDA0002470206930000091
例如,es=1时,
Figure BDA0002470206930000092
es=2时,
Figure BDA0002470206930000093
假设一个Posit浮点数的符号为s,regime的值为r,指数的值为e,含隐藏位的尾数值为m,那么该Posit浮点数对应的十进制实数为:4. The mantissa field, that is, the second mantissa field. If the exponent field and the regime field do not use up the total bit width agreed in advance, the remaining total bit width is the bit width of the mantissa field. It can be understood that, in the decimal system, since the mantissa is a decimal number greater than or equal to 1.0 and less than 10, its integer part takes any integer from 1 to 9. In binary, the integer part of the mantissa can only be 1. In order to reduce unnecessary encoding, the Posit floating-point number standard uses the integer bits as hidden bits, and only records the decimal place in the mantissa field of the Posit floating-point number. For example: if the mantissa field is 1001, then it is 11001 plus hidden bits, and the corresponding decimal value is 1×2 0 +1×2 -1 +0×2 -2 +0×2 -3 +1×2 - 4 = 1.5625. In the Posit floating-point number standard, the concept of used is also defined, which is used to unify the regime field and the exponent field numerically. The value of used is related to the bit width of the exponent field of the pre-agreed Posit floating-point number. For any fixed-format Posit floating-point number, the value of used is also fixed. Assuming that the bit width of the exponent field is es, the value of used is
Figure BDA0002470206930000091
For example, when es=1,
Figure BDA0002470206930000092
When es=2,
Figure BDA0002470206930000093
Assuming that the symbol of a Posit floating-point number is s, the value of the regime is r, the value of the exponent is e, and the value of the mantissa with hidden bits is m, then the decimal real number corresponding to the Posit floating-point number is:

(-1)s×useedr×2e×m(-1) s ×used r ×2 e ×m

目前在Posit浮点数的相关研究中,将Posit浮点数转换为原码,即将符号为负的Posit浮点数转换为绝对值,绝对值是该符号为负的Posit浮点数对应的正数,再加上表示负数的符号位。由于计算机采用补码进行运算,运算电路在运算时,需要将该符号为负的Posit浮点数对应的正数的尾数部分再转换为补码;在编码过程中,再次需要将补码转换为原码。由此可见,整个对Posit浮点数的处理器需要多个进行原码到补码的相互转换的电路,造成用于处理Posit浮点数的电路的面积较大、发热较大。At present, in the related research of Posit floating-point numbers, the Posit floating-point number is converted into the original code, that is, the Posit floating-point number with a negative sign is converted into an absolute value, and the absolute value is the positive number corresponding to the Posit floating-point number with the negative sign, plus The sign bit above represents a negative number. Since the computer uses the complement code for operation, the operation circuit needs to convert the mantissa part of the positive number corresponding to the negative Posit floating point number to the complement code during the operation; in the encoding process, the complement code needs to be converted to the original again. code. It can be seen that the entire processor for Posit floating-point numbers requires multiple circuits for mutual conversion between original code and complement code, resulting in a larger area and greater heat generation of the circuit for processing Posit floating-point numbers.

本申请实施例独创了补码型的解码电路,以独创的解码电路将Posit浮点数解码为可以直接参与运算的中间数据,再使用运算电路直接以中间数据进行运算,得到以中间数据表示的运算结果,最后使用独创的补码型编码电路将运算结果编码为Posit浮点数。整个对Posit浮点数的处理过程(解码、运算、编码)都以补码进行,没有大量的补码原码转化,减少了功耗。The embodiment of the present application creates an original decoding circuit of complement code type, uses the original decoding circuit to decode the Posit floating point number into intermediate data that can directly participate in the operation, and then uses the operation circuit to directly perform operations on the intermediate data to obtain the operation represented by the intermediate data. As a result, the operation result is finally encoded as a Posit floating point number using an original complement-type encoding circuit. The entire processing process (decoding, operation, and encoding) of Posit floating-point numbers is carried out in complement code, without a large number of complement code conversion, which reduces power consumption.

上述对Posit浮点数的处理的各个电路和模块已经集成到开源RISC-V(基于精简指令集原则的开源指令集架构)处理器RocketChip(基于开源硬件构造语言开发的一款开源集成芯片生成器)中,构成了本申请提出的Posit浮点数处理器,可以执行所有的浮点指令,并正确完成相应的功能。The above circuits and modules for processing Posit floating point numbers have been integrated into the open source RISC-V (open source instruction set architecture based on reduced instruction set principle) processor RocketChip (an open source integrated chip generator developed based on open source hardware construction language) , which constitutes the Posit floating point processor proposed in this application, which can execute all floating point instructions and correctly complete the corresponding functions.

参考图1,图1是本申请实施例解码电路的结构示意图。首先对Posit浮点数处理器的解码电路进行说明。解码电路包括:无穷数确定模块101、零值判断模块102、符号判断模块103、regime真实符号确定模块104、regime字段统一模块105、regime值计算模块106、提取模块107、真实指数确定模块108、第一尾数字段确定模块109、保护位输出模块110。Referring to FIG. 1 , FIG. 1 is a schematic structural diagram of a decoding circuit according to an embodiment of the present application. First, the decoding circuit of the Posit floating-point number processor will be described. The decoding circuit includes: an infinite number determination module 101, a zero value determination module 102, a symbol determination module 103, a regular real symbol determination module 104, a regular field unification module 105, a regular value calculation module 106, an extraction module 107, a real index determination module 108, The first mantissa field determination module 109 and the protection bit output module 110 .

所述解码电路用于根据CPU的计算指令,获取参与运算的多个目标Posit浮点数,并将所述多个目标Posit浮点数转换为各自对应的补码形式的中间数据;所述中间数据包括多个字段:符号字段、真实指数字段、第一尾数字段以及保护位字段;The decoding circuit is used to obtain a plurality of target Posit floating-point numbers participating in the operation according to a calculation instruction of the CPU, and convert the plurality of target Posit floating-point numbers into respective corresponding intermediate data in complement form; the intermediate data includes Multiple fields: sign field, real exponent field, first mantissa field and protection bit field;

相较于目前在计算Posit浮点数之前,需要通过判断Posit浮点数的符号来判断是否对Posit浮点数进行补码的转换,本申请实施例中的符号字段可以直接参与运算,减少了Posit浮点数在运算前和运算完成后的逻辑判断。Compared with the current need to determine whether to perform complement conversion on the Posit floating point number by judging the sign of the Posit floating point number before calculating the Posit floating point number, the sign field in the embodiment of the present application can directly participate in the operation, reducing the Posit floating point number. The logical judgment before and after the operation is completed.

目标Posit浮点数是解码电路根据计算指令获取的待解码的Posit浮点数。因目标Posit浮点数是参与运算的,所以目标Posit浮点数的个数是两个或大于两个,解码电路可以对多个目标Posit浮点数可以同时解码,也可以依次解码。The target Posit floating-point number is the Posit floating-point number to be decoded obtained by the decoding circuit according to the calculation instruction. Since the target Posit floating-point numbers are involved in the operation, the number of target Posit floating-point numbers is two or more, and the decoding circuit can decode multiple target Posit floating-point numbers at the same time or sequentially.

本申请实施例设置的中间数据是定点数的格式,具体包括:无穷数字段、零值字段、符号字段、真实指数字段、第一尾数字段和保护位字段。The intermediate data set in this embodiment of the present application is in a fixed-point format, and specifically includes: an infinite number field, a zero value field, a sign field, a real exponent field, a first mantissa field, and a protection bit field.

为区分中间数据和目标Posit浮点数的尾数字段,以第一尾数字段表示将中间数据中的尾数字段,以第二尾数字段表示目标Posit浮点数的尾数字段。In order to distinguish between the intermediate data and the mantissa field of the target Posit floating point number, the first mantissa field represents the mantissa field in the intermediate data, and the second mantissa field represents the mantissa field of the target Posit floating point number.

Posit浮点数中只有两个特殊编码:以所有位数全部是0的编码表示实数0,以最高位是1,其余位数全部是0的编码表示无穷数。因此,在解码电路设置了无穷数确定模块和零值判断模块,以对特殊编码的目标Posit浮点数作标记,使运算电路在根据标记识别到特殊编码的目标Posit浮点数时,能够直接输出,对多个特殊编码的目标Posit浮点数运算后的运算结果,进而使编码电路在运算结果是表示特殊编码的中间数据时,能够直接输出表示无穷数的编码和表示零的编码。根据上述分析可知,本申请提出的Posit浮点数处理器处理特殊编码的目标Posit浮点数的过程,更加快捷。There are only two special codes in Posit floating-point numbers: the real number 0 is represented by the code where all the digits are 0, the real number is represented by the code where the highest digit is 1, and the code where the rest of the digits are all 0 represents the infinite number. Therefore, an infinite number determination module and a zero value judgment module are set in the decoding circuit to mark the special-coded target Posit floating-point number, so that when the arithmetic circuit recognizes the special-coded target Posit floating-point number according to the mark, it can directly output, The operation result after the operation on a plurality of special-coded target Posit floating-point numbers enables the encoding circuit to directly output the code representing infinite number and the code representing zero when the operation result is intermediate data representing the special code. According to the above analysis, the Posit floating point number processor proposed in the present application processes the specially encoded target Posit floating point number more quickly.

假设指定格式是Posit<8,1>,那么无穷数的编码是10000000,零的编码是00000000。Assuming that the specified format is Posit<8,1>, the encoding of an infinite number is 10000000, and the encoding of zero is 00000000.

解码电路还包括:无穷数确定模块101和零值判断模块102;The decoding circuit further includes: an infinite number determination module 101 and a zero value determination module 102;

所述中间数据还包括无穷数字段和零值字段;所述解码电路还包括:无穷数确定模块和零值判断模块;The intermediate data further includes an infinite number field and a zero value field; the decoding circuit further includes: an infinite number determination module and a zero value judgment module;

所述无穷数确定模块101,用于在所述目标Posit浮点数是无穷数时,将所述目标Posit浮点数对应的中间数据的无穷数字段置为真;The infinite number determination module 101 is used to set the infinite number field of the intermediate data corresponding to the target Posit floating point number to true when the target Posit floating point number is an infinite number;

所述零值判断模块102,用于在所述目标Posit浮点数是零时,将所述目标Posit浮点数对应的中间数据的零值字段置为真。The zero value judgment module 102 is configured to set the zero value field of the intermediate data corresponding to the target Posit floating point number to true when the target Posit floating point number is zero.

在无穷数确定模块判断得到目标Posit浮点数不是无穷数时,将零值字段和无穷数字段置为假。无穷数确定模块101、零值判断模块102和符号判断模块103并联,无论无穷数字段和零值字段是否为真,解码电路都会对目标Posit浮点数解码,得到符号字段、真实指数字段、第一尾数字段以及保护位字段。无穷数字段和零值字段用于保证因目标Posit浮点数是零或无穷数,而导致的运算结果是零或无穷数时,无论依据符号字段、真实指数字段、第一尾数字段以及保护位字段计算后得到的编码是否是零或无穷数的编码,以及无论依据符号字段、真实指数字段、第一尾数字段以及保护位字段计算得到特殊编码的计算效率,Posit浮点数处理器都能够快捷准确地输出表示零或无穷数的Posit浮点数。When the infinite number determination module determines that the target Posit floating point number is not an infinite number, the zero value field and the infinite number field are set to false. The infinite number determination module 101, the zero value judgment module 102 and the symbol judgment module 103 are connected in parallel, no matter whether the infinite number field and the zero value field are true, the decoding circuit will decode the target Posit floating point number to obtain the symbol field, the real exponent field, the first The mantissa field and the protection bit field. The infinity field and the zero value field are used to ensure that when the target Posit floating-point number is zero or infinity, the result of the operation is zero or infinity, regardless of the sign field, the real exponent field, the first mantissa field, and the protection bit field. Whether the code obtained after the calculation is the code of zero or infinite number, and whether the calculation efficiency of the special code is calculated according to the sign field, the real exponent field, the first mantissa field and the guard bit field, the Posit floating point number processor can quickly and accurately. Output a Position floating point number representing zero or infinity.

所述中间数据还包括符号字段;所述解码电路还包括:符号判断模块;The intermediate data further includes a symbol field; the decoding circuit further includes: a symbol judgment module;

所述符号判断模块103,用于根据所述目标Posit浮点数的最高位,确定该目标Posit浮点数的符号,再以该目标Posit浮点数的符号作为该目标Posit浮点数对应的中间数据的符号,并输出该目标Posit浮点数对应的中间数据的符号字段为所述中间数据的符号。The symbol judgment module 103 is used to determine the symbol of the target Posit floating point number according to the highest bit of the target Posit floating point number, and then use the symbol of the target Posit floating point number as the symbol of the intermediate data corresponding to the target Posit floating point number , and output the symbol field of the intermediate data corresponding to the target Posit floating point number as the symbol of the intermediate data.

根据Posit浮点数标准,目标Posit浮点数的最高位为符号位。当目标Posit浮点数不是无穷数或零时,若其最高位是1时,目标Posit浮点数为负数,以1作为符号字段,若其最高位是0时,目标Posit浮点数为正数,以0作为符号字段。中间数据的符号字段是解码电路解析Posit浮点数编码后,直接以Posit浮点数的最高位,即Posit浮点数的符号字段作为符号字段。According to the Posit floating point number standard, the most significant bit of the target Posit floating point number is the sign bit. When the target Posit floating-point number is not an infinite number or zero, if its highest bit is 1, the target Posit floating-point number is a negative number, and 1 is used as the sign field; if its highest bit is 0, the target Position floating-point number is a positive number, with 0 as the sign field. The symbol field of the intermediate data is that after the decoding circuit parses the encoding of the Posit floating-point number, the highest bit of the Posit floating-point number, that is, the symbol field of the Posit floating-point number, is directly used as the symbol field.

解码电路还包括:第一异或器件、第二异或器件、反向前导零检测电路器件、第一移位电路器件、第一拼接电路器件、第一提取电路器件。The decoding circuit further includes: a first XOR device, a second XOR device, a reverse leading zero detection circuit device, a first shift circuit device, a first splicing circuit device, and a first extraction circuit device.

regime真实符号确定模块104,用于通过所述第一异或器件对目标Posit浮点数的最高位与所述目标Posit浮点数的次高位进行异或操作,得到所述目标Posit浮点数的regime字段的真实符号;The real symbol determination module 104 of the regime is configured to perform an XOR operation on the highest bit of the target Posit floating point number and the second highest bit of the target Posit floating point number through the first XOR device to obtain the regime field of the target Posit floating point number the real symbol of ;

由于Posit浮点数整体是补码形式,因此负数的Posit浮点数的regime字段的符号,并不能直接由该Posit浮点数的regime字段的形式判断得到。具体表现在Posit浮点数在表示负数的时候,并不是将对应的正数的符号改成1,而是像补码一样,将Posit浮点数整体取反加一。例如,假设目标Posit浮点数的格式是Posit<8,1>,目标Posit浮点数是01011000,01011000表示3,但-3并不是11011000,而是10100111+1=10101000。Since the entire Posit floating-point number is in complement form, the sign of the registry field of a negative Posit floating-point number cannot be directly judged by the form of the registry field of the Posit floating-point number. Specifically, when the Posit floating-point number represents a negative number, it does not change the sign of the corresponding positive number to 1, but inverts and adds one to the entire Posit floating-point number like a complement. For example, suppose the format of the target Posit float is Posit<8, 1>, the target Posit float is 01011000, 01011000 means 3, but -3 is not 11011000, but 10100111+1=10101000.

本申请实施例以regime真实符号确定模块,仅以异或电路器件对两位数(目标Posit浮点数的最高位和次高位)进行计算,就能分辨目标Posit浮点数中的regime字段的真实符号,减少了电路的面积,并且减少了Posit浮点数处理器运行时的发热。In the embodiment of the present application, the real symbol of the regime is determined by the module, and the two-digit number (the highest bit and the second highest bit of the target Posit floating-point number) can be calculated only by the XOR circuit device, so that the real symbol of the regime field in the target Posit floating-point number can be distinguished. , reduces the area of the circuit, and reduces the heat generated when the Posit floating point processor is running.

继续以上述关于regime字段的示例进行说明,假设从Posit浮点数中获取regime字段的形式是1110,在Posit浮点数是正数时,Posit浮点数的regime字段是1110;在Posit浮点数是负数时,整个Posit浮点数是由另外一个编码补码得到的,必然地其中的regime字段也是由另一个编码0001补码得到的。Continuing with the above example about the regime field, assuming that the form of the regime field obtained from the Posit floating-point number is 1110, when the Posit floating-point number is positive, the regime field of the Posit floating-point number is 1110; when the Posit floating-point number is negative, The entire Posit floating-point number is obtained by another encoding's complement, and inevitably the region field is also obtained by another encoding 0001's complement.

鉴于此,本申请实施例提出的Posit浮点数的解码电路以regime真实符号确定模块得到Posit浮点数中regime字段的真实符号。In view of this, the decoding circuit of the Posit floating-point number proposed in the embodiment of the present application obtains the real symbol of the regime field in the Posit floating-point number by using the real symbol determination module of the regime.

regime真实符号确定模块的工作原理是:二进制的任意位数与0异或保持不变,与1异或取该位数的反码。Posit浮点数是正数时,最高位是0,0与regime字段的第一位异或,regime字段的第一位保持不变;Posit浮点数是负数时,最高位是1,1与regime字段的第一位异或,regime字段的第一位取反。例如,Posit浮点数是01110,regime字段1110是正数,Posit浮点数是11110,regime字段1110应该是0001,是负数。本申请实施例结合异算法的特点和regime字段本身的性质,以异或器件仅对最高位和次高位两位数进行异或,就能得到regime字段的真实符号,电路简单,不需要增加其他运算电路。The working principle of the real sign determination module of the regime is that any digit in binary is XORed with 0 and remains unchanged, and XORed with 1 to take the inverse of the digit. When the Posit floating-point number is positive, the highest bit is 0, and 0 is XORed with the first bit of the regime field, and the first bit of the regime field remains unchanged; when the Posit floating-point number is negative, the highest bit is 1, and 1 and the first bit of the regime field remain unchanged. The first bit is XORed, and the first bit of the regime field is negated. For example, the Posit floating point number is 01110, the regime field 1110 is a positive number, the Posit floating point number is 11110, and the regime field 1110 should be 0001, which is a negative number. Combining the characteristics of the exclusive algorithm and the properties of the regime field itself, the embodiment of the present application uses the XOR device to XOR only the highest-order and second-highest two digits to obtain the real symbol of the regime field. The circuit is simple and does not need to add other arithmetic circuit.

regime字段统一模块105,用于第一次除去所述目标Posit浮点数的最高位和次高位,第二次除去所述目标Posit浮点数的最高位和最低位,再通过所述第二异或器件对所述第一次除去的结果和所述第二次除去的结果进行异或操作,得到regime统一字段;The regime field unification module 105 is used to remove the highest bit and the second highest bit of the target Posit floating point number for the first time, remove the highest bit and the lowest bit of the target Posit floating point number for the second time, and then pass the second XOR The device performs an XOR operation on the result of the first removal and the result of the second removal to obtain the uniform field of the regime;

第一次除去是将目标Posit浮点数除去最高位和次高位;第二次除去是将相同的目标Posit浮点数除去最高位和最低位。第一次除去和第二次除去指的是,对于同一目标Posit浮点数,分别对其除去最高位和次高位,除去最高位和最低位。其中第一和第二并不表示对步骤执行顺序的限制。The first removal is to remove the highest and second highest bits of the target Posit floating point number; the second removal is to remove the highest and lowest bits of the same target Posit floating point number. The first removal and the second removal refer to removing the highest and second highest bits, and removing the highest and lowest bits, respectively, for the same target Posit floating-point number. The first and the second do not represent restrictions on the execution order of the steps.

regime字段统一模块的工作原理是:除去最高位和最低位后的Posit浮点数,与除去最高位和次高位后的Posit浮点数,会相差一位,而regime字段的最低位会翻转,因此regime字段的最后一位一定会与regime字段次低位异或,属于不同数的异或,regime字段的最低位之前的位数异或都是相同数的异或,而不同的数异或得到的是1,相同的数异或得到的是0,进而,得到的regime统一字段一定是以一串0再加1的形式。regime统一字段是将前导0的regime字段和前导1的regime字段进行统一后的字段。The working principle of the unified module of the regime field is: the Posit floating-point number after removing the highest and lowest bits and the Posit floating-point number after removing the highest and second highest bits will differ by one bit, and the lowest bit of the regime field will be flipped, so the regime The last bit of the field must be XORed with the next-lowest bit of the regime field, which belongs to the XOR of different numbers. The XOR of the bits before the lowest bit of the regime field is the XOR of the same number, and the XOR of different numbers is 1. The XOR of the same number results in 0, and further, the uniform field of the regime must be in the form of a string of 0 plus 1. The unified regime field is a field that unifies the regime field with leading 0 and the regime field with leading 1.

例如,假设目标Posit浮点数是“0|110|0|000”,第一次除去的结果是“110|0|00”,第二次除去的结果是“10|0|000”,将“0|110|0|000”和“10|0|000”进行异或后,得到regime统一字段“01|0000”。For example, assuming that the target position float is "0|110|0|000", the result of the first removal is "110|0|00", and the result of the second removal is "10|0|000", the " 0|110|0|000" and "10|0|000" are XORed to obtain the uniform field "01|0000" of the regime.

本申请实施例通过regime字段统一模块,将regime字段的两种编码形式,统一为一种编码形式,以达到直接通过一个前导零检测电路,就能得到所有regime字段(例如:11110和00001)的值的效果,避免了对两种编码形式的regime字段需要分别使用前导零检测电路和前导一检测电路的缺陷,避免了同时使用前导零检测电路和前导一检测电路导致的电路面积过大。In this embodiment of the present application, the two encoding forms of the regime field are unified into one encoding form through the regime field unification module, so that all the regime fields (for example: 11110 and 00001) can be obtained directly through a leading zero detection circuit. The effect of the value avoids the defect that a leading zero detection circuit and a leading one detection circuit need to be used separately for the regime fields of the two encoding forms, and avoids the use of the leading zero detection circuit and the leading one detection circuit at the same time. The circuit area is too large.

regime值计算模块106,用于通过所述反向前导零检测电路器件对所述regime统一字段进行检测,并根据所述反向前导零检测电路器件的输出得到所述regime字段的取值字段;The regime value calculation module 106 is used to detect the uniform field of the regime by the reverse leading zero detection circuit device, and obtain the value field of the regime field according to the output of the reverse leading zero detection circuit device;

所述regime字段的取值字段是以二进制表示的regime字段的取值。The value field of the regime field is the value of the regime field in binary representation.

本申请另一种实施例提出,以反向前导零检测电路对regime统一字段进行检测,得到regime字段的值的方法。参考图2,图2是本申请实施例提出的反向前导零检测电路器件的结构示意图。Another embodiment of the present application proposes a method for detecting the uniform field of the regime with a reverse leading zero detection circuit to obtain the value of the regime field. Referring to FIG. 2 , FIG. 2 is a schematic structural diagram of a reverse leading zero detection circuit device proposed by an embodiment of the present application.

所述反向前导零检测电路器件包括或器件,第一取反器件,第二取反器件;The reverse leading zero detection circuit device includes an OR device, a first inversion device, and a second inversion device;

所述反向前导零检测电路器件,用于以所述第一取反器件分别对多个位宽为2的输入字段的第0位进行取反运算,再以所述或器件,分别对多个取反结果和所述多个位宽为2的输入字段的第1位进行或运算,得到多个输出字段的第0位;所述位宽为2的输入字段是所述regime统一字段通过二分法处理后得到的;The reverse leading zero detection circuit device is used to use the first inversion device to respectively invert the 0th bit of a plurality of input fields with a bit width of 2, and then use the OR device to respectively invert multiple bits. The inversion results are ORed with the first bits of the input fields with a bit width of 2 to obtain the 0th bit of the output fields; the input fields with a bit width of 2 are the unified obtained after dichotomous processing;

所述反向前导零检测电路器件,还用于以所述或器件分别对所述多个位宽为2的输入字段的第0位和所述多个位宽为2的输入字段的第1位进行或运算,得到所述多个输出字段的第1位;The reverse leading zero detection circuit device is further configured to use the OR device to detect the 0th bit of the plurality of input fields with a bit width of 2 and the first bit of the plurality of input fields with a bit width of 2 respectively. performing an OR operation on the bits to obtain the first bit of the plurality of output fields;

所述反向前导零检测电路器件,还用将所述多个输出字段拼接,得到所述regime统一字段的取值的反码。The reverse leading zero detection circuit device is also used for splicing the multiple output fields to obtain the inverse code of the value of the regular uniform field.

反向前导零检测电路器件首先将regime统一字段多次折半,得到多个位宽为2的输入字段。例如,假设regime统一字段是000001,通过二分电路得到的多个的位宽为2的输入字段是(00)、(00)、(01)。再以子电路对每个位宽为2的输入字段进行检测,得到每个位宽为2的输入字段中0的个数的反码。The reverse leading zero detection circuit device firstly halves the uniform field of the regime several times to obtain a plurality of input fields with a bit width of 2. For example, assuming that the uniform field of the regime is 000001, the multiple input fields with a bit width of 2 obtained by the binary circuit are (00), (00), (01). The sub-circuit is then used to detect each input field with a bit width of 2, and obtain the inverse code of the number of 0s in each input field with a bit width of 2.

示例地,以多个位宽为2的输入字段中的(01)进行说明,“1”是输入字段(01)的第0位,“0”是输入字段(01)的第1位,“1”取反后得到“0”,“0”与“0”进行或运算,得到0,作为(01)对应的输出字段的第0位。同理得到输出字段的第1位是1,(01)对应的输出字段是“10”,同理,以子电路对(00)进行计算,得到(00)对应的输出字段是01,进而输出regime统一字段的取值的反码[(01)(01)(10)]。As an example, it is described with (01) in a plurality of input fields with a bit width of 2, "1" is the 0th bit of the input field (01), "0" is the 1st bit of the input field (01), " After inversion of 1", "0" is obtained, and "0" is ORed with "0" to obtain 0, which is used as the 0th bit of the output field corresponding to (01). Similarly, the first bit of the output field is 1, and the output field corresponding to (01) is "10". Similarly, the sub-circuit calculates (00), and the output field corresponding to (00) is 01, and then output The complement of the value of the unified field of regime [(01)(01)(10)].

得到regime统一字段的取值的反码[(01)(01)(10)]后,对“10”取反得到“01”,01即为(01)中0的个数,表示(01)中有1个0。对01取反,01取反得到10,10即(00)中0的个数,表示(00)中有2个0。进而得到多个位宽为2的输入字段[(00)(00)(01)]的检测结果是[(2)+(2)+(1)],即000001中一共有5个0。After obtaining the inverse code of the value of the unified field of the regime [(01)(01)(10)], invert "10" to get "01", 01 is the number of 0s in (01), indicating (01) There is 1 0 in it. Invert 01, invert 01 to get 10, 10 is the number of 0s in (00), indicating that there are 2 0s in (00). Then, the detection results of multiple input fields [(00)(00)(01)] with a bit width of 2 are obtained as [(2)+(2)+(1)], that is, there are a total of 5 0s in 000001.

regime取值计算子模块,用于在所述regime字段的真实符号为正时,对所述反向前导零检测电路器件输出的反码取反,再对取反后的所述反向前导零检测电路器件输出的反码的最高位添加所述regime字段的真实符号,得到所述regime字段的取值字段;The regime value calculation sub-module is used to invert the inverse code output by the reverse leading zero detection circuit device when the real symbol of the regime field is positive, and then invert the reversed leading zero The highest bit of the inverse code output by the detection circuit device adds the real symbol of the regime field to obtain the value field of the regime field;

regime取值计算子模块,还用于在所述regime字段的真实符号为负时,对所述反向前导零检测电路器件输出的反码的最高位添加所述regime字段的真实符号,得到所述regime字段的取值字段。The regime value calculation submodule is also used to add the real symbol of the regime field to the highest bit of the complement code output by the reverse leading zero detection circuit device when the real symbol of the regime field is negative, to obtain the Describe the value field of the regime field.

检测regime统一字段000001,得出其中有5个零,即regime字段的取值是5,得到regime字段的取值字段是101。根据regime真实符号和regime统一字段的取值,可以明确得到目标Posit浮点数中regime字段的取值。Detecting the uniform field of the regime 000001, it is found that there are 5 zeros, that is, the value of the regime field is 5, and the value field of the regime field is 101. According to the real symbol of the regime and the value of the uniform field of the regime, the value of the regime field in the target Posit floating-point number can be clearly obtained.

本申请实施例提出的反向前导零检测电路器,首先检测regime统一字段直接得到regime字段的取值的反码,再对每个子电路得到的输出字段统一逻辑取反,避免了由于在每个子电路分别对输入字段的第1位和第0位的频繁取反,导致的电路面积增加。The reverse leading zero detection circuit proposed in the embodiment of the present application firstly detects the unified field of the regime to directly obtain the inverse code of the value of the region field, and then inverts the unified logic of the output field obtained by each sub-circuit, avoiding the need for a unified logic in each sub-circuit. The circuit frequently inverts the 1st and 0th bits of the input field, respectively, resulting in an increase in the circuit area.

提取模块107,用于通过所述第一移位电路器件,将所述目标Posit浮点数的最高三位移出,并将移出最高三位后的所述目标Posit浮点数的剩余字段左移指定位数;所述指定位数是根据所述反向前导零检测电路器件的输出得到的;The extraction module 107 is configured to shift out the highest three bits of the target Posit floating-point number through the first shifting circuit device, and shift the remaining fields of the target Posit floating-point number after the highest three bits are shifted left by a specified position The specified number of digits is obtained according to the output of the reverse leading zero detection circuit device;

移出的最高三位分别是目标Posit浮点的符号位、目标Posit浮点的regime字段的翻转位,以及regime统一字段与regime字段相差的1位。The highest three bits shifted out are the sign bit of the target Posit floating point, the flip bit of the regime field of the target Posit floating point, and the 1-bit difference between the uniform field and the regime field.

指定位数是反向前导零检测电路器件检测regime统一字段后,得到到regime统一字段的0的个数。例如,假设regime统一字段的是0001,那么指定位数是3。The specified number of bits is the number of 0s obtained in the uniform field of the regime after the reverse leading zero detection circuit device detects the uniform field of the regime. For example, if the uniform field of the regime is 0001, then the specified number of digits is 3.

本申请实施例提供的解码电路,以反向前导零检测电路器件检测得到regime统一字段的0的个数,再将regime统一字段的0的个数和符号位、翻转位和regime统一字段与regime字段相差的1位移出,得到剩下的位宽确定的指数字段和第二尾数字段,解决了由于Posit浮点数中的regime字段位宽不确定,导致指数分辨困难的问题,以进一步地直接从移出最高三位和指定位数后的目标Posit浮点数中提取得到指数字段。The decoding circuit provided by the embodiment of the present application uses the reverse leading zero detection circuit device to detect the number of 0s in the uniform field of the regime, and then compares the number of 0s in the uniform field of the regime and the sign bit, the flip bit and the uniform field of the regime with the regular The 1-bit difference of the fields is shifted out to obtain the exponent field and the second mantissa field with the remaining bit width determined, which solves the problem that the exponent is difficult to distinguish due to the uncertainty of the bit width of the regime field in the Posit floating-point number. The exponent field is extracted from the target Posit floating-point number after removing the highest three digits and the specified number of digits.

所述提取模块,还用于根据所述目标Posit浮点数的指数字段的位宽,在左移后的目标Posit浮点数中,提取得到所述目标Posit浮点数的指数字段和第二尾数字段;The extraction module is further configured to extract the exponent field and the second mantissa field of the target Posit floating-point number from the left-shifted target Posit floating-point number according to the bit width of the exponent field of the target Posit floating-point number;

真实指数确定模块108,用于在所述目标Posit浮点数是负数时,对所述指数字段进行取反,再通过所述第一拼接电路器件,将所述指数字段或取反后的所述指数字段与所述regime字段的取值字段进行拼接,得到并输出所述目标Posit浮点数对应的中间数据中的真实指数字段;The true exponent determination module 108 is configured to invert the exponent field when the target Posit floating point number is a negative number, and then use the first splicing circuit device to invert the exponent field or the inverted The exponent field is spliced with the value field of the regime field to obtain and output the real exponent field in the intermediate data corresponding to the target Posit floating point number;

第一尾数字段确定模块109,用于按照所述第一尾数字段的最大位宽,对所述第二尾数字段的低位补零得到所述第一尾数字段,输出所述第一尾数字段;所述第一尾数字段的最大位宽是所述目标Posit浮点数的总位宽减去所述目标Posit浮点数的符号位的位宽、所述指数字段的位宽,和所述regime字段的最小位宽得到的;The first mantissa field determining module 109 is configured to, according to the maximum bit width of the first mantissa field, fill in the lower bits of the second mantissa field with zeros to obtain the first mantissa field, and output the first mantissa field; The maximum bit width of the first mantissa field is the total bit width of the target Posit floating point number minus the bit width of the sign bit of the target Posit floating point number, the bit width of the exponent field, and the minimum of the regime field. bit width obtained;

将从Posit浮点数中的提取的第二尾数字段,直接作为中间数据的第一尾数字段。将从Posit浮点数中的提取的指数字段与regime字段的取值字段进行拼接,得到中间数据的真实指数字段。拼接regime指数和指数字段时,regime指数在高位。The second mantissa field extracted from the Posit floating point number is directly used as the first mantissa field of the intermediate data. The exponent field extracted from the Posit floating point number is spliced with the value field of the regime field to obtain the real exponent field of the intermediate data. When splicing the regime index and the index field, the regime index is high.

由于指数字段左移的位宽正是2es,本申请实施例直接将指数字段拼接在regime字段的取值字段的低位,实现regime字段的取值字段的进位。具体将指数字段置于低位,regime字段的取值字段置于高位,通过拼接,完成了regime字段的指数化,避免了利用useed对regime字段进行指数化需要的多余逻辑电路,进而减少了Posit浮点数处理器的电路面积。Since the bit width of the left shift of the exponent field is exactly 2 es , in this embodiment of the present application, the exponent field is directly spliced into the low-order bit of the value field of the regime field to implement the carry of the value field of the regime field. Specifically, the index field is placed at a low position, and the value field of the regime field is placed at a high position. Through splicing, the indexation of the regime field is completed, which avoids the redundant logic circuit required to use used to index the regime field, thereby reducing the Posit floating point. The circuit area of the point processor.

在将Posit浮点数转换为对应的二进制表示的实数值,会通过useed,对Posit浮点数的指数字段和regime字段进行统一。统一后的指数字段和regime字段是:useed·regime+e,其中useed=2es,其中e指的是指数字段,regime指的是regime字段,es指的是Posit浮点数的指数位宽。When converting the Posit floating point number to the corresponding real value represented by binary, the exponent field and the regime field of the Posit floating point number will be unified through used. The unified exponent field and regime field are: used·regime+e, where used=2 es , where e refers to the exponent field, regime refers to the regime field, and es refers to the exponent bit width of the Posit floating point number.

真实指数字段的位宽由指数的位宽和regime字段的取值字段的位宽确定,是固定的值。再进一步确定第一尾数字段的位宽的范围:目标Posit浮点数总位宽-指数字段的位宽-符号位-最小的regime字段(2位)=第一尾数字段的位宽的最大值。The bit width of the real exponent field is determined by the bit width of the exponent and the bit width of the value field of the regular field, and is a fixed value. The range of the bit width of the first mantissa field is further determined: the total bit width of the target Posit floating point number - the bit width of the exponent field - the sign bit - the smallest regular field (2 bits) = the maximum value of the bit width of the first mantissa field.

本申请实施例得到的中间数据的真实指数字段,仅需要将regime字段的取值字段和指数字段进行拼接,就能得到能够参与运算的真实指数字段,以提取的第二尾数字段就能直接作为中间数据的第一尾数字段,解码过程简单,简化了解码电路的计算步骤。The real exponent field of the intermediate data obtained in the embodiment of the present application only needs to splicing the value field and exponent field of the regime field to obtain the real exponent field that can participate in the operation, and the extracted second mantissa field can be directly used as The first mantissa field of the intermediate data, the decoding process is simple, and the calculation steps of the decoding circuit are simplified.

保护位输出模块110,用于将每一位的值都为0的字段作为所述保护位字段,并输出所述保护位字段;所述保护位字段的位宽为3。The protection bit output module 110 is configured to use a field whose value of each bit is 0 as the protection bit field, and output the protection bit field; the bit width of the protection bit field is 3.

解码电路将目标Posit浮点数转换为中间数据的过程中不存在右移舍入,所以直接将保护位字段的三个保护位的值设置为0。The decoding circuit converts the target Posit floating-point number into intermediate data without right-shift rounding, so the value of the three protection bits of the protection bit field is directly set to 0.

在运算电路以中间数据进行运算时,保护位字段用于对运算后的结果进行舍入操作,遵循了Posit浮点数标准中的舍入原则,另一方面真实指数字段和第一尾数字段,是直接提取的目标Posit浮点数的字段,或由目标Posit浮点数中的各个字段拼接得到的,仍然是补码形式,进而使本申请实施例提出的Posit浮点数处理器得到的中间数据,严格遵循了Posit浮点数标准,并且得到中间数据不需要转换为原码,解码过程简单。When the arithmetic circuit operates with intermediate data, the protection bit field is used to round the result after the operation, which follows the rounding principle in the Posit floating-point number standard. On the other hand, the real exponent field and the first mantissa field are The directly extracted field of the target Posit floating-point number, or obtained by splicing each field in the target Posit floating-point number, is still in the form of complement code, so that the intermediate data obtained by the Posit floating-point number processor proposed in the embodiment of the present application is strictly complied with. The Posit floating point number standard is adopted, and the intermediate data does not need to be converted into the original code, and the decoding process is simple.

参考图3,图3是本申请实施例提出的Posit浮点数处理器的结构示意图。所述Posit浮点数处理器包括:解码电路301、运算电路302以及编码电路303;Referring to FIG. 3 , FIG. 3 is a schematic structural diagram of a Posit floating-point number processor proposed by an embodiment of the present application. The Posit floating point number processor includes: a decoding circuit 301, an arithmetic circuit 302 and an encoding circuit 303;

所述运算电路302,用于根据所述计算指令,对接收的所述解码电路输出的多个中间数据进行运算,得到以补码形式的中间数据表示的运算结果;The operation circuit 302 is configured to perform operation on the received multiple intermediate data output by the decoding circuit according to the calculation instruction, to obtain an operation result represented by the intermediate data in the form of complement code;

解码电路得到中间数据:无穷数字段、零值字段、符号字段、真实指数字段、第一尾数字段和保护位字段后,运算电路直接以中间数据进行运算。在中间数据中的无穷数字段或零值字段为真时,运算电路可以直接得到对应的特殊值(无穷数或零的中间数据),保护位字段在运算过程中,或对运算结果进行舍入操作。整个运算电路的输入是补码形式中间数据,输出仍是补码形式中间数据,不需要对中间数据进行原码和补码的转换,简化了运算过程。After the decoding circuit obtains the intermediate data: the infinite number field, the zero value field, the sign field, the real exponent field, the first mantissa field and the protection bit field, the operation circuit directly performs the operation on the intermediate data. When the infinite number field or zero value field in the intermediate data is true, the operation circuit can directly obtain the corresponding special value (infinite number or zero intermediate data), protect the bit field during the operation process, or round the operation result operate. The input of the whole operation circuit is the intermediate data in complement form, and the output is still the intermediate data in complement form, and there is no need to convert the intermediate data between the original code and the complement code, which simplifies the operation process.

所述编码电路303,用于根据所述计算指令中的指定格式,将所述运算结果转换为所述指定格式的Posit浮点数。The encoding circuit 303 is configured to convert the operation result into a Posit floating point number in the specified format according to the specified format in the calculation instruction.

指定格式指的是对Posit浮点数的总位宽和指数位宽的约定。一般地以Posit<总位宽,指数位宽>作为指定格式。The specified format refers to the convention for the total bit width and exponent bit width of the Posit floating point number. Generally, the specified format is Position<total bit width, index bit width>.

编码电路依据计算机处理器(CPU)对运算结果指定的格式,将运算电路输出的中间数据转换为Posit浮点数编码。整个编码的过程不涉及原码到补码的转换,只需要将中间数据的各个字段还原为Posit浮点数编码的各个字段,编码电路逻辑简单。The encoding circuit converts the intermediate data output by the operation circuit into Posit floating point code according to the format specified by the computer processor (CPU) for the operation result. The entire encoding process does not involve the conversion of the original code to the complement code, and only needs to restore each field of the intermediate data to each field of the Posit floating point number encoding, and the logic of the encoding circuit is simple.

所述编码电路还包括输出模块:The encoding circuit also includes an output module:

所述输出模块401用于在所述中间数据的无穷数字段真时,直接输出所述指定格式的Posit浮点数为表示无穷数的无穷数编码字段;The output module 401 is configured to directly output the Posit floating point number of the specified format as an infinite number encoding field representing an infinite number when the infinite number field of the intermediate data is true;

所述输出模块401还用于在所述中间数据的零值字段为真时,直接输出所述指定格式的Posit浮点数为表示零值的无穷数编码字段。The output module 401 is further configured to directly output the Posit floating point number in the specified format as an infinite number encoding field representing a zero value when the zero value field of the intermediate data is true.

输出模块在中间数据的无穷数字段不为真,且零值字段不为真时,输出通过中间数据的符号字段、真实指数字段、第一尾数字段、保护位字段编码得到的Posit浮点数。可以理解的是,根据中间数据的符号字段、真实指数字段、第一尾数字段、保护位字段,编码得到Posit浮点数的计算较为复杂,Posit浮点数处理器将多个目标Posit浮点数进行处理,得到输出的Posit浮点数的时间较长,因此,通过输出模块,在无穷数字段真,或零值字段为真时,强行、优先直接输出表示0或无穷数的特殊编码,能够避免等待Posit浮点数处理器对目标Posit浮点数转换为中间数据,再计算中间数据耗费的时间,直接输出特殊编码,提高了Posit浮点数处理器对0或无穷数的特殊编码的输出效率。When the infinite number field of the intermediate data is not true and the zero value field is not true, the output module outputs the Posit floating point number encoded by the sign field, the real exponent field, the first mantissa field and the protection bit field of the intermediate data. It can be understood that, according to the symbol field, the real exponent field, the first mantissa field, and the protection bit field of the intermediate data, the calculation of the Posit floating-point number obtained by encoding is relatively complicated. The Posit floating-point number processor processes multiple target Posit floating-point numbers. It takes a long time to get the output Posit floating point number. Therefore, through the output module, when the infinite number field is true, or the zero value field is true, the special code representing 0 or infinite number is forcibly and preferentially output directly, which can avoid waiting for the Posit floating point number. The point processor converts the target Posit floating point number into intermediate data, then calculates the time consumed by the intermediate data, and directly outputs the special code, which improves the output efficiency of the Posit floating point number processor for the special encoding of 0 or infinite number.

参考图4,图4是本申请实施例提出的编码电路的结构示意图。Referring to FIG. 4 , FIG. 4 is a schematic structural diagram of an encoding circuit proposed by an embodiment of the present application.

所述编码电路303包括:第二提取电路器件、第二移位电路器件、第二拼接电路器件以及以下模块:The encoding circuit 303 includes: a second extraction circuit device, a second shift circuit device, a second splicing circuit device, and the following modules:

指数字段编码模块402,用于以所述第二提取电路器件,在所述运算结果的真实指数字段中,按照最低位到最高位的顺序,提取得到位宽与指数编码字段的位宽相同的字段,根据所述位宽与指数编码字段的位宽相同的字段得到所述指数编码字段,并以提取所述位宽与指数编码字段的位宽相同的字段后的所述真实指数字段,作为所述regime编码字段对应的数值;The exponent field encoding module 402 is used for extracting the second extraction circuit device from the real exponent field of the operation result, in the order of the lowest bit to the highest bit, to obtain a bit width that is the same as the bit width of the exponent encoding field. field, the exponent encoding field is obtained according to the field whose bit width is the same as that of the exponent encoding field, and the real exponent field after the field whose bit width is the same as that of the exponent encoding field is extracted, as the value corresponding to the regular code field;

所述指数字段编码模块,还用于在所述中间数据的符号字段表示负数时,对所述位宽与指数编码字段的位宽相同的字段取反,得到所述指数编码字段;The exponent field encoding module is further configured to invert a field whose bit width is the same as that of the exponent encoding field when the symbol field of the intermediate data represents a negative number to obtain the exponent encoding field;

在所述中间数据的符号字段表示正数时,将所述位宽与指数编码字段的位宽相同的字段作为所述指数编码字段。When the sign field of the intermediate data represents a positive number, a field with the same bit width as that of the exponent encoding field is used as the exponent encoding field.

编码电路是解码电路的逆过程,也就是根据一个具体的中间数据类型输出一个Posit<总位宽,指数位宽>的编码,需要进行移位舍入操作。The encoding circuit is the inverse process of the decoding circuit, that is, according to a specific intermediate data type, it outputs a Posit<total bit width, index bit width> encoding, which needs to be shifted and rounded.

指数编码字段指的是表示运算结果的Posit浮点数的指数字段。The exponent encoding field refers to the exponent field of the Position floating-point number representing the operation result.

真实指数字段中,regime指数在高位,指数字段在低位,运算结果Posit浮点数的格式确定了指数编码字段的位宽,从而可以从真实指数字段中快速地提取出指数编码字段。例如,假设真实指数字段是11101011,表示运算结果的Posit浮点数的指数位宽是2,直接提取得到11作为指数编码字段,剩余的111010作为待转换为regime编码字段的regime指数。In the real exponent field, the regular exponent is in the high position and the exponent field is in the low position. The format of the Posit floating point number of the operation result determines the bit width of the exponent encoding field, so that the exponent encoding field can be quickly extracted from the real exponent field. For example, assuming that the real exponent field is 11101011, and the exponent bit width of the Posit floating-point number representing the operation result is 2, 11 is directly extracted as the exponent coding field, and the remaining 111010 is used as the regime exponent to be converted into the regime coding field.

regime格式确定模块403,根据所述运算结果的符号字段和所述regime编码字段的符号,确定所述regime编码字段的填充格式;Regime format determination module 403, according to the symbol field of described operation result and the symbol of described regime coding field, determine the filling format of described regime coding field;

regime编码字段指的是表示运算结果的Posit浮点数的regime字段。The regime encoding field refers to the regime field of the Posit floating point number representing the operation result.

由于regime取值计算子模块对反向前导零检测电路器件输出的反码取反,添加上regime字段的真实符号,得到regime字段的取值字段,或者regime取值计算子模块对反向前导零检测电路器件输出的反码,添加上regime字段的真实符号,得到的regime字段的取值字段,因此运算结果对应的中间数据中的真实指数字段中的regime字段的取值字段,携带了regime编码字段的符号,因此编码电路可以在提取指数编码字段的真实指数字段中,根据regime字段的取值字段直接获得regime编码字段的符号。Because the regime value calculation sub-module inverts the inverse code output by the reverse leading zero detection circuit device, adds the real symbol of the regime field, and obtains the value field of the regime field, or the regime value calculation sub-module reverses the leading zero. Detect the inverse code output by the circuit device, add the real symbol of the regime field, and obtain the value field of the regime field. Therefore, the value field of the regime field in the real exponent field in the intermediate data corresponding to the operation result carries the regime code. Therefore, the coding circuit can directly obtain the symbol of the regime coding field according to the value field of the regime field in the real exponent field of the extracted exponent coding field.

进一步确定regime编码字段在运算结果的Posit浮点数中的表现形式,还需要结合运算结果的Posit浮点数的符号,即中间数据的符号,也是中间数据的符号字段。To further determine the representation of the regime encoding field in the Posit floating-point number of the operation result, it is also necessary to combine the sign of the Posit floating-point number of the operation result, that is, the symbol of the intermediate data, which is also the symbol field of the intermediate data.

填充格式指的是:根据regime编码字段的符号和Posit浮点数的符号(符号字段)确定的,regime编码字段是前导一还是前导零的形式。如果Posit浮点数是正数,regime编码字段也是正数,则填充10;如果Posit浮点数是正数,regime是编码字段负数,则填充01;如果Posit浮点数是负数,regime编码字段是正数,则填充01;如果Posit浮点数是负数,regime编码字段也是负数,则填充10。The padding format refers to whether the regime encoding field is in the form of a leading one or a leading zero, determined according to the sign of the regime encoding field and the sign (sign field) of the Posit floating point number. If the Posit floating point number is positive and the regime encoding field is also positive, fill in 10; if the Posit floating point number is positive and the regime is a negative encoding field, fill in 01; if the Posit floating point number is negative and the regime encoding field is positive, fill in 01; if the Posit floating point number is negative and the registry encoding field is also negative, then fill with 10.

regime字段编码模块404,用于以所述第二拼接电路器件,将所述填充格式、所述指数编码字段、所述运算结果的第一尾数字段以及所述运算结果的保护位字段依次拼接,得到拼接字段,并以所述第二移位电路器件,依据所述regime编码字段对应的数值,将所述拼接字段算术右移,得到所述regime编码字段;The regime field encoding module 404 is used for sequentially splicing the padding format, the exponent encoding field, the first mantissa field of the operation result and the protection bit field of the operation result with the second splicing circuit device, Obtaining the splicing field, and with the second shift circuit device, according to the numerical value corresponding to the regime encoding field, the splicing field is arithmetically shifted to the right to obtain the regime encoding field;

拼接字段的最低三位是保护位字段,以保证按照填充格式填充时,对整个拼接字段的输入保护。The lowest three bits of the splicing field are the protection bit fields to ensure the input protection of the entire splicing field when filling according to the padding format.

示例地,假设Posit浮点数是正数,regime编码字段是正数,填充格式是10,指数编码字段是11,运算结果的第一尾数字段是110111,得到拼接字段是10|11|110111|000,regime编码字段对应的值是3,需要将拼接字段11110111 000算术右移3位,得到11110|11|110|111。尾数字段的111经过保护位,保护位最后形成111。从而直接得到regime编码字段11110。保护位用于保护Posit浮点数的精度。Posit浮点数标准中规定了三位保护位GRS分别称作Guard,Round,Sticky。For example, assuming that the Posit floating point number is a positive number, the registry encoding field is a positive number, the padding format is 10, the exponent encoding field is 11, the first mantissa field of the operation result is 110111, the concatenated field is 10|11|110111|000, and the regime The value corresponding to the encoding field is 3, and the splicing field 11110111 000 needs to be arithmetically shifted 3 bits to the right to obtain 11110|11|110|111. The 111 of the mantissa field passes through the protection bit, and the protection bit finally forms 111. Thus, the regime code field 11110 is directly obtained. Guard bits are used to protect the precision of Posit floating point numbers. The Posit floating-point number standard specifies three protection bits GRS called Guard, Round, and Sticky respectively.

若计算指令规定的计算结果Posit浮点数Posit<12,2>的总位宽是12bit,则需要对1111110 11110111进行舍入,舍入后的拼接字段是1111110 11110,在舍入过程中,111经过了保护位000,000分别对应GRS位,即S位,S位固定为1。If the total bit width of the calculation result Posit<12,2> specified by the calculation instruction is 12 bits, then 1111110 11110111 needs to be rounded, and the rounded concatenated field is 1111110 11110. During the rounding process, 111 passes through The protection bits 000 and 000 correspond to the GRS bits, that is, the S bit, and the S bit is fixed to 1.

浮点数结果确定模块405,用于利用所述保护位字段对向右移位后的所述拼接字段进行舍入操作,并对进行舍入操作后的所述拼接字段的最高位添加所述运算结果的符号字段,得到所述指定格式的Posit浮点数。A floating-point number result determination module 405, configured to perform a rounding operation on the right-shifted splicing field by using the guard bit field, and add the operation to the highest bit of the rounded splicing field The sign field of the result, obtains the Position floating point number in the specified format.

舍入操作可以理解为二进制的“四舍五入”操作。The rounding operation can be understood as a binary "rounding" operation.

根据Posit浮点数是正数,中间数据的符号字段是1,在舍入后的拼接字段111111011110的最高位拼接上符号位,得到指定格式的运算结果Posit浮点数11111110 11110。According to the positive number of the Posit floating point number, the sign field of the intermediate data is 1, and the sign bit is spliced in the highest bit of the rounded concatenation field 111111011110 to obtain the operation result of the specified format Posit floating point number 11111110 11110.

根据Posit的标准规范,编码电路对中间数据的编码过程采取饱和操作。According to the standard specification of Posit, the encoding circuit takes a saturation operation on the encoding process of the intermediate data.

所述浮点数结果确定模块包括:The floating point result determination module includes:

保护位子模块,用于在向右移位后的所述拼接字段的每一位都为0时,在向右移位后的所述拼接字段的最低位加1,在向右移位后的所述拼接字段的所有值都为1时,保持向右移位后的所述拼接字段不变;The protection bit submodule is used to add 1 to the lowest bit of the splicing field after shifting to the right when each bit of the splicing field after shifting to the right is 0, and When all the values of the splicing field are 1, keep the splicing field after shifting to the right unchanged;

所述保护位子模块,还用于在向右移位后的所述拼接字段中的任意两位的取值不相同,并且所述保护位的值大于4时,在向右移位后的所述拼接字段的最低位加1,或在向右移位后的所述拼接字段中的任意两位不相同,所述保护位的值等于4时,且向右移位后的所述拼接字段的最低位是1时,在向右移位后的所述拼接字段的最低位加1。The protection bit submodule is further configured to, when the values of any two bits in the splicing field shifted to the right are not the same, and the value of the protection bit is greater than 4, when the value of the protection bit shifted to the right is greater than 4. The lowest bit of the splicing field is added by 1, or any two bits in the splicing field after shifting to the right are not the same, when the value of the protection bit is equal to 4, and the splicing field after shifting to the right When the lowest bit of is 1, add 1 to the lowest bit of the spliced field after shifting to the right.

右移位后的所述拼接字段中的任意两位的取值不相同是,除了右移位后的所述拼接字段是00000……0和11111……1的形式外,其他所有形式拼接字段。The value of any two bits in the right-shifted splicing field is different, except that the right-shifted splicing field is in the form of 00000...0 and 11111...1, all other forms of splicing field .

Posit的标准规范了,在编码时不考虑特殊编码(无穷数编码和零值编码)时,正的Posit浮点数最小值的编码是00000……01,正的Posit浮点数最大值的编码是011111……1,负的Posit浮点数在其绝对值最大时,编码是1111111……1,负的Posit浮点数在其绝对值最小时,编码是10000……01,饱和操作操作是,在编码后的数小于Posit浮点数最小值的编码时,取Posit浮点数最小值的编码,即00000……01;在编码后的数小于Posit浮点数最大值的编码时,取Posit浮点数最大值的编码,即1111111……1。The standard of Posit is standardized. When special encoding (infinite number encoding and zero value encoding) is not considered during encoding, the encoding of the minimum value of positive Posit floating-point numbers is 00000...01, and the encoding of the maximum value of positive Posit floating-point numbers is 011111 ...... 1, when the absolute value of the negative Posit floating point number is the largest, the encoding is 1111111... 1, when the absolute value of the negative Posit floating point number is the smallest, the encoding is 10000...... 01, the saturation operation is, after encoding When the number is less than the encoding of the minimum value of the Posit floating-point number, the encoding of the minimum value of the Posit floating-point number is taken, that is, 00000... , which is 1111111...1.

本申请实施例提出的Posit浮点数处理器,利用解码电路,将根据计算指令得到的Posit浮点数转换为补码形式的中间数据,中间数据包含了表示特殊Posit浮点数的无穷数字段和零值字段,以使运算电路和编码电路在计算参数或计算结果是特殊Posit浮点数时,可以直接输出表示特殊Posit浮点数的无穷数编码字段或零值编码字段,提高了Posit浮点数处理器的输出效率。The Posit floating-point number processor proposed by the embodiment of the present application uses a decoding circuit to convert the Posit floating-point number obtained according to the calculation instruction into intermediate data in complement form, where the intermediate data includes an infinite number field and a zero value representing a special Posit floating-point number field, so that when the calculation parameter or the calculation result is a special Posit floating point number, the arithmetic circuit and the encoding circuit can directly output the infinite number encoding field or zero value encoding field representing the special Posit floating point number, which improves the output of the Posit floating point number processor efficiency.

运算电路可以直接使用中间数据中的真实指数字段、第一尾数字段进行运算,而在Posit浮点数的编码规则,对Posit浮点数的组成字段进行提取和拼接后,就可得到真实指数字段和第一尾数字段,真实指数字段和第一尾数字段为补码形式的定点数,多个中间数据根据计算指令进行运算后,得到的中间数据表示的运算结果,仍然是补码形式的定点数,编码电路只需按照CPU处理器指定的格式,将补码形式的定点数转换为Posit浮点数的编码格式,就可以完成Posit浮点数的编码。上述过程不需要将Posit浮点数转换为原码,再将原码转换为Posit浮点数,简化了Posit浮点数的处理操作。避免了将Posit浮点数转换为原码,计算时却需要补码,而导致的计算冗余和浪费。The arithmetic circuit can directly use the real exponent field and the first mantissa field in the intermediate data for operation, and in the coding rules of Posit floating point numbers, after extracting and splicing the constituent fields of the Posit floating point number, the real exponent field and the first mantissa field can be obtained. The one-mantissa field, the real exponent field and the first mantissa field are fixed-point numbers in complement form. After multiple intermediate data are operated according to the calculation instructions, the operation result represented by the intermediate data is still the fixed-point number in complement form. The circuit only needs to convert the fixed-point number in complement form to the encoding format of Posit floating-point number according to the format specified by the CPU processor, and then the encoding of the Posit floating-point number can be completed. The above process does not need to convert the Posit floating point number into the original code, and then convert the original code into the Posit floating point number, which simplifies the processing operation of the Posit floating point number. It avoids the redundancy and waste of calculation caused by converting the Posit floating point number to the original code, but it needs to complement the calculation.

中间数据中的符号字段在运算电路中参与尾数字段的运算,直接输出运算结果的符号字段。可以直接用于运算电路中,对得到运算结果的符号,还可以用于编码电路中,得到regime编码字段,并直接作为最终表示运算结果的Posit浮点数的最高位,不用再考虑补码时,正负Posit浮点数的编码形式的差异,简化了Posit浮点数的处理操作。The sign field in the intermediate data participates in the operation of the mantissa field in the operation circuit, and directly outputs the sign field of the operation result. It can be directly used in the operation circuit, and the symbol of the operation result can also be used in the encoding circuit to obtain the regular code field, which can be directly used as the highest bit of the Posit floating-point number that finally represents the operation result. When the complement code is no longer considered, The difference in the encoding form of positive and negative Posit floating-point numbers simplifies the processing of Posit floating-point numbers.

中间数据中的保护位字段,用于运算电路中,对运算结果进行舍入操作,还可以用于编码电路中,对编码过程进行舍入操作,使Posit浮点数处理器的工作符合Posit浮点数的规范。The protection bit field in the intermediate data is used in the operation circuit to round the operation result, and it can also be used in the encoding circuit to round the encoding process, so that the work of the Posit floating point number processor conforms to the Posit floating point number. specification.

本说明书中的各个实施例均采用递进或说明的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。Each embodiment in this specification is described in a progressive or illustrative manner, and each embodiment focuses on the differences from other embodiments, and the same and similar parts between the various embodiments may be referred to each other.

尽管已描述了本申请实施例的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例做出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本申请实施例范围的所有变更和修改。Although the preferred embodiments of the embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once the basic inventive concepts are known. Therefore, the appended claims are intended to be construed to include the preferred embodiments as well as all changes and modifications that fall within the scope of the embodiments of the present application.

最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、装置或者终端设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、装置或者电路所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、装置或者电路中还存在另外的相同要素。Finally, it should also be noted that in this document, relational terms such as first and second are used only to distinguish one entity or operation from another, and do not necessarily require or imply these entities or that there is any such actual relationship or sequence between operations. Furthermore, the terms "comprising", "comprising" or any other variation thereof are intended to encompass a non-exclusive inclusion such that a process, apparatus or terminal device comprising a list of elements includes not only those elements, but also not expressly listed Other elements, or elements inherent to such a process, apparatus or circuit are also included. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in the process, device, or circuit that includes the element.

以上对本申请所提供的一种Posit浮点数处理器,进行了详细介绍,以上实施例的说明只是用于帮助理解本申请Posit浮点数处理器的工作原理;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。The above provides a detailed introduction to a Posit floating-point number processor provided by the present application. The descriptions of the above embodiments are only used to help understand the working principle of the Posit floating-point number processor of the present application; meanwhile, for those skilled in the art, According to the idea of the present application, there will be changes in the specific embodiments and application scope. In conclusion, the content of this specification should not be construed as a limitation on the present application.

Claims (10)

1. A Posit floating point number processor, comprising: a decoding circuit, an arithmetic circuit, and an encoding circuit;
the decoding circuit is used for acquiring a plurality of target Posit floating point numbers participating in operation according to a calculation instruction of the CPU, and converting the plurality of target Posit floating point numbers into intermediate data in a complementary code form corresponding to each target Posit floating point number; the intermediate data includes a plurality of fields: a sign field, a true exponent field, a first mantissa field, and a protection bit field;
the arithmetic circuit is used for carrying out arithmetic on a plurality of received intermediate data output by the decoding circuit according to the calculation instruction to obtain an arithmetic result represented by the intermediate data in a complementary code form;
and the coding circuit is used for converting the operation result into a Posit floating point number in a specified format according to the specified format in the calculation instruction.
2. The Posit floating point number processor of claim 1, wherein the decoding circuit comprises: a first exclusive-or device, a second exclusive-or device, an inverted leading zero detection circuit device, a first shift circuit device, a first splicing circuit device, a first extraction circuit device, and the following modules:
the register real symbol determining module is used for carrying out XOR operation on the highest bit of the target Posit floating point number and the second highest bit of the target Posit floating point number through the first XOR device to obtain a real symbol of a register field of the target Posit floating point number;
the region field unifying module is used for removing the highest bit and the second highest bit of the target Posite floating point number for the first time, removing the highest bit and the second lowest bit of the target Posite floating point number for the second time, and then performing XOR operation on the result of the first removal and the result of the second removal through the second XOR device to obtain a region unifying field;
the reverse leading zero detection circuit device is used for detecting the reverse leading zero value of the region field;
the extraction module is used for shifting out the highest three bits of the target Posit floating point number through the first shift circuit device and shifting left assigned numbers of the residual fields of the target Posit floating point number after the highest three bits are shifted out; the specified bit number is obtained according to the output of the reverse leading zero detection circuit device;
the extraction module is further configured to extract an exponent field and a second mantissa field of the target Posit floating point number from the left-shifted target Posit floating point number according to the bit width of the exponent field of the target Posit floating point number;
the real exponent determining module is used for negating the exponent field when the target Posit floating point number is a negative number, and splicing the exponent field or the negated exponent field with the value field of the register field through the first splicing circuit device to obtain and output a real exponent field in intermediate data corresponding to the target Posit floating point number;
a first mantissa field determining module, configured to perform zero padding on a low bit of the second mantissa field according to a maximum bit width of the first mantissa field to obtain a first mantissa field, and output the first mantissa field; the maximum bit width of the first mantissa field is obtained by subtracting the bit width of the sign bit of the target Posite floating point number from the total bit width of the target Posite floating point number, the bit width of the exponent field, and the minimum bit width of the register field;
a protection bit output module, configured to use a field with a value of 0 for each bit as the protection bit field, and output the protection bit field; the bit width of the protection bit field is 3.
3. The Posit floating point number processor of claim 1, wherein the intermediate data further comprises an infinity field and a zero value field; the decoding circuit further includes: an infinite number determining module and a zero value judging module;
the infinity determination module is configured to set an infinity number segment of intermediate data corresponding to the target Posit floating point number to true when the target Posit floating point number is an infinity number;
and the zero value judging module is used for setting a zero value field of intermediate data corresponding to the target Posit floating point number to be true when the target Posit floating point number is zero.
4. The Posit floating point number processor of claim 3, wherein the intermediate data further comprises a sign field; the decoding circuit further includes: a symbol judgment module;
and the symbol judgment module is used for determining the symbol of the target Posit floating point number according to the highest bit of the target Posit floating point number, taking the symbol of the target Posit floating point number as the symbol of the intermediate data corresponding to the target Posit floating point number, and outputting the symbol field of the intermediate data corresponding to the target Posit floating point number as the symbol of the intermediate data.
5. The Posit floating point number processor of claim 1, wherein the encoding circuit comprises: a second extraction circuit device, a second shift circuit device, a second stitching circuit device, and the following modules:
an exponent field encoding module, configured to extract, by the second extraction circuit device, a field with a bit width that is the same as a bit width of an exponent encoding field from a lowest bit to a highest bit in a true exponent field of the operation result, obtain the exponent encoding field according to the field with the bit width that is the same as the bit width of the exponent encoding field, and extract the true exponent field after the field with the bit width that is the same as the bit width of the exponent encoding field as a numerical value corresponding to the regime encoding field;
the region format determining module is used for determining the filling format of the region coding field according to the symbol field of the operation result and the symbol of the region coding field;
the region field coding module is used for sequentially splicing the filling format, the exponent coding field, the first mantissa field of the operation result and the protection bit field of the operation result by using the second splicing circuit device to obtain a spliced field, and arithmetically right-shifting the spliced field by using the second shifting circuit device according to a numerical value corresponding to the region coding field to obtain the region coding field;
and the floating point number result determining module is used for rounding the spliced field after right shifting by using the protection bit field, and adding the sign field of the operation result to the highest bit of the spliced field after rounding to obtain the Posite floating point number in the specified format.
6. The Posit floating point number processor of claim 5, wherein the encoding circuit further comprises an output module:
the output module is used for directly outputting the Posite floating point number in the specified format as an infinite number encoding field representing an infinite number when the infinite number field of the intermediate data is true;
the output module is further configured to directly output the Posite floating point number in the specified format as an infinity encoded field representing a zero value when the zero value field of the intermediate data is true.
7. The Posit floating point number processor of claim 2, wherein the inverted leading zero detection circuit device comprises an OR device, a first inverting device, a second inverting device;
the reverse leading zero detection circuit device is used for respectively carrying out negation operation on the 0 th bits of a plurality of input fields with the bit width of 2 by using the first negation device, and then respectively carrying out OR operation on a plurality of negation results and the 1 st bits of the plurality of input fields with the bit width of 2 by using the OR device to obtain the 0 th bits of a plurality of output fields; the input field with the bit width of 2 is obtained after the region unified field is processed by a binary circuit;
the reverse leading zero detection circuit device is further configured to perform an or operation on the 0 th bits of the input fields with the bit width of 2 and the 1 st bits of the input fields with the bit width of 2 by using the or device, respectively, to obtain the 1 st bits of the output fields;
the reverse leading zero detection circuit device is also used for splicing the output fields to obtain the inverted code of the value of the region uniform field.
8. The Posit floating point number processor of claim 7, wherein the regime value calculation module comprises:
the region value calculation submodule is used for negating the inverse code output by the reverse leading zero detection circuit device when the real symbol of the region field is positive, and then adding the real symbol of the region field to the highest bit of the inverse code output by the reversed reverse leading zero detection circuit device to obtain the value field of the region field;
and the region value calculation sub-module is further used for adding the real symbol of the region field to the highest bit of the inverse code output by the reverse leading zero detection circuit device when the real symbol of the region field is negative, so as to obtain the value field of the region field.
9. The Posit floating point number processor of claim 5, wherein the floating point number result determination module comprises:
a protection bit sub-module, configured to add 1 to the lowest bit of the right-shifted concatenation field when each bit of the right-shifted concatenation field is 0, and keep the right-shifted concatenation field unchanged when all values of the right-shifted concatenation field are 1;
the protection bit submodule is further configured to, when values of any two bits in the concatenation field after right shift are different and the value of the protection bit is greater than 4, add 1 to the lowest bit of the concatenation field after right shift, or when any two bits in the concatenation field after right shift are different, and when the value of the protection bit is equal to 4 and the lowest bit of the concatenation field after right shift is 1, add 1 to the lowest bit of the concatenation field after right shift.
10. The Posit floating point number processor of claim 5, wherein the exponent field encoding module is further configured to, when the sign field of the intermediate data represents a negative number, invert the field having the same bit width as the exponent encoded field to obtain the exponent encoded field;
and when the sign field of the intermediate data represents a positive number, taking the field with the bit width being the same as that of the exponent encoding field as the exponent encoding field.
CN202010348464.7A 2020-04-27 2020-04-27 A Posit Floating Point Processor Active CN111538473B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010348464.7A CN111538473B (en) 2020-04-27 2020-04-27 A Posit Floating Point Processor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010348464.7A CN111538473B (en) 2020-04-27 2020-04-27 A Posit Floating Point Processor

Publications (2)

Publication Number Publication Date
CN111538473A true CN111538473A (en) 2020-08-14
CN111538473B CN111538473B (en) 2023-05-30

Family

ID=71977242

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010348464.7A Active CN111538473B (en) 2020-04-27 2020-04-27 A Posit Floating Point Processor

Country Status (1)

Country Link
CN (1) CN111538473B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112667197A (en) * 2020-12-29 2021-04-16 中山大学 Parameterized addition and subtraction operation circuit based on POSIT floating point number format
CN112671411A (en) * 2020-12-29 2021-04-16 中山大学 Two-way conversion circuit of floating point data format based on IEEE754 and POSIT
CN114221766A (en) * 2022-02-18 2022-03-22 阿里云计算有限公司 Data encryption method, data decryption method and data encryption device
CN117785108A (en) * 2024-02-27 2024-03-29 芯来智融半导体科技(上海)有限公司 Method, system, equipment and storage medium for processing front derivative
CN118051200A (en) * 2024-03-08 2024-05-17 摩尔线程智能科技(北京)有限责任公司 Data format conversion device and method, electronic device, and computer storage medium

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5257215A (en) * 1992-03-31 1993-10-26 Intel Corporation Floating point and integer number conversions in a floating point adder
US6154760A (en) * 1995-11-27 2000-11-28 Intel Corporation Instruction to normalize redundantly encoded floating point numbers
CN101847087A (en) * 2010-04-28 2010-09-29 中国科学院自动化研究所 Reconfigurable transverse summing network structure for supporting fixed and floating points
CN102122240A (en) * 2011-01-20 2011-07-13 东莞市泰斗微电子科技有限公司 Data type conversion circuit
US20120215822A1 (en) * 2011-02-22 2012-08-23 Arm Limited Number format pre-conversion instructions
CN106990937A (en) * 2016-01-20 2017-07-28 南京艾溪信息科技有限公司 A kind of floating number processing unit
CN108628589A (en) * 2017-03-24 2018-10-09 畅想科技有限公司 Floating-point is converted to fixed point
CN109582355A (en) * 2017-09-29 2019-04-05 英特尔公司 Pinpoint floating-point conversion
US20200125991A1 (en) * 2018-10-18 2020-04-23 Facebook, Inc. Optimization of neural networks using hardware calculation efficiency

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5257215A (en) * 1992-03-31 1993-10-26 Intel Corporation Floating point and integer number conversions in a floating point adder
US6154760A (en) * 1995-11-27 2000-11-28 Intel Corporation Instruction to normalize redundantly encoded floating point numbers
CN101847087A (en) * 2010-04-28 2010-09-29 中国科学院自动化研究所 Reconfigurable transverse summing network structure for supporting fixed and floating points
CN102122240A (en) * 2011-01-20 2011-07-13 东莞市泰斗微电子科技有限公司 Data type conversion circuit
US20120215822A1 (en) * 2011-02-22 2012-08-23 Arm Limited Number format pre-conversion instructions
CN106990937A (en) * 2016-01-20 2017-07-28 南京艾溪信息科技有限公司 A kind of floating number processing unit
CN108628589A (en) * 2017-03-24 2018-10-09 畅想科技有限公司 Floating-point is converted to fixed point
CN109582355A (en) * 2017-09-29 2019-04-05 英特尔公司 Pinpoint floating-point conversion
US20200125991A1 (en) * 2018-10-18 2020-04-23 Facebook, Inc. Optimization of neural networks using hardware calculation efficiency

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
徐爱芸: "计算机中浮点数的溢出与规格化处理", 《黑龙江科技信息》 *
柴晓东: "计算机浮点运算的尾数处理", 《郑州牧业工程高等专科学校学报》 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112667197A (en) * 2020-12-29 2021-04-16 中山大学 Parameterized addition and subtraction operation circuit based on POSIT floating point number format
CN112671411A (en) * 2020-12-29 2021-04-16 中山大学 Two-way conversion circuit of floating point data format based on IEEE754 and POSIT
CN112667197B (en) * 2020-12-29 2023-07-14 中山大学 A Parameterized Addition and Subtraction Operation Circuit Based on POSIT Floating Point Format
CN114221766A (en) * 2022-02-18 2022-03-22 阿里云计算有限公司 Data encryption method, data decryption method and data encryption device
CN114221766B (en) * 2022-02-18 2022-05-20 阿里云计算有限公司 Data encryption method, data decryption method and data encryption device
CN117785108A (en) * 2024-02-27 2024-03-29 芯来智融半导体科技(上海)有限公司 Method, system, equipment and storage medium for processing front derivative
CN118051200A (en) * 2024-03-08 2024-05-17 摩尔线程智能科技(北京)有限责任公司 Data format conversion device and method, electronic device, and computer storage medium

Also Published As

Publication number Publication date
CN111538473B (en) 2023-05-30

Similar Documents

Publication Publication Date Title
CN111538473A (en) A Posit floating point processor
CN115934030B (en) Arithmetic logic unit, floating point number multiplication calculation method and equipment
CN107273090B (en) Approximate floating-point multiplier and floating-point multiplication oriented to neural network processor
CN102722352B (en) A kind of Booth multiplier
CN112639722A (en) Apparatus and method for accelerating matrix multiplication
US8577948B2 (en) Split path multiply accumulate unit
CN111538472B (en) Positt floating point number arithmetic processor and arithmetic processing system
CN106951211B (en) A Reconfigurable Fixed-Floating-Point Universal Multiplier
WO2022052625A1 (en) Fixed-point and floating-point converter, processor, method, and storage medium
CN109901813B (en) Floating point operation device and method
US20170293471A1 (en) Arithmetic units and related converters
CN104778026A (en) High-speed data format conversion part with SIMD and conversion method
Raveendran et al. A novel parametrized fused division and square-root POSIT arithmetic architecture
CN102378960B (en) Semiconductor integrated circuit and index calculation method
CN112527239B (en) Floating point data processing method and device
CN113377334B (en) Floating point data processing method and device and storage medium
CN111538474B (en) Division and evolution operation processor and operation processing system of Posit floating point number
Sasidharan et al. VHDL Implementation of IEEE 754 floating point unit
CN112667197B (en) A Parameterized Addition and Subtraction Operation Circuit Based on POSIT Floating Point Format
US20120259903A1 (en) Arithmetic circuit, arithmetic processing apparatus and method of controlling arithmetic circuit
CN201628951U (en) A high-speed floating-point normalization arithmetic unit
KR101922462B1 (en) A data processing apparatus and method for performing a shift function on a binary number
Kornerup Correcting the normalization shift of redundant binary representations
JP2018097864A (en) Leading zero anticipation
CN112671411B (en) Bidirectional conversion circuit of floating point data format based on IEEE754 and POSIT

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant