A resource-reuse transcendental function calculation implementation device

By designing a resource-reusable transcendental function computation device, and utilizing preprocessing, table lookup, and calculation modules, hardware resources are reused, solving the problems of high resource consumption and slow speed in existing transcendental function computation, and realizing efficient and low-resource-consumption transcendental function computation.

CN115617307BActive Publication Date: 2025-10-28ZHEJIANG UNIV
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211149857.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-21
Publication Date
2025-10-28
Estimated Expiration
2042-09-21

AI Technical Summary

Technical Problem

Existing hardware implementations of transcendental function operations are insufficient in terms of resource consumption and computation time, especially in data-intensive and real-time applications. Series convergence methods and lookup table methods consume a lot of resources, while the CORDIC algorithm has a slow convergence speed.

Method used

Design a resource-reusable transcendental function computation implementation device, including a preprocessing module, a lookup table module, a computation module, and a postprocessing module. By reusing hardware resources such as adders/subtractors and multipliers, and combining lookup tables and fixed-point algorithms, it can realize the computation of various transcendental functions.

Benefits of technology

It achieves efficient calculation of various transcendental functions with an error of less than 2ulp and a frequency of up to 270MHz, meeting the design accuracy requirements with low resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115617307B_ABST
    Figure CN115617307B_ABST
Patent Text Reader

Abstract

This invention belongs to the field of transcendental function computation technology and discloses a resource-reusable transcendental function computation implementation device, including a preprocessing module, a table lookup module, a calculation module, and a post-processing module. The preprocessing module performs corresponding data processing according to the type of the computation function and sends the processed data to the other three modules. The table lookup module searches for the corresponding table according to the type of the computation function, obtains the polynomial coefficients, and sends them to the calculation module. The calculation module performs a finite number of multiplications and additions on the processed data from the preprocessing module and the coefficients from the table lookup module, and sends the results to the post-processing module. The post-processing module performs corresponding data post-processing according to the type of the computation function, obtains the results, and outputs them. This invention, by reusing hardware resources such as adders / subtractors and multipliers, can realize the calculation of sine, cosine, arctangent, exponential, and logarithmic functions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of transcendental function operation technology, and particularly relates to a resource-reusable transcendental function operation implementation device. Background Technology

[0002] Today, transcendental functions have an increasingly wide range of applications, including image and speech processing, scientific computing, digital signal processing, and real-time motor control, which involve a large number of trigonometric functions, inverse trigonometric functions, exponential functions, and logarithmic operations.

[0003] These functions are mathematically distinct from algebraic functions, as they cannot be obtained through a finite number of linear operations on variables, and are therefore called transcendental functions.

[0004] Performing transcendental function calculations using general-purpose multiplication and addition units to execute corresponding software algorithms requires a long computation time and consumes significant computational resources. Therefore, designing dedicated hardware units for implementing transcendental functions is crucial for data-intensive and real-time applications. For example, TI's TMX320 series DSP chips include a dedicated fast computation unit for implementing transcendental functions.

[0005] The main methods for implementing transcendental functions in hardware include series convergence, lookup table methods, and the CORDIC (Coordinate Rotation Digital Computer) algorithm. Different hardware architectures are required for series convergence of different transcendental functions, and achieving high precision necessitates the superposition of many series, which consumes significant hardware resources. Using lookup tables requires storing large amounts of data, also resulting in high hardware consumption. The CORDIC algorithm has the advantage of small circuit area, requiring only shift registers and adders / subtractors for computation. However, its disadvantage is its slow convergence speed; typically, only one significant digit is added per iteration. For single-precision floating-point operations, the CORDIC algorithm requires a considerable number of clock cycles to achieve the required precision. Summary of the Invention

[0006] The purpose of this invention is to provide a resource-reusable transcendental function operation implementation device to solve the above-mentioned technical problems.

[0007] To solve the above-mentioned technical problems, the specific technical solution of the resource reuse type transcendental function operation implementation device of the present invention is as follows:

[0008] A resource-reusable transcendental function operation implementation device includes a preprocessing module, a table lookup module, a calculation module, and a post-processing module. The preprocessing module performs corresponding data processing according to the type of the operation function and sends the processed data to the other three modules. The table lookup module searches for the corresponding table according to the type of the operation function, obtains the polynomial coefficients, and sends them to the calculation module. The calculation module performs a finite number of multiplications and additions on the processed data from the preprocessing module and the coefficients from the table lookup module, and sends the results to the post-processing module. The post-processing module performs corresponding data post-processing according to the type of the operation function, obtains the results, and outputs them.

[0009] Furthermore, the preprocessing module includes a floating-point to fixed-point conversion module, a subtractor, a first multiplier, an inverter, a first selector, a second selector, a third selector, a fourth selector, and a selection logic module. The floating-point to fixed-point conversion module outputs a fixed-point number to the first selector, the second selector, the inverter, and the selection logic module. The selection logic module determines the output of the first selector based on the characteristics of the fixed-point number. The subtractor subtracts 127 from the exponent exp of the floating-point number to be logarithmically calculated to obtain the actual exponent, and outputs the result to the second selector. The second and third selectors select the appropriate multiplier based on the function type of the operation and feed it to the first multiplier for operation. The fourth selector then outputs the appropriate calculation address to the lookup table module and the number to be calculated to the calculation module based on the function type of the operation. The other outputs of the preprocessing module are connected to the postprocessing module.

[0010] Furthermore, the logarithmic and exponential function preprocessing stages share the first multiplier.

[0011] Furthermore, the lookup module includes a sine / cosine function table, an arctangent function table, an exponential function table, a logarithmic function table, and a fifth selector; the sine / cosine function table, arctangent function table, exponential function table, and logarithmic function table are used to look up and output the binomial y = ax 2 The coefficients of the quadratic term a, the linear term b, and the zero-order term c of +bx+c; the fifth selector selects the fitting parameters corresponding to the currently specified operation from the five outputs according to the mode code, and outputs them to the calculation module for use.

[0012] Furthermore, the calculation module includes a sixth selector, an adder / subtractor, a second multiplier, a third multiplier, a first adder, and a second adder. The sixth selector outputs the corresponding result to the adder / subtractor according to the function type of the operation. The second multiplier performs an a×x operation, and the adder / subtractor obtains the result (a×x)±b. The third multiplier obtains the result of the operation (a×x+b)×x, and the first adder obtains the result (a×x+b)×x+c. The second adder is used to perform a rounding operation and outputs the rounded data to the post-processing module.

[0013] Furthermore, the post-processing module includes a seventh selector, an eighth selector, a fixed-point to floating-point conversion module, a third adder, a fourth adder, and a symbolic processing logic module. The seventh selector outputs the corresponding result to the fixed-point to floating-point conversion module according to the function type of the operation. The fixed-point to floating-point conversion module is used to convert the calculation result output by the calculation module into a floating-point number. The adder adds exp*ln2 to the calculation result of the logarithmic function operation. The fourth adder adds ln_add to the exponent of the floating-point number obtained by the exponential function operation. The symbolic processing logic module and the fourth adder output the result to the eighth selector, and the eighth selector outputs the corresponding floating-point result according to the function type of the operation to obtain the operation result.

[0014] Furthermore, the device is connected to floating-point arithmetic hardware to realize hyperbolic function operations.

[0015] Furthermore, the device reuses adders / subtractors and multipliers to realize the sine function y = sin(πx), the cosine function y = cos(πx), and the arctangent function. Exponential function y = e x Calculation of the logarithmic function y = ln(x).

[0016] Furthermore, the device also includes a floating-point adder / subtractor and a floating-point multiplier for performing operations on hyperbolic functions y = sinh(x), y = cosh(x), and y = atanh(x).

[0017] The resource-reuse-type transcendental function operation implementation device of the present invention has the following advantages: By reusing hardware resources such as adders / subtractors and multipliers, the present invention can implement the sine function y = sin(πx), the cosine function y = cos(πx), and the arctangent function. Exponential function y = e x The device calculates the logarithmic function y = ln(x). Furthermore, by adding a floating-point adder / subtractor and a floating-point multiplier, it can also perform calculations of hyperbolic functions y = sinh(x), y = cosh(x), and y = atanh(x). The error of each function implemented by the device is less than 2ulp, meeting the design accuracy requirements. In terms of performance, under SMIC 40nm process technology, the frequency of the 4-cycle transcendental function calculation implementation device can reach 270MHz. Attached Figure Description

[0018] Figure 1 This is a schematic diagram of the hardware architecture of the transcendental function operation implementation device of the present invention;

[0019] Figure 2 This is a schematic diagram of the hardware structure of the preprocessing module of the present invention;

[0020] Figure 3 This is a schematic diagram of the hardware structure of the table lookup module of the present invention;

[0021] Figure 4 This is a schematic diagram of the hardware structure of the computing module of the present invention;

[0022] Figure 5 This is a schematic diagram of the hardware structure of the post-processing module of the present invention. Detailed Implementation

[0023] To better understand the purpose, structure, and function of this invention, the following detailed description of a resource-reuse-type transcendental function operation implementation device is provided in conjunction with the accompanying drawings.

[0024] like Figure 1 As shown, the present invention provides a resource-reusable transcendental function operation implementation device, comprising a preprocessing module, a table lookup module, a calculation module, and a post-processing module. The preprocessing module performs corresponding data processing based on the type of the operation function and sends the processed data to the other three modules. The table lookup module searches for the corresponding table based on the type of the operation function, obtains the polynomial coefficients, and sends them to the calculation module. The calculation module performs a finite number of multiplications and additions on the processed data from the preprocessing module and the coefficients from the table lookup module, and sends the results to the post-processing module. The post-processing module performs corresponding data post-processing based on the type of the operation function, obtains the results, and outputs them.

[0025] Trigonometric functions, exponential functions with base e, and logarithmic operations are all implemented using second-order polynomials based on the lookup table method.

[0026] Based on the periodicity of the sine and cosine functions, we can compress the inputs of y = sin(πx) and y = cos(πx) to the range [-1, 1). Furthermore, the sine function is symmetric about the origin, while the cosine function is symmetric about y, thus further compressing the input range to [0, 1). Simultaneously, the graph of the sine function in the range [0, 1] is symmetric about the line x = 0.5, and the graph of the cosine function in the range [0, 1] is symmetric about the point (0.5, 0), ultimately compressing the computational input to [0, 0.5].

[0027] In practical applications, the input of the arctangent function is not large, generally between -1 and 1. Based on the odd function property of the arctangent function, we compress the input range to [0, 1).

[0028] For the exponential function e x According to the formula (where i is) The integer part, d is From the decimal part, we can see that we can express y = e x x∈(-∞,+∞) transforms into y=2 x Operations on x∈[0,1). According to the IEEE 754 floating-point representation, the floating-point number a×2i is equal to the exponent value of a in its floating-point representation +i.

[0029] For the logarithmic function ln(x), according to the formula (where exp is the exponent of the floating-point number x and man is the mantissa) It can be seen that we can compress the input range of y = ln(x), x∈(0,+∞) to [1,2).

[0030] The hardware architecture diagram of the entire transcendental function computation device is as follows: Figure 1 As shown, the device is divided into four modules based on its functions: a preprocessing module (Pre), a lookup table module (Lut), a calculation module (Calu), and a postprocessing module (Post). These modules respectively complete four steps: input preprocessing, looking up the fitting parameter table, calculating the function value based on the fitting parameters, and output processing. In terms of specific computational structure design, the resource-reuse transcendental function operation implementation device of this invention adopts a fixed-point algorithm, which consumes fewer resources compared to floating-point arithmetic devices.

[0031] The hardware architecture of the preprocessing module is as follows: Figure 2 As shown, the system includes a floating-point to fixed-point conversion module, a subtractor, a first multiplier, an inverter, a first selector, a second selector, a third selector, a fourth selector, and a selection logic module. The floating-point to fixed-point conversion module outputs a fixed-point number to the first selector, the second selector, the inverter, and the selection logic module. The selection logic module determines the output of the first selector (a fixed-point number or its inverted form) based on the characteristics of the fixed-point number. The subtractor subtracts 127 from the exponent (exp) of the floating-point number to be logarithmically processed to obtain the true exponent (IEEE standard floating-point exponent definition) and outputs the result to the second selector. Because the multipliers required for the logarithmic and exponential function preprocessing stages can be shared, the second and third selectors select the appropriate multipliers for the first multiplier based on the function type of the operation. The fourth selector then outputs the corresponding computation address to the lookup table module and the number to be computed to the computation module, based on the function type of the operation. Meanwhile, other outputs of the preprocessing module, such as the integer part of the exponential function, the addend of the logarithmic function, and the sign bit of the floating-point input, are connected to the postprocessing module.

[0032] The preprocessing module takes floating-point input values ​​`input` and `mode` as inputs. Based on the `mode` value, the preprocessing module performs the following processing on the input data: trigonometric functions convert the input number to a fixed-point number, then trigonometric identities transform the input to the specified range [0, 0.5). Finally, the high 7 bits and low 16 bits of `sin_data_qn` are output to the lookup table module and the calculation module; the exponential function first converts the input to a fixed-point number, then processes it through the first multiplier. The multiplication is performed, and the high 7 bits and low 16 bits of the 8-bit integer part exp_int and the fractional part exp_data_qn are output to the post-processing module, the lookup table module, and the calculation module, respectively. The logarithmic function takes the exponent of the floating-point input exp, performs exp*ln2 multiplication, and outputs the result ln_add directly to the post-processing module. The high 7 bits and low 16 bits of the 23-bit mantissa ln_data_qn of the floating-point input are output to the lookup table module and the calculation module, respectively. The multipliers required for the logarithmic and exponential function preprocessing stages can be shared.

[0033] The hardware architecture of the table lookup module is as follows: Figure 3 As shown, this includes four pre-generated lookup tables (sine and cosine function table, arctangent function table, exponential function table, and logarithmic function table) and a fifth selector. After receiving the address from the preprocessing module, the lookup module searches for and outputs the binomial y = ax from the four pre-generated tables. 2 The coefficients of the quadratic term *a*, the linear term *b*, and the zeroth-order term *c* are calculated for the operation +bx+c. Then, based on the mode code, the fitting parameters corresponding to the currently specified operation are selected from five outputs and output to the calculation module.

[0034] The hardware architecture of the computing module is as follows: Figure 4 As shown, the module includes a sixth selector, an adder / subtractor, a second multiplier, a third multiplier, a first adder, and a second adder. The calculation module performs the following calculations sequentially using fixed-point computation: the sixth selector outputs the corresponding result to the adder / subtractor based on the function type; the second multiplier first performs the operation a×x; the adder / subtractor obtains the result (a×x)±b (since the coefficients of the quadratic terms in the sine and cosine function fitting coefficients are all less than zero, while the coefficients of the quadratic terms in other functions are all greater than zero, subtraction is performed when performing sine function operations, and addition is performed when performing other function operations); the third multiplier obtains the result (a×x+b)×x; and the first adder obtains the result (a×x+b)×x+c. This is then summed with the result of calculating each term individually, resulting in ax. 2 Compared to +bx+c, this saves one multiplication operation. Finally, when truncating the data, a second adder performs rounding to improve precision before outputting the rounded data to the post-processing module.

[0035] The hardware architecture of the post-processing module is as follows: Figure 5As shown, the system includes a seventh selector, an eighth selector, a fixed-point to floating-point conversion module, a third adder, a fourth adder, and a symbolic processing logic module. The seventh selector outputs the corresponding result to the fixed-point to floating-point conversion module based on the function type of the operation. The fixed-point to floating-point conversion module converts the calculation result output by the calculation module (if it's a logarithmic function operation, the result is first added to exp*ln2 using the third adder) into a floating-point number, and outputs the resulting floating-point number to the symbolic processing logic or the fourth adder (for exponential function operations). The fourth adder is used to add ln_add (equivalent to multiplying by 2) to the exponent of the floating-point number obtained from the exponential function operation. i The symbol processing logic module and the fourth adder output the result to the eighth selector, which outputs the corresponding floating-point result according to the function type of the operation, thus obtaining the operation result.

[0036] After receiving the sign bit, calculation result from the preprocessing module, and fixed-point calculation result from the calculation module, the post-processing module performs the final processing on the received data according to the mode code: the trigonometric function converts the fixed-point result into a floating-point number and combines it with the sign bit before outputting; the exponential function converts the fixed-point result into a floating-point number, adds the integer part exponent from the preprocessing module to the exponent part, and combines it with the sign bit before outputting; the logarithmic function adds the fixed-point result to exp*ln2 from the preprocessing module, converts it into a floating-point number, and combines it with the sign bit before outputting.

[0037] The resource-reuse transcendental function operation implementation device of the present invention can directly implement trigonometric functions (sine and cosine functions, arctangent functions) and exponential functions e. x And operations with the logarithmic function ln(x). For example, when implementing trigonometric function operations, the steps are as follows: First, the preprocessing module converts the input fixed-point number to a floating-point number, then performs range conversion according to the properties of trigonometric functions, selecting the data itself or its inverted form for operation and table lookup. The table lookup module looks up the table based on the address output by the preprocessing module, obtains the coefficients, and outputs them to the calculation module. The calculation module performs a finite number of fixed-point multiplications and additions on the number to be calculated and the coefficients, and outputs the fixed-point result to the post-processing module. The post-processing module converts the obtained fixed-point number to a floating-point number and then performs symbolic logic processing to obtain the final floating-point operation result.

[0038] In addition, this device can be connected to floating-point arithmetic hardware to perform hyperbolic function operations. For hyperbolic functions, after performing the aforementioned exponential or logarithmic operations using this device, the corresponding floating-point addition / subtraction / multiplication is performed to obtain the corresponding calculation result.

[0039] According to the formula When calculating hyperbolic sine and cosine functions, one can first use a transcendental function calculation device to calculate e. x With e -xThen perform another floating-point addition / subtraction, and finally perform a floating-point multiplication with the constant 0.5 to obtain the final result.

[0040] According to the formula To calculate the hyperbolic arctangent function, you first need to perform floating-point addition / subtraction of 1+x and 1-x, then use the transcendental function calculation device to calculate ln(1+x) and ln(1-x), then perform floating-point addition / subtraction on the result, and finally perform floating-point multiplication with the constant 0.5 to obtain the final result.

[0041] In summary, by reusing hardware resources such as adders / subtractors and multipliers, the resource-reuse transcendental function operation implementation device of the present invention can implement the sine function y = sin(πx), the cosine function y = cos(πx), and the arctangent function. Exponential function y = e x The device is used to calculate the logarithmic function y = ln(x). Furthermore, by adding a floating-point adder / subtractor and a floating-point multiplier, it can also perform calculations of hyperbolic functions y = sinh(x), y = cosh(x), and y = atanh(x). Verification shows that the error of this transcendental function implementation device for each function is less than 2ulp, meeting the design accuracy requirements. In terms of performance, using SMIC's 40nm process, the frequency of this 4-cycle transcendental function implementation device can reach 270MHz.

[0042] It is understood that the present invention has been described through some embodiments, and those skilled in the art will recognize that various changes or equivalent substitutions can be made to these features and embodiments without departing from the spirit and scope of the invention. Furthermore, under the teachings of the present invention, these features and embodiments can be modified to adapt to specific situations and materials without departing from the spirit and scope of the invention. Therefore, the present invention is not limited to the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of this application are within the protection scope of the present invention.

Claims

1. A resource-reuse-type transcendental function operation implementation device, characterized in that, It includes a preprocessing module, a table lookup module, a calculation module, and a post-processing module. The preprocessing module performs corresponding data processing according to the type of operation function and sends the processed data to the other three modules. The table lookup module searches for the corresponding table according to the type of operation function, obtains the polynomial coefficients, and sends them to the calculation module. The calculation module performs a finite number of multiplications and additions on the processed data from the preprocessing module and the coefficients from the table lookup module, and sends the results to the post-processing module. The post-processing module performs corresponding data post-processing according to the type of the operation function, obtains the result, and outputs it. The pre-processing module includes a floating-point to fixed-point module, a subtractor, a first multiplier, an inverter, a first selector, a second selector, a third selector, a fourth selector, and a selection logic module. The floating-point to fixed-point module outputs a fixed-point number to the first selector, the second selector, the inverter, and the selection logic module. The selection logic module determines the output of the first selector based on the characteristics of the fixed-point number. The subtractor subtracts 127 from the exponent exp of the floating-point number to be logarithmically operated on to obtain the actual exponent and outputs the result to the second selector. The second and third selectors select the corresponding multiplier according to the type of the operation function and send it to the first multiplier for operation. The fourth selector then outputs the corresponding calculation address to the lookup table module and the number to be calculated to the calculation module according to the type of the operation function. The other outputs of the pre-processing module are connected to the post-processing module. The logarithmic and exponential function preprocessing stages share the first multiplier.

2. The resource-reuse-type transcendental function operation implementation device according to claim 1, characterized in that, The lookup module includes sine and cosine function tables, arctangent function tables, exponential function tables, logarithmic function tables, and a fifth selector; the sine and cosine function tables, arctangent function tables, exponential function tables, and logarithmic function tables are used to look up and output the binomial y = ax 2 The coefficients of the quadratic term a, the linear term b, and the zero-order term c of +bx+c; the fifth selector selects the fitting parameters corresponding to the currently specified operation from the five outputs according to the mode code, and outputs them to the calculation module for use.

3. The resource-reuse-type transcendental function operation implementation device according to claim 1, characterized in that, The calculation module includes a sixth selector, an adder / subtractor, a second multiplier, a third multiplier, a first adder, and a second adder. The sixth selector outputs the corresponding result to the adder / subtractor according to the function type of the operation. The second multiplier performs an a×x operation, and the adder / subtractor obtains the result (a×x)±b. The third multiplier obtains the result of the (a×x+b)×x operation, and the first adder obtains the result (a×x+b)×x+c. The second adder is used to perform a rounding operation and outputs the rounded data to the post-processing module.

4. The resource-reuse-type transcendental function operation implementation device according to claim 1, characterized in that, The post-processing module includes a seventh selector, an eighth selector, a fixed-point to floating-point conversion module, a third adder, a fourth adder, and a symbolic processing logic module; the seventh selector outputs the corresponding result to the fixed-point to floating-point conversion module according to the function type of the operation; The fixed-point to floating-point module converts the calculation result output by the calculation module into a floating-point number; the adder adds exp*ln2 to the calculation result of the logarithmic function operation; the fourth adder adds ln_add to the exponent of the floating-point number obtained by the exponential function operation; the symbol processing logic module and the fourth adder output the result to the eighth selector, and the eighth selector outputs the corresponding floating-point result according to the function type of the operation to obtain the calculation result.

5. The resource-reuse-type transcendental function operation implementation device according to claim 1, characterized in that, The device is connected to floating-point arithmetic hardware to perform hyperbolic function operations.

6. The resource-reuse-type transcendental function operation implementation device according to claim 3, characterized in that, The device reuses adders / subtractors and multipliers to realize the sine function y = sin(πx), the cosine function y = cos(πx), and the arctangent function. Exponential function y = e x Calculation of the logarithmic function y = ln(x).

7. The resource-reuse-type transcendental function operation implementation device according to claim 3, characterized in that, The device also includes a floating-point adder / subtractor and a floating-point multiplier for performing operations on hyperbolic functions y = sinh(x), y = cosh(x), and y = atanh(x).

Citation Information

Patent Citations

  • Resource reuse type transcendental function operation implementation method

    CN115658008A