[go: up one dir, main page]

CN108052307B - A look-ahead computing method and system for the number of leading zeros in a floating-point unit of a processor - Google Patents

A look-ahead computing method and system for the number of leading zeros in a floating-point unit of a processor Download PDF

Info

Publication number
CN108052307B
CN108052307B CN201711207258.9A CN201711207258A CN108052307B CN 108052307 B CN108052307 B CN 108052307B CN 201711207258 A CN201711207258 A CN 201711207258A CN 108052307 B CN108052307 B CN 108052307B
Authority
CN
China
Prior art keywords
data
output
pair
leading zeros
bit
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.)
Active
Application number
CN201711207258.9A
Other languages
Chinese (zh)
Other versions
CN108052307A (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.)
Beijing Microelectronic Technology Institute
Mxtronics Corp
Original Assignee
Beijing Microelectronic Technology Institute
Mxtronics Corp
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 Beijing Microelectronic Technology Institute, Mxtronics Corp filed Critical Beijing Microelectronic Technology Institute
Priority to CN201711207258.9A priority Critical patent/CN108052307B/en
Publication of CN108052307A publication Critical patent/CN108052307A/en
Application granted granted Critical
Publication of CN108052307B publication Critical patent/CN108052307B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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/57Arithmetic logic units [ALU], i.e. arrangements or devices for performing two or more of the operations covered by groups G06F7/483 – G06F7/556 or for performing logical operations
    • G06F7/575Basic arithmetic logic units, i.e. devices selectable to perform either addition, subtraction or one of several logical operations, using, at least partially, the same circuitry

Landscapes

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

Abstract

The invention discloses a method and a system for advanced operation of leading zero quantity of a floating point unit of a processor. The method comprises the following steps of decoding operation to obtain the leading zero number of each 8-bit data: the data bit is 8n bit data A [8n-1:0]Sequentially dividing the high order into 8-bit groups according to the sequence from high order to low order, and decoding the number B of leading zeros in n 8-bit data through n 8-4 decoders respectivelym[3:0](ii) a Wherein, BmRepresenting the leading zero number of the m-th group of 8-bit data, wherein m is 1-n, and n is 1-8; obtaining data A [8n-1:0] by advanced operation and logic judgment of each stage of three stages]The number of leading zeros is that each level will carry out two bisection pairs to the input data, and the operation is carried out in parallel between each pair; where n is an odd number, the last pair has only one input data. The invention solves the problem of long time consumption of multi-group data accumulation and achieves the effect of rapidly giving the number of leading zeros.

Description

处理器浮点单元前导零数量的超前运算方法及系统A look-ahead computing method and system for the number of leading zeros in a floating-point unit of a processor

技术领域technical field

本发明属于浮点运算领域,尤其涉及一种处理器浮点单元前导零数量的超前运算方法及系统。The invention belongs to the field of floating-point operations, and in particular relates to a method and system for the advance operation of the number of leading zeros in a floating-point unit of a processor.

背景技术Background technique

前导零是指从二进制数据的最高位开始扫描截至到第一个1为止之间所出现的0的个数。确定前导零个数的作用是保持字符的长度一致,方便字符串排序。前导零预测通过对尾数减法结果的前导零预测来减少规格化移位运算所需要的时间,需要用到前导零计数部件。Leading zeros refer to the number of 0s that appear between the most significant bit of binary data and the first 1. The purpose of determining the number of leading zeros is to keep the length of the characters consistent and to facilitate string sorting. Leading zero prediction reduces the time required for normalized shift operations by predicting the leading zeros of the mantissa subtraction result, requiring the use of a leading zero counting component.

中国专利公开号CN 102664637A,公开日是2012年9月12日,名称为“确定二进制数据前导零个数的方法及装置”中公开了,对于一个32位数据的前导零运算,一种比较通用、简便的方法是,将其由高位至低位分成4组,8位数为一组,每组的数据经过一个编码器,编码器的输出则代表每个8位数据的前导零的个数,接下来依次判断这四个编码器的输出是否为8,然后经过累加运算得出前导零的个数。累加运算是前导零运算中较为普遍使用的方法,其缺点在于多个数据累加需要消耗较长的时间。Chinese Patent Publication No. CN 102664637A, the publication date is September 12, 2012, and the title is "Method and Device for Determining the Number of Leading Zeros in Binary Data". For a 32-bit data leading zero operation, a more general , The easy way is to divide it into 4 groups from high to low, 8-digit group is a group, the data of each group passes through an encoder, and the output of the encoder represents the number of leading zeros of each 8-bit data, Next, judge whether the output of these four encoders is 8 in turn, and then obtain the number of leading zeros through accumulation operation. The accumulation operation is a more commonly used method in the operation of leading zeros, and its disadvantage is that it takes a long time to accumulate multiple data.

发明内容SUMMARY OF THE INVENTION

本发明解决的技术问题是:克服现有技术的不足,提供一种处理器浮点单元前导零数量的超前运算方法及系统,解决了多组数据累加耗时较长的问题,达到了快速给出前导零数量的效果。The technical problem solved by the present invention is: to overcome the deficiencies of the prior art, to provide a method and system for the advance calculation of the number of leading zeros in the floating-point unit of a processor, to solve the problem that the accumulation of multiple groups of data takes a long time, and to achieve a fast delivery time. out the effect of the number of leading zeros.

本发明目的通过以下技术方案予以实现:根据本发明的一个方面,提供了一种处理器浮点单元前导零数量的超前运算方法,所述方法包括下列步骤:步骤100:译码运算,得到每8位数据的前导零个数:将数据位为8n位的数据A[8n-1:0]按照从高位到低位的顺序依次分为8位一组,分别通过n个8-4译码器译出n个8位数据中前导零的个数Bm[3:0];其中,Bm表示第m组8位数据的前导零个数,m=1~n,n=1~8;步骤200:通过三级中的每一级的超前运算和逻辑判断得到数据A[8n-1:0]的前导零个数,每一级中会对输入数据进行两两分对,各对之间并行开展运算;其中,n为奇数时,最后一对只有一个输入数据。The object of the present invention is achieved by the following technical solutions: According to one aspect of the present invention, a method for calculating the number of leading zeros in the floating point unit of a processor is provided, the method includes the following steps: Step 100: decoding operation, obtaining each The number of leading zeros of 8-bit data: Divide the data A[8n-1:0] whose data bits are 8n bits into 8-bit groups in order from high to low, and pass through n 8-4 decoders respectively Decode the number of leading zeros in the n 8-bit data B m [3:0]; wherein, B m represents the number of leading zeros in the mth group of 8-bit data, m=1~n, n=1~8; Step 200: Obtain the number of leading zeros of the data A[8n-1:0] through the advance operation and logical judgment of each of the three levels, and in each level, the input data will be paired in twos, and each pair will be matched. The operations are performed in parallel between them; among them, when n is an odd number, the last pair has only one input data.

上述处理器浮点单元前导零数量的超前运算方法中,步骤200包括以下步骤:步骤210:第一级输入为译码运算的结果Bm[3:0],输出为每16位或8位数据的前导零个数Bjk[4:0],逻辑判断依据为每对输入数据的最高位Bm[3],输出来自超前运算的结果和/或输入数据的低三位Bm[2:0];其中,k=j+1,j=1,3,5,7且j≤n;步骤220:第二级输入为第一级输出的结果Bjk[4:0],输出为每32位、16位或8位数据的前导零个数Bjkrs[5:0],逻辑判断依据为每对输入数据的最高位Bjk[4],输出来自超前运算的结果和/或输入数据的低四位Bjk[3:0];其中,k=j+1,r=j+2,s=j+3,j=1,5且j≤n;步骤230:第三级输入为第二级输出的结果Bjkrs[5:0],输出为8n位数据的前导零个数B;逻辑判断依据为每对输入数据的最高位Bjkrs[5],输出来自超前运算的结果和/或输入数据的低四位Bjkrs[4:0];其中,n=1~8。In the above calculation method for the number of leading zeros in the floating point unit of the processor, step 200 includes the following steps: Step 210: the first stage input is the result of the decoding operation B m [3:0], and the output is every 16 bits or 8 bits. The number of leading zeros B jk [4:0] of the data, the logic judgment is based on the highest bit B m [3] of each pair of input data, and the result from the advance operation and/or the lower three bits of the input data B m [2 :0]; wherein, k=j+1, j=1, 3, 5, 7 and j≤n; Step 220: The second stage input is the result B jk [4:0] of the first stage output, and the output is The number of leading zeros B jkrs [5:0] of each 32-bit, 16-bit or 8-bit data, the logical judgment is based on the highest bit B jk [4] of each pair of input data, and the result and/or input from the look-ahead operation are output. The lower four bits of the data B jk [3:0]; wherein, k=j+1, r=j+2, s=j+3, j=1,5 and j≤n; Step 230: third-level input It is the result B jkrs [5:0] output by the second stage, and the output is the leading zero number B of the 8n-bit data; the logic judgment is based on the highest bit B jkrs [5] of each pair of input data, and the output comes from the result of the advance operation. and/or the lower four bits of the input data B jkrs [4:0]; wherein, n=1˜8.

上述处理器浮点单元前导零数量的超前运算方法中,8-4译码器的译码原理为,当输入数据为8’b00000000时,输出数据为4’b1000;当输入数据为8’b00000001时,输出数据为4’b0111;当输入数据为8’b0000001x(x=0或1)时,输出数据为4’b0110;当输入数据为8’b000001xx时,输出数据为4’b0101;当输入数据为8’b00001xxx时,输出数据为4’b0100;当输入数据为8’b0001xxxx时,输出数据为4’b0011;当输入数据为8’b001xxxxx时,输出数据为4’b0010;当输入数据为8’b01xxxxxx时,输出数据为4’b0001;当输入数据为8’b1xxxxxxx时,输出数据为4’b0000。In the preceding calculation method of the number of leading zeros in the floating-point unit of the above-mentioned processor, the decoding principle of the 8-4 decoder is that when the input data is 8'b00000000, the output data is 4'b1000; when the input data is 8'b00000001 , the output data is 4'b0111; when the input data is 8'b0000001x (x=0 or 1), the output data is 4'b0110; when the input data is 8'b000001xx, the output data is 4'b0101; when the input data is 8'b000001xx When the data is 8'b00001xxx, the output data is 4'b0100; when the input data is 8'b0001xxxx, the output data is 4'b0011; when the input data is 8'b001xxxxx, the output data is 4'b0010; when the input data is When 8'b01xxxxxx, the output data is 4'b0001; when the input data is 8'b1xxxxxxx, the output data is 4'b0000.

上述处理器浮点单元前导零数量的超前运算方法中,数据Bm[3:0]的运算公式为:In the preceding operation method for the number of leading zeros in the floating-point unit of the processor, the operation formula of the data B m [3:0] is:

Bm[3]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|A[0]);B m [3]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|A[0]);

Bm[2]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|~A[0])&(A[3]|A[2]|~A[1])&(A[3]|~A[2])&(~A[3]);B m [2]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|~A[0])&(A[3]|A[2]|~A[1])&(A[3]|~A[2])&(~A[3]);

Bm[1]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|((A[1]|~A[0])&~A[1]))&(A[5]|~A[4])&(~A[5]);B m [1]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|((A[1]|~A[0] )&~A[1]))&(A[5]|~A[4])&(~A[5]);

Bm[0]=~(A[7]|(A[6]|A[5]|(A[4]|A[3]|(A[2]|A[1]|~A[0])&~A[2])&~A[4])&~A[6]);B m [0]=~(A[7]|(A[6]|A[5]|(A[4]|A[3]|(A[2]|A[1]|~A[0 ])&~A[2])&~A[4])&~A[6]);

其中,A[p]为数据A的第p+1位,Bm[q](q=0~3)为数据Bm的第q+1位;其中,p=0~7。Among them, A[p] is the p+1th bit of the data A, and Bm [q] (q=0~3) is the q+1th bit of the data Bm; wherein, p =0~7.

上述处理器浮点单元前导零数量的超前运算方法中,每一级逻辑判断中,对数据两两分对的方法为:当n=1时,B1即为运算的前导零数量,运算结束;当1<n≤8时,将Bm由高位到低位两两分为一对,各对之间并行开展第一级运算,当n为奇数时最后一对不足两个数据,则保留Bn不做运算,Bn的值直接传输给下一级,位数不足时高位补零;或当n=2时,B1和B2的运算结果B12即为运算的前导零数量,运算结束;当2<n≤8时,进入第二级逻辑判断,将第一级逻辑判断的输出结果Bjk(其中k=j+1;j=1,3,5,7且j≤n)由高位到低位两两分为一对,各对之间并行开展第二级逻辑判断,若最后一对不足两个数据,则保留一个数据不做运算直接传递给下一级,位数不足时高位补零,其中k=j+1;j=1,3,5,7且j≤n;或当2<n≤4时,B1234即为运算的前导零数量,运算结束;当4<n≤8时,进入第三级逻辑判断,对第二级逻辑判断的两个运算结果进行运算。In the preceding operation method for the number of leading zeros in the floating-point unit of the above-mentioned processor, in each level of logic judgment, the method for pairing the data is as follows: when n=1, B 1 is the number of leading zeros in the operation, and the operation ends. ; When 1<n≤8, divide B m into pairs from high to low, and carry out the first-level operation in parallel between each pair. When n is an odd number, the last pair is less than two data, then keep B n does not perform operation, the value of B n is directly transmitted to the next stage, and the high-order zeros are filled when the number of digits is insufficient; or when n=2, the operation result B 12 of B 1 and B 2 is the number of leading zeros of the operation. End; when 2<n≤8, enter the second-level logic judgment, and the output result of the first-level logic judgment B jk (where k=j+1; j=1, 3, 5, 7 and j≤n) Two pairs from high to low are divided into a pair, and the second-level logic judgment is carried out in parallel between each pair. If the last pair has less than two data, one data is reserved without operation and directly passed to the next level. When the number of digits is insufficient High-order zero-fill, where k=j+1; j=1, 3, 5, 7 and j≤n; or when 2<n≤4, B 1234 is the number of leading zeros in the operation, and the operation ends; when 4< When n≤8, enter the third-level logic judgment, and perform operations on the two operation results of the second-level logic judgment.

上述处理器浮点单元前导零数量的超前运算方法中,每一级超前运算包括:在第一级超前运算中,若高位数值Bj<8,则该对数据前导零个数为Bjk=5’b{00,Bj[2:0]};若高位数值Bj=8,而低位数值Bk<8,则该对数据前导零个数为Bjk=5’b{01,Bk[2:0]};若高位数值Bj=8,且低位数值Bk=8,则该对数据前导零个数为Bjk=5’b{10,000};当n为奇数时,最后一对只有Bn,只需在高位补零即可输出Bjk=5’b{0,Bn[3:0]};其中,k=j+1,j=1,3,5,7且j≤n;在第二级超前运算中,若高位数值Bjk<16,则该对数据前导零个数为Bjkrs=6’b{00,Bjk[3:0]};若高位数值Bjk=16,而低位数值Brs<16,则该对数据前导零个数为Bjkrs=6’b{01,Brs[3:0]};若高位数Bjk=16,且低位数值Brs=16,则该对数据前导零个数为Bjkrs=6’b{100,000};当最后一对只有一个数据Bjk时,只需在高位补零即可输出Bjkrs=6’b{0,Bjk[4:0]};其中,k=j+1,r=j+2,s=j+3,j=1,5且j≤n;在第三级超前运算中,若高位数值B1234<32,则该对数据前导零个数为B=7’b{00,B1234[4:0]};若高位数值B1234=32,而低位数值B5678<32,则该对数据前导零个数为B=7’b{01,B5678[4:0]};若高位数B1234=32,且低位数值B5678=32,则该对数据前导零个数为B=7’b{1,000,000}。In the above-mentioned advanced operation method for the number of leading zeros in the floating-point unit of the processor, each stage of the advanced operation includes: in the first-level advanced operation, if the high-order value B j <8, then the number of leading zeros of the pair of data is B jk = 5'b{00,B j [2:0]}; if the high-order value B j = 8, and the low-order value B k <8, then the number of leading zeros in the pair of data is B jk =5'b{01,B k [2:0]}; if the high-order value B j = 8, and the low-order value B k = 8, the number of leading zeros of the pair of data is B jk = 5'b{10,000}; when n is an odd number, the last A pair only has B n , only need to fill the high-order zeros to output B jk =5'b{0,B n [3:0]}; among them, k=j+1, j=1,3,5,7 And j≤n; in the second-level look-ahead operation, if the high-order value B jk <16, the number of leading zeros of the pair of data is B jkrs = 6'b{00,B jk [3:0]}; if the high-order value The value B jk = 16, and the low-order value B rs <16, then the number of leading zeros in the pair of data is B jkrs = 6'b{01, B rs [3:0]}; if the high-order value B jk = 16, and The low-order value B rs = 16, then the number of leading zeros in the pair of data is B jkrs = 6'b{100,000}; when the last pair has only one data B jk , just fill in the high-order zeros to output B jkrs = 6 'b{0,B jk [4:0]}; where k=j+1, r=j+2, s=j+3, j=1,5 and j≤n; run ahead at the third stage , if the high-order value B 1234 <32, the number of leading zeros in the pair of data is B=7'b{00,B 1234 [4:0]}; if the high-order value B 1234 =32, and the low-order value B 5678 < 32, the number of leading zeros in the pair of data is B=7'b{01,B 5678 [4:0]}; if the high-order value B 1234 =32, and the low-order value B 5678 =32, then the pair of data has leading zeros The number is B=7'b{1,000,000}.

上述处理器浮点单元前导零数量的超前运算方法中,每一级逻辑判断包括:在第一级逻辑判断中,若Bj的最高位Bj[3]=0,则输出Bjk=5’b{00,Bj[2:0]};若Bj[3]=1,而Bk[3]=0,则输出Bjk=5’b{01,Bk[2:0]};若Bj[3]=1,且Bk[3]=1,则输出Bjk=5’b{10,000};当n为奇数时,最后一对只有Bn,输出Bjk=5’b{0,Bn[3:0]};其中,k=j+1,j=1,3,5,7且j≤n;在第二级逻辑判断中,若Bjk[4]=0,则输出Bjkrs=6’b{00,Bjk[3:0]};若Bjk[4]=1,而Brs[4]=0,则输出Bjkrs=6’b{01,Brs[3:0]};若Bjk[4]=1,且Brs[4]=1,则输出Bjkrs=6’b{100,000};当最后一对只有一个数据Bjk时,输出Bjkrs=6’b{0,Bjk[4:0]};其中,k=j+1,r=j+2,s=j+3,j=1,5且j≤n;在第三级逻辑判断中,,若B1234[5]=0,则输出B=7’b{00,B1234[4:0]};若B1234[5]=1而B5678[5]=0,则输出B=7’b{01,B5678[4:0]};若B1234[5]=1且B5678[5]=1,则输出B=7’b{1,000,000}。当只存在B1234,没有B5678时,前导零个数B=B1234In the preceding calculation method for the number of leading zeros in the floating-point unit of the above-mentioned processor, each level of logical judgment includes: in the first level of logical judgment, if the highest bit of B j B j [3]=0, then output B jk =5 'b{00, Bj [2:0]}; if Bj [3]=1, and Bk [3]=0, then output Bjk =5'b{01, Bk [2:0] }; If B j [3]=1, and B k [3]=1, then output B jk =5'b{10,000}; when n is odd, the last pair has only B n , output B jk =5 'b{0,B n [3:0]}; where k=j+1, j=1, 3, 5, 7 and j≤n; in the second-level logical judgment, if B jk [4] =0, then output B jkrs =6'b{00,B jk [3:0]}; if B jk [4]=1, and B rs [4]=0, then output B jkrs =6'b{ 01,B rs [3:0]}; if B jk [4]=1, and B rs [4]=1, then output B jkrs =6'b{100,000}; when the last pair has only one data B jk , output B jkrs =6'b{0,B jk [4:0]}; where k=j+1, r=j+2, s=j+3, j=1,5 and j≤n ;In the third-level logical judgment, if B 1234 [5]=0, then output B=7'b{00,B 1234 [4:0]}; if B 1234 [5]=1 and B 5678 [ 5]=0, then output B=7'b{01,B 5678 [4:0]}; if B 1234 [5]=1 and B 5678 [5]=1, then output B=7'b{1,000,000 }. When only B 1234 exists and no B 5678 exists, the number of leading zeros B=B 1234 .

根据本发明的另一方面,还提供了一种处理器浮点单元前导零数量的超前运算系统,包括:第一模块,用于译码运算得到每8位数据的前导零个数:将数据位为8n位的数据A[8n-1:0]按照从高位到低位的顺序依次分为8位一组,分别通过n个8-4译码器译出n个8位数据中前导零的个数Bm[3:0];其中,Bm表示第m组8位数据的前导零个数,m=1~n,n=1~8;第二模块,用于通过三级中的每一级的超前运算和逻辑判断得到数据A[8n-1:0]的前导零个数,每一级中会对输入数据进行两两分对,各对之间并行开展运算;其中,n为奇数时,最后一对只有一个输入数据。According to another aspect of the present invention, there is also provided an advanced operation system for the number of leading zeros in a floating-point unit of a processor, including: a first module, used for decoding and operation to obtain the number of leading zeros per 8-bit data: The data A[8n-1:0] with 8n bits is divided into groups of 8 bits in order from high bits to low bits, and the leading zeros in the n 8-bit data are decoded by n 8-4 decoders respectively. The number B m [3:0]; wherein, B m represents the number of leading zeros of the mth group of 8-bit data, m=1~n, n=1~8; the second module is used to pass the The number of leading zeros of the data A[8n-1:0] is obtained by the advance operation and logical judgment of each level. In each level, the input data will be divided into two pairs, and each pair will be operated in parallel; among them, n When odd, the last pair has only one input data.

上述处理器浮点单元前导零数量的超前运算方系统中,8-4译码器的译码原理为,当输入数据为8’b00000000时,输出数据为4’b1000;当输入数据为8’b00000001时,输出数据为4’b0111;当输入数据为8’b0000001x时,输出数据为4’b0110;当输入数据为8’b000001xx时,输出数据为4’b0101;当输入数据为8’b00001xxx时,输出数据为4’b0100;当输入数据为8’b0001xxxx时,输出数据为4’b0011;当输入数据为8’b001xxxxx时,输出数据为4’b0010;当输入数据为8’b01xxxxxx时,输出数据为4’b0001;当输入数据为8’b1xxxxxxx时,输出数据为4’b0000;其中,x=0或1。In the preceding arithmetic system with the number of leading zeros in the floating-point unit of the above-mentioned processor, the decoding principle of the 8-4 decoder is that when the input data is 8'b00000000, the output data is 4'b1000; when the input data is 8' When b00000001, the output data is 4'b0111; when the input data is 8'b0000001x, the output data is 4'b0110; when the input data is 8'b000001xx, the output data is 4'b0101; when the input data is 8'b00001xxx , the output data is 4'b0100; when the input data is 8'b0001xxxx, the output data is 4'b0011; when the input data is 8'b001xxxxx, the output data is 4'b0010; when the input data is 8'b01xxxxxx, the output The data is 4'b0001; when the input data is 8'b1xxxxxxx, the output data is 4'b0000; where x=0 or 1.

上述处理器浮点单元前导零数量的超前运算方系统中,数据Bm[3:0]的运算公式为:In the preceding operator system with the number of leading zeros in the floating-point unit of the processor, the operation formula of the data B m [3:0] is:

Bm[3]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|A[0]);B m [3]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|A[0]);

Bm[2]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|~A[0])&(A[3]|A[2]|~A[1])&(A[3]|~A[2])&(~A[3]);B m [2]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|~A[0])&(A[3]|A[2]|~A[1])&(A[3]|~A[2])&(~A[3]);

Bm[1]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|((A[1]|~A[0])&~A[1]))&(A[5]|~A[4])&(~A[5]);B m [1]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|((A[1]|~A[0] )&~A[1]))&(A[5]|~A[4])&(~A[5]);

Bm[0]=~(A[7]|(A[6]|A[5]|(A[4]|A[3]|(A[2]|A[1]|~A[0])&~A[2])&~A[4])&~A[6]);B m [0]=~(A[7]|(A[6]|A[5]|(A[4]|A[3]|(A[2]|A[1]|~A[0 ])&~A[2])&~A[4])&~A[6]);

其中,A[p]为数据A的第p+1位,Bm[q](q=0~3)为数据Bm的第q+1位;其中,p=0~7。Among them, A[p] is the p+1th bit of the data A, and Bm [q] (q=0~3) is the q+1th bit of the data Bm; wherein, p =0~7.

本发明与现有技术相比具有如下有益效果:Compared with the prior art, the present invention has the following beneficial effects:

(1)本发明使用的8-4译码器相比常用的8-3译码器能够直接提供选择器的控制位和输出位,以很小的面积代价换取了高效的运算速度。(1) Compared with the commonly used 8-3 decoder, the 8-4 decoder used in the present invention can directly provide the control bits and output bits of the selector, and exchange for high-efficiency operation speed with a small area cost.

(2)对数据两两分对运算是本发明降低运算速度的一种辅助手段,可以让每一级中的数据按对并行运算,8n位数据分对运算需要的级数是log2n,而逐个运算所需的运算级数是n-1,每一级的运算时间基本相同,所以运算的数据位越大优势越明显。( 2 ) The pairwise operation of the data is a kind of auxiliary means for reducing the operation speed of the present invention, which can allow the data in each level to be operated in parallel by pairs. The number of operation stages required for one-by-one operation is n-1, and the operation time of each stage is basically the same, so the larger the data bits of the operation, the more obvious the advantage.

(3)本发明采用超前运算的优势在于,在得到8-4译码器的译码结果时,输入数据的前导零数量就已确定,只需配合控制位选择确定的结果输出,而不需要再做加法运算,是本发明获取高效运算速度的核心所在。(3) The advantage of adopting the advanced operation of the present invention is that when the decoding result of the 8-4 decoder is obtained, the number of leading zeros of the input data has been determined, and the determined result output only needs to be selected in conjunction with the control bit, without the need for The addition operation is performed again, which is the core of the present invention to obtain high-efficiency operation speed.

附图说明Description of drawings

通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are for the purpose of illustrating preferred embodiments only and are not to be considered limiting of the invention. Also, the same components are denoted by the same reference numerals throughout the drawings. In the attached image:

图1是本发明实施例提供的处理器浮点单元前导零数量的超前运算方法的功能框图。FIG. 1 is a functional block diagram of a method for leading zeros in a processor floating-point unit provided by an embodiment of the present invention.

具体实施方式Detailed ways

下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。需要说明的是,在不冲突的情况下,本发明中的实施例及实施例中的特征可以相互组合。下面将参考附图并结合实施例来详细说明本发明。Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that the present disclosure will be more thoroughly understood, and will fully convey the scope of the present disclosure to those skilled in the art. It should be noted that the embodiments of the present invention and the features of the embodiments may be combined with each other under the condition of no conflict. The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.

图1是本发明实施例提供的处理器浮点单元前导零数量的超前运算方法的功能框图。如图1所述,该处理器浮点单元前导零数量的超前运算方法包括下列步骤:FIG. 1 is a functional block diagram of a method for leading zeros in a processor floating-point unit provided by an embodiment of the present invention. As shown in FIG. 1 , the advanced operation method for the number of leading zeros in the floating-point unit of the processor includes the following steps:

步骤100:译码运算,得到每8位数据的前导零个数:将数据位为8n位数据A[8n-1:0]按照从高位到低位的顺序依次分为8位一组,分别通过n个8-4译码器译出n个8位数据中前导零的个数Bm[3:0];其中,Bm表示第m组8位数据的前导零个数,m=1~n,n=1~8;Step 100: Decoding operation to obtain the number of leading zeros of each 8-bit data: Divide the data bits into 8n-bit data A[8n-1:0] according to the order from high to low. The n 8-4 decoders decode the number of leading zeros in the n 8-bit data B m [3:0]; wherein, B m represents the number of leading zeros in the mth group of 8-bit data, m=1~ n, n=1~8;

步骤200:通过三级中的每一级的超前运算和逻辑判断得到数据A[8n-1:0]的前导零个数,每一级中会对输入数据进行两两分对,各对之间并行开展运算;其中,n为奇数时,最后一对只有一个输入数据。Step 200: Obtain the number of leading zeros of the data A[8n-1:0] through the advance operation and logical judgment of each of the three levels, and in each level, the input data will be paired in twos, and each pair will be matched. The operations are performed in parallel between them; among them, when n is an odd number, the last pair has only one input data.

步骤200包括以下步骤:Step 200 includes the following steps:

步骤210:第一级输入为译码运算的结果Bm[3:0],输出为每16位或8位数据的前导零个数Bjk[4:0],逻辑判断依据为每对输入数据的最高位Bm[3],输出来自超前运算的结果和/或输入数据的低三位Bm[2:0];其中,k=j+1,j=1,3,5,7且j≤n;Step 210: The input of the first stage is the result of the decoding operation B m [3:0], the output is the number of leading zeros B jk [4:0] of each 16-bit or 8-bit data, and the logical judgment is based on each pair of inputs The highest bit B m [3] of the data, outputs the result from the look-ahead operation and/or the lower three bits B m [2:0] of the input data; where, k=j+1, j=1,3,5,7 and j≤n;

步骤220:第二级输入为第一级输出的结果Bjk[4:0],输出为每32位、16位或8位数据的前导零个数Bjkrs[5:0],逻辑判断依据为每对输入数据的最高位Bjk[4],输出来自超前运算的结果和/或输入数据的低四位Bjk[3:0];其中,k=j+1,r=j+2,s=j+3,j=1,5且j≤n;Step 220: The input of the second stage is the result B jk [4:0] of the output of the first stage, and the output is the number of leading zeros B jkrs [5:0] of each 32-bit, 16-bit or 8-bit data, the logic judgment basis For the highest bit B jk [4] of each pair of input data, output the result from the look-ahead operation and/or the lower four bits B jk [3:0] of the input data; where k=j+1, r=j+2 , s=j+3, j=1,5 and j≤n;

步骤230:第三级输入为第二级输出的结果Bjkrs[5:0],输出为8n位数据的前导零个数B;逻辑判断依据为每对输入数据的最高位Bjkrs[5],输出来自前运算的结果和/或输入数据的低四位Bjkrs[4:0];其中,n=1~8。Step 230: The input of the third stage is the result B jkrs [5:0] of the output of the second stage, and the output is the leading zero number B of the 8n-bit data; the logic judgment basis is the highest bit B jkrs [5] of each pair of input data , output the lower four bits B jkrs [4:0] from the result of the previous operation and/or the input data; wherein, n=1˜8.

上述实施例中,8-4译码器的译码原理为,当输入数据为8’b00000000时,输出数据为4’b1000;当输入数据为8’b00000001时,输出数据为4’b0111;当输入数据为8’b0000001x(x=0或1)时,输出数据为4’b0110;当输入数据为8’b000001xx时,输出数据为4’b0101;当输入数据为8’b00001xxx时,输出数据为4’b0100;当输入数据为8’b0001xxxx时,输出数据为4’b0011;当输入数据为8’b001xxxxx时,输出数据为4’b0010;当输入数据为8’b01xxxxxx时,输出数据为4’b0001;当输入数据为8’b1xxxxxxx时,输出数据为4’b0000。数据Bm[3:0]的运算公式为:In the above embodiment, the decoding principle of the 8-4 decoder is that when the input data is 8'b00000000, the output data is 4'b1000; when the input data is 8'b00000001, the output data is 4'b0111; When the input data is 8'b0000001x (x=0 or 1), the output data is 4'b0110; when the input data is 8'b000001xx, the output data is 4'b0101; when the input data is 8'b00001xxx, the output data is 4'b0100; when the input data is 8'b0001xxxx, the output data is 4'b0011; when the input data is 8'b001xxxxx, the output data is 4'b0010; when the input data is 8'b01xxxxxx, the output data is 4'b0001; when the input data is 8'b1xxxxxxx, the output data is 4'b0000. The operation formula of data B m [3:0] is:

Bm[3]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|A[0]);B m [3]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|A[0]);

Bm[2]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|~A[0])&(A[3]|A[2]|~A[1])&(A[3]|~A[2])&(~A[3]);B m [2]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|~A[0])&(A[3]|A[2]|~A[1])&(A[3]|~A[2])&(~A[3]);

Bm[1]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|((A[1]|~A[0])&~A[1]))&(A[5]|~A[4])&(~A[5]);B m [1]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|((A[1]|~A[0] )&~A[1]))&(A[5]|~A[4])&(~A[5]);

Bm[0]=~(A[7]|(A[6]|A[5]|(A[4]|A[3]|(A[2]|A[1]|~A[0])&~A[2])&~A[4])&~A[6]);B m [0]=~(A[7]|(A[6]|A[5]|(A[4]|A[3]|(A[2]|A[1]|~A[0 ])&~A[2])&~A[4])&~A[6]);

其中,A[p](p=0~7)为数据A的第p+1位,Bm[q](q=0~3)为数据Bm的第q+1位。Among them, A[p] (p=0-7) is the p +1th bit of the data A, and Bm[q] (q=0-3) is the q+1th bit of the data Bm .

上述实施例中,每一级逻辑判断中,对数据两两分对的方法为:In the above-mentioned embodiment, in each level of logical judgment, the method for pairing data in pairs is as follows:

当n=1时,B1即为运算的前导零数量,运算结束;当1<n≤8时,将Bm由高位到低位两两分为一对,各对之间并行开展第一级运算,当n为奇数时最后一对不足两个数据,则保留Bn不做运算,Bn的值直接传输给下一级,位数不足时高位补零;或When n=1, B 1 is the number of leading zeros in the operation, and the operation ends; when 1<n≤8, divide B m into pairs from high to low, and carry out the first level in parallel between each pair operation, when n is an odd number, the last pair of data is less than two data, then keep B n for no operation, the value of B n is directly transmitted to the next level, and the high-order bits are filled with zeros when the number of digits is insufficient; or

当n=2时,B1和B2的运算结果B12即为运算的前导零数量,运算结束;当2<n≤8时,进入第二级逻辑判断,将第一级逻辑判断的输出结果Bjk(其中k=j+1;j=1,3,5,7且j≤n)由高位到低位两两分为一对,各对之间并行开展第二级逻辑判断,若最后一对不足两个数据,则保留一个数据不做运算直接传递给下一级,位数不足时高位补零,其中k=j+1;j=1,3,5,7且j≤n;或When n=2, the operation result B 12 of B 1 and B 2 is the number of leading zeros of the operation, and the operation ends; when 2<n≤8, enter the second-level logic judgment, and the output of the first-level logic judgment The result B jk (where k=j+1; j=1, 3, 5, 7 and j≤n) is divided into two pairs from high to low, and the second-level logical judgment is carried out in parallel between each pair. If a pair of data is less than two, keep one data and pass it directly to the next level without operation. When the number of digits is insufficient, the high-order bits are filled with zeros, where k=j+1; j=1, 3, 5, 7 and j≤n; or

当2<n≤4时,B1234即为运算的前导零数量,运算结束;当4<n≤8时,进入第三级逻辑判断,对第二级逻辑判断的两个运算结果进行运算。When 2<n≤4, B 1234 is the number of leading zeros of the operation, and the operation ends; when 4<n≤8, enter the third-level logic judgment, and operate on the two operation results of the second-level logic judgment.

上述实施例中,每一级超前运算包括:In the above embodiment, each level of look-ahead operation includes:

在第一级超前运算中,若高位数值Bj<8,则该对数据前导零个数为Bjk=5’b{00,Bj[2:0]};若高位数值Bj=8,而低位数值Bk<8,则该对数据前导零个数为Bjk=5’b{01,Bk[2:0]};若高位数值Bj=8,且低位数值Bk=8,则该对数据前导零个数为Bjk=5’b{10,000};当n为奇数时,最后一对只有Bn,只需在高位补零即可输出Bjk=5’b{0,Bn[3:0]};其中,k=j+1,j=1,3,5,7且j≤n;In the first-level look-ahead operation, if the high-order value B j <8, the number of leading zeros in the pair of data is B jk =5'b{00,B j [2:0]}; if the high-order value B j =8 , and the low-order value B k <8, then the number of leading zeros in the pair of data is B jk =5'b{01,B k [2:0]}; if the high-order value B j =8, and the low-order value B k = 8, then the number of leading zeros in the pair of data is B jk =5'b{10,000}; when n is an odd number, the last pair has only B n , and only need to fill in the high-order zeros to output B jk =5'b{ 0,B n [3:0]}; where k=j+1, j=1,3,5,7 and j≤n;

在第二级超前运算中,若高位数值Bjk<16,则该对数据前导零个数为Bjkrs=6’b{00,Bjk[3:0]};若高位数值Bjk=16,而低位数值Brs<16,则该对数据前导零个数为Bjkrs=6’b{01,Brs[3:0]};若高位数Bjk=16,且低位数值Brs=16,则该对数据前导零个数为Bjkrs=6’b{100,000};当最后一对只有一个数据Bjk时,只需在高位补零即可输出Bjkrs=6’b{0,Bjk[4:0]};其中,k=j+1,r=j+2,s=j+3,j=1,5且j≤n;In the second-level look-ahead operation, if the high-order value B jk <16, the number of leading zeros in the pair of data is B jkrs =6'b{00,B jk [3:0]}; if the high-order value B jk =16 , and the low-order value B rs <16, the number of leading zeros in the pair of data is B jkrs =6'b{01,B rs [3:0]}; if the high-order value B jk =16, and the low-order value B rs = 16, then the number of leading zeros in the pair of data is B jkrs = 6'b{100,000}; when the last pair has only one data B jk , it is only necessary to add zeros in the high bits to output B jkrs = 6'b{0, B jk [4:0]}; where k=j+1, r=j+2, s=j+3, j=1,5 and j≤n;

在第三级超前运算中,若高位数值B1234<32,则该对数据前导零个数为B=7’b{00,B1234[4:0]};若高位数值B1234=32,而低位数值B5678<32,则该对数据前导零个数为B=7’b{01,B5678[4:0]};若高位数B1234=32,且低位数值B5678=32,则该对数据前导零个数为B=7’b{1,000,000}。In the third-level look-ahead operation, if the high-order value B 1234 <32, the number of leading zeros in the pair of data is B=7'b{00,B 1234 [4:0]}; if the high-order value B 1234 =32, And the low-order value B 5678 <32, the number of leading zeros in the pair of data is B=7'b{01,B 5678 [4:0]}; if the high-order value B 1234 =32, and the low-order value B 5678 =32, Then the number of leading zeros in the pair of data is B=7'b{1,000,000}.

上述实施例中,每一级逻辑判断包括:In the above embodiment, each level of logical judgment includes:

在第一级逻辑判断中,若Bj的最高位Bj[3]=0,则输出Bjk=5’b{00,Bj[2:0]};若Bj[3]=1,而Bk[3]=0,则输出Bjk=5’b{01,Bk[2:0]};若Bj[3]=1,且Bk[3]=1,则输出Bjk=5’b{10,000};当n为奇数时,最后一对只有Bn,输出Bjk=5’b{0,Bn[3:0]};其中,k=j+1,j=1,3,5,7且j≤n;In the first-level logical judgment, if the highest bit of B j B j [3]=0, then output B jk =5'b{00,B j [2:0]}; if B j [3]=1 , and B k [3]=0, then output B jk =5'b{01,B k [2:0]}; if B j [3]=1, and B k [3]=1, then output B jk =5'b{10,000}; when n is an odd number, the last pair has only B n , and the output B jk =5'b{0,B n [3:0]}; where k=j+1, j=1,3,5,7 and j≤n;

在第二级逻辑判断中,若Bjk[4]=0,则输出Bjkrs=6’b{00,Bjk[3:0]};若Bjk[4]=1,而Brs[4]=0,则输出Bjkrs=6’b{01,Brs[3:0]};若Bjk[4]=1,且Brs[4]=1,则输出Bjkrs=6’b{100,000};当最后一对只有一个数据Bjk时,输出Bjkrs=6’b{0,Bjk[4:0]};其中,k=j+1,r=j+2,s=j+3,j=1,5且j≤n;In the second-level logical judgment, if B jk [4]=0, then output B jkrs =6'b{00,B jk [3:0]}; if B jk [4]=1, and B rs [ 4]=0, then output B jkrs =6'b{01,B rs [3:0]}; if B jk [4]=1, and B rs [4]=1, then output B jkrs =6'b{100,000}; when the last pair has only one data B jk , output B jkrs = 6'b{0, B jk [4:0]}; where k=j+1, r=j+2, s =j+3, j=1,5 and j≤n;

在第三级逻辑判断中,,若B1234[5]=0,则输出B=7’b{00,B1234[4:0]};若B1234[5]=1而B5678[5]=0,则输出B=7’b{01,B5678[4:0]};若B1234[5]=1且B5678[5]=1,则输出B=7’b{1,000,000}。当只存在B1234,没有B5678时,前导零个数B=B1234In the third-level logical judgment, if B 1234 [5]=0, then output B=7'b{00,B 1234 [4:0]}; if B 1234 [5]=1 and B 5678 [5 ]=0, then output B=7'b{01,B 5678 [4:0]}; if B 1234 [5]=1 and B 5678 [5]=1, then output B=7'b{1,000,000} . When only B 1234 exists and no B 5678 exists, the number of leading zeros B=B 1234 .

下面以64位数据为例,本发明采用的前导零计算方式为,先通过8-4译码器译出每8位中前导零的个数,然后将译码值的最高位作为判决条件,译码值的低位作为供选择的输出值,输出值同时还有超前运算的数据,逐级两两判决之后给出最终结果,即为前导零的个数。Taking 64-bit data as an example below, the calculation method of leading zeros adopted in the present invention is to first decode the number of leading zeros in every 8 bits through an 8-4 decoder, and then use the highest bit of the decoded value as a judgment condition, The lower bit of the decoded value is used as the output value for selection, and the output value also has the data of the advance operation, and the final result is given after the two-level decision is made, which is the number of leading zeros.

实施例:Example:

如图1所示,处理64位数据时,需要用到B1~B8八个译码器经过三级逻辑判断给出结果。将64位数据A[63:0]分为8位一组,分别通过八个8-4译码器,译出八个8位数据中前导零的个数Bm[3:0](m=1~8)。译码原理如下表所示:As shown in Figure 1, when processing 64-bit data, eight decoders B1 to B8 need to be used to give results through three-level logic judgment. Divide the 64-bit data A[63:0] into 8-bit groups, and pass through eight 8-4 decoders to decode the number of leading zeros in the eight 8-bit data B m [3:0](m = 1 to 8). The decoding principle is shown in the following table:

Figure BDA0001483929370000101
Figure BDA0001483929370000101

完成译码后,如下表所示,进入第一级逻辑判断:若最高8位数据A[63:56]译出的数据B1数值小于8,即B1[3]=0,则B12=5’b{00,B1[2:0]}。若B1[3]=1而B2[3]=0,则B12=5’b{01,B2[2:0]}。若B1[3]=1且B2[3]=1,则B12=5’b{10,000}。After completing the decoding, as shown in the following table, enter the first level of logical judgment: if the value of the data B 1 decoded by the highest 8-bit data A[63:56] is less than 8, that is, B 1 [3]=0, then B 12 =5'b{00,B1[ 2 :0]}. If B1[3]= 1 and B2[ 3 ]=0, then B12=5'b{01,B2[ 2 : 0 ]}. If B 1 [3]=1 and B 2 [3]=1, then B 12 =5'b{10,000}.

在检测B1值的同时,检测B3数值是否小于8,若B3[3]=0,则B34=5’b{00,B3[2:0]};若B3[3]=1而B4[3]=0,在运算B12的同时运算B34,B34=5’b{01,B4[2:0]};若B3[3]=1且B4[3]=1,则在运算B12的同时得出B34=5’b{10,000}。B56、B78的逻辑判断和输出原理同B12和B34While detecting the value of B 1 , check whether the value of B 3 is less than 8. If B 3 [3]=0, then B 34 =5'b{00,B 3 [2:0]}; if B 3 [3] =1 and B 4 [3]=0, B 34 is computed at the same time as B 12 , B 34 =5'b{01,B 4 [2:0]}; if B 3 [3]=1 and B 4 [3]=1, then B 34 =5'b{10,000} is obtained while calculating B 12 . The logic judgment and output principles of B 56 and B 78 are the same as those of B 12 and B 34 .

在第二级逻辑判断中,首先检测最高位输入B12的值,若B12[4]=0,则B1234=6’b{00,B12[3:0]}。若B12[4]=1而B34[4]=0,则B1234=6’b{01,B34[3:0]}。若B12[4]=1且B34[4]=1,则B1234=6’b{100,000}。B5678的逻辑判断和输出原理同B1234In the second-level logic judgment, the value of the highest-order input B 12 is detected first, and if B 12 [4]=0, then B 1234 =6'b{00,B 12 [3:0]}. If B12[ 4 ]=1 and B34[4]=0, then B1234 = 6'b {01, B34 [3:0]}. If B12[ 4 ]=1 and B34[4]=1, then B1234 = 6'b {100,000}. The logic judgment and output principle of B 5678 is the same as that of B 1234 .

在第三级逻辑判断中,首先检测最高位输入B1234的值,若B1234[5]=0,则前导零的个数B=7’b{00,B1234[4:0]}。若B1234[5]=1而B5678[5]=0,则前导零的个数B=7’b{01,B5678[4:0]}。若B1234[5]=1且B5678[5]=1,则B=7’b{1,000,000}即32。运算结束。In the third-level logical judgment, the value of the highest-order input B 1234 is first detected. If B 1234 [5]=0, the number of leading zeros B=7'b{00,B 1234 [4:0]}. If B 1234 [5]=1 and B 5678 [5]=0, then the number of leading zeros B=7'b{01,B 5678 [4:0]}. If B1234 [5]=1 and B5678 [5]=1, then B=7'b{1,000,000} or 32. The operation ends.

上述逻辑判别条件与输出结果的关系可以在下表中清晰对应。The relationship between the above-mentioned logical judgment conditions and the output results can be clearly corresponding in the following table.

Figure BDA0001483929370000111
Figure BDA0001483929370000111

综合以上步骤,每一级逻辑判断时,只是通过控制信号选择对应的输入值或超前运算值作为输出,而不需要再做其他运算(如加法运算),从而节省了运算时间。各级中,将数据划分两两一对并行运算,64位数据只需要经过3级逻辑判断即可获得前导零数量,小于从高位到低位顺序运算需要经过7级逻辑判断的时间消耗。Combining the above steps, during each level of logic judgment, only the corresponding input value or advanced operation value is selected as the output through the control signal, and no other operations (such as addition operations) are needed, thus saving the operation time. In each level, the data is divided into two pairs of parallel operations, and the 64-bit data only needs to go through 3 levels of logic judgment to obtain the number of leading zeros, which is less than the time consumption of 7 levels of logic judgment required for sequential operations from high to low.

本实施例使用的8-4译码器相比常用的8-3译码器能够直接提供选择器的控制位和输出位,以很小的面积代价换取了高效的运算速度;对数据两两分对运算是本实施例降低运算速度的一种辅助手段,可以让每一级中的数据按对并行运算,8n位数据分对运算需要的级数是log2n,而逐个运算所需的运算级数是n-1,每一级的运算时间基本相同,所以运算的数据位越大优势越明显;本实施例采用超前运算的优势在于,在得到8-4译码器的译码结果时,输入数据的前导零数量就已确定,只需配合控制位选择确定的结果输出,而不需要再做加法运算,是本发明获取高效运算速度的核心所在。Compared with the commonly used 8-3 decoder, the 8-4 decoder used in this embodiment can directly provide the control bits and output bits of the selector, and obtains efficient operation speed at a small area cost; Pairwise operation is an auxiliary means to reduce the operation speed in this embodiment, which allows the data in each stage to be operated in parallel in pairs. The number of operation stages is n-1, and the operation time of each stage is basically the same, so the larger the data bits of the operation, the more obvious the advantage; the advantage of using the advanced operation in this embodiment is that the decoding result of the 8-4 decoder is obtained after the decoding. When the number of leading zeros of the input data has been determined, only the determined result output needs to be selected in conjunction with the control bits, and no addition operation is required, which is the core of the present invention to obtain efficient operation speed.

装置实施例Device embodiment

本实施例还提供了一种处理器浮点单元前导零数量的超前运算系统,包括:第一模块和第二模块。其中。This embodiment also provides a look-ahead computing system for the number of leading zeros in a floating-point unit of a processor, including: a first module and a second module. in.

第一模块,用于译码运算得到每8位数据的前导零个数:将数据位为8n位数据A[8n-1:0]按照从高位到低位的顺序依次分为8位一组,分别通过n个8-4译码器译出n个8位数据中前导零的个数Bm[3:0];其中,Bm表示第m组8位数据的前导零个数,m=1~n,n=1~8;The first module is used for decoding operation to obtain the number of leading zeros of each 8-bit data: the data bits are 8n-bit data A[8n-1:0] divided into 8-bit groups in the order from high to low, Decode the number of leading zeros B m [3:0] in the n 8-bit data through n 8-4 decoders respectively; wherein, B m represents the number of leading zeros of the mth group of 8-bit data, m= 1~n, n=1~8;

第二模块,用于通过三级中的每一级的超前运算和逻辑判断得到数据A[8n-1:0]的前导零个数,每一级中会对输入数据进行两两分对,各对之间并行开展运算;其中,n为奇数时,最后一对只有一个输入数据。The second module is used to obtain the number of leading zeros of the data A[8n-1:0] through the advance operation and logical judgment of each of the three stages, and the input data will be paired in pairs in each stage, Operations are performed in parallel between pairs; where n is odd, the last pair has only one input data.

上述实施例中,8-4译码器的译码原理为,当输入数据为8’b00000000时,输出数据为4’b1000;当输入数据为8’b00000001时,输出数据为4’b0111;当输入数据为8’b0000001x时,输出数据为4’b0110;当输入数据为8’b000001xx时,输出数据为4’b0101;当输入数据为8’b00001xxx时,输出数据为4’b0100;当输入数据为8’b0001xxxx时,输出数据为4’b0011;当输入数据为8’b001xxxxx时,输出数据为4’b0010;当输入数据为8’b01xxxxxx时,输出数据为4’b0001;当输入数据为8’b1xxxxxxx时,输出数据为4’b0000;其中,x=0或1。In the above embodiment, the decoding principle of the 8-4 decoder is that when the input data is 8'b00000000, the output data is 4'b1000; when the input data is 8'b00000001, the output data is 4'b0111; When the input data is 8'b0000001x, the output data is 4'b0110; when the input data is 8'b000001xx, the output data is 4'b0101; when the input data is 8'b00001xxx, the output data is 4'b0100; when the input data is 8'b00001xxx, the output data is 4'b0100; When the input data is 8'b0001xxxx, the output data is 4'b0011; when the input data is 8'b001xxxxx, the output data is 4'b0010; when the input data is 8'b01xxxxxx, the output data is 4'b0001; when the input data is 8 'b1xxxxxxx, the output data is 4'b0000; where x=0 or 1.

上述实施例中,数据Bm[3:0]的运算公式为:In the above embodiment, the operation formula of data B m [3:0] is:

Bm[3]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|A[0]);B m [3]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|A[0]);

Bm[2]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|~A[0])&(A[3]|A[2]|~A[1])&(A[3]|~A[2])&(~A[3]);B m [2]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|~A[0])&(A[3]|A[2]|~A[1])&(A[3]|~A[2])&(~A[3]);

Bm[1]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|((A[1]|~A[0])&~A[1]))&(A[5]|~A[4])&(~A[5]);B m [1]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|((A[1]|~A[0] )&~A[1]))&(A[5]|~A[4])&(~A[5]);

Bm[0]=~(A[7]|(A[6]|A[5]|(A[4]|A[3]|(A[2]|A[1]|~A[0])&~A[2])&~A[4])&~A[6]);B m [0]=~(A[7]|(A[6]|A[5]|(A[4]|A[3]|(A[2]|A[1]|~A[0 ])&~A[2])&~A[4])&~A[6]);

其中,A[p]为数据A的第p+1位,Bm[q](q=0~3)为数据Bm的第q+1位;其中,p=0~7。Among them, A[p] is the p+1th bit of the data A, and Bm [q] (q=0~3) is the q+1th bit of the data Bm; wherein, p =0~7.

本实施例使用的8-4译码器相比常用的8-3译码器能够直接提供选择器的控制位和输出位,以很小的面积代价换取了高效的运算速度;对数据两两分对运算是本实施例降低运算速度的一种辅助手段,可以让每一级中的数据按对并行运算,8n位数据分对运算需要的级数是log2n,而逐个运算所需的运算级数是n-1,每一级的运算时间基本相同,所以运算的数据位越大优势越明显;本实施例采用超前运算的优势在于,在得到8-4译码器的译码结果时,输入数据的前导零数量就已确定,只需配合控制位选择确定的结果输出,而不需要再做加法运算,是本发明获取高效运算速度的核心所在。Compared with the commonly used 8-3 decoder, the 8-4 decoder used in this embodiment can directly provide the control bits and output bits of the selector, and obtains efficient operation speed at a small area cost; Pairwise operation is an auxiliary means to reduce the operation speed in this embodiment, which allows the data in each stage to be operated in parallel in pairs. The number of operation stages is n-1, and the operation time of each stage is basically the same, so the larger the data bits of the operation, the more obvious the advantage; the advantage of using the advanced operation in this embodiment is that the decoding result of the 8-4 decoder is obtained after the decoding. When the number of leading zeros of the input data has been determined, only the determined result output needs to be selected in conjunction with the control bits, and no addition operation is required, which is the core of the present invention to obtain efficient operation speed.

以上所述的实施例只是本发明较优选的具体实施方式,本领域的技术人员在本发明技术方案范围内进行的通常变化和替换都应包含在本发明的保护范围内。The above-mentioned embodiments are only preferred specific implementations of the present invention, and general changes and substitutions made by those skilled in the art within the scope of the technical solutions of the present invention should be included in the protection scope of the present invention.

Claims (2)

1.一种处理器浮点单元前导零数量的超前运算方法,其特征在于,所述方法包括下列步骤:1. an advanced operation method for the number of leading zeros of a processor floating-point unit, characterized in that the method comprises the following steps: 步骤100:译码运算,得到每8位数据的前导零个数:将数据位为8n位的数据A[8n-1:0]按照从高位到低位的顺序依次分为8位一组,分别通过n个8-4译码器译出n个8位数据中前导零的个数Bm[3:0];其中,Bm表示第m组8位数据的前导零个数,m=1~n,n=1~8;Step 100: Decoding operation to obtain the number of leading zeros of each 8-bit data: Divide the data A[8n-1:0] whose data bits are 8n-bits into 8-bit groups in order from high-bit to low-bit, respectively. The number of leading zeros in the n 8-bit data is decoded by n 8-4 decoders B m [3:0]; wherein, B m represents the number of leading zeros in the mth group of 8-bit data, m=1 ~n, n=1~8; 步骤200:通过三级中的每一级的超前运算和逻辑判断得到数据A[8n-1:0]的前导零个数,每一级中会对输入数据进行两两分对,各对之间并行开展运算;其中,n为奇数时,最后一对只有一个输入数据;其中,Step 200: Obtain the number of leading zeros of the data A[8n-1:0] through the advance operation and logical judgment of each of the three levels, and in each level, the input data will be paired in twos, and each pair will be matched. The operation is carried out in parallel between the two; among them, when n is odd, the last pair has only one input data; 步骤200包括以下步骤:Step 200 includes the following steps: 步骤210:第一级输入为译码运算的结果Bm[3:0],输出为每16位或8位数据的前导零个数Bjk[4:0],逻辑判断依据为每对输入数据的最高位Bm[3],输出来自超前运算的结果和/或输入数据的低三位Bm[2:0];其中,k=j+1,j=1,3,5,7且j≤n;Step 210: The input of the first stage is the result of the decoding operation B m [3:0], the output is the number of leading zeros B jk [4:0] of each 16-bit or 8-bit data, and the logical judgment is based on each pair of inputs The highest bit B m [3] of the data, outputs the result from the look-ahead operation and/or the lower three bits B m [2:0] of the input data; where, k=j+1, j=1,3,5,7 and j≤n; 步骤220:第二级输入为第一级输出的结果Bjk[4:0],输出为每32位、16位或8位数据的前导零个数Bjkrs[5:0],逻辑判断依据为每对输入数据的最高位Bjk[4],输出来自超前运算的结果和/或输入数据的低四位Bjk[3:0];其中,k=j+1,r=j+2,s=j+3,j=1,5且j≤n;Step 220: The input of the second stage is the result B jk [4:0] of the output of the first stage, and the output is the number of leading zeros B jkrs [5:0] of each 32-bit, 16-bit or 8-bit data, the logic judgment basis For the highest bit B jk [4] of each pair of input data, output the result from the look-ahead operation and/or the lower four bits B jk [3:0] of the input data; where k=j+1, r=j+2 , s=j+3, j=1,5 and j≤n; 步骤230:第三级输入为第二级输出的结果Bjkrs[5:0],输出为8n位数据的前导零个数B;逻辑判断依据为每对输入数据的最高位Bjkrs[5],输出来自超前运算的结果和/或输入数据的低四位Bjkrs[4:0];其中,n=1~8;Step 230: The input of the third stage is the result B jkrs [5:0] of the output of the second stage, and the output is the leading zero number B of the 8n-bit data; the logic judgment basis is the highest bit B jkrs [5] of each pair of input data , output the result from the look-ahead operation and/or the lower four bits of the input data B jkrs [4:0]; wherein, n=1~8; 8-4译码器的译码原理为,当输入数据为8’b00000000时,输出数据为4’b1000;当输入数据为8’b00000001时,输出数据为4’b0111;当输入数据为8’b0000001x时,输出数据为4’b0110;当输入数据为8’b000001xx时,输出数据为4’b0101;当输入数据为8’b00001xxx时,输出数据为4’b0100;当输入数据为8’b0001xxxx时,输出数据为4’b0011;当输入数据为8’b001xxxxx时,输出数据为4’b0010;当输入数据为8’b01xxxxxx时,输出数据为4’b0001;当输入数据为8’b1xxxxxxx时,输出数据为4’b0000;其中,x=0或1;The decoding principle of the 8-4 decoder is that when the input data is 8'b00000000, the output data is 4'b1000; when the input data is 8'b00000001, the output data is 4'b0111; when the input data is 8' When b0000001x, the output data is 4'b0110; when the input data is 8'b000001xx, the output data is 4'b0101; when the input data is 8'b00001xxx, the output data is 4'b0100; when the input data is 8'b0001xxxx , the output data is 4'b0011; when the input data is 8'b001xxxxx, the output data is 4'b0010; when the input data is 8'b01xxxxxx, the output data is 4'b0001; when the input data is 8'b1xxxxxxx, the output The data is 4'b0000; where, x=0 or 1; 数据Bm[3:0]的运算公式为:The operation formula of data B m [3:0] is: Bm[3]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|A[0]);B m [3]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|A[0]); Bm[2]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|~A[0])&(A[3]|A[2]|~A[1])&(A[3]|~A[2])&(~A[3]);B m [2]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|~A[0])&(A[3]|A[2]|~A[1])&(A[3]|~A[2])&(~A[3]); Bm[1]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|((A[1]|~A[0])&~A[1]))&(A[5]|~A[4])&(~A[5]);B m [1]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|((A[1]|~A[0] )&~A[1]))&(A[5]|~A[4])&(~A[5]); Bm[0]=~(A[7]|(A[6]|A[5]|(A[4]|A[3]|(A[2]|A[1]|~A[0])&~A[2])&~A[4])&~A[6]);B m [0]=~(A[7]|(A[6]|A[5]|(A[4]|A[3]|(A[2]|A[1]|~A[0 ])&~A[2])&~A[4])&~A[6]); 其中,A[p]为数据A的第p+1位,Bm[q](q=0~3)为数据Bm的第q+1位;其中,p=0~7;Among them, A[p] is the p +1th bit of data A, and Bm[q] (q=0~3) is the q+1th bit of data Bm; among them, p =0~7; 当n=1时,B1即为运算的前导零数量,运算结束;当1<n≤8时,将Bm由高位到低位两两分为一对,各对之间并行开展第一级运算,当n为奇数时最后一对不足两个数据,则保留Bn不做运算,Bn的值直接传输给下一级,位数不足时高位补零;或When n=1, B 1 is the number of leading zeros in the operation, and the operation ends; when 1<n≤8, divide B m into pairs from high to low, and carry out the first level in parallel between each pair operation, when n is an odd number, the last pair of data is less than two data, then keep B n for no operation, the value of B n is directly transmitted to the next level, and the high-order bits are filled with zeros when the number of digits is insufficient; or 当n=2时,B1和B2的运算结果B12即为运算的前导零数量,运算结束;当2<n≤8时,进入第二级逻辑判断,将第一级逻辑判断的输出结果Bjk由高位到低位两两分为一对,各对之间并行开展第二级逻辑判断,若最后一对不足两个数据,则保留一个数据不做运算直接传递给下一级,位数不足时高位补零,其中k=j+1;j=1,3,5,7且j≤n;或When n=2, the operation result B 12 of B 1 and B 2 is the number of leading zeros of the operation, and the operation ends; when 2<n≤8, enter the second-level logic judgment, and the output of the first-level logic judgment The result B jk is divided into two pairs from high bits to low bits, and the second-level logic judgment is carried out in parallel between each pair. If the last pair is less than two data, one data is reserved and directly passed to the next level without operation. When the number is insufficient, high-order zeros are filled, where k=j+1; j=1, 3, 5, 7 and j≤n; or 当2<n≤4时,B1234即为运算的前导零数量,运算结束;当4<n≤8时,进入第三级逻辑判断,对第二级逻辑判断的两个运算结果进行运算;When 2<n≤4, B 1234 is the number of leading zeros of the operation, and the operation ends; when 4<n≤8, enter the third-level logic judgment, and perform the operation on the two operation results of the second-level logic judgment; 每一级超前运算包括:Each level of lookahead operations includes: 在第一级超前运算中,若高位数值Bj<8,则该对数据前导零个数为Bjk=5’b{00,Bj[2:0]};若高位数值Bj=8,而低位数值Bk<8,则该对数据前导零个数为Bjk=5’b{01,Bk[2:0]};若高位数值Bj=8,且低位数值Bk=8,则该对数据前导零个数为Bjk=5’b{10,000};当n为奇数时,最后一对只有Bn,只需在高位补零即可输出Bjk=5’b{0,Bn[3:0]};其中,k=j+1,j=1,3,5,7且j≤n;In the first-level look-ahead operation, if the high-order value B j <8, the number of leading zeros in the pair of data is B jk =5'b{00,B j [2:0]}; if the high-order value B j =8 , and the low-order value B k <8, then the number of leading zeros in the pair of data is B jk =5'b{01,B k [2:0]}; if the high-order value B j =8, and the low-order value B k = 8, then the number of leading zeros in the pair of data is B jk =5'b{10,000}; when n is an odd number, the last pair has only B n , and only need to fill in the high-order zeros to output B jk =5'b{ 0,B n [3:0]}; where k=j+1, j=1,3,5,7 and j≤n; 在第二级超前运算中,若高位数值Bjk<16,则该对数据前导零个数为Bjkrs=6’b{00,Bjk[3:0]};若高位数值Bjk=16,而低位数值Brs<16,则该对数据前导零个数为Bjkrs=6’b{01,Brs[3:0]};若高位数Bjk=16,且低位数值Brs=16,则该对数据前导零个数为Bjkrs=6’b{100,000};当最后一对只有一个数据Bjk时,只需在高位补零即可输出Bjkrs=6’b{0,Bjk[4:0]};其中,k=j+1,r=j+2,s=j+3,j=1,5且j≤n;In the second-level look-ahead operation, if the high-order value B jk <16, the number of leading zeros in the pair of data is B jkrs =6'b{00,B jk [3:0]}; if the high-order value B jk =16 , and the low-order value B rs <16, the number of leading zeros in the pair of data is B jkrs =6'b{01,B rs [3:0]}; if the high-order value B jk =16, and the low-order value B rs = 16, then the number of leading zeros in the pair of data is B jkrs = 6'b{100,000}; when the last pair has only one data B jk , it is only necessary to add zeros in the high bits to output B jkrs = 6'b{0, B jk [4:0]}; where k=j+1, r=j+2, s=j+3, j=1,5 and j≤n; 在第三级超前运算中,若高位数值B1234<32,则该对数据前导零个数为B=7’b{00,B1234[4:0]};若高位数值B1234=32,而低位数值B5678<32,则该对数据前导零个数为B=7’b{01,B5678[4:0]};若高位数B1234=32,且低位数值B5678=32,则该对数据前导零个数为B=7’b{1,000,000};In the third-level look-ahead operation, if the high-order value B 1234 <32, the number of leading zeros in the pair of data is B=7'b{00,B 1234 [4:0]}; if the high-order value B 1234 =32, And the low-order value B 5678 <32, the number of leading zeros in the pair of data is B=7'b{01,B 5678 [4:0]}; if the high-order value B 1234 =32, and the low-order value B 5678 =32, Then the number of leading zeros in the pair of data is B=7'b{1,000,000}; 每一级逻辑判断包括:Each level of logical judgment includes: 在第一级逻辑判断中,若Bj的最高位Bj[3]=0,则输出Bjk=5’b{00,Bj[2:0]};若Bj[3]=1,而Bk[3]=0,则输出Bjk=5’b{01,Bk[2:0]};若Bj[3]=1,且Bk[3]=1,则输出Bjk=5’b{10,000};当n为奇数时,最后一对只有Bn,输出Bjk=5’b{0,Bn[3:0]};其中,k=j+1,j=1,3,5,7且j≤n;In the first-level logical judgment, if the highest bit of B j B j [3]=0, then output B jk =5'b{00,B j [2:0]}; if B j [3]=1 , and B k [3]=0, then output B jk =5'b{01,B k [2:0]}; if B j [3]=1, and B k [3]=1, then output B jk =5'b{10,000}; when n is an odd number, the last pair has only B n , and the output B jk =5'b{0,B n [3:0]}; where k=j+1, j=1,3,5,7 and j≤n; 在第二级逻辑判断中,若Bjk[4]=0,则输出Bjkrs=6’b{00,Bjk[3:0]};若Bjk[4]=1,而Brs[4]=0,则输出Bjkrs=6’b{01,Brs[3:0]};若Bjk[4]=1,且Brs[4]=1,则输出Bjkrs=6’b{100,000};当最后一对只有一个数据Bjk时,输出Bjkrs=6’b{0,Bjk[4:0]};其中,k=j+1,r=j+2,s=j+3,j=1,5且j≤n;In the second-level logical judgment, if B jk [4]=0, then output B jkrs =6'b{00,B jk [3:0]}; if B jk [4]=1, and B rs [ 4]=0, then output B jkrs =6'b{01,B rs [3:0]}; if B jk [4]=1, and B rs [4]=1, then output B jkrs =6'b{100,000}; when the last pair has only one data B jk , output B jkrs = 6'b{0, B jk [4:0]}; where k=j+1, r=j+2, s =j+3, j=1,5 and j≤n; 在第三级逻辑判断中,若B1234[5]=0,则输出B=7’b{00,B1234[4:0]};若B1234[5]=1而B5678[5]=0,则输出B=7’b{01,B5678[4:0]};若B1234[5]=1且B5678[5]=1,则输出B=7’b{1,000,000};当只存在B1234,没有B5678时,前导零个数B=B1234In the third-level logic judgment, if B 1234 [5]=0, then output B=7'b{00, B 1234 [4:0]}; if B 1234 [5]=1 and B 5678 [5] =0, then output B=7'b{01,B 5678 [4:0]}; if B 1234 [5]=1 and B 5678 [5]=1, then output B=7'b{1,000,000}; When only B 1234 exists and no B 5678 exists, the number of leading zeros B=B 1234 . 2.一种处理器浮点单元前导零数量的超前运算系统,其特征在于包括:2. A look-ahead computing system for the number of leading zeros in a floating-point unit of a processor, characterized in that it comprises: 第一模块,用于译码运算得到每8位数据的前导零个数:将数据位为8n位的数据A[8n-1:0]按照从高位到低位的顺序依次分为8位一组,分别通过n个8-4译码器译出n个8位数据中前导零的个数Bm[3:0];其中,Bm表示第m组8位数据的前导零个数,m=1~n,n=1~8;The first module is used for decoding operation to obtain the number of leading zeros per 8-bit data: the data A[8n-1:0] whose data bits are 8n bits is divided into 8-bit groups in the order from high to low. , respectively decode the number of leading zeros B m [3:0] in the n 8-bit data through n 8-4 decoders; among them, B m represents the number of leading zeros of the mth group of 8-bit data, m =1~n, n=1~8; 第二模块,用于通过三级中的每一级的超前运算和逻辑判断得到数据A[8n-1:0]的前导零个数,每一级中会对输入数据进行两两分对,各对之间并行开展运算;其中,n为奇数时,最后一对只有一个输入数据;The second module is used to obtain the number of leading zeros of the data A[8n-1:0] through the advance operation and logical judgment of each of the three stages, and the input data will be paired in pairs in each stage, The operation is carried out in parallel between each pair; among them, when n is an odd number, the last pair has only one input data; 8-4译码器的译码原理为,当输入数据为8’b00000000时,输出数据为4’b1000;当输入数据为8’b00000001时,输出数据为4’b0111;当输入数据为8’b0000001x时,输出数据为4’b0110;当输入数据为8’b000001xx时,输出数据为4’b0101;当输入数据为8’b00001xxx时,输出数据为4’b0100;当输入数据为8’b0001xxxx时,输出数据为4’b0011;当输入数据为8’b001xxxxx时,输出数据为4’b0010;当输入数据为8’b01xxxxxx时,输出数据为4’b0001;当输入数据为8’b1xxxxxxx时,输出数据为4’b0000;其中,x=0或1;The decoding principle of the 8-4 decoder is that when the input data is 8'b00000000, the output data is 4'b1000; when the input data is 8'b00000001, the output data is 4'b0111; when the input data is 8' When b0000001x, the output data is 4'b0110; when the input data is 8'b000001xx, the output data is 4'b0101; when the input data is 8'b00001xxx, the output data is 4'b0100; when the input data is 8'b0001xxxx , the output data is 4'b0011; when the input data is 8'b001xxxxx, the output data is 4'b0010; when the input data is 8'b01xxxxxx, the output data is 4'b0001; when the input data is 8'b1xxxxxxx, the output The data is 4'b0000; where, x=0 or 1; 数据Bm[3:0]的运算公式为:The operation formula of data B m [3:0] is: Bm[3]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|A[0]);B m [3]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|A[0]); Bm[2]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|~A[0])&(A[3]|A[2]|~A[1])&(A[3]|~A[2])&(~A[3]);B m [2]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|A[1]|~A[0])&(A[3]|A[2]|~A[1])&(A[3]|~A[2])&(~A[3]); Bm[1]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|((A[1]|~A[0])&~A[1]))&(A[5]|~A[4])&(~A[5]);B m [1]=~(A[7]|A[6]|A[5]|A[4]|A[3]|A[2]|((A[1]|~A[0] )&~A[1]))&(A[5]|~A[4])&(~A[5]); Bm[0]=~(A[7]|(A[6]|A[5]|(A[4]|A[3]|(A[2]|A[1]|~A[0])&~A[2])&~A[4])&~A[6]);B m [0]=~(A[7]|(A[6]|A[5]|(A[4]|A[3]|(A[2]|A[1]|~A[0 ])&~A[2])&~A[4])&~A[6]); 其中,A[p]为数据A的第p+1位,Bm[q](q=0~3)为数据Bm的第q+1位;其中,p=0~7;Among them, A[p] is the p +1th bit of data A, and Bm[q] (q=0~3) is the q+1th bit of data Bm; among them, p =0~7; 当n=1时,B1即为运算的前导零数量,运算结束;当1<n≤8时,将Bm由高位到低位两两分为一对,各对之间并行开展第一级运算,当n为奇数时最后一对不足两个数据,则保留Bn不做运算,Bn的值直接传输给下一级,位数不足时高位补零;或When n=1, B 1 is the number of leading zeros in the operation, and the operation ends; when 1<n≤8, divide B m into pairs from high to low, and carry out the first level in parallel between each pair operation, when n is an odd number, the last pair of data is less than two data, then keep B n for no operation, the value of B n is directly transmitted to the next level, and the high-order bits are filled with zeros when the number of digits is insufficient; or 当n=2时,B1和B2的运算结果B12即为运算的前导零数量,运算结束;当2<n≤8时,进入第二级逻辑判断,将第一级逻辑判断的输出结果Bjk由高位到低位两两分为一对,各对之间并行开展第二级逻辑判断,若最后一对不足两个数据,则保留一个数据不做运算直接传递给下一级,位数不足时高位补零,其中k=j+1;j=1,3,5,7且j≤n;或When n=2, the operation result B 12 of B 1 and B 2 is the number of leading zeros of the operation, and the operation ends; when 2<n≤8, enter the second-level logic judgment, and the output of the first-level logic judgment The result B jk is divided into two pairs from high bits to low bits, and the second-level logic judgment is carried out in parallel between each pair. If the last pair is less than two data, one data is reserved and directly passed to the next level without operation. When the number is insufficient, high-order zeros are filled, where k=j+1; j=1, 3, 5, 7 and j≤n; or 当2<n≤4时,B1234即为运算的前导零数量,运算结束;当4<n≤8时,进入第三级逻辑判断,对第二级逻辑判断的两个运算结果进行运算;When 2<n≤4, B 1234 is the number of leading zeros of the operation, and the operation ends; when 4<n≤8, enter the third-level logic judgment, and perform the operation on the two operation results of the second-level logic judgment; 每一级超前运算包括:Each level of lookahead operations includes: 在第一级超前运算中,若高位数值Bj<8,则该对数据前导零个数为Bjk=5’b{00,Bj[2:0]};若高位数值Bj=8,而低位数值Bk<8,则该对数据前导零个数为Bjk=5’b{01,Bk[2:0]};若高位数值Bj=8,且低位数值Bk=8,则该对数据前导零个数为Bjk=5’b{10,000};当n为奇数时,最后一对只有Bn,只需在高位补零即可输出Bjk=5’b{0,Bn[3:0]};其中,k=j+1,j=1,3,5,7且j≤n;In the first-level look-ahead operation, if the high-order value B j <8, the number of leading zeros in the pair of data is B jk =5'b{00,B j [2:0]}; if the high-order value B j =8 , and the low-order value B k <8, then the number of leading zeros in the pair of data is B jk =5'b{01,B k [2:0]}; if the high-order value B j =8, and the low-order value B k = 8, then the number of leading zeros in the pair of data is B jk =5'b{10,000}; when n is an odd number, the last pair has only B n , and only need to fill in the high-order zeros to output B jk =5'b{ 0,B n [3:0]}; where k=j+1, j=1,3,5,7 and j≤n; 在第二级超前运算中,若高位数值Bjk<16,则该对数据前导零个数为Bjkrs=6’b{00,Bjk[3:0]};若高位数值Bjk=16,而低位数值Brs<16,则该对数据前导零个数为Bjkrs=6’b{01,Brs[3:0]};若高位数Bjk=16,且低位数值Brs=16,则该对数据前导零个数为Bjkrs=6’b{100,000};当最后一对只有一个数据Bjk时,只需在高位补零即可输出Bjkrs=6’b{0,Bjk[4:0]};其中,k=j+1,r=j+2,s=j+3,j=1,5且j≤n;In the second-level look-ahead operation, if the high-order value B jk <16, the number of leading zeros in the pair of data is B jkrs =6'b{00,B jk [3:0]}; if the high-order value B jk =16 , and the low-order value B rs <16, the number of leading zeros in the pair of data is B jkrs =6'b{01,B rs [3:0]}; if the high-order value B jk =16, and the low-order value B rs = 16, then the number of leading zeros in the pair of data is B jkrs = 6'b{100,000}; when the last pair has only one data B jk , it is only necessary to add zeros in the high bits to output B jkrs = 6'b{0, B jk [4:0]}; where k=j+1, r=j+2, s=j+3, j=1,5 and j≤n; 在第三级超前运算中,若高位数值B1234<32,则该对数据前导零个数为B=7’b{00,B1234[4:0]};若高位数值B1234=32,而低位数值B5678<32,则该对数据前导零个数为B=7’b{01,B5678[4:0]};若高位数B1234=32,且低位数值B5678=32,则该对数据前导零个数为B=7’b{1,000,000};In the third-level look-ahead operation, if the high-order value B 1234 <32, the number of leading zeros in the pair of data is B=7'b{00,B 1234 [4:0]}; if the high-order value B 1234 =32, And the low-order value B 5678 <32, the number of leading zeros in the pair of data is B=7'b{01,B 5678 [4:0]}; if the high-order value B 1234 =32, and the low-order value B 5678 =32, Then the number of leading zeros in the pair of data is B=7'b{1,000,000}; 每一级逻辑判断包括:Each level of logical judgment includes: 在第一级逻辑判断中,若Bj的最高位Bj[3]=0,则输出Bjk=5’b{00,Bj[2:0]};若Bj[3]=1,而Bk[3]=0,则输出Bjk=5’b{01,Bk[2:0]};若Bj[3]=1,且Bk[3]=1,则输出Bjk=5’b{10,000};当n为奇数时,最后一对只有Bn,输出Bjk=5’b{0,Bn[3:0]};其中,k=j+1,j=1,3,5,7且j≤n;In the first-level logical judgment, if the highest bit of B j B j [3]=0, then output B jk =5'b{00,B j [2:0]}; if B j [3]=1 , and B k [3]=0, then output B jk =5'b{01,B k [2:0]}; if B j [3]=1, and B k [3]=1, then output B jk =5'b{10,000}; when n is an odd number, the last pair has only B n , and the output B jk =5'b{0,B n [3:0]}; where k=j+1, j=1,3,5,7 and j≤n; 在第二级逻辑判断中,若Bjk[4]=0,则输出Bjkrs=6’b{00,Bjk[3:0]};若Bjk[4]=1,而Brs[4]=0,则输出Bjkrs=6’b{01,Brs[3:0]};若Bjk[4]=1,且Brs[4]=1,则输出Bjkrs=6’b{100,000};当最后一对只有一个数据Bjk时,输出Bjkrs=6’b{0,Bjk[4:0]};其中,k=j+1,r=j+2,s=j+3,j=1,5且j≤n;In the second-level logical judgment, if B jk [4]=0, then output B jkrs =6'b{00,B jk [3:0]}; if B jk [4]=1, and B rs [ 4]=0, then output B jkrs =6'b{01,B rs [3:0]}; if B jk [4]=1, and B rs [4]=1, then output B jkrs =6'b{100,000}; when the last pair has only one data B jk , output B jkrs = 6'b{0, B jk [4:0]}; where k=j+1, r=j+2, s =j+3, j=1,5 and j≤n; 在第三级逻辑判断中,若B1234[5]=0,则输出B=7’b{00,B1234[4:0]};若B1234[5]=1而B5678[5]=0,则输出B=7’b{01,B5678[4:0]};若B1234[5]=1且B5678[5]=1,则输出B=7’b{1,000,000};当只存在B1234,没有B5678时,前导零个数B=B1234In the third-level logic judgment, if B 1234 [5]=0, then output B=7'b{00, B 1234 [4:0]}; if B 1234 [5]=1 and B 5678 [5] =0, then output B=7'b{01,B 5678 [4:0]}; if B 1234 [5]=1 and B 5678 [5]=1, then output B=7'b{1,000,000}; When only B 1234 exists and no B 5678 exists, the number of leading zeros B=B 1234 .
CN201711207258.9A 2017-11-27 2017-11-27 A look-ahead computing method and system for the number of leading zeros in a floating-point unit of a processor Active CN108052307B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711207258.9A CN108052307B (en) 2017-11-27 2017-11-27 A look-ahead computing method and system for the number of leading zeros in a floating-point unit of a processor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711207258.9A CN108052307B (en) 2017-11-27 2017-11-27 A look-ahead computing method and system for the number of leading zeros in a floating-point unit of a processor

Publications (2)

Publication Number Publication Date
CN108052307A CN108052307A (en) 2018-05-18
CN108052307B true CN108052307B (en) 2020-07-03

Family

ID=62120588

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711207258.9A Active CN108052307B (en) 2017-11-27 2017-11-27 A look-ahead computing method and system for the number of leading zeros in a floating-point unit of a processor

Country Status (1)

Country Link
CN (1) CN108052307B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109960486B (en) * 2019-02-14 2021-06-25 安谋科技(中国)有限公司 Binary data processing method, and apparatus, medium, and system thereof
CN114327359B (en) * 2021-12-07 2024-11-12 江苏华创微系统有限公司 Prediction method for three input leading zeros

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3453452B2 (en) * 1995-05-19 2003-10-06 キヤノン株式会社 Decryption device
CN105468331A (en) * 2014-09-26 2016-04-06 Arm有限公司 Standalone floating-point conversion unit
CN105786444A (en) * 2014-12-26 2016-07-20 联想(北京)有限公司 Detection method and apparatus for leading zeros in mantissas of floating-point number

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8116378B2 (en) * 2006-12-15 2012-02-14 Arcsoft, Inc. Variable length decoding method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3453452B2 (en) * 1995-05-19 2003-10-06 キヤノン株式会社 Decryption device
CN105468331A (en) * 2014-09-26 2016-04-06 Arm有限公司 Standalone floating-point conversion unit
CN105786444A (en) * 2014-12-26 2016-07-20 联想(北京)有限公司 Detection method and apparatus for leading zeros in mantissas of floating-point number

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于浮点融合乘加部件的前导零预测与检测方法研究;邰强强等;《第十六届计算机工程与工艺年会受第二届微处理器技术论坛论文集》;国防科技大学出版社;20120817;第131-136页 *

Also Published As

Publication number Publication date
CN108052307A (en) 2018-05-18

Similar Documents

Publication Publication Date Title
CN108292222B (en) Hardware apparatus and method for data decompression
US9851945B2 (en) Bit remapping mechanism to enhance lossy compression in floating-point applications
US11036504B2 (en) Systems and methods for performing 16-bit floating-point vector dot product instructions
US8766827B1 (en) Parallel apparatus for high-speed, highly compressed LZ77 tokenization and Huffman encoding for deflate compression
CN105512724B (en) Adder device, data accumulation method and data processing device
US20210124581A1 (en) Systems and methods for performing instructions to convert to 16-bit floating-point format
CN107273090A (en) Towards the approximate floating-point multiplier and floating number multiplication of neural network processor
US9473168B1 (en) Systems, methods, and apparatuses for compression using hardware and software
CN105828070A (en) Anti-error code propagation JPEG-LS image lossless/near-lossless compression algorithm hardware realization method
CN108052307B (en) A look-ahead computing method and system for the number of leading zeros in a floating-point unit of a processor
US20140026021A1 (en) Cyclic redundancy check generation via distributed time multiplexed linear feedback shift registers
TW201720063A (en) Heterogeneous compression architecture for optimized compression ratio
CN107704335B (en) A CRC Parallel Operation IP Core Based on FPGA
US9047069B2 (en) Computer implemented method of electing K extreme entries from a list using separate section comparisons
CN105183425A (en) Fixed-bit-width multiplier with high accuracy and low complexity properties
GB2513987A (en) Parallel apparatus for high-speed, highly compressed LZ77 tokenization and huffman encoding for deflate compression
CN102736888A (en) Data retrieval circuit being synchronous with data stream
CN102378960B (en) Semiconductor integrated circuit and index calculation method
CN103746704B (en) Test data of chip transmission methods based on double distance of swimming alternate coded
CN105786444B (en) A kind of floating number mantissa leading zero detection method and device
JPH09244874A (en) Method for predicting position of most significant digit bit
CN116738132A (en) Processing method of overrunning function, overrunning function unit and graphic processor
CN1160630C (en) Content-addressable memory addressable by redundant forms of input data
CN104469366B (en) A kind of 0 rank Exp- Golomb decoder and coding/decoding method
CN201628951U (en) A high-speed floating-point normalization arithmetic unit

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