Logarithmic approximate multiplier circuit structure based on three-segment linear fitting

By using a three-stage linear fitting method in the approximate multiplier circuit to process the mantissa part of the multiplier, the problem of low accuracy in the existing technology is solved, and the effect of improving the accuracy of the multiplication operation without increasing hardware consumption is achieved. .

CN118409730BActive Publication Date: 2024-08-30沐曦科技(成都)有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410874640.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-02
Publication Date
2024-08-30
Estimated Expiration
2044-07-02

AI Technical Summary

Technical Problem

The processing accuracy of the existing approximate multiplier circuit structure is not high and cannot meet application scenarios with high accuracy requirements. Moreover, the increased hardware consumption makes it difficult to effectively improve the calculation accuracy.

Method used

The three-stage linear fitting method is used to process the mantissa part of the two multipliers, and circuit structures such as first 1 detection, logarithmic three-stage linear fitting transformation, splicing, and antilog three-stage linear fitting transformation are used to improve the performance of the approximate multiplier. Operational accuracy.

Benefits of technology

On the premise that the hardware consumption is increased as little as possible, the operation accuracy of the approximate multiplier circuit structure is significantly improved, and higher multiplication operation accuracy is achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118409730B
    Figure CN118409730B
Patent Text Reader

Abstract

The present invention relates to the technical field of integrated circuits, and in particular to a logarithmic approximate multiplier circuit structure based on three-segment linear fitting, comprising a first conversion circuit, a second conversion circuit, a logarithmic coding adder, an antilogarithmic three-segment linear fitting conversion circuit and an output shifter; the first conversion circuit and the second conversion circuit both comprise a first 1 detection circuit, a mantissa acquisition circuit, a logarithmic three-segment linear fitting conversion circuit and a splicing circuit; the first 1 detection circuit is respectively connected to the mantissa acquisition circuit and the splicing circuit, the mantissa acquisition circuit is connected to the logarithmic three-segment linear fitting conversion circuit, the logarithmic three-segment linear fitting conversion circuit is connected to the splicing circuit, the logarithmic coding adder is connected to the splicing circuit and the antilogarithmic three-segment linear fitting conversion circuit, and the antilogarithmic three-segment linear fitting conversion circuit is connected to the output shifter. The present invention improves the calculation accuracy of the approximate multiplier circuit structure.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of integrated circuits, and in particular to a logarithmic approximation multiplier circuit structure based on three-segment linear fitting. Background Art

[0002] Computers usually use binary calculations, and multiplication operations usually need to be converted into addition, subtraction, shift and other operations when implemented with hardware circuits. In the prior art, an approximate multiplier based on a two-segment piecewise linear Mitchell algorithm is proposed. Based on the Mitchell approximate algorithm, the mantissa part of the two multipliers is processed in two segments [0, 0.5) and [0.5, 1], and then the integer part is combined to perform addition, subtraction, shift operations, etc. to obtain the approximate value of the product of the two numbers. However, the processing accuracy of the existing approximate multiplier circuit structure is not high, and it cannot meet the application scenarios with high precision requirements. It can be seen that how to improve the calculation accuracy of the approximate multiplier circuit structure while minimizing the increase in hardware consumption has become a technical problem that needs to be solved urgently. Summary of the invention

[0003] The purpose of the present invention is to provide a logarithmic approximate multiplier circuit structure based on three-segment linear fitting. Under the premise of minimizing the increase in hardware consumption, the mantissa parts of two multipliers are processed based on the three-segment linear fitting method, thereby improving the calculation accuracy of the approximate multiplier circuit structure.

[0004] According to a first aspect of the present invention, a logarithmic approximate multiplier circuit structure based on three-segment linear fitting is provided, comprising a first conversion circuit, a second conversion circuit, a logarithmic coding adder, an anti-logarithmic three-segment linear fitting conversion circuit and an output shifter, wherein the data transmitted by the approximate multiplier circuit structure are all binary numbers;

[0005] Wherein, the first conversion circuit and the second conversion circuit both include a first 1 detection circuit, a mantissa acquisition circuit, a logarithmic three-segment linear fitting conversion circuit and a splicing circuit;

[0006] The first 1 detection circuit is respectively connected to the mantissa acquisition circuit and the splicing circuit, the mantissa acquisition circuit is connected to the logarithmic three-segment linear fitting transformation circuit, the logarithmic three-segment linear fitting transformation circuit is connected to the splicing circuit, the logarithmic encoding adder is connected to the splicing circuit and the anti-logarithmic three-segment linear fitting transformation circuit, and the anti-logarithmic three-segment linear fitting transformation circuit is connected to the output shifter;

[0007] The first 1 detection circuit is used to traverse from the high bit to the low bit of the input parameter R, obtain the index k of the first bit weight of 1 in R, and transmit k to the mantissa acquisition circuit and the splicing circuit;

[0008] The mantissa acquisition circuit is used to shift R to the left by (W-1-k) bits, remove the first high-order bit of R after the left shift, and determine the remaining number as the mantissa part x of R, where W is the bit width of R;

[0009] The logarithmic three-segment linear fitting transformation circuit is used to output an approximate logarithmic transformation result m(x) of x based on x and the logarithmic transformation three-segment linear fitting logic;

[0010] The concatenation circuit is used to concatenate k and m(x) to generate a transformation result;

[0011] The input parameter of the first conversion circuit is R=A, A is a first multiplier, and the generated conversion result is AL;

[0012] The input parameter of the second conversion circuit is R=B, B is a second multiplier, and the generated conversion result is BL;

[0013] The logarithmic coding adder is used to obtain AL and BL, and output the sum CL of AL and BL;

[0014] The anti-logarithmic three-segment linear fitting transformation circuit is used to obtain the corresponding mantissa part z in CL, and outputs the approximate logarithmic anti-logarithmic transformation result n(z) of z based on z and the anti-logarithmic transformation three-segment linear fitting logic;

[0015] The output shifter is used to obtain the part d except z in CL, obtain n(z), and add a "1" to the high bit of n(z) to obtain f(z), then shift f(z) left by d bits, and output the [3W-2:W-1] bits in the shifted f(z) as the result of A×B.

[0016] Compared with the prior art, the present invention has obvious advantages and beneficial effects. By means of the above technical solution, the logarithmic approximation multiplier circuit structure based on three-segment linear fitting provided by the present invention can achieve considerable technical advancement and practicality, and has wide industrial utilization value, and has at least the following beneficial effects:

[0017] When the circuit realizes multiplication operation, the present invention performs three-segment linear fitting processing on the mantissa parts of two multipliers, thereby improving the accuracy of the circuit structure in realizing approximate multiplication operation while minimizing the increase in hardware consumption. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0019] Figure 1 A schematic diagram of the structure of a three-segment linear fitting multiplier circuit provided by an embodiment of the present invention;

[0020] Figure 2 A schematic diagram of a circuit structure of a three-segment linear fitting multiplier including a truncation circuit provided in an embodiment of the present invention;

[0021] Figure 3 A schematic diagram of a logarithmic three-segment linear fitting transformation circuit provided by an embodiment of the present invention;

[0022] Figure 4 An antilogarithmic three-segment linear fitting transformation circuit is provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0023] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0024] The embodiment of the present invention provides a logarithmic approximation multiplier circuit structure based on three-segment linear fitting, such as Figure 1 As shown, it includes a first conversion circuit 1, a second conversion circuit 2, a logarithmic coding adder 3, an anti-logarithmic three-segment linear fitting conversion circuit 4 and an output shifter 5. The data transmitted by the approximate multiplier circuit structure are all binary numbers.

[0025] Among them, the first conversion circuit 1 and the second conversion circuit 2 have the same structure, and the first conversion circuit 1 and the second conversion circuit 2 both include a first digit 1 detection circuit 21, a mantissa acquisition circuit 22, a logarithmic three-segment linear fitting conversion circuit 23 and a splicing circuit 24.

[0026] like Figure 1 As shown, the first digit 1 detection circuit 21 is respectively connected to the mantissa acquisition circuit 22 and the splicing circuit 24, the mantissa acquisition circuit 22 is connected to the logarithmic three-segment linear fitting transformation circuit 23, the logarithmic three-segment linear fitting transformation circuit 23 is connected to the splicing circuit 24, the logarithmic encoding adder 3 is connected to the splicing circuit 24 and the anti-logarithmic three-segment linear fitting transformation circuit 4, and the anti-logarithmic three-segment linear fitting transformation circuit 4 is connected to the output shifter 5.

[0027] The first 1 detection circuit 21 is used to traverse from the high bit to the low bit of the input parameter R, obtain the index k of the first bit weight of 1 in R, and transmit k to the mantissa acquisition circuit 22 and the splicing circuit 24. For example, R=01100110, then the corresponding k=6.

[0028] The mantissa acquisition circuit 22 is used to shift R to the left by (W-1-k) bits, which can be implemented by a barrel shifter. The first high-order bit of R after the left shift is removed, and the remaining number is determined as the mantissa part x of R, where W is the bit width of R. It should be noted that R=2 k (1+x), where k is the exponent of the first bit weight of 1 in R, and x is the mantissa of R. Still taking R=01100110 as an example, the mantissa acquisition circuit 22 needs to shift R left by 8-1-6=1 bit to obtain 11001100, and then remove the first 1 to obtain x=1001100.

[0029] The logarithmic three-segment linear fitting transformation circuit 23 is used to output an approximate logarithmic transformation result m(x) of x based on x and the logarithmic transformation three-segment linear fitting logic.

[0030] The concatenation circuit 24 is used to concatenate k and m(x) to generate a transformation result.

[0031] The input parameter of the first transformation circuit 1 is R=A, A is the first multiplier, the corresponding x=x1, and the generated transformation result is AL.

[0032] The input parameter of the second transformation circuit 2 is R=B, B is the second multiplier, the corresponding x=x1, and the generated transformation result is BL.

[0033] It should be noted that A=2 k1 (1+x1),B=2 k2 (1+x2), where k1 is the index of the first bit weight of 1 in A, x1 is the mantissa of A, k2 is the index of the first bit weight of 1 in B, and x2 is the mantissa of .

[0034] Perform logarithmic transformation on A and B to obtain Log2A=k1+log2(1+x1),log2B=k2+log2(1+x2)

[0035] Log2(A×B)=Log2A+log2B=k1+log2(1+x1)+k2+log2(1+x2)

[0036] The first conversion circuit 1 of the present invention is used to obtain the result of k1+log2(1+x1), and the second conversion circuit 2 is used to obtain the result of k2+log2(1+x2). However, it should be noted that since the present invention adopts binary arithmetic operation, the binary results of k1 and log2(1+x1) and the binary results of k2 and log2(1+x2) are directly spliced ​​instead of directly summed.

[0037] For obtaining log2(1+x1) and log2(1+x1), approximate operation is required. The three-stage linear fitting logic of logarithmic transformation in the embodiment of the present invention is implemented as follows:

[0038] The three-stage linear fitting logic of logarithmic transformation is:

[0039] .

[0040] The three-stage linear fitting logic can improve the accuracy of the entire log2(1+x1) and log2(1+x1), thereby improving the accuracy of the multiplier. It should be noted that, when expressed in decimal, the first three high-order digits of x are 000, 001 or 010, which is equivalent to the value range of x being [0, 0.375), the first three high-order digits of x are 001 or 100, which is equivalent to the value range of x being [0.375, 0.625), and the first three high-order digits of x are 101, 110 or 111, which is equivalent to the value range of x being (0.625, 1).

[0041] It can be understood that if we want to obtain A×B, we perform an antilogarithmic transformation n(z)=2 on Log2(A×B) z -1.

[0042] The logarithmic coding adder 3 is used to obtain AL and BL, and output the sum CL of AL and BL.

[0043] The antilogarithmic three-segment linear fitting transformation circuit 4 is used to obtain the corresponding mantissa part z in CL, and output the approximate antilogarithmic transformation result n(z) of z based on z and the antilogarithmic transformation three-segment linear fitting logic. It should be noted that the bit width of z is the same as the bit width of x.

[0044] The three-stage linear fitting logic of the antilogarithmic transformation is:

[0045] .

[0046] It should be noted that, when expressed in decimal, the first three high-order digits of z are 000, 001 or 010, which is equivalent to the value range of z being [0, 0.375), the first three high-order digits of z are 001 or 100, which is equivalent to the value range of z being [0.375, 0.625), and the first three high-order digits of z are 101, 110 or 111, which is equivalent to the value range of z being (0.625, 1).

[0047] The output shifter 5 is used to obtain the part d except z in CL, obtain n(z), and add a "1" to the high bit of n(z) to obtain f(z), then shift f(z) left by d bits, and output the [3W-2:W-1] bits in the shifted f(z) as the result of A×B.

[0048] If we perform logarithmic antilogarithmic transformation based on Log2(A×B)=Log2A+log2B=k1+log2(1+x1)+k2+log2(1+x2)≈k1+m(x1)+k2+m(x2), we can get the algorithm logic of A×B:

[0049] .

[0050] It should be noted that x1+x2 in the algorithm logic of A×B is not the sum of x1 output by the first conversion circuit of this application and x2 corresponding to the second conversion circuit, because this application will further process x1 and x2. And since this application is implemented by hardware circuit, x and k are spliced ​​and processed, and then the corresponding mantissa z is obtained from the spliced ​​CL, which is equivalent to the above calculation of m(x1)+m(x2) in A×B. Since z is the result after the error compensation of the mantissa, z must be less than 1. Therefore, 2 k1+k2 ×[1+n(m(x1)+m(x2))] to obtain the approximate value of A×B. In the circuit processing of the present invention, the part d of CL except z obtained by the output shifter 5 is equivalent to 2 in the formula k1+k2 ×[1+n(m(x1)+m(x2))], the result output by the antilogarithmic transformation three-stage linear fitting circuit 4 is equivalent to n(m(x1)+m(x2). Based on the above-mentioned A×B algorithm logic, when the hardware circuit is used to obtain the approximate value of A×B, it is necessary to shift [1+n(m(x1)+m(x2))] left by d bits. Therefore, the output shifter 5 also needs to add a "1" to the high bit of n(z) to obtain f(z), and then shift f(z) left by d bits, and output the [3W-2:W-1] bits in the shifted f(z) as the approximate value result of A×B.

[0051] It should be noted that the larger the bit width in the circuit processing, the more resources are consumed, and the lower bits of the mantissa part will not have much impact on the accuracy of the calculation result. Therefore, under the premise of ensuring the accuracy of the calculation result, the present application further adds a truncation circuit 6. As an embodiment, the first conversion circuit 1 and the second conversion circuit 2 also include a truncation circuit 6, and the truncation circuit 6 is arranged between the mantissa acquisition circuit 22 and the splicing circuit 24. Figure 2 As shown, the truncation circuit 6 is used to truncate the lower h bits of x, and then transmit x to the splicing circuit 24. After the truncation circuit 6 is added, compensation needs to be performed when the splicing circuit 24 splices to ensure the accuracy of the calculation result. Specifically, the splicing circuit 24 is used to splice k and m(x), and then compensate 1'b1 at the end of the splicing result to generate the transformation result RL. The output shifter 5 outputs the [3×W-1-h:Wh] bits in f(z) as the result of A×B.

[0052] It should be noted that, regardless of whether 1'b1 is compensated at the tail of the splicing result, the bit widths of the logarithmic three-segment linear fitting transformation circuit 23 and the antilogarithmic three-segment linear fitting transformation circuit 4 are the same. Because in the case of 1'b1 compensation at the tail of the splicing result, the last bit of AL and BL is always 0 after summing, so it is sufficient to directly not retain the number of bits compensated after summing.

[0053] As an embodiment, h satisfies: the difference between the multiplication result generated after truncating the lower h bits of x and the multiplication result generated after truncating x by (h-1) bits is less than a preset first error threshold, and the difference between the multiplication result generated after truncating the lower (h+1) bits of x and the multiplication result generated after truncating x by h bits is greater than a preset second error threshold, and the second error threshold is greater than the first error threshold.

[0054] As an embodiment, the logarithmic three-segment linear fitting transformation circuit 23 includes a first logarithmic transformation circuit 231, a second logarithmic transformation circuit 232, a third logarithmic transformation circuit 233 and a logarithmic transformation selection circuit 234, wherein the logarithmic three-segment linear fitting transformation circuit 23 synchronously inputs x to the first logarithmic transformation circuit 231, the second logarithmic transformation circuit 232, and the third logarithmic transformation circuit 233, and synchronously inputs the high-order first three bits of x to the logarithmic transformation selection circuit 234, and the first logarithmic transformation circuit 231, the second logarithmic transformation circuit 232, the third logarithmic transformation circuit 233 and the logarithmic transformation selection circuit 234 run in parallel, which can greatly improve the computing efficiency.

[0055] The first logarithmic transformation circuit 231 is used to obtain x+0.09375, and transmit the result to the logarithmic transformation selection circuit 234. Specifically, the first logarithmic transformation circuit 231 is used to sum the first five high-order bits of x with 5'b00011, and concatenate the summation result with the data other than the first five high-order bits of x to obtain the result of x+0.09375, and only perform the addition operation on the first five high-order bits to save hardware resources.

[0056] The second logarithmic transformation circuit 232 is used to obtain 1.25x and transmit the result to the logarithmic transformation selection circuit 234; the third logarithmic transformation circuit 233 is used to obtain 0.75x+0.25 and transmit the result to the logarithmic transformation selection circuit 234.

[0057] Specifically, the second logarithmic transformation circuit 232 and the third logarithmic transformation circuit 233 share a first shifter 20, and the first shifter 20 is used to shift x right by two bits to obtain 0.25x; the second logarithmic transformation circuit 232 is used to sum x and 0.25x output by the first shifter 20 through an adder to obtain 1.25x; the third logarithmic transformation circuit 233 is used to subtract x from 0.25x output by the first shifter 20 through a subtractor to obtain 0.75x, and then set the first high bit of 0.75x to 1, invert the second high bit, and keep the other bits unchanged to obtain 0.75x+0.25.

[0058] The logarithmic transformation selection circuit 234 is used to select the result of the second logarithmic transformation circuit 232 as m(x) when the first three high-order bits of x are 000, 001 or 010; select the result of the first logarithmic transformation circuit 231 as m(x) when the first three high-order bits of x are 001 or 100; select the result of the third logarithmic transformation circuit 233 as m(x) when the first three high-order bits of x are 101, 110 or 111. Since the first logarithmic transformation circuit 231, the second logarithmic transformation circuit 232, the third logarithmic transformation circuit 233 and the logarithmic transformation selection circuit 234 operate in parallel, after the first logarithmic transformation circuit 231, the second logarithmic transformation circuit 232 and the third logarithmic transformation circuit 233 calculate the results, the logarithmic transformation selection circuit 234 can quickly select and output the results.

[0059] It should be noted that when the third logarithmic conversion circuit 233 obtains 0.75x+0.25, an overflow may occur, which will affect the accuracy of the result. If the bit width of the entire third logarithmic conversion circuit 233 is widened, although the accuracy can be guaranteed, it will cause a large resource consumption. In order to balance the accuracy and resource consumption, the present invention further proposes Figure 3The structure shown is as follows: the second logarithmic conversion circuit 232 and the third logarithmic conversion circuit 233 share a first shifter 20, and after adding a 0 at the end of x, the 0 is input into the first shifter 20, that is, the 0 is widened by one bit inside the third logarithmic conversion circuit 233. The first shifter 20 is used to shift the 0-filled x right by two bits to obtain 0.25x; the second logarithmic conversion circuit 232 is used to sum the numbers in 0.25x except the last bit with x to obtain the result of 1.25x. The widening by one bit is mainly to ensure that the third logarithmic conversion circuit 233 will not have an error caused by overflow when calculating 0.75x+0.25, thereby improving the accuracy. In order to save hardware consumption, the second logarithmic conversion circuit 232 and the third logarithmic conversion circuit 233 share the first shifter 20 to obtain 0.25x. Therefore, when the second logarithmic conversion circuit 232 calculates, the widened last bit can be directly discarded. The third logarithmic transformation circuit 233 is used to calculate the difference between x and 0.25x output by the first shifter 20 through a subtractor to obtain 0.75x, then set the first high bit of 0.75x to 1, invert the second high bit, discard the last bit, and keep the other bits unchanged to obtain 0.75x+0.25, expand when obtaining 0.25x, and discard the last bit when the third logarithmic transformation circuit 233 completes the operation, ensuring that the output bit widths of the first logarithmic transformation circuit 231, the second logarithmic transformation circuit 232, and the third logarithmic transformation circuit 233 are consistent, thereby ensuring the accuracy of the operation results and saving hardware resources as much as possible. In addition, when the first three high-order digits of x are 000, 001 or 010, by obtaining the operation rule of 0.75x+0.25, it can be known that the first digit of the result of 0.75x+0.25 is always 1, the second digit is always opposite to the second digit of 0.75x, and the other digits remain unchanged. Therefore, the first high-order digit of 0.75x is directly set to 1 in the third logarithmic transformation circuit 233, the second high-order digit is inverted, the last digit is discarded, and the other digits remain unchanged to obtain 0.75x+0.25, which reduces the use of an adder and further saves hardware resources.

[0060] As an example, Figure 4 As shown, the antilog three-segment linear fitting transformation circuit 4 includes a first antilog transformation circuit 41, a second antilog transformation circuit 42, a third antilog transformation circuit 43 and an antilog transformation selection circuit 44. The antilog three-segment linear fitting transformation circuit 4 synchronously inputs z to the first antilog transformation circuit 41, the second antilog transformation circuit 42, and the third antilog transformation circuit 43, and synchronously inputs the high-order first three bits of z to the antilog transformation selection circuit 44. The first antilog transformation circuit 41, the second antilog transformation circuit 42, the third antilog transformation circuit 43 and the antilog transformation selection circuit 44 run in parallel, which can greatly improve the operation efficiency.

[0061] The first anti-logarithmic transformation circuit 41 is used to obtain z-0.09375 and transmit the result to the anti-logarithmic transformation selection circuit 44; specifically, the first anti-logarithmic transformation circuit 41 is used to find the difference between the first five high-order bits of z and 5'b00011, and concatenate the difference result with the data other than the first five high-order bits of z to obtain the result of z-0.09375, and only perform subtraction operation on the first five high-order bits to save hardware resources.

[0062] The second inverse logarithmic transformation circuit 42 is used to obtain 0.75z and transmit the result to the inverse logarithmic transformation selection circuit 44.

[0063] The third inverse logarithmic transformation circuit 43 is used to obtain 1.25z-0.25 and transmit the result to the inverse logarithmic transformation selection circuit 44.

[0064] Specifically, the second anti-logarithmic transform circuit 42 and the third anti-logarithmic transform circuit 43 share a second shifter 40, and the second shifter 40 is used to shift z right by two bits to obtain 0.25z; the second anti-logarithmic transform circuit 42 is used to sum x and 0.25z output by the first shifter 20 through a subtractor to obtain a result of 0.75z. When the first three high-order bits of z are 000, 001 or 010, it can be known from the operation rule of 1.25z-0.25 that the first bit of the result of 1.25z-0.25 is always 1, the second bit is always opposite to the second bit of 0.75x, and the other bits remain unchanged. Therefore, the third anti-logarithmic conversion circuit 43 is used to sum z and 0.25z output by the first shifter 20 through an adder to obtain 1.25z, and then set the first high-order bit of 1.25z to 1, invert the second high-order bit, and keep the other bits unchanged to obtain 1.25z-0.25, thereby reducing the use of a subtractor and further saving hardware resources. Since there is no overflow in the first anti-logarithmic conversion circuit 41, the second anti-logarithmic conversion circuit 42, and the third anti-logarithmic conversion circuit 43, there is no need to perform bit expansion processing here.

[0065] The anti-logarithmic transformation selection circuit 44 is used to select the result of the second anti-logarithmic transformation circuit 42 as n(z) when the first three high-order bits of z are 000, 001 or 010; select the result of the first anti-logarithmic transformation circuit 41 as n(z) when the first three high-order bits of z are 001 or 100; and select the result of the third anti-logarithmic transformation circuit 43 as n(z) when the first three high-order bits of z are 101, 110 or 111. Since the first anti-logarithmic transformation circuit 41, the second anti-logarithmic transformation circuit 42, the third anti-logarithmic transformation circuit 43 and the anti-logarithmic transformation selection circuit 44 operate in parallel, after the first anti-logarithmic transformation circuit 41, the second anti-logarithmic transformation circuit 42 and the third anti-logarithmic transformation circuit 43 calculate the result, the anti-logarithmic transformation selection circuit 44 can quickly select and output the result.

[0066] When the circuit implements multiplication operation, the embodiment of the present invention performs three-segment linear fitting processing on the mantissas of two multipliers, thereby improving the accuracy of the circuit structure in implementing approximate multiplication operation while minimizing the increase in hardware consumption.

[0067] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment as above, it is not used to limit the present invention. Any technician familiar with this profession can make some changes or modifications to equivalent embodiments of equivalent changes using the technical contents disclosed above without departing from the scope of the technical solution of the present invention. However, any simple modification, equivalent change and modification made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention still falls within the scope of the technical solution of the present invention.

Claims

1. A logarithmic approximation multiplier circuit structure based on three-segment linear fitting, characterized in that: It includes a first conversion circuit, a second conversion circuit, a logarithmic coding adder, an antilogarithmic three-segment linear fitting conversion circuit and an output shifter, and the data transmitted by the approximate multiplier circuit structure are all binary numbers; Wherein, the first conversion circuit and the second conversion circuit both include a first 1 detection circuit, a mantissa acquisition circuit, a logarithmic three-segment linear fitting conversion circuit and a splicing circuit; The first 1 detection circuit is respectively connected to the mantissa acquisition circuit and the splicing circuit, the mantissa acquisition circuit is connected to the logarithmic three-segment linear fitting transformation circuit, the logarithmic three-segment linear fitting transformation circuit is connected to the splicing circuit, the logarithmic encoding adder is connected to the splicing circuit and the anti-logarithmic three-segment linear fitting transformation circuit, and the anti-logarithmic three-segment linear fitting transformation circuit is connected to the output shifter; The first 1 detection circuit is used to traverse from the high bit to the low bit of the input parameter R, obtain the index k of the first bit weight of 1 in R, and transmit k to the mantissa acquisition circuit and the splicing circuit; The mantissa acquisition circuit is used to shift R to the left by (W-1-k) bits, remove the first high-order bit of R after the left shift, and determine the remaining number as the mantissa part x of R, where W is the bit width of R; The logarithmic three-segment linear fitting transformation circuit is used to output an approximate logarithmic transformation result m(x) of x based on x and the logarithmic transformation three-segment linear fitting logic; The concatenation circuit is used to concatenate k and m(x) to generate a transformation result; The input parameter of the first conversion circuit is R=A, A is a first multiplier, and the generated conversion result is AL; The input parameter of the second conversion circuit is R=B, B is a second multiplier, and the generated conversion result is BL; The logarithmic coding adder is used to obtain AL and BL, and output the sum CL of AL and BL; The antilogarithmic three-segment linear fitting transformation circuit is used to obtain the corresponding mantissa part z in CL, and output the approximate logarithmic antilogarithmic transformation result n(z) of z based on z and the antilogarithmic transformation three-segment linear fitting logic; The output shifter is used to obtain the part d except z in CL, obtain n(z), and add a "1" to the high bit of n(z) to obtain f(z), then shift f(z) left by d bits, and output the [3×W-2:W-1] bits in the shifted f(z) as the result of A×B.

2. The circuit structure according to claim 1, characterized in that: The first conversion circuit and the second conversion circuit further include a truncation circuit, which is arranged between the mantissa acquisition circuit and the splicing circuit, and is used to truncate the lower h bits of x and then transmit x to the splicing circuit; The concatenation circuit is used to concatenate k and m(x), and then compensate 1'b1 at the end of the concatenation result to generate a transformation result RL; The output shifter outputs [3×W-1-h:Wh] bits in f(z) as the result of A×B.

3. The circuit structure according to claim 1 or 2, characterized in that: The logarithmic three-segment linear fitting transformation circuit and the anti-logarithmic three-segment linear fitting transformation circuit have the same bit width.

4. The circuit structure according to claim 1 or 2, characterized in that: The logarithmic three-segment linear fitting transformation circuit includes a first logarithmic transformation circuit, a second logarithmic transformation circuit, a third logarithmic transformation circuit and a logarithmic transformation selection circuit, wherein: The logarithmic three-segment linear fitting transformation circuit synchronously inputs x to the first logarithmic transformation circuit, the second logarithmic transformation circuit, and the third logarithmic transformation circuit, and synchronously inputs the first three high-order bits of x to the logarithmic transformation selection circuit, and the first logarithmic transformation circuit, the second logarithmic transformation circuit, the third logarithmic transformation circuit and the logarithmic transformation selection circuit operate in parallel; The first logarithmic transformation circuit is used to obtain x+0.09375 and transmit the result to the logarithmic transformation selection circuit; The second logarithmic transformation circuit is used to obtain 1.25x and transmit the result to the logarithmic transformation selection circuit; The third logarithmic transformation circuit is used to obtain 0.75x+0.25 and transmit the result to the logarithmic transformation selection circuit; The logarithmic transformation selection circuit is used to select the result of the second logarithmic transformation circuit as m(x) when the first three high-order bits of x are 000, 001 or 010; select the result of the first logarithmic transformation circuit as m(x) when the first three high-order bits of x are 001 or 100; and select the result of the third logarithmic transformation circuit as m(x) when the first three high-order bits of x are 101, 110 or 111.

5. The circuit structure according to claim 4, characterized in that: The first logarithmic transformation circuit is used to sum the first five high-order bits of x and 5'b00011, and concatenate the summation result with the data other than the first five high-order bits of x to obtain the result of x+0.09375.

6. The circuit structure according to claim 4, characterized in that: The second logarithmic transformation circuit and the third logarithmic transformation circuit share a first shifter, and the first shifter is used to shift x right by two bits to obtain 0.25x; The second logarithmic conversion circuit is used to add x and 0.25x output by the first shifter through an adder to obtain 1.25x; The third logarithmic transformation circuit is used to calculate the difference between x and 0.25x output by the first shifter through a subtractor to obtain 0.75x, then set the first high bit of 0.75x to 1, invert the second high bit, and keep the other bits unchanged to obtain 0.75x+0.

25.

7. The circuit structure according to claim 4, characterized in that: The second logarithmic conversion circuit and the third logarithmic conversion circuit share a first shifter, and the x is padded with a 0 at the end before being input into the first shifter, and the first shifter is used to shift the padded x right by two bits to obtain 0.25x; The second logarithmic conversion circuit is used to sum the numbers except the last digit in 0.25x with x to obtain a result of 1.25x; The third logarithmic transformation circuit is used to calculate the difference between x and 0.25x output by the first shifter through a subtractor to obtain 0.75x, then set the first high bit of 0.75x to 1, invert the second high bit, discard the last bit, and keep the other bits unchanged to obtain 0.75x+0.

25.

8. The circuit structure according to claim 1 or 2, characterized in that: The antilogarithmic three-segment linear fitting transformation circuit includes a first antilogarithmic transformation circuit, a second antilogarithmic transformation circuit, a third antilogarithmic transformation circuit and an antilogarithmic transformation selection circuit. The antilogarithmic three-segment linear fitting transformation circuit synchronously inputs z to the first antilogarithmic transformation circuit, the second antilogarithmic transformation circuit, and the third antilogarithmic transformation circuit, and synchronously inputs the first three high-order bits of z to the antilogarithmic transformation selection circuit, and the first antilogarithmic transformation circuit, the second antilogarithmic transformation circuit, the third antilogarithmic transformation circuit and the antilogarithmic transformation selection circuit operate in parallel; The first antilogarithmic transformation circuit is used to obtain z-0.09375 and transmit the result to the antilogarithmic transformation selection circuit; The second anti-logarithmic transformation circuit is used to obtain 0.75z and transmit the result to the anti-logarithmic transformation selection circuit; The third antilogarithmic transformation circuit is used to obtain 1.25z-0.25 and transmit the result to the antilogarithmic transformation selection circuit; The anti-logarithmic transformation selection circuit is used to select the result of the second anti-logarithmic transformation circuit as n(z) when the first three high-order bits of z are 000, 001 or 010; select the result of the first anti-logarithmic transformation circuit as n(z) when the first three high-order bits of z are 001 or 100; and select the result of the third anti-logarithmic transformation circuit as n(z) when the first three high-order bits of z are 101, 110 or 111.

9. The circuit structure according to claim 8, characterized in that: The first antilogarithmic transformation circuit is used to obtain the difference between the first five high-order bits of z and 5'b00011, and to concatenate the difference result with data other than the first five high-order bits of z to obtain the result of z-0.09375.

10. The circuit structure according to claim 8, characterized in that: The second anti-logarithmic transformation circuit and the third anti-logarithmic transformation circuit share a second shifter, the second shifter is used to shift z right by two bits to obtain 0.25z; the second anti-logarithmic transformation circuit is used to sum x and 0.25z output by the first shifter through a subtractor to obtain a result of 0.75z; The third antilogarithmic transformation circuit is used to sum z and 0.25z output by the first shifter through an adder to obtain 1.25z, then set the high first bit of 1.25z to 1, invert the high second bit, and keep the other bits unchanged to obtain 1.25z-0.25.

Citation Information

Patent Citations

  • Low-precision multiply-add arithmetic unit supporting multiple inputs and multiple formats

    CN116661734A

  • Time-frequency feature extraction circuit and self-adaptive noise suppression circuit for multichannel time sequence signals

    CN116701921A