Power function calculation device and power function calculation method

文档序号:1270564 发布日期:2020-08-25 浏览:16次 中文

阅读说明:本技术 一种幂函数计算装置及幂函数计算方法 (Power function calculation device and power function calculation method ) 是由 侯亮 江宏武 于振华 于 2020-04-10 设计创作,主要内容包括:本发明公开了一种幂函数计算装置及幂函数计算方法,其中,装置包括:输入电路,用于接收第一输入信息;存储电路,用于存储指定幂函数查找表;第一判断电路,连接输入电路,用于判断第一输入信息是否处于预设区间内;移位电路,连接第一判断电路,用于在第一输入信息未处于预设区间内时,利用第一移位值对第一输入信息进行移位得到第二信息,第二信息在预设区间内;运算电路,连接移位电路及存储电路,用于使用处于预设区间内的第一输入信息或第二信息在指定幂函数查找表中进行查找得到查表结果,并利用查表结果及幂函数的指数进行第一计算获取第一输入信息的幂函数值。用以在数字电路中实现特殊幂函数的计算,并且输出结果精度高。(The invention discloses a power function calculation device and a power function calculation method, wherein the device comprises: an input circuit for receiving first input information; a storage circuit for storing a specified power function lookup table; the first judgment circuit is connected with the input circuit and used for judging whether the first input information is in a preset interval or not; the shifting circuit is connected with the first judging circuit and used for shifting the first input information by utilizing the first shifting value to obtain second information when the first input information is not in the preset interval, and the second information is in the preset interval; and the operation circuit is connected with the shift circuit and the storage circuit and used for searching in the specified power function lookup table by using the first input information or the second information in the preset interval to obtain a lookup table result, and performing first calculation by using the lookup table result and the exponent of the power function to obtain the power function value of the first input information. The method is used for realizing the calculation of the special power function in the digital circuit, and the output result has high precision.)

1. A power function calculation apparatus, comprising:

an input circuit for receiving first input information;

a storage circuit for storing a specified power function lookup table;

the first judgment circuit is connected with the input circuit and used for judging whether the first input information is in a preset interval or not;

the shifting circuit is connected with the first judging circuit and used for shifting the first input information by using a first shifting value to obtain second information when the first input information is not in the preset interval, and the second information is in the preset interval;

and the operation circuit is connected with the shift circuit and the storage circuit and used for searching in a specified power function lookup table by using the first input information or the second information in the preset interval to obtain a lookup result, and performing first calculation by using the lookup result and the exponent of the power function to obtain the power function value of the first input information.

2. The computing device of claim 1, wherein the device further comprises: a second judgment circuit and a numerical value conversion circuit;

the second judgment circuit is connected with the input circuit and the first judgment circuit and is used for judging whether the first input information is a fixed-point numerical value or not;

and the value conversion circuit is connected with the second judgment circuit and the first judgment circuit and is used for converting the first input information into a fixed point value by using a first scaling value when the first input information is not the fixed point value.

3. The computing device of claim 1, wherein the storage circuit is configured to store a first lookup table that has undergone a first compression; or

The storage circuit is used for storing a second lookup table subjected to second compression;

wherein the second compression is based on the first compression.

4. The computing device according to claim 3, wherein the storage circuit is configured to store the specified function values of the sampling points at the specified positions in each of the plurality of groups within a preset interval, and the specified power function values of the other sampling points and the specified power function values of the sampling points at the specified positions;

wherein the difference removes a cardinality portion common to other differences in the same group.

5. The computing device according to claim 4, wherein the storage circuit is configured to store the original values of the sampling points at the specified positions in each group, and the correction values of at least some other sampling points, wherein the correction values are power function value differences of adjacent sampling points and granularity differences, and the granularity is an integer of an average difference of all sampling points in the group.

6. The computing device of claim 1, wherein the exponent of the power function is a negative number greater than or equal to-1.

7. The computing device of claim 1, wherein the operation circuit comprises a multiplier and an adder, and the operation circuit obtains the power function value of the first input information by performing a first calculation through the multiplier and the adder by using the table look-up result and the exponent of the power function.

8. A power function calculation method, characterized in that the method comprises:

receiving first input information;

judging whether the first input information is in a preset interval or not;

if so, searching in the specified power function lookup table by using the first input information to obtain a lookup result, otherwise, shifting the first input information by using a first shift value to obtain second information, wherein the second information is in the preset interval, and then

Searching in a specified power function lookup table by using the second information to obtain a lookup result;

and performing first calculation by using the table look-up result and the exponent of the power function to obtain the power function value of the first input information.

9. The method of claim 8, wherein the first computation comprises a shift operation and an add operation and/or a multiply operation.

10. The method of claim 8, wherein the exponent of the specified power function is-0.5.

11. The method of claim 8, wherein the step of determining whether the first input information is within a preset interval further comprises:

judging whether the first input information is a fixed-point numerical value or not;

if not, converting the first input information into a fixed point numerical value by using a first fixed scale value;

and if so, executing the step of judging whether the first input information is in a preset interval.

12. The method of claim 11,

the step of performing a first calculation by using the table look-up result and the exponent of the power function to obtain the power function value of the first input information includes:

and calculating the power function value of the first input information by using the lookup table result, the scaling value corresponding to the lookup table result, the first scaling value, the scaling value corresponding to the power function value of the first input information, the first shift value and the exponent of the power function.

13. The method of claim 1, wherein the exponent of the power function is a negative number greater than or equal to-1.

14. The method of claim 8, wherein prior to using the second information for lookup in a specified power function lookup table and/or using the first input information for lookup in a specified power function lookup table, further comprising:

and establishing the specified power function lookup table.

15. The method of claim 14, wherein the building the specified power function lookup table further comprises:

performing first compression on the specified power function lookup table to obtain a first lookup table;

and performing second compression on the first lookup table to obtain a second lookup table.

16. The method of claim 15,

the first compressing the specified power function lookup table to obtain a first lookup table comprises:

the specified power function lookup table includes a plurality of sampling points within the preset interval and specified power function values thereof, the sampling points are divided into a plurality of groups, the specified power function value of the sampling point at a specified position in each group is stored in an original numerical value manner, the specified power function values of other sampling points are stored in a difference value manner with the specified power function values of the sampling points at the specified positions, and the difference value removes a base number part common to other difference values in the same group.

17. The method of claim 16,

performing a second compression on the first lookup table to obtain a second lookup table specifically includes:

and the specified power function value of the sampling points at the specified position in each group is stored in an original numerical value mode, and at least part of other sampling points are stored in a corrected value mode, wherein the corrected value is the difference value of the specified power function values of the adjacent sampling points and the granularity, and the granularity is the integral result of the average difference value of all the sampling points in the group.

Technical Field

The invention relates to the technical field of digital circuits, in particular to a power function calculation device and a power function calculation method.

Background

With the advancement of science and technology, no matter cloud computing, big data or artificial intelligence, the cloud computing, big data or artificial intelligence will become the mainstream of the future market, and the advancement of human beings is promoted. While these fields are developing and involve the processing of large amounts of data, the quality of data processing performance is directly related to their development, and energy efficiency and throughput are particularly important as key parts of data processing performance. Heterogeneous systems based on Application Specific Integrated Circuits (ASICs) and Field Programmable Gate Arrays (FPGAs) are one of the research focuses in the industry due to their high energy efficiency ratio and throughput.

In practical business application, hardware implementation of various operators has certain difficulty, especially the implementation of special power functions in digital circuits. A common implementation of the power function is the inverse square Root algorithm (Fast inverse square Root). This method is limited to power functions due to its floating point nature and high multiplier consumptionThe case of n being 2 does not allow the computation of a special power function in a digital circuit when n is not equal to 2.

Disclosure of Invention

The invention provides a power function calculation device and a power function calculation method, which are used for realizing the calculation of a special power function in a digital circuit and have high output result precision.

In order to solve the above technical problems, a first technical solution provided by the present invention is: there is provided a power function calculation device including: an input circuit for receiving first input information; a storage circuit for storing a specified power function lookup table; the first judgment circuit is connected with the input circuit and used for judging whether the first input information is in a preset interval or not; the shifting circuit is connected with the first judging circuit and used for shifting the first input information by using a first shifting value to obtain second information when the first input information is not in the preset interval, and the second information is in the preset interval; and the operation circuit is connected with the shift circuit and the storage circuit and used for searching in a specified power function lookup table by using the first input information or the second information in the preset interval to obtain a lookup result, and performing first calculation by using the lookup result and the exponent of the power function to obtain the power function value of the first input information.

Wherein the apparatus further comprises: a second judgment circuit and a numerical value conversion circuit; the second judgment circuit is connected with the input circuit and the first judgment circuit and is used for judging whether the first input information is a fixed-point numerical value or not; and the value conversion circuit is connected with the second judgment circuit and the first judgment circuit and is used for converting the first input information into a fixed point value by using a first scaling value when the first input information is not the fixed point value.

The storage circuit is used for storing a first lookup table subjected to first compression; or the storage circuit is used for storing a second lookup table after the second compression; wherein the second compression is based on the first compression.

The storage circuit is used for storing the specified function value of the sampling point at the specified position in each group in a plurality of groups in a preset interval and the difference value of the specified power function value of other sampling points and the specified power function value of the sampling point at the specified position; wherein the difference removes a cardinality portion common to other differences in the same group.

The storage circuit is used for storing original numerical values of the sampling points at the specified positions in each group and at least partial correction values of other sampling points, wherein the correction values are power function value difference values of adjacent sampling points and granularity difference values, and the granularity is an integral result of average difference values of all the sampling points in the group.

Wherein the exponent of the power function is a negative number greater than or equal to-1.

The arithmetic circuit comprises a multiplier and an adder, and the arithmetic circuit performs first calculation by using the table look-up result and the exponent of the power function through the multiplier and the adder to obtain the power function value of the first input information.

In order to solve the above technical problems, a second technical solution provided by the present invention is: there is provided a power function calculation method including: receiving first input information; judging whether the first input information is in a preset interval or not; if so, searching in the specified power function lookup table by using the first input information to obtain a lookup result, if not, shifting the first input information by using a first shift value to obtain second information, and searching in the specified power function lookup table by using the second information to obtain a lookup result within the preset interval; and performing first calculation by using the table look-up result and the exponent of the power function to obtain the power function value of the first input information.

Wherein the first calculation comprises a shift operation and an addition operation and/or a multiplication operation.

Wherein the exponent of the specified power function is-0.5.

Wherein, before the step of judging whether the first input information is in a preset interval, the method further comprises: judging whether the first input information is a fixed-point numerical value or not; if not, converting the first input information into a fixed point numerical value by using a first fixed scale value; and if so, executing the step of judging whether the first input information is in a preset interval.

Wherein, the step of performing the first calculation by using the table look-up result and the exponent of the power function to obtain the power function value of the first input information comprises: and calculating the power function value of the first input information by using the lookup table result, the scaling value corresponding to the lookup table result, the first scaling value, the scaling value corresponding to the power function value of the first input information, the first shift value and the exponent of the power function.

Wherein the exponent of the power function is a negative number greater than or equal to-1.

Wherein the using the second information for lookup in a specified power function lookup table and/or using the first input information for lookup in a specified power function lookup table further comprises: and establishing the specified power function lookup table.

Wherein the establishing the specified power function lookup table further comprises: performing first compression on the specified power function lookup table to obtain a first lookup table; and performing second compression on the first lookup table to obtain a second lookup table.

Wherein the first compressing the specified power function lookup table to obtain a first lookup table comprises: the specified power function lookup table includes a plurality of sampling points within the preset interval and specified power function values thereof, the sampling points are divided into a plurality of groups, the specified power function value of the sampling point at a specified position in each group is stored in an original numerical value manner, the specified power function values of other sampling points are stored in a difference value manner with the specified power function values of the sampling points at the specified positions, and the difference value removes a base number part common to other difference values in the same group.

Wherein, compressing the first lookup table for the second time to obtain a second lookup table specifically includes: and the specified power function value of the sampling points at the specified position in each group is stored in an original numerical value mode, and at least part of other sampling points are stored in a corrected value mode, wherein the corrected value is the difference value of the specified power function values of the adjacent sampling points and the granularity, and the granularity is the integral result of the average difference value of all the sampling points in the group.

The invention has the beneficial effects that: different from the prior art, the method shifts the first input information which is not in the preset interval to obtain the second information, then searches in the specified power function lookup table by using the first input information or the second information which is in the preset interval to obtain a lookup result, and performs the first operation by using the lookup result and the exponent of the power function to obtain the power function value of the first input information. So as to realize the calculation of special power function in the digital circuit and the output result has high precision.

Drawings

In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without inventive efforts, wherein:

FIG. 1 is a schematic structural diagram of a power function calculating apparatus according to a first embodiment of the present invention;

FIG. 2 is a schematic structural diagram of a power function calculating device according to a second embodiment of the present invention;

FIG. 3 is a flow chart illustrating a first embodiment of the power function calculation method of the present invention;

FIG. 4 is a flow chart of a second embodiment of the power function calculation method of the present invention.

Detailed Description

The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.

The present invention will be described in detail below with reference to the accompanying drawings and examples.

Please refer to fig. 1, which is a schematic structural diagram of a power function calculating device according to a first embodiment of the present invention. The method comprises the following steps: an input circuit 11, a memory circuit 12, a first judgment circuit 13, a shift circuit 14, and an arithmetic circuit 15. The input circuit 11 is used for receiving first input information; the storage circuit 12 is used for storing a specified power function lookup table; the first judging circuit 13 is connected to the input circuit 11 and is configured to judge whether the first input information is within a preset interval; the shift circuit 14 is connected to the first judging circuit 13, and configured to shift the first input information by using the first shift value to obtain second information when the first input information is not within the preset interval, where the second information is within the preset interval; the operation circuit 15 is connected to the shift circuit 14 and the storage circuit 12, and configured to perform lookup in a specified power function lookup table using the first input information or the second information within the preset interval to obtain a lookup result, and perform a first calculation using the lookup result and an exponent of the power function to obtain a power function value of the first input information.

Specifically, after the input circuit 11 acquires the first input information, the first determining circuit 13 determines whether the first input information is in a preset interval, and if the first input information is not in the preset interval, the shifting circuit 14 shifts the first input information to the preset interval by using a first shift value to obtain the second information. Specifically, the first input information may be shifted using the following formula (1):

xc=x×2s(1)

wherein x is the first input information, s is the first shift value, xcThe second information is the second information in the preset interval.

For example, in an embodiment, if the first input information x is 12 and the preset interval is [0.5,1 ], if the first input information x is to be shifted into the preset interval [0.5,1) by using the above formula (1), the first shift value may be set to-4, that is: x is the number ofc=12×2-4Calculating the available xc=0.75,xc0.75 is within a preset interval [0.5, 1). The first shift value is negative, and it can be seen that when the first input information is shifted, the first input information is shifted to the right to be reduced. For example, in another embodiment, if the first input information x is 0.1 and the preset interval is [0.5,1 ], if the first input information x is to be shifted into the preset interval [0.5,1) by using the above formula (1), the first shift value may be set to 3, that is: x is the number ofc=0.1×23Calculating the available xc=0.8,xc0.8 is within a preset interval [0.5, 1). The first shift value is a positive number, and it can be seen that when the first input information is shifted, the first input information is shifted to the left to be amplified.

After the first input information is shifted to the preset interval, the arithmetic circuit 15 uses the first input information located in the preset interval or the second information located in the preset interval to search in the specified power function lookup table stored in the storage circuit 12 to obtain a lookup result, and uses the lookup result and the exponent of the power function to perform a first calculation to obtain the power function value of the first input information. In particular, due to power functionsUnder the effect of the negative half axis of x, it is symmetrical with the origin, so it is only necessary to construct a lookup table for x ≧ 0. Further, to simplify the operation, the input information may be shifted by shifting or the like and reduced or enlarged to the interval, so that the lookup table is constructed only at xc∈ [0.5,1) interval is constructed, so that the storage space of the storage circuit 12 can be saved.

Specifically, when the storage circuit 12 stores the specified power function lookup table, the first lookup table subjected to the first compression may be stored, that is, only the specified function value of the sampling point at the specified position in each of the plurality of groups within the preset interval and the difference value between the specified power function value of the other sampling point and the specified power function value of the sampling point at the specified position are stored; wherein the difference removes a portion of the cardinality common to other differences in the same group.

For example, W sampling points are uniformly collected in a preset interval, and the W sampling points are divided into N groups including G1、G2、G3……GNGroups, each group comprising M sampling points: d1、D2、D3……DM. The storage circuit 12 stores the first sampling point D in each group1Specified power function value B of1Subsequent sampling point D2、D3……DMRespectively with the first sampling point D1Specified power function value B of1Is stored, e.g. the second sample point D2Given power function value of B2Third sampling point D3Given power function value of B3M th sampling point DMGiven power function value of BM. At this time, the second sampling point D2Specified power function value B of2And the first sampling point D1Specified power function value B of1Has a difference of Δ1Third sampling point D3Specified power function value B of3And the first sampling point D1Specified power function value B of1Has a difference of Δ2Fourth sample point D4Specified power function value B of4And the first sampling point D1Specified power function value B of1Has a difference of Δ3M th sampling point DMSpecified power function value B ofMAnd the first sampling point D1Specified power function value B of1Has a difference of ΔM-1. In one embodiment, the storage circuit 12 may store only the first sampling point D in each group1Specified power function value B of1And the difference between the remaining sample points and the first sample point, e.g. delta1、Δ2、Δ3……ΔM-1. Further, to save the storage space of the storage circuit 12, the storage circuit 12 may also store only the first sampling points D in each group of the first sampling points1Specified power function value B of1And the difference between the remaining sample points and the first sample point, e.g. delta1、Δ2、Δ3……ΔM-1Wherein, is1、Δ2、Δ3……ΔM-1Removing the common base part thereof, e.g. if Δ1、Δ2、Δ3……ΔM-12, 4, 6 … … 2(M-1), respectively, then the memory circuit 12 stores 1, 2, 3 … … M-1.

The storage circuit 12 stores the data in the above manner, so that the storage space can be effectively reduced. For example, if the number M of sampling points in each group is 8, and the specified power function values of the sampling points in each group are all stored, the storage of the specified power function lookup table occupies 4096/8-512 groups in total, and when the specified power function lookup table is stored according to the above compression scheme, 16-bit storage B is used in each group1Storing delta with 8bit1、Δ2、Δ3……ΔM-1And removing the residual numbers in the radix part, each packet occupies 72 bits (7 × 8 bits +16 bits) of storage space, and the whole specified power function lookup table is compressed to occupy 36 kbits (512 × 72 bits).

In another embodiment, the storage circuit 12 may be further configured to store a second lookup table after the second compression, that is, to store the original values of the sampling points at the specified positions in each group, and the modified values of at least some other sampling points, where the modified values are the difference between the power function values of adjacent sampling points and the granularity, where the granularity is the integral of the average difference of all the sampling points in the group.

Specifically, assuming that 8 sampling points in each group correspond to specified power function values of 67, 78, 89, 101, 112, 123, 135, 146, and the 8 sampling points correspond to each other, the storage circuit 12 stores the minimum specified power function value in each group, which is denoted as Bn, and the storage circuit 12 stores Bn 67, for example. Dividing the difference between the maximum value and the minimum value of 8 data in each group by (M-1), namely obtaining the quotient after (8-1), namely the quotient is rounded, called granularity and marked as GrThe granularity G of 8 specified power function values corresponding to the 8 sampling points listed aboverThe particle size is 11, i.e. (146-67) ÷ 7 ═ 11. Calculating the difference between the other values except the minimum value and the adjacent smaller value in each group of specified power function values, and calculating the difference and the granularity GrTo obtain a correction value GvE.g. Cv={[(78-67)-11],[(89-78)-11],[(101-89)-11],[(112-101)-11],[(123-112)-11],[(135-123)-11],[(146-135)-11]}={0,0,1,0,0,1,0}。

When the lookup table is looked up, the minimum specified power function value Bn and the granularity G in each group can be usedrCorrection value GvIf the search result is found, for example, if the search result for the seventh sampling point is to be found, since the specified power function is a monotonically decreasing function in the preset interval, the smallest specified power function value Bn plus the sum of 6 granularities plus the correction value, i.e., B is 67+6 × 11+2 is 135.

By using the above compression scheme, the storage circuit 12 stores the minimum value B of each set of sampling points by 16 bitsnAnd 5bit is used for storing granularity Gr7 bits are used for storing correction values C corresponding to the other 7 numerical values except the minimum valuevThus, the entire lookup table is recompressed to occupy 18Kbit (512 × (16+5+7) bit) to further compress the space occupied by the given power function lookup table to further conserve memory in the memory circuit 12.

In one embodiment, the power function calculation device provided by the invention can calculate the power function with the exponent greater than or equal to negative number of-1. The arithmetic circuit 15 provided in this embodiment includes a multiplier and an adder, and the arithmetic circuit 15 performs a first calculation by using the table lookup result and the exponent of the power function through the multiplier and the adder to obtain the power function value of the first input information.

The power function calculation apparatus provided in this embodiment combines the shift operation with the lookup table in the process of calculating the power function value corresponding to the first input information, and only uses one multiplier and one adder in the process of finally obtaining the calculation result, thereby saving calculation resources.

Fig. 2 is a schematic structural diagram of a power function calculating device according to a second embodiment of the present invention. Compared with the first embodiment shown in fig. 1, the difference is that the present embodiment further includes: a second judgment circuit 16 and a numerical value conversion circuit 17. The second judging circuit 16 is connected to the input circuit 11 and the first judging circuit 13, and is configured to judge whether the first input information is a fixed-point value; the value conversion circuit 17 is connected to the second judgment circuit 16 and the first judgment circuit 13, and is configured to convert the first input information into a fixed-point value by using the first scaling value when the first input information is not the fixed-point value.

Specifically, since the digital circuit cannot recognize a floating point value, if the second determination circuit 16 determines that the first input information is a floating point value, the first input information is converted from the floating point value to a fixed point value by the value conversion circuit 17 using the first fixed scale value. Specifically, the first input information may be converted from a floating-point value to a fixed-point value by using the following formula (2):

F=f×2Q(2)

where F is a fixed-point number, F is a floating-point number, and Q is a first scaled value.

The power function calculation apparatus according to this embodiment can convert the first input information, which is a floating-point value, into a fixed-point value by the value conversion circuit 17 in the process of calculating the power function value corresponding to the first input information, so that the power function calculation apparatus can be applied to the operation of a digital circuit. And the power function calculation device combines the shift operation with the lookup table, and only uses one multiplier and one adder in the process of finally obtaining the calculation result, thereby saving the calculation resources.

Fig. 3 is a schematic flow chart of a power function calculation method according to a first embodiment of the present invention.

The method comprises the following steps:

step S31: first input information is received.

Specifically, the first input information may be received by the input circuit, and is denoted as x.

Step S32: and judging whether the first input information is in a preset interval.

Specifically, whether the first input information x is within the preset interval can be judged through the first judging circuit. In one embodiment, the predetermined interval is [0.5,1 ].

Step S33: and if the first input information is in the preset interval, searching in the specified power function lookup table by using the first input information to obtain a lookup table result.

Specifically, if the first input information x is within a predetermined interval, such as x ∈ [0.5,1), the first input information x is directly used to perform a lookup in the specified power function lookup table to obtain a lookup result.Where n is a rational number greater than or equal to 1, in one embodiment, the exponent of the specified power function may be-0.5, i.e., n may be 2.

Step S34: and if the first input information is not in the preset interval, shifting the first input information by using a first shifting value to obtain second information, wherein the second information is in the preset interval.

Specifically, in one embodiment, the first input information may be shifted by the shift circuit using the following formula (1):

xc=x×2s(1)

wherein the content of the first and second substances,x is the first input information, s is the first shift value, xcThe second information is the second information in the preset interval.

For example, in an embodiment, if the first input information x is 12 and the preset interval is [0.5,1 ], if the first input information x is to be shifted into the preset interval [0.5,1) by using the above formula (1), the first shift value may be set to-4, that is: x is the number ofc=12×2-4Calculating the available xc=0.75,xc0.75 is within a preset interval [0.5, 1). The first shift value is negative, and it can be seen that when the first input information is shifted, the first input information is shifted to the right to be reduced. For example, in another embodiment, if the first input information x is 0.1 and the preset interval is [0.5,1 ], if the first input information x is to be shifted into the preset interval [0.5,1) by using the above formula (1), the first shift value may be set to 3, that is: x is the number ofc=0.1×23Calculating the available xc=0.8,xc0.8 is within a preset interval [0.5, 1). The first shift value is a positive number, and it can be seen that when the first input information is shifted, the first input information is shifted to the left to be amplified.

Step S35: and searching in the specified power function lookup table by using the second information to obtain a lookup result.

Specifically, the second information x in the preset interval is utilizedcAnd searching in a specified power function lookup table to obtain a lookup result. The specified power function may be:where n is a rational number greater than or equal to 1, in one embodiment, the exponent of the specified power function may be-0.5, i.e., n may be 2.

Specifically, in an embodiment, before the second information within the preset interval or the first input information within the preset interval is used to perform lookup in the specified power function lookup table to obtain the lookup result, the lookup table of the specified power function is further established. In one embodiment, the exponent of the specified power function may be-0.5, i.e., the specified power function may beWhen building the lookup table, by functionThe establishment is performed. In the case of creating a lookup table specifying a power function, the corresponding values are fixed-point values for the convenience of digital circuit identification, and if they are floating-point values, they are converted into fixed-point values by, for example, the method of formula (2).

In one embodiment, after the lookup table is built, to reduce the memory space of the memory circuit, the lookup table specifying the power function may be compressed a first time to form a first lookup table. Specifically, the specified power function lookup table includes a plurality of sampling points and specified power function values thereof within a preset interval, the sampling points are divided into a plurality of groups, the specified power function value of the sampling point at a specified position in each group is stored in the form of an original numerical value, the specified power function values of other sampling points are stored in the form of a difference value between the specified power function values of the sampling points at the specified positions, and a base number part common to other difference values in the same group is removed from the difference value. Specifically, for example, W sampling points are uniformly collected within a preset interval, and the W sampling points are divided into N groups including G1、G2、G3……GNGroups, each group comprising M sampling points: d1、D2、D3……DM. The storage circuit 12 stores the first sampling point D in each group1Specified power function value B of1Subsequent sampling point D2、D3……DMRespectively with the first sampling point D1Specified power function value B of1Is stored, e.g. the second sample point D2Given power function value of B2Third sampling point D3Given power function value of B3M th sampling point DMGiven power function value of BM. At this time, the second sampling point D2Specified power function value B of2And the first sampling point D1Specified power function value B of1Has a difference of Δ1Third sampling point D3Specified power function value B of3And the first sampling point D1Specified power function value B of1Has a difference of Δ2Fourth sample point D4Specified power function value B of4And the first sampling point D1Specified power function value B of1Has a difference of Δ3M th sampling point DMSpecified power function value B ofMAnd the first sampling point D1Specified power function value B of1Has a difference of ΔM-1. In one embodiment, the storage circuit may store only the first sampling point D in each group1Specified power function value B of1And the difference between the remaining sample points and the first sample point, e.g. delta1、Δ2、Δ3……ΔM-1. Furthermore, in order to save the storage space of the storage circuit, the storage circuit can also only store the first sampling points D in each group of the first sampling points1Specified power function value B of1And the difference between the remaining sample points and the first sample point, e.g. delta1、Δ2、Δ3……ΔM-1Wherein, is1、Δ2、Δ3……ΔM-1Removing the common base part thereof, e.g. if Δ1、Δ2、Δ3……ΔM-12, 4, 6 … … 2(M-1), respectively, the memory circuit stores 1, 2, 3 … … M-1.

The storage circuit stores in the mode, and the storage space can be effectively reduced. For example, if the number M of sampling points in each group is 8, and the specified power function values of the sampling points in each group are all stored, the storage of the specified power function lookup table occupies 4096/8-512 groups in total, and when the specified power function lookup table is stored according to the above compression scheme, 16-bit storage B is used in each group1Storing delta with 8bit1、Δ2、Δ3……ΔM-1And removing the residual numbers in the radix part, each packet occupies 72 bits (7 × 8 bits +16 bits) of storage space, and the whole specified power function lookup table is compressed to occupy 36 kbits (512 × 72 bits).

In another embodiment, the power function is specified for further compressionThe space occupied by the lookup table may be compressed a second time for the first lookup table to obtain a second lookup table. Specifically, the specified power function value of each set of sampling points at a specified position is stored in an original numerical value mode, and at least part of other sampling points are stored in a modified value mode, wherein the modified value is the difference value between the specified power function values of adjacent sampling points and the granularity, and the granularity is the integral result of the average difference value of all the sampling points in the set. For example, it is specifically assumed that 8 sampling points in each group correspond to specified power function values of 67, 78, 89, 101, 112, 123, 135, and 146, and the storage circuit stores the minimum specified power function value in each group, which is denoted as Bn, and for example, the storage circuit stores Bn 67. Dividing the difference between the maximum value and the minimum value of 8 data in each group by (M-1), namely obtaining the quotient after (8-1), namely the quotient is rounded, called granularity and marked as GrThe granularity G of 8 specified power function values corresponding to the 8 sampling points listed aboverThe particle size is 11, i.e. (146-67) ÷ 7 ═ 11. Calculating the difference between the other values except the minimum value and the adjacent smaller value in each group of specified power function values, and calculating the difference and the granularity GrTo obtain a correction value GcE.g. Cv={[(78-67)-11],[(89-78)-11],[(101-89)-11],[(112-101)-11],[(123-112)-11],[(135-123)-11],[(146-135)-11]}={0,0,1,0,0,1,0}。

When the lookup table is looked up, the minimum specified power function value Bn and the granularity G in each group can be usedrCorrection value GvIf the search result is found, for example, if the search result for the seventh sampling point is to be found, since the specified power function is a monotonically decreasing function in the preset interval, the smallest specified power function value Bn plus the sum of 6 granularities plus the correction value, i.e., B is 67+6 × 11+2 is 135.

By using the compression scheme, the storage circuit stores the minimum value B in each group of sampling points by 16 bitsnAnd 5bit is used for storing granularity Gr7 bits are used for storing correction values C corresponding to the other 7 numerical values except the minimum valuev. Thus, the entire specified power function lookup table occupies memory space after recompressionThe interval is 18Kbit (512 × (16+5+7) bit), so as to further compress the occupied space of the specified power function lookup table and further save the storage space of the storage circuit.

Step S36: and performing first calculation by using the table look-up result and the exponent of the power function to obtain the power function value of the first input information.

After the table lookup result is obtained, the arithmetic circuit performs first calculation through the table lookup result and the exponent of the power function to be calculated to obtain the power function value corresponding to the first input information. Specifically, the first calculation includes a shift operation and an addition operation and/or a multiplication operation.

Specifically, the power function value of the first input information may be calculated by using the lookup table result, the scaling value corresponding to the lookup table result, the first scaling value Q, the scaling value corresponding to the power function value of the first input information x, the first shift value s, and the exponent of the power function.

Specifically, the power function value of the first input information may be calculated by using the lookup table result, the scaling value corresponding to the lookup table result, the first scaling value Q, the scaling value corresponding to the power function value of the first input information x, the first shift value s, and the exponent of the power function according to the following formula (3):

wherein, ytableFor the look-up table result, QtFor a scaled value, Q, corresponding to the look-up table resultiIs said first scaling value, QoA scaling value corresponding to a power function value y of the first input information,is a pair ofRounding to the result of the rounding, s being the first shift value, n being a rational number greater than or equal to 1,is the exponent of the power function.

Wherein when mod (Q)iWhen + s, n) ═ 0, then:

wherein when mod (Q)iWhen + s, n) ═ 1, then:

according to the above formula, the present application makes the calculation of the power function through the lookup table and the shift operation, and only uses one hardware multiplier and one hardware adder, so that the calculation is easily realized in the digital circuit. In addition, the power function calculation method provided by the invention can solve the problem that the conventional power function calculation limited to n-2 is not applicable to a digital circuit.

In one embodiment, the exponent of the power function is a negative number greater than or equal to-1.

In the power function calculation method shown in this embodiment, in the process of obtaining the power function value corresponding to the first input information through calculation, the shift operation is combined with the lookup table, and in the process of finally obtaining the calculation result, only one multiplier and one adder are used, so that the calculation resources are saved.

Fig. 4 is a flowchart illustrating a power function calculation method according to a second embodiment of the present invention. Step S41, step S44, step S45, step S46, step S47 and step S48 in the present embodiment are the same as step S31, step S32, step S33, step S34, step S35 and step S36 in the first embodiment shown in fig. 3, except that the present embodiment further includes, after step S41:

step S42: and judging whether the first input information is a fixed-point numerical value.

Specifically, since the digital circuit cannot recognize the floating-point value, a second determining circuit is further required to determine whether the first input information is the floating-point value.

Step S43: if the first input information is not a fixed-point numerical value, converting the first input information into the fixed-point numerical value by using a first scaling value.

Specifically, if the first input information is the fixed-point value, the step of determining whether the first input information is within the preset interval is performed, i.e., step S44. If the first input information is not a fixed point value, it is converted to a fixed point value. Specifically, the first input information is converted from a floating-point numerical value to a fixed-point numerical value by a numerical value conversion circuit by using a first fixed-point value. Specifically, the first input information may be converted from a floating-point value to a fixed-point value by using the following formula (2):

F=f×2Q(2)

where F is a fixed-point number, F is a floating-point number, and Q is a first scaled value.

In the power function calculation method provided by this embodiment, in the process of calculating the power function value corresponding to the first input information, the first input information which is a floating-point numerical value can be converted into a fixed-point numerical value, so that the power function calculation method can be applied to the operation of a digital circuit. And the power function calculation device combines the shift operation with the lookup table, and only uses one multiplier and one adder in the process of finally obtaining the calculation result, thereby saving the calculation resources.

The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

15页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种数字电路结构

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类