Operation method of logarithmic calculation circuit and logarithmic calculation circuit

By simplifying the logarithmic calculation method, each iteration operation requires only two additions and one shift, which solves the problems of circuit design complexity and high cost in the existing technology, and achieves efficient logarithmic calculation.

CN113721886BActive Publication Date: 2024-08-27REALTEK SEMICON CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010446312.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-05-25
Publication Date
2024-08-27
Estimated Expiration
2040-05-25

AI Technical Summary

Technical Problem

The design of existing logarithmic calculation circuits is complex and costly, mainly due to the need to store large parameter tables and multiple complex multipliers.

Method used

A logarithmic calculation method is proposed. Each iterative operation requires only two additions and one shift. By selecting appropriate parameters and iterative operation process, the circuit design is simplified.

Benefits of technology

It effectively reduces the complexity of logarithmic calculation and circuit manufacturing and design costs, and achieves efficient logarithmic calculation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113721886B
    Figure CN113721886B
Patent Text Reader

Abstract

The present invention relates to a logarithmic calculation method and a logarithmic calculation circuit. The present invention discloses a logarithmic calculation method, which includes the following steps: (a) selecting a first parameter, a second parameter, a third parameter and a fourth parameter corresponding to the i-th iteration operation; (b) determining whether an input value is greater than the third parameter or less than the fourth parameter; (c) if the input value is greater than the third parameter, updating the input value by multiplying the first parameter, and updating the output value by subtracting the logarithmic value of the first parameter; if the input value is less than the fourth parameter, updating the input value by multiplying the second parameter, and updating the output value by subtracting the logarithmic value of the second parameter; if the input value is between the third parameter and the fourth parameter, not changing the input value and the output value; (d) adding 1 to i and returning to step (a) until i is equal to a preset value; (e) when i is equal to the preset value, taking the current output value as the calculation result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a logarithmic calculation method. Background Art

[0002] In general logarithmic calculation circuits, a coordinate rotation digital computer (CORDIC) method is usually used to implement logarithmic calculation. However, the above method requires storing a large parameter table and also requires using multiple multipliers with complex circuit designs, thereby increasing the complexity and cost of circuit design. Summary of the invention

[0003] Therefore, one of the objectives of the present invention is to provide a logarithmic calculation method and a related circuit, which only requires two additions and one shift in each iteration operation process, thereby greatly simplifying the circuit design to solve the problems in the prior art.

[0004] In one embodiment of the present invention, a logarithmic calculation method is disclosed, which is used to perform logarithmic operation on an initial input value, and includes the following steps: (a) selecting a first parameter, a second parameter, a third parameter, and a fourth parameter corresponding to the i-th iteration operation; (b) determining whether an input value is greater than the third parameter, less than the fourth parameter, or between the third parameter and the fourth parameter, wherein the input value is obtained from the initial input value; (c) if the input value is greater than the third parameter, updating an input value by multiplying the first parameter (d) adding 1 to i and returning to step (a) until i equals a preset value; and (e) when i equals the preset value, using the current output value as an output result of performing a logarithmic operation on the initial input value.

[0005] In another embodiment of the present invention, a logarithmic calculation circuit is disclosed, which is used to perform logarithmic operation on an initial input value, and includes an iterative operation circuit, and the iterative operation circuit is used to perform multiple iterative operations in sequence; for any iterative operation performed by the iterative operation circuit, the iterative operation circuit performs the following operations: (a) selects a first parameter, a second parameter, a third parameter, and a fourth parameter corresponding to the first parameter, the second parameter, the third parameter, and the fourth parameter; (b) determines whether an input value is greater than the third parameter, less than the fourth parameter, or between the third parameter and the fourth parameter, wherein the input value is obtained according to the initial input value; (c) if the input value is greater than the third parameter, the input value is less than the fourth parameter, or is between the third parameter and the fourth parameter; (d) if the input value is greater than the third parameter, the input value is updated by multiplying it by the first parameter, and an output value is updated by subtracting the logarithm of the first parameter; if the input value is less than the fourth parameter, the input value is updated by multiplying it by the second parameter, and the output value is updated by subtracting the logarithm of the second parameter; if the input value is between the third parameter and the fourth parameter, the input value and the output value are not changed; (d) the updated input value and the output value are used as the output value and input value of the next iterative operation; wherein the output value generated by the last iterative operation of the iterative operation circuit is used as a calculation result of the logarithmic operation on the initial input value. BRIEF DESCRIPTION OF THE DRAWINGS

[0006] Figure 1 FIG. 4 is a flow chart of a logarithm calculation method according to an embodiment of the present invention.

[0007] Figure 2 FIG. 4 is a schematic diagram of a logarithmic calculation circuit according to an embodiment of the present invention. DETAILED DESCRIPTION

[0008] Figure 1 FIG. 1 is a flow chart of a logarithmic calculation method according to an embodiment of the present invention. Figure 1As shown, in step 100, the process starts and is ready to perform a logarithmic operation on an initial input value x to obtain an output value y, that is, y=ln(x). In step 102, the output value y is first set to 0, the parameter i is set to 1 (that is, the first iteration operation is performed, and the initial input value x is converted to a floating point representation, that is, the initial input value x is converted to x=m*2^n, where n is a positive integer, and m is a value between 0.5 and 1. In one embodiment, m can be a 16-bit digital value, and n can be a 6-bit digital value. In step 104, the i-th group of parameters is selected, where the i-th group of parameters includes xa(i), xb(i), limit_up(i), and limit_low(i). At this time, since i is equal to 1 at the beginning of the calculation, xa(1), xb(1), limit_up(1), and limit_low(1) included in the first group of parameters are (1 / 2), (3 / 2), (4 / 3), and (4 / 5), respectively. In step 106, the initial input value x and the parameters limit_up(1), limit_low (1), if the initial input value x is greater than the parameter limit_up(1), the process proceeds to step 108; if the initial input value x is less than the parameter limit_low(1), the process proceeds to step 110; if the initial input value x is between the parameters limit_up(1) and limit_low(1), the process proceeds to step 112. In step 108, the initial input value x is multiplied by the parameter xa(1) for updating (the subsequent x is referred to as the input value), and the output value y is subtracted from ln(xa(1)), that is, x = x*xa(1), and y = y-ln(xa(1)). In step 110, the input value x is multiplied by the parameter xb(1), and the output value y is subtracted from ln(xb(1)), that is, x = x*xb(1), and y = y-ln(xb(1)). In step 112, the parameter i is increased by 1, and the process returns to step 104 to start the second iteration operation.

[0009] It should be noted that, since the above parameters xa(1) and xb(1) satisfy the structures of 1-2^(-1) and 1+2^(-1) respectively, x*xa(1) in step 108 can be implemented in circuit through a shift register and an adder, that is, x*xa(1)=x*(1-2^(-1))=xx>>1, where “>>” is a shift operator; similarly, x*xb(1) in step 110 can be implemented in circuit through a shift register and an adder, that is, x*xb(1)=x*(1+2^(-1))=x+x>>1, where “>>” is a shift operator.

[0010] In the second iteration, the second set of parameters selected in step 104 includes parameters xa(2), xb(2), limit_up(2), and limit_low(2), which are (3 / 4), (5 / 4), (8 / 7), and (8 / 9), respectively. In step 106, the relationship between the input value x and the parameters limit_up(2) and limit_low(2) is determined. If the input value x is greater than limit_up(2), the process proceeds to step 108; if the input value x is less than the parameter limit_low(2), the process proceeds to step 110; if the input value x is between the parameters limit_up(2) and limit_low(2), the process proceeds to step 112. In step 108, x is multiplied by xa(2), and the output value y is subtracted by ln(xa(2)), that is, x=x*xa(2), and y=y-ln(xa(2)). In step 110 , the input value x is multiplied by xb(2), and the output value y is subtracted by ln(xb(2)), that is, x=x*xb(2), and y=y-ln(xb(2)).

[0011] Since the above parameters xa(2) and xb(2) satisfy the structures of 1-2^(-2) and 1+2^(-2) respectively, x*xa(2) in step 108 can be implemented in circuit through a shift register and an adder, that is, x*xa(2)=x*(1-2^(-2))=xx>>2; similarly, x*xb(2) in step 110 can be implemented in circuit through a shift register and an adder, that is, x*xb(2)=x*(1+2^(-2))=x+x>>2.

[0012] Then, the third iterative operation, the fourth iterative operation, ... are continued until a preset value of the system is reached. For example, when the eighth iterative operation is completed, the calculated output value y is output as the final calculation result, that is, the result of logarithmic calculation of the initial input value.

[0013] In one embodiment, the parameters xa(i), xb(i), limit_up(i), and limit_low(i) used in each iteration operation are designed as shown in Table 1 and Table 2 below:

[0014] i xa(i) xb(i) 1 1 / 2 3 / 2 2 3 / 4 5 / 4 3 7 / 8 9 / 8 4 15 / 16 17 / 16 5 31 / 32 33 / 32 6 63 / 64 65 / 64 7 127 / 128 129 / 128 8 255 / 256 257 / 256 9 511 / 512 513 / 512 10 1023 / 1024 1025 / 1024 11 2047 / 2048 2049 / 2048 12 4095 / 4096 4097 / 4096 13 8191 / 8192 8193 / 8192 14 16383 / 16384 16385 / 16384 15 32767 / 32768 32769 / 32768 16 65535 / 65536 65537 / 65536

[0015] Table 1

[0016]

[0017]

[0018] Table 2

[0019] Through the parameter design in the above table, the input value x after the first iteration operation will be between (2 / 3) and (4 / 3), the input value x after the second iteration operation will be between (5 / 6) and (8 / 7), the input value x after the third iteration operation will be between (14 / 15) and (16 / 15), the input value x after the fourth iteration operation will be between (30 / 31) and (32 / 31), the input value x after the fifth iteration operation will be between (62 / 63) and (64 / 63), the input value x after the sixth iteration operation will be between (126 / 127) and (128 / 127), ..., that is, as the number of iteration operations increases, the value of the input value x will be closer to 1, so that the output value y will be closer to the ideal value. In an example, if 16 iteration operations are performed, the error between the output value y and the ideal value is 7.6*10^(-6).

[0020] As described in the above table, since the parameters xa(i) and xb(i) respectively satisfy the structures of 1-2^(-i) and 1+2^(-i), the calculation of the input value x in each iteration operation can be implemented in the circuit through a shift register and an adder; in addition, since the parameters xa(i), xb(i), limit_up(i), and limit_low(i) are all constants, the logarithmic values ​​of these parameters can be pre-calculated in advance and a lookup table can be established for use in calculating the output value y in each iteration operation, that is, the calculation of the output value y in each iteration operation can be implemented in the circuit through only one adder. In summary, each iteration operation only requires one shift operation, two addition operations, and two comparison operations to be implemented, thereby effectively reducing the complexity of the logarithmic calculation process and also reducing the manufacturing and design costs of the circuit.

[0021] Figure 2 FIG. 2 is a schematic diagram of a logarithmic calculation circuit 200 according to an embodiment of the present invention. Figure 2 As shown, the logarithmic calculation circuit 200 includes an iterative operation circuit 210 and a selection circuit 220, wherein the iterative operation circuit 210 is used to perform Figure 1For each iteration operation shown, the selection circuit 220 transmits relevant parameters to the iteration operation circuit 210 according to the i-th iteration operation currently being performed, such as the above-mentioned i, xa(i), xb(i), limit_up(i), limit_low(i) and the current input value x and output value y. In the operation of the iterative operation circuit 210 in this embodiment, the iterative operation circuit 210 includes a shift register 202 and two adders 204 and 206, wherein the shift register 202 and the adder 204 are used to perform the operation on the input value x in steps 108 and 110, that is, x=x*xa(i) or x=x*xb(i), wherein the illustrated x' is used to represent the input value x of the next iterative operation circuit 210; and the adder 206 is used to perform the operation on the output value y in steps 108 and 110, that is, y=y-ln(xa(i)) or y=y-ln(xb(i)), wherein the illustrated y' is used to represent the output value y of the next iterative operation. As those skilled in the art can also combine with the relevant Figure 1 The operation of the logarithmic calculation circuit 200 can be easily understood after the above-described process, so the operation details of the logarithmic calculation circuit 200 will not be repeated.

[0022] To briefly summarize the present invention, in the logarithmic calculation method and related circuits of the present invention, through special parameter settings and iterative operation processes, each iterative operation can be implemented through only one shift register and two adders. Therefore, the complexity of the logarithmic calculation process can be effectively reduced, and the manufacturing and design costs of the circuit are also reduced.

[0023] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.

[0024]

Explanation of symbols

[0025] 100~112: Steps

[0026] 200: Logarithmic calculation circuit

[0027] 210: Iterative operation circuit

[0028] 202: Shift register

[0029] 204: Adder

[0030] 206: Adder

[0031] 220: Select Circuit

[0032] x,x': input value

[0033] xa(i):parameter

[0034] xb(i): parameter

[0035] y,y': output value

Claims

1. An operating method of a logarithmic calculation circuit, which is used to perform a logarithmic operation on an initial input value, the operating method comprising: Multiple iterative operations are performed sequentially by an iterative operation circuit, the iterative operation circuit comprising a shift register and two adders, wherein for any iterative operation performed by the iterative operation circuit, the iterative operation circuit performs the following operations: (a) Select a first parameter and a second parameter corresponding to the i-th iteration operation. number, a third parameter and a fourth parameter; (b) determining whether an input value is greater than the third parameter, less than the fourth parameter, or between the third parameter and the fourth parameter, wherein the input value is obtained from the initial input value; (c) if the input value is greater than the third parameter, updating an input value by multiplying the first parameter, and updating an output value by subtracting a logarithmic value of the first parameter; if the input value is less than the fourth parameter, updating the input value by multiplying the second parameter, and updating the output value by subtracting a logarithmic value of the second parameter; If the input value is between the third parameter and the fourth parameter, the input value and the output value are not changed, wherein in step (c), the operation of updating the input value is completed only through the shift register and one of the two adders, and the operation of updating the output value is completed only through the other of the two adders; (d) adding 1 to i and returning to step (a) until i equals a preset value; as well as (e) when i is equal to the preset value, taking the current output value as a calculation result of performing a logarithmic operation on the initial input value; and The relevant parameters are transmitted to the iterative operation circuit through a selection circuit according to the iterative operation currently being performed.

2. The operating method according to claim 1, wherein when i is equal to 1, the first parameter, the second parameter, the third parameter and the fourth parameter are (1 / 2), (3 / 2), (4 / 3), and (4 / 5), respectively; when i is equal to 2, the first parameter, the second parameter, the third parameter and the fourth parameter are (3 / 4), (5 / 4), (8 / 7), and (8 / 9), respectively; when i is equal to 3, the first parameter, the second parameter, the third parameter and the fourth parameter are (7 / 8), (9 / 8), (16 / 15), and (16 / 17), respectively; when i is equal to 4, the first parameter, the second parameter, the third parameter and the fourth parameter are (15 / 16), (17 / 16), (32 / 31), and (32 / 33), respectively. 3 . The operating method according to claim 1 , wherein the third parameter is greater than the fourth parameter, and the first parameter is 1-2^(-i), and the second parameter is 1+2^(-i).

4. A logarithmic calculation circuit for performing a logarithmic operation on an initial input value, comprising: an iterative operation circuit for sequentially performing multiple iterative operations, the iterative operation circuit comprising a shift register and two adders; and a selection circuit for transmitting relevant parameters to the iterative operation circuit according to the iterative operation currently being performed; For any iterative operation performed by the iterative operation circuit, the iterative operation circuit performs the following operations: (a) selects a first parameter, a second parameter, a third parameter, and a fourth parameter corresponding to the first parameter, (b) determines whether an input value is greater than the third parameter, less than the fourth parameter, or between the third parameter and the fourth parameter, wherein the input value is obtained according to the initial input value; (c) if the input value is greater than the third parameter, updates the input value by multiplying the first parameter, and updates an output value by subtracting the logarithm of the first parameter; if the input value is less than the fourth parameter, updates the input value by multiplying the second parameter, and updates the output value by subtracting the logarithm of the second parameter; if the input value is between the third parameter and the fourth parameter, does not change the input value and the output value; (d) uses the updated input value and the output value as the output value and the input value of the next iterative operation; The output value generated by the last iteration of the iteration circuit is used as a calculation result of the logarithmic operation of the initial input value, and The iterative operation circuit completes the operation of updating the input value only through the shift register and one of the two adders, and completes the operation of updating the output value only through the other of the two adders.

5. The logarithmic calculation circuit according to claim 4, wherein the first parameter, the second parameter, the third parameter and the fourth parameter selected by the first iteration operation of the multiple iteration operations are (1 / 2), (3 / 2), (4 / 3), (4 / 5) respectively; the first parameter, the second parameter, the third parameter and the fourth parameter selected by the second iteration operation of the multiple iteration operations are (3 / 4), (5 / 4), (8 / 7), (8 / 9) respectively; the first parameter, the second parameter, the third parameter and the fourth parameter selected by the third iteration operation of the multiple iteration operations are (7 / 8), (9 / 8), (16 / 15), (16 / 17) respectively; the first parameter, the second parameter, the third parameter and the fourth parameter selected by the fourth iteration operation of the multiple iteration operations are (15 / 16), (17 / 16), (32 / 31), (32 / 33) respectively. 6 . The logarithmic calculation circuit according to claim 4 , wherein the third parameter is greater than the fourth parameter, and the first parameter is 1-2^(-i), and the second parameter is 1+2^(-i).