Arithmetic square root approximate calculation device and calculation method based on random calculation

By designing an arithmetic square root approximation calculation device based on random calculations, using a random number generation logic circuit to perform square root approximation calculation, the problems of large resource consumption and low computing efficiency in traditional methods are solved, and efficient square root calculation is achieved.

CN119829008AActive Publication Date: 2025-04-15ANHUI UNIV
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411919499.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-04-15
Estimated Expiration
2044-12-25

Smart Images

  • Figure CN119829008A_ABST
    Figure CN119829008A_ABST
Patent Text Reader

Abstract

The invention provides an arithmetic square root approximate calculation device and method based on random calculation, and belongs to the field of integrated circuit design. The method comprises a random sequence generation unit and an extraction calculation unit, wherein the random sequence generation unit comprises a linear feedback shift register and a comparator; and the root extraction calculation unit comprises a square root settlement unit, an uncorrelated median generation unit, a half-value scaling unit and a data coupling unit. According to the arithmetic square root approximate calculation device based on random calculation, when the data to be subjected to square extraction is subjected to square extraction calculation of a 3-10-bit binary number X, high calculation precision can be achieved, and the average value of root mean square errors and the average value of mean absolute errors are small.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of integrated circuit design, and relates to an arithmetic square root approximate calculation device and a calculation method based on random calculation. Background Art

[0002] In recent years, stochastic computing has received increasing attention as an emerging computing method. Stochastic computing uses random sequences generated by random number generators to represent and process digital information. By converting complex mathematical operations (such as square root calculations) into simple logic gate operations, the computing process can be simplified. The core advantage of stochastic computing lies in its low-cost computing form and high fault tolerance to soft errors, which enables it to have obvious resource savings and high efficiency in implementing complex functions.

[0003] In the field of modern computing and signal processing, square root calculation is a basic and important task, which is widely used in image processing, digital signal analysis and various scientific calculations. Traditional square root calculation methods usually require complex logic circuits to meet the square root calculation requirements. To this end, the present application has developed an arithmetic square root approximate calculation device and calculation method based on random calculation with simple logic circuits. Summary of the invention

[0004] In view of the defects and shortcomings in the above-mentioned prior art, the present application proposes an arithmetic square root approximate calculation device and calculation method based on random calculation.

[0005] In order to achieve the above-mentioned purpose, the present invention adopts the following technical scheme:

[0006] An arithmetic square root approximate calculation device based on random calculation includes a random sequence generation unit and a square root calculation unit; wherein the random sequence generation unit includes a linear feedback shift register and a comparator; the square root calculation unit includes a square root settlement unit, a non-correlated median generation unit, a half-value scaling unit and a data coupling unit;

[0007] In the present application, one input end of the comparator serves as the input end of the entire arithmetic square root approximate calculation device based on random calculation, the other input end of the comparator is connected to the output end of the linear feedback shift register, and the output end of the comparator is connected to one input end of the square root settlement unit;

[0008] The output end of the square root settlement unit is also connected to the input end of the non-correlated median generation unit and one of the input ends of the half-value scaling unit, the output end of the non-correlated median generation unit is connected to the other input end of the half-value scaling unit and the input end K of the data coupling unit, the output end of the half-value scaling unit is connected to the input end J of the data coupling unit, and the output end Q of the data coupling unit is connected to the other input end of the square root settlement unit; the probability value of the occurrence of the bit "1" in the random sequence composed of the bits output by the output end of the square root settlement unit in all clock cycles according to the time sequence is the square root calculation result of the arithmetic square root approximate calculation device based on random calculation described in the present application

[0009] Preferably, the square root settlement unit is an "OR" logic gate.

[0010] Preferably, the data coupling unit is a JK flip-flop.

[0011] Preferably, the half-value scaling unit is an AND logic gate.

[0012] Preferably, the non-correlated median generating unit is a T flip-flop.

[0013] A square root calculation method using the arithmetic square root approximate calculation device based on random calculation comprises the following steps:

[0014] S1, performing multiple charge and discharge operations on the linear feedback shift register in the random sequence generation unit, so that the internal portion thereof has an initial state that is not all "0"; performing a charge and discharge operation on the non-correlated median generation unit and the data coupling unit respectively, so that the non-correlated median generation unit and the data coupling unit respectively have their own initial bits;

[0015] S2, inputting an N-bit binary number X from the input end of the entire arithmetic square root approximate calculation device based on random calculation, wherein the N-bit binary number X is the data to be squared, and N is the same as the number of bits of the linear feedback shift register; the comparator compares the internal state of the linear feedback shift register with the binary number X; wherein, in the first clock cycle, the internal state of the linear feedback shift register refers to the initial state obtained by the linear feedback shift register through multiple charging and discharging in step S1;

[0016] S3, using the square root settlement unit to perform an "OR" logic operation on the bit output by the comparator and the bit output by the data coupling unit; wherein, in the first clock cycle, the bit output by the data coupling unit refers to the initial bit obtained by the data coupling unit through one charge and discharge in step S1;

[0017] S4, using the non-correlated median generation unit to perform an "exclusive OR" logic operation on the bit output by the square root settlement unit and the current internal state of the non-correlated median generation unit; wherein, in the first clock cycle, the bit output by the non-correlated median generation unit refers to the initial bit obtained by the non-correlated median generation unit through a charge and discharge operation in step S1;

[0018] S5, using the half-value scaling unit to perform an “AND” logic operation on the bits output by the non-correlated median generation unit and the bits output by the square root settlement unit;

[0019] S6, using the data coupling unit to couple the bits output by the half-value scaling unit and the bits output by the uncorrelated median generation unit, and transmitting the calculation results to the square root settlement unit to complete the calculation process of one clock cycle; then, the internal state of the linear feedback shift register is shifted and updated according to the clock signal to obtain a new state different from the previous state; then, the calculation process described in step S2 to step S6 is repeated. N -2 times to get the final calculation result. In this application, a total of 2 N -1 clock cycle calculation process.

[0020] Preferably, in step S2, if the binary number X is greater than the internal state of the linear feedback shift register, the comparator outputs a bit "1", and if the binary number X is less than the internal state of the linear feedback shift register, the comparator outputs a bit "0".

[0021] Preferably, in step S4, the bits output by the uncorrelated median generating unit in all clock cycles form a random sequence in time sequence, the probability value of the occurrence of bit "1" in the random sequence is 0.5, and the random sequence is uncorrelated with the input of the uncorrelated median generating unit; the input of the uncorrelated median generating unit refers to another random sequence formed by the bits input by the uncorrelated median generating unit in all clock cycles in time sequence.

[0022] Preferably, in step S4, the correlation represents the degree of overlap of the positions of the bit "1" in the two random sequences. When the positions where the bit "1" appears in the two random sequences completely overlap, the correlation is maximum and is regarded as 1. When the value represented by the random sequence obtained after the bitwise "AND" logic operation of the two random sequences is equal to the product of the values ​​respectively represented by the above two random sequences, it is regarded as having no correlation, that is, the correlation is 0. The correlation value calculation method of the present application is as follows: a) calculating the absolute value of the difference between the value represented by the random sequence obtained after the bitwise "AND" logic operation of the two random sequences and the product of the values ​​respectively represented by the above two random sequences; b) calculating the difference between the minimum value among the values ​​respectively represented by the above two random sequences and the product of the values ​​respectively represented by the above two random sequences; c) calculating the ratio between the absolute value of the difference obtained in step a) and the difference calculated in step b); the ratio is the correlation value; when the value represented by the random sequence obtained after the bitwise "AND" logic operation of the two random sequences is equal to the product of the values ​​respectively represented by the above two random sequences, the difference between the value represented by the random sequence obtained after the bitwise "AND" logic operation of the two random sequences and the product of the values ​​respectively represented by the above two random sequences is 0, and therefore, the correlation is 0.

[0023] The correlation between the two random sequences is the ratio of the difference between the result of the bitwise AND logic operation and the product of the "1" probability values ​​represented by the two sequences and the minimum value of the two.

[0024] Preferably, the non-correlated median generation unit uses a T trigger to implement the function, and the state transition characteristic formula of the T trigger is shown in formula (1):

[0025]

[0026] In formula (1), represents the next state of the T flip-flop, T represents the current input bit, Indicates the current state of the T flip-flop.

[0027] Preferably, the probability value PT of the bit "1" appearing in the random sequence composed of the bits output by the T flip-flop in all clock cycles according to the timing is expressed as follows:

[0028]

[0029] In formula (2), PT represents the probability value of the bit "1" appearing in the random sequence of bits output by the uncorrelated median generation unit (i.e., the T flip-flop) in all clock cycles according to the timing sequence. The probability value shown by PT is the value represented by the random sequence of bits output by the T flip-flop in all clock cycles according to the timing sequence.

[0030] Preferably, the half-value scaling unit is used to perform an "AND" logic operation on the bit output by the uncorrelated median generation unit and the bit output by the square root settlement unit, and output a bit; the half-value scaling unit outputs a bit in each clock cycle, and the relationship between the probability value PJ of the bit "1" appearing in the random sequence composed of the bits output in all clock cycles according to the time sequence and PT and PO is as shown in formula (3):

[0031]

[0032] In formula (3), PJ represents the probability value of the bit "1" appearing in the random sequence composed of the bits output by the half-value scaling unit in all clock cycles according to the timing sequence, and also represents the probability value of the bit "1" appearing in the random sequence composed of the bits input by the input terminal J of the data coupling unit in all clock cycles according to the timing sequence; PT represents the probability value of the bit "1" appearing in the random sequence composed of the bits output by the uncorrelated median generation unit (i.e., T trigger) in all clock cycles according to the timing sequence; PO represents the probability value of the bit "1" appearing in the random sequence composed of the bits output by the square root settlement unit in all clock cycles according to the timing sequence.

[0033] Preferably, the probability value PK of the occurrence of bit "1" in the random sequence composed of bits input at the input terminal K of the data coupling unit in all clock cycles according to the time sequence is as shown in formula (4):

[0034]

[0035] In formula (4), PK represents the probability value of the bit "1" appearing in the random sequence composed of the bits input by the input terminal K of the data coupling unit in all clock cycles according to the timing sequence, that is, the value represented by this random sequence; PT represents the probability value of the bit "1" appearing in the random sequence composed of the bits output by the uncorrelated median generation unit (i.e., T flip-flop) in all clock cycles according to the timing sequence.

[0036] Preferably, the data coupling unit uses a JK trigger to implement the function, and the state transfer formula of the JK trigger is shown in formula (5):

[0037]

[0038] In formula (5), Indicates the next state of the JK flip-flop, J indicates the bit currently input to the JK flip-flop input terminal J, and K indicates the bit currently input to the JK flip-flop input terminal K. Indicates the current state of the JK flip-flop, and Indicates the state of the JK flip-flop in two different clock cycles.

[0039] Preferably, the relationship between the probability value PQ of the occurrence of bit "1" in the random sequence composed of the bits output by the output terminal Q of the data coupling unit in all clock cycles according to the timing and the probability value PO of the occurrence of bit "1" in the random sequence composed of the bits output by the square root settlement unit in all clock cycles according to the timing is as shown in formula (7):

[0040]

[0041] In formula (7), PQ represents the probability value of the bit "1" appearing in the random sequence composed of the bits output by the output terminal Q of the data coupling unit in all clock cycles according to the timing; PO represents the probability value of the bit "1" appearing in the random sequence composed of the bits output by the square root settlement unit in all clock cycles according to the timing.

[0042] Preferably, the probability value PO of the bit "1" appearing in the random sequence composed of the bits output by the square root settlement unit in all clock cycles according to the time sequence is calculated using formula (8):

[0043] PX+PQ-PX×PQ=PO (8)

[0044] In formula (8), PX represents the probability value of the bit "1" appearing in the random sequence composed of the bits output by the comparator in all clock cycles according to the timing; PQ represents the probability value of the bit "1" appearing in the random sequence composed of the bits output by the output terminal Q of the data coupling unit in all clock cycles according to the timing.

[0045] Compared with the prior art, the beneficial effects of this application are:

[0046] In the arithmetic square root approximate calculation device based on random calculation described in the present application, the probability value PT of the occurrence of bit "1" in the random sequence composed of the bits output by the uncorrelated median unit (i.e., T trigger) in all clock cycles according to the timing sequence is 1 / 2, and the random sequence composed of the bits output by the uncorrelated median unit in all clock cycles according to the timing sequence and the input of the uncorrelated median unit (the input of the uncorrelated median unit refers to the random sequence composed of the bits input by the uncorrelated median unit in all clock cycles according to the timing sequence) are uncorrelated; the half-value scaling unit is used to perform "AND" on the bits output by the uncorrelated median generation unit and the bits output by the square root settlement unit. Logical operation is performed and a bit is output. The half-value scaling unit outputs a bit in each clock cycle. The probability value PJ of the bit "1" appearing in the random sequence composed of the bits output in all clock cycles according to the timing sequence is equal to PO / 2. The data coupling unit couples the bits output by the half-value scaling unit and the bits output by the uncorrelated median generation unit for calculation. The probability value PQ of the bit "1" appearing in the random sequence composed of the bits output at the output end Q of the data coupling unit according to the timing sequence and the probability value PO of the bit "1" appearing in the random sequence composed of the bits output in all clock cycles according to the timing sequence of the square root settlement unit satisfy The square root settlement unit performs an "OR" logic operation on the bits output by the comparator and the bits output by the data coupling unit. The probability value PO of the occurrence of the bit "1" in the random sequence composed of the bits output by the square root settlement unit in all clock cycles according to the timing is the square root calculation result of the device. By performing square root approximation calculation on binary numbers using the arithmetic square root approximation calculation device based on random calculation described in the present application, better test accuracy can be achieved. In particular, when the linear feedback shift register is a 7-bit linear feedback shift register and the input data to be squared is a 7-bit binary number X, higher accuracy can be achieved when calculating the square root using the arithmetic square root approximation calculation device based on random calculation described in the present application. Through testing, it can be seen that when the linear feedback shift register is a 7-bit linear feedback shift register and the input data to be squared is a 7-bit binary number X, when the square root is calculated using the arithmetic square root approximation calculation device based on random calculation described in the present application, the average value of the root mean square error MAE reaches 0.071 and the average value of the mean absolute error MSE reaches 0.008. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 is a structural diagram of the arithmetic square root approximate calculation device based on random calculation according to the present invention;

[0048] Figure 2 It is a state transition table without associated median unit (i.e., T flip-flop);

[0049] Figure 3 It is the state transfer table of the data coupling unit (ie, JK flip-flop). DETAILED DESCRIPTION

[0050] To facilitate those skilled in the art to understand the technical content of the present invention, the present invention is further explained below in conjunction with the accompanying drawings. The description here is only used to explain the present invention and is not intended to limit the present invention.

[0051] like Figure 1 As shown, the present invention proposes an arithmetic square root approximate calculation device based on random calculation, including a random sequence generation unit and a square root calculation unit; wherein the random sequence generation unit includes a linear feedback shift register and a comparator; the square root calculation unit includes a square root settlement unit, an uncorrelated median generation unit, a half-value scaling unit and a data coupling unit; the square root settlement unit is an "OR" logic gate, the data coupling unit is a JK trigger, the half-value scaling unit is an "AND" logic gate, and the uncorrelated median generation unit is a T trigger; the linear feedback shift register in the present application is a prior art, for example, the linear feedback shift register described in the present application can be the linear feedback shift register disclosed in a non-monotonic function approximate calculation device based on random calculation in CN 111428196 A;

[0052] In the present application, one input end of the comparator serves as the input end of the entire arithmetic square root approximate calculation device based on random calculation, the other input end of the comparator is connected to the output end of the linear feedback shift register, and the output end of the comparator is connected to one input end of the square root settlement unit;

[0053] The output end of the square root settlement unit is also connected to the input end of the non-correlated median generation unit and one of the input ends of the half-value scaling unit, the output end of the non-correlated median generation unit is connected to the other input end of the half-value scaling unit and the input end K of the data coupling unit, the output end of the half-value scaling unit is connected to the input end J of the data coupling unit, and the output end Q of the data coupling unit is connected to the other input end of the square root settlement unit; the probability value of the occurrence of the bit "1" in the random sequence composed of the bits output by the output end of the square root settlement unit in all clock cycles according to the time sequence is the square root calculation result of the arithmetic square root approximate calculation device based on random calculation described in the present application

[0054] A square root calculation method using the arithmetic square root approximate calculation device based on random calculation comprises the following steps:

[0055] S1, performing multiple charge and discharge operations on the linear feedback shift register in the random sequence generation unit, so that the internal portion thereof has an initial state that is not all "0"; performing a charge and discharge operation on the non-correlated median generation unit and the data coupling unit respectively, so that the non-correlated median generation unit and the data coupling unit respectively have their own initial bits;

[0056] S2. Input an N-bit binary number X from the input end of the entire arithmetic square root approximate calculation device based on random calculation (i.e., one input end of the comparator), wherein the N-bit binary number X is the data to be squared, and N is the same as the number of bits of the linear feedback shift register; the comparator compares the internal state of the linear feedback shift register with the binary number X; if the binary number X is greater than the internal state of the linear feedback shift register, the comparator outputs a bit "1", and if the binary number X is less than the internal state of the linear feedback shift register, the comparator outputs a bit "0"; wherein, in the first clock cycle, the internal state of the linear feedback shift register refers to the initial state obtained by the linear feedback shift register through multiple charging and discharging in step S1;

[0057] In the present application, the comparator compares the internal state of the linear feedback shift register with the binary number X in each clock cycle. If the binary number X is greater than the internal state of the linear feedback shift register, the comparator outputs a bit "1". If the binary number X is less than the internal state of the linear feedback shift register, the comparator outputs a bit "0". After all clock cycles are completed, the bits output by the comparator in all clock cycles form a random sequence according to the time sequence. The probability value of the occurrence of the bit "1" in the random sequence is the same as the value represented by the binary number X. Since the probability value of the bit "1" in the above random sequence is the same as the value represented by the binary number X, the above random sequence can be used to represent the binary number X to be squared.

[0058] S3, using the square root settlement unit to perform an "OR" logic operation on the bit output by the comparator and the bit output by the data coupling unit; wherein, in the first clock cycle, the bit output by the data coupling unit refers to the initial bit obtained by the data coupling unit through one charge and discharge in step S1;

[0059] In step S3 of the present application, the data coupling unit outputs a bit in each clock cycle. After all clock cycles are completed, the bits output by the data coupling unit in all clock cycles form a random sequence according to the timing. The probability value of the occurrence of the bit "1" in the random sequence is the square root calculation result of the binary number X.

[0060] S4, using the non-correlated median generation unit to perform an "exclusive OR" logic operation on the bit output by the square root settlement unit and the current internal state of the non-correlated median generation unit; wherein the bit output by the non-correlated median generation unit refers to the initial bit obtained by the non-correlated median generation unit through a charge and discharge operation in step S1;

[0061] In the present application, the uncorrelated median generating unit outputs a bit in each clock cycle. After all the clock cycles are over, the bits output by the uncorrelated median generating unit in all the clock cycles form a random sequence in time sequence. The random sequence has no correlation with the input of the uncorrelated median generating unit, and the probability value of the occurrence of bit "1" in the random sequence is 0.5; wherein, the input of the uncorrelated median generating unit refers to the random sequence composed of the bits input by the uncorrelated median generating unit in all the clock cycles in time sequence; in the present application, the correlation represents the overlap of the positions of the occurrence of bit "1" in two random sequences. When the positions of the occurrence of bit "1" in the two random sequences completely overlap, the correlation is the largest and is regarded as 1; when the value represented by the random sequence obtained after the bitwise "AND" logic operation of the two random sequences (the value represented by the random sequence is the probability value of the occurrence of bit "1" in the random sequence) is equal to the above two random sequences respectively. When the products of the numerical values ​​represented by the two random sequences are equal, it is considered that there is no correlation, that is, the correlation is 0; the correlation value calculation method of the present application is: a), calculating the absolute value of the difference between the numerical value represented by the random sequence obtained after the bitwise "AND" logic operation of the two random sequences and the product of the numerical values ​​represented by the above two random sequences; b), calculating the difference between the minimum numerical value among the numerical values ​​represented by the above two random sequences and the product of the numerical values ​​represented by the above two random sequences; c), calculating the ratio between the absolute value of the difference obtained in step a) and the difference calculated in step b); the ratio is the correlation value; when the numerical value represented by the random sequence obtained after the bitwise "AND" logic operation of the two random sequences is equal to the product of the numerical values ​​represented by the above two random sequences, the difference between the numerical value represented by the random sequence obtained after the bitwise "AND" logic operation of the two random sequences and the product of the numerical values ​​represented by the above two random sequences is 0, therefore, the correlation is 0.

[0062] Specifically for the non-correlated median generating unit, the bits output by the non-correlated median generating unit in all clock cycles form a random sequence according to the time sequence, and the bits input by the non-correlated median generating unit in all clock cycles form another random sequence according to the time sequence, and the value represented by the random sequence obtained after the bitwise "AND" logic operation of the above two random sequences is equal to the product of the values ​​respectively represented by the above two random sequences. Therefore, the random sequence composed of the bits output by the non-correlated median generating unit in all clock cycles according to the time sequence and the other random sequence composed of the bits input by the non-correlated median generating unit in all clock cycles according to the time sequence are non-correlated, that is, the correlation is 0;

[0063] S5, using the half-value scaling unit to perform an “AND” logic operation on the bits output by the non-correlated median generation unit and the bits output by the square root settlement unit;

[0064] In the present application, the half-value scaling unit outputs a bit in each clock cycle. After all clock cycles are completed, the bits output by the half-value scaling unit in all clock cycles form a random sequence in the order of the timing. The probability value of the occurrence of the bit "1" in the random sequence is the same as The values ​​represented are the same, that is, the value represented by the random sequence is half of the value represented by the random sequence composed of the bits input by the half-value scaling unit in all clock cycles according to the time sequence;

[0065] S6, using the data coupling unit to couple the bits output by the half-value scaling unit and the bits output by the uncorrelated median generation unit, and transmitting the calculation results to the square root settlement unit to complete the calculation process of one clock cycle; then, the internal state of the linear feedback shift register is shifted and updated according to the clock signal to obtain a new state different from the previous state;

[0066] S7, repeat the calculation process 2 described in step S2 to step S6 N -2 times to get the final calculation result. In this application, a total of 2 N -1 clock cycle calculation process.

[0067] In this application, the working principles of the unrelated median generation unit (ie, T flip-flop), the half-value scaling unit (ie, "AND" logic gate), the data coupling unit (ie, JK flip-flop) and the square root settlement unit (ie, "OR" logic gate) are as follows:

[0068] The uncorrelated median generation unit uses a T flip-flop to implement the function. The state transition characteristic formula of the T flip-flop is shown in formula (1):

[0069]

[0070] In formula (1), represents the next state of the T flip-flop, T represents the current input bit, Represents the current state of the T flip-flop; according to this characteristic formula, combined with Figure 2 , we can know that the input of the T flip-flop will frequently perform "XOR" logic operation with its internal state, and will output a bit in each clock cycle. The probability value PT of the bit "1" appearing in the random sequence composed of the bits output by the T flip-flop in all clock cycles according to the timing sequence is about 1 / 2. In random calculation, it is considered to be 1 / 2. Therefore, the probability value PT of the bit "1" appearing in the random sequence composed of the bits output by the T flip-flop in all clock cycles according to the timing sequence can be expressed by formula (2):

[0071]

[0072] In formula (2), PT represents the probability value of the bit "1" appearing in the random sequence of bits output by the uncorrelated median generation unit (i.e., the T flip-flop) in all clock cycles according to the timing sequence. The probability value shown by PT is the value represented by the random sequence of bits output by the T flip-flop in all clock cycles according to the timing sequence.

[0073] In the present application, the half-value scaling unit is used to perform an "AND" logic operation on the bits output by the uncorrelated median generation unit and the bits output by the square root settlement unit, and output a bit. The half-value scaling unit outputs a bit in each clock cycle. The probability value PJ of the occurrence of the bit "1" in the random sequence composed of the bits output in all clock cycles according to the timing is related to PT and PO as shown in formula (3):

[0074]

[0075] In formula (3), PJ represents the probability value of the bit "1" appearing in the random sequence composed of the bits output by the half-value scaling unit in all clock cycles according to the timing sequence, and also represents the probability value of the bit "1" appearing in the random sequence composed of the bits input by the input terminal J of the data coupling unit in all clock cycles according to the timing sequence, that is, the value represented by the random sequence; PT represents the probability value of the bit "1" appearing in the random sequence composed of the bits output by the uncorrelated median generation unit (i.e., T trigger) in all clock cycles according to the timing sequence; PO represents the probability value of the bit "1" appearing in the random sequence composed of the bits output by the square root settlement unit in all clock cycles according to the timing sequence.

[0076] In the present application, since the random sequence of bits output by the uncorrelated median generation unit (i.e., T trigger) in all clock cycles according to the timing sequence is uncorrelated with the random sequence of bits input by the uncorrelated median generation unit in all clock cycles according to the timing sequence, and the random sequence of bits input by the uncorrelated median generation unit in all clock cycles according to the timing sequence is the random sequence of bits output by the square root settlement unit in all clock cycles according to the timing sequence, therefore, the random sequence of bits output by the uncorrelated median generation unit (i.e., T trigger) in all clock cycles according to the timing sequence is uncorrelated with the random sequence of bits output by the square root settlement unit in all clock cycles according to the timing sequence, therefore, the probability value PJ of the occurrence of bit "1" in the random sequence of bits composed of the bits output by the half-value scaling unit in all clock cycles by performing "AND" logic operations on the bits output by the uncorrelated median generation unit and the bits output by the square root settlement unit is equal to

[0077] Combination Figure 1 From the circuit structure, it can be seen that the probability value PK of the bit "1" appearing in the random sequence composed of the bits input at the input terminal K of the data coupling unit in all clock cycles according to the timing can be shown as formula (4):

[0078]

[0079] In formula (4), PK represents the probability value of the bit "1" appearing in the random sequence composed of the bits input by the input terminal K of the data coupling unit in all clock cycles according to the timing sequence, that is, the value represented by this random sequence; PT represents the probability value of the bit "1" appearing in the random sequence composed of the bits output by the uncorrelated median generation unit in all clock cycles according to the timing sequence.

[0080] In this application, the data coupling unit uses a JK trigger to implement the function, and the state transfer formula of the JK trigger is shown in formula (5):

[0081]

[0082] In formula (5), represents the next state of the JK flip-flop, J represents the bit currently input to the JK flip-flop input terminal J, and K represents the bit currently input to the JK flip-flop input terminal K. Indicates the current state of the JK flip-flop. and It represents the states of the JK flip-flop in two different clock cycles. From the perspective of all clock cycles, they belong to the same random sequence.

[0083] Substitute equation (3) and equation (4) into equation (5), and combine Figure 3, it can be known that the relationship between the probability value PQ of the occurrence of bit "1" in the random sequence composed of the bits output by the output end Q of the data coupling unit in all clock cycles and the probability value PO of the occurrence of bit "1" in the random sequence composed of the bits output by the square root settlement unit in all clock cycles according to the timing is as shown in formula (6):

[0084]

[0085] In formula (6), the probability value of the occurrence of bit "1" in the random sequence composed of bits output by the output terminal Q of the data coupling unit in all clock cycles according to the time sequence is the value represented by this random sequence.

[0086] By simplifying formula (6), the relationship between the probability value PQ of the occurrence of bit "1" in the random sequence composed of the bits output by the output terminal Q of the data coupling unit in all clock cycles according to the timing and the probability value PO of the occurrence of bit "1" in the random sequence composed of the bits output by the square root settlement unit in all clock cycles according to the timing can be obtained, as shown in formula (7):

[0087]

[0088] In formula (7), the probability value of the bit "1" appearing in the random sequence composed of the bits output by the output terminal Q of the data coupling unit in all clock cycles according to the timing sequence; PO represents the probability value of the bit "1" appearing in the random sequence composed of the bits output by the square root settlement unit in all clock cycles according to the timing sequence.

[0089] In the present application, the square root settlement unit is used to perform an "OR" logic operation on the bits output by the comparator and the bits output by the data coupling unit, and output a bit; the probability value of the bit "1" appearing in the random sequence composed of bits output by the square root settlement unit in all clock cycles is PO.

[0090] In the present application, the relationship between the probability value PO of the occurrence of bit "1" in the random sequence composed of the bits output by the square root settlement unit in all clock cycles according to the timing, the probability value PQ of the occurrence of bit "1" in the random sequence composed of the bits output by the data coupling unit in all clock cycles according to the timing, and the probability value PX of the occurrence of bit "1" in the random sequence composed of the bits output by the comparator in all clock cycles according to the timing is as shown in formula (8):

[0091] PX+PQ-PX×PQ=PO (8)

[0092] In formula (8), PX represents the probability value of the occurrence of bit "1" in the random sequence composed of bits output by the comparator in all clock cycles according to the timing, that is, the value represented by this random sequence.

[0093] Substituting formula (7) into formula (8), we can get formula (9):

[0094]

[0095] Since the value represented by the input N-bit binary number X of the device in the present application is equal to the probability value PX of the bit "1" appearing in the random sequence composed of the bits output by the comparator in all clock cycles according to the timing, the square root calculation method of the device can be obtained, as shown in formula (10):

[0096]

[0097] test:

[0098] The present application performs numerical simulation calculations based on MATLAB software, simulates the arithmetic square root approximate calculation device based on random calculation described in the present application, and simulates all data that can be represented by 3 to 10-bit linear feedback shift registers, and compares them with theoretical values, calculates the root mean square error and mean absolute error between the simulation calculation results and the theoretical values, and then repeats the above process 20,000 times, and calculates the average value MAE of the root mean square error and the average value MSE of the mean absolute error, respectively, to reflect the calculation accuracy of the arithmetic square root approximate calculation device based on random calculation described in the present application. The test results are shown in Table 1:

[0099] Table 1

[0100]

[0101] It can be seen from Table 1 that the calculation accuracy of the arithmetic square root approximate calculation device based on random calculation described in the present application can achieve high calculation accuracy when the square root calculation is performed on the 3- to 10-bit binary number X to be squared, and the average value of the root mean square error and the average value of the mean absolute error are both small; in particular, when the linear feedback shift register is a 7-bit linear feedback shift register and the input data to be squared is a 7-bit binary number X, the square root is calculated using the arithmetic square root approximate calculation device based on random calculation described in the present application. The highest accuracy is achieved, and the average value of the root mean square error MAE reaches 0.071 and the average value of the mean absolute error MSE reaches 0.008.

Claims

1. An arithmetic square root approximate calculation device based on random calculation, characterized in that: The invention comprises a random sequence generating unit and a square root calculating unit; wherein the random sequence generating unit comprises a linear feedback shift register and a comparator; the square root calculating unit comprises a square root settlement unit, an uncorrelated median generating unit, a half value scaling unit and a data coupling unit; one input end of the comparator is used as the input end of the entire arithmetic square root approximate calculating device based on random calculation, the other input end of the comparator is connected to the output end of the linear feedback shift register, and the output end of the comparator is connected to one input end of the square root settlement unit; the output end of the square root settlement unit is also respectively connected to the input end of the uncorrelated median generating unit and one of the input ends of the half value scaling unit, the output end of the uncorrelated median generating unit is respectively connected to the other input end of the half value scaling unit and the input end K of the data coupling unit, the output end of the half value scaling unit is connected to the input end J of the data coupling unit, and the output end Q of the data coupling unit is connected to the other input end of the square root settlement unit; the probability value of the occurrence of the bit "1" in the random sequence composed of the bits outputted by the square root settlement unit in all clock cycles according to the time sequence is the square root calculation result of the arithmetic square root approximate calculating device based on random calculation described in the present application 2. The arithmetic square root approximate calculation device based on random calculation according to claim 1, characterized in that: The square root settlement unit is an "OR" logic gate.

3. The arithmetic square root approximate calculation device based on random calculation according to claim 1, characterized in that: The data coupling unit is a JK flip-flop.

4. The arithmetic square root approximate calculation device based on random calculation according to claim 1, characterized in that: The half-value scaling unit is an AND logic gate.

5. The arithmetic square root approximate calculation device based on random calculation according to claim 1, characterized in that: The non-correlated median generating unit is a T flip-flop.

6. A square root calculation method of an arithmetic square root approximate calculation device based on random calculation, characterized in that: The arithmetic square root approximate calculation device based on random calculation is the arithmetic square root approximate calculation device based on random calculation according to claim 1; the square root calculation method of the arithmetic square root approximate calculation device based on random calculation comprises the following steps: S1, performing multiple charge and discharge operations on the linear feedback shift register in the random sequence generation unit, so that the internal portion thereof has an initial state that is not all "0"; performing a charge and discharge operation on the non-correlated median generation unit and the data coupling unit respectively, so that the non-correlated median generation unit and the data coupling unit respectively have their own initial bits; S2, inputting an N-bit binary number X from the input end of the entire arithmetic square root approximate calculation device based on random calculation, where N is the same as the number of bits of the linear feedback shift register; the comparator compares the internal state of the linear feedback shift register with the binary number X; wherein, in the first clock cycle, the internal state of the linear feedback shift register refers to the initial state of the linear feedback shift register; S3, using the square root settlement unit to perform an "OR" logic operation on the bit output by the comparator and the bit output by the data coupling unit; wherein, in the first clock cycle, the bit output by the data coupling unit refers to the initial bit obtained by the data coupling unit through one charge and discharge in step S1; S4, using the non-correlated median generation unit to perform an "exclusive OR" logic operation on the bit output by the square root settlement unit and the current internal state of the non-correlated median generation unit; wherein, in the first clock cycle, the bit output by the non-correlated median generation unit refers to the initial bit obtained by the non-correlated median generation unit through one charge and discharge in step S1; S5, using the half-value scaling unit to perform an AND logic operation on the bits output by the non-correlated median generation unit and the bits output by the square root settlement unit; S6, using the data coupling unit to couple the bits output by the half-value scaling unit and the bits output by the uncorrelated median generation unit, and transmitting the calculation results to the square root settlement unit to complete the calculation process of one clock cycle; then, the internal state of the linear feedback shift register is shifted and updated according to the clock signal to obtain a new state different from the previous state; S7, repeat the calculation process 2 described in step S2 to step S6 N -2 times to get the final calculation result.

7. The square root calculation method of the arithmetic square root approximate calculation device based on random calculation according to claim 6, characterized in that: In step S2, if the binary number X is greater than the internal state of the linear feedback shift register, the comparator outputs a bit "1", and if the binary number X is less than the internal state of the linear feedback shift register, the comparator outputs a bit "0".

8. The square root calculation method of the arithmetic square root approximate calculation device based on random calculation according to claim 6, characterized in that: In step S4, the bits output by the uncorrelated median generating unit in all clock cycles form a random sequence in time sequence, the probability value of the occurrence of bit "1" in the random sequence is 0.5, and the random sequence is uncorrelated with the input of the uncorrelated median generating unit; wherein the input of the uncorrelated median generating unit refers to another random sequence formed by the bits input by the uncorrelated median generating unit in all clock cycles in time sequence.

9. The square root calculation method of the arithmetic square root approximate calculation device based on random calculation according to claim 8, characterized in that: In step S4, the correlation represents the degree of overlap of the positions of the bit "1" in the two random sequences. When the positions of the bit "1" in the two random sequences completely overlap, the correlation is the largest and is regarded as 1. When the value represented by the random sequence obtained after the bitwise "AND" logic operation of the two random sequences is equal to the product of the values ​​represented by the above two random sequences, it is regarded as no correlation, that is, the correlation is 0.

10. The square root calculation method of the arithmetic square root approximate calculation device based on random calculation according to claim 6, characterized in that: The uncorrelated median generation unit uses a T flip-flop to implement the function. The state transfer characteristic formula of the T flip-flop is shown in formula (1): In formula (1), represents the next state of the T flip-flop, T represents the current input bit, Indicates the current state of the T flip-flop.

Citation Information

Patent Citations

  • Bit stream generator and bit stream generation method for random computation

    CN111338602A

  • Non-monotonic function approximate calculation device based on random calculation

    CN111428196A

  • Random source circuit for random calculation and configuration optimization method thereof

    CN115935874A

  • Digital device for extracting square root

    SU763893A1

  • Fraction bus for use in a numeric data processor

    US4484259A