WO2019174263A1 - 用于随机计算的多加数加法电路 - Google Patents

用于随机计算的多加数加法电路 Download PDF

Info

Publication number
WO2019174263A1
WO2019174263A1 PCT/CN2018/113353 CN2018113353W WO2019174263A1 WO 2019174263 A1 WO2019174263 A1 WO 2019174263A1 CN 2018113353 W CN2018113353 W CN 2018113353W WO 2019174263 A1 WO2019174263 A1 WO 2019174263A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
circuit
bit stream
output
buffer
Prior art date
Application number
PCT/CN2018/113353
Other languages
English (en)
French (fr)
Inventor
张健
唐样洋
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2019174263A1 publication Critical patent/WO2019174263A1/zh
Priority to US17/004,893 priority Critical patent/US11119732B2/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06GANALOGUE COMPUTERS
    • G06G7/00Devices in which the computing operation is performed by varying electric or magnetic quantities
    • G06G7/12Arrangements for performing computing operations, e.g. operational amplifiers
    • G06G7/14Arrangements for performing computing operations, e.g. operational amplifiers for addition or subtraction 
    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03KPULSE TECHNIQUE
    • H03K19/00Logic circuits, i.e. having at least two inputs acting on one output; Inverting circuits
    • H03K19/20Logic circuits, i.e. having at least two inputs acting on one output; Inverting circuits characterised by logic function, e.g. AND, OR, NOR, NOT circuits
    • H03K19/21EXCLUSIVE-OR circuits, i.e. giving output if input signal exists at only one input; COINCIDENCE circuits, i.e. giving output only if all input signals are identical
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/02Comparing digital values
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
    • G06F7/48Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
    • G06F7/491Computations with decimal numbers radix 12 or 20.
    • G06F7/498Computations with decimal numbers radix 12 or 20. using counter-type accumulators
    • G06F7/4981Adding; Subtracting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
    • G06F7/48Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
    • G06F7/50Adding; Subtracting
    • G06F7/505Adding; Subtracting in bit-parallel fashion, i.e. having a different digit-handling circuit for each denomination
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
    • G06F7/48Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
    • G06F7/52Multiplying; Dividing
    • G06F7/535Dividing only
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/60Methods or arrangements for performing computations using a digital non-denominational number representation, i.e. number representation without radix; Computing devices using combinations of denominational and non-denominational quantity representations, e.g. using difunction pulse trains, STEELE computers, phase computers
    • G06F7/70Methods or arrangements for performing computations using a digital non-denominational number representation, i.e. number representation without radix; Computing devices using combinations of denominational and non-denominational quantity representations, e.g. using difunction pulse trains, STEELE computers, phase computers using stochastic pulse trains, i.e. randomly occurring pulses the average pulse rates of which represent numbers
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present invention relates to the field of random computing, and more particularly to a multi-addition adding circuit.
  • the input data and output data are typically bitstreams under polarization representation.
  • the bit stream under polarization representation can be implemented by simple logic circuits.
  • a multi-addition adding circuit 100 for random calculation includes a plurality of two-input adding circuits 110.
  • the multi-addition adding circuit 100 receives a plurality of bit streams A 0 -A N-1 representing numbers in a random calculation, and generates a bit stream S, where:
  • the two-input adder circuit 110 is a two-input selector whose data input receives two input bit streams, and the signal selection terminal receives a selected bit stream having a value of 0.5 under the polarization representation, for example, using a unipolar polarization representation. Bit stream 01011100.
  • the two-input addition circuit 110 implements the function of the two-input addition circuit by performing a random selection of 50% probability on the two input bit streams.
  • the multi-addition adding circuit 100 performs addition of a plurality of bit streams A 0 -A N-1 through a plurality of two-input adding circuits 110 in a tree structure, wherein each stage two-input adding circuit 110 reduces the number of input bit streams Half, finally get a bit stream S. Since the input bit stream is randomly selected by the selection bit stream to realize the calculation of the two-input addition, a large calculation error may be caused, resulting in a decrease in the calculation accuracy of the multi-addition adding circuit 100.
  • Embodiments of the present invention provide a multi-additive adder circuit for random calculation to improve the computational accuracy of a multi-additive adder circuit.
  • m[i:j] the value of the ith bit to the jth bit of the data m under the binary, for example, when m is 0100 under the binary, then m[2:1] is 10 under the binary;
  • Rounding down the integer means that the value x is rounded down, for example
  • a multi-addition adding circuit for random computing including a buffer circuit and a calculation circuit, wherein the buffer circuit is configured to store the buffer input data for at least one cycle and output the data as a buffer.
  • the calculation circuit is configured to calculate the plurality of first bit stream data and the buffer output data, and output the second bit stream data and the buffer input data, wherein the buffer input data is for all periods up to the current period And a remainder obtained by dividing the sum of the data by the reduction coefficient, wherein the summed data is the number of the first bit stream data having a value of 1 in the plurality of first bit stream data of each period, and the second bit stream data is The quotient of the summation data of the cycle and the sum of the buffered output data divided by the reduction factor.
  • the first bit stream data and the second bit stream data are data in a polarization representation, and the reduction coefficient is a preset parameter, and the period is a period in which a plurality of first bit stream data are input.
  • the buffer circuit Since the buffer circuit stores the buffered input data generated by the calculation circuit in each cycle and is used for the calculation of the next cycle, the calculation of the multi-addition addition circuit in the current cycle is actually the input of the plurality of first bitstream data and The calculation of the buffered input data generated by a cycle calculation is performed, thereby reducing the calculation error and improving the calculation accuracy of the multi-addition addition circuit.
  • the first bit stream data is represented as A i (j), where i can take 0 to N-1, j can take 0 to x, and A i (j) is represented in the jth The i-th bitstream data of the cycle. Then the summation data of the jth cycle Caching input data
  • the computing circuit includes a summing circuit, wherein the summing circuit is configured to receive the plurality of first bitstream data and generate the first intermediate data, wherein the first intermediate data is the summed data.
  • the calculating circuit further includes an adding circuit, wherein the adding circuit is configured to receive the first intermediate data and the buffer output data, and generate second intermediate data, wherein the second intermediate data is the first intermediate data and the buffer The sum of the output data.
  • the calculation circuit further includes a comparison circuit, wherein the comparison circuit is configured to receive the second intermediate data, compare the second intermediate data with the reduction coefficient, and generate second bitstream data, wherein, when the second intermediate When the data is greater than or equal to the reduction factor, the second bit stream data is 1, otherwise the second bit stream data is 0.
  • the calculation circuit further includes a subtraction circuit, wherein the subtraction circuit is configured to receive the second intermediate data and the second bit stream data, and generate buffered input data, wherein when the second bit stream data is 1
  • the buffered input data is the difference between the second intermediate data and the reduction coefficient.
  • the buffered input data is the second intermediate data.
  • the number of bits of the capacity of the buffer circuit is at least the logarithm of the base 2 reduction factor.
  • the cache circuit is a register.
  • the summing circuit is a parallel counter.
  • the second bit stream data generated by the comparison circuit is the highest bit of the second intermediate data, wherein the second intermediate data is data represented by binary.
  • the circuit structure of the comparison circuit is simplified.
  • the buffer data of the current period generated by the subtraction circuit is the next highest to the lowest bit of the second intermediate data, wherein the second intermediate data is represented by a binary representation. data.
  • the circuit structure of the subtraction circuit is simplified.
  • a multi-addition adding circuit for random computing including: a summing circuit, an adding circuit, a comparing circuit, a subtracting circuit, and one or more buffer circuits.
  • the summing circuit is configured to receive the plurality of first bitstream data, calculate the number of the first bitstream data having a value of 1 in the plurality of first bitstream data of each period, and generate the first intermediate data;
  • the circuit adds the first intermediate data and the third intermediate data to generate second intermediate data, wherein the third intermediate data is an output of the subtraction circuit;
  • the comparison circuit receives the second intermediate data to generate second bit stream data, wherein If the second intermediate data is greater than or equal to the reduction coefficient, the second bit stream data is 1, otherwise the second bit stream data is 0;
  • the plurality of first bit stream data and the second bit stream data are data in a polarization representation,
  • the reduction factor is a preset parameter;
  • the subtraction circuit receives the second intermediate data and the second bit stream to generate a third intermediate data,
  • the buffer circuit stores the above-mentioned cache data in each cycle and uses it for the calculation of the next cycle
  • the calculation of the multi-addition addition circuit in the current cycle actually includes the calculation of the cache data stored in the cache circuit in the previous cycle. Therefore, the calculation error is reduced, and the calculation accuracy of the multi-addition adding circuit is improved.
  • the one or more buffer circuits store the second intermediate data generated by the adding circuit for at least one of the periods and output to the subtracting circuit and the comparing circuit.
  • the cache circuit is a register.
  • the summing circuit is a parallel counter.
  • the second bit stream data generated by the comparison circuit is the highest bit of the second intermediate data, wherein the second intermediate data is data represented by binary.
  • the circuit structure of the comparison circuit is simplified.
  • the buffer data of the current period generated by the subtraction circuit is the next highest to the lowest bit of the second intermediate data, wherein the second intermediate data is represented by a binary representation. data.
  • the circuit structure of the subtraction circuit is simplified.
  • a multi-addition adding circuit for random computing including: a buffer circuit and a calculation circuit, wherein the buffer circuit is configured to store the buffer input data for one cycle and generate buffered output data.
  • the buffer circuit is configured to store the buffer input data for one cycle and generate buffered output data.
  • the buffered input data is 0, the value of the buffered output data remains unchanged.
  • the calculation circuit is configured to perform data on the plurality of first bitstream data and the buffered output data.
  • the buffer input data is a value obtained by performing an exclusive OR operation on the plurality of first bit stream data
  • the number of the plurality of second bit stream data is a plurality of The number of bits of one bit stream is divided by 2 and the integer value is taken up.
  • the plurality of second bit stream data includes W 1 bit stream data having a value of 1, W t values of bit stream data of the buffer output data, and W 0 Bitstream data with a value of 0, where W 1 is the sum of the summed data divided by 2 and rounded down, ie W t is the remainder of the summed data divided by 2, that is, m mod 2; W 0 is the number of the plurality of second bit stream data minus the sum of W 1 and W t , that is,
  • the plurality of first bit stream data and the plurality of second bit stream data are data in a polarization representation, and the period is a period in which the plurality of first bit stream data are input.
  • the buffer circuit Since the buffer circuit stores the buffered input data generated by the calculation circuit in each cycle and is used for the calculation of the next cycle, the calculation of the multi-addition addition circuit in the current cycle is actually the input of the plurality of first bitstream data and The calculation of the buffered input data generated by a cycle calculation is performed, thereby reducing the calculation error and improving the calculation accuracy of the multi-addition addition circuit.
  • the cache circuit is a flip trigger.
  • the computing circuit includes a summing circuit and an output logic circuit.
  • the summing circuit is configured to receive a plurality of first bit stream data of a current period, calculate the summation data, and generate first intermediate data and second intermediate data, wherein the first intermediate data is a lowest bit of the summed data, The second intermediate data is the highest to the next lowest bit of the summation data, and the summation data is data represented by binary;
  • the output logic circuit is configured to receive the first intermediate data, the second intermediate data, and the first buffer data to generate second bit stream data.
  • the summing circuit is a parallel counter.
  • FIG. 1 is a schematic diagram of a multi-addition adding circuit in the prior art
  • FIG. 2 is a schematic diagram of a specific multi-addition adding circuit in the prior art
  • FIG. 3 is a schematic diagram of a multi-addition adding circuit according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of a specific multi-addition adding circuit according to an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of a more specific multi-addition adding circuit according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of another multi-addition adding circuit according to an embodiment of the present invention.
  • FIG. 7 is a schematic diagram of a multi-level circuit according to an embodiment of the present invention.
  • FIG. 8 is a schematic diagram of still another multi-addition adding circuit according to an embodiment of the present invention.
  • FIG. 9 is a schematic diagram of still another specific multi-addition adding circuit according to an embodiment of the present invention.
  • FIG. 10 is an output truth table according to an embodiment of the present invention.
  • FIG. 11 is a schematic diagram of still another specific multi-addition adding circuit according to an embodiment of the present invention.
  • FIG. 12 is another output truth table in the embodiment of the present invention.
  • the bit stream is calculated under the polarization representation.
  • the same bit stream can represent different numbers.
  • P x N 1 /N.
  • the 8-bit bit stream 0100 1001 in the bipolar polarization representation, represents the number -1/8.
  • the bit stream in all embodiments of the present invention is represented by a unipolar polarization representation, but it should be noted that the bit stream in all embodiments according to the present invention may also be represented by a bipolar polarization. Method or other polarization representation.
  • Pay more additions circuit 100 includes a two-input selector 112, two-input selector 114 and a two-input selector 116, wherein a two-input selector 112 to the bitstream A 0 -A 1 are summed and reduce its output
  • Two-input selector 114 will be summed bitstream A 2 -A 3 and reduce its output
  • the two input selector 116 sums and reduces S 0 and S 1 to obtain a second bit stream S.
  • the workflow of the multi-addition adding circuit 100 is illustrated by a specific example, wherein the bit stream A 0 is 01 00 (1/4), the bit stream A 1 is 01 00 (1/4), and the bit stream A 2 is 00 10 ( 1/4), the bit stream A 3 is 00 11 (2/4), and the selection signal r is 00 11 (2/4), and the lowest bit in each bit stream is first input to the multi-addition adding circuit 200 .
  • the actual calculation results differ from the theoretical calculation results by 7/16. Since the input signal r is used to randomly select the input two bit streams with a probability of 50%, and the selection signal r cannot be kept independent of the input two bit streams at the same time, the calculation accuracy of the multi-addition adding circuit 100 is low.
  • an embodiment of the present invention provides a multi-addition adding circuit 300 as shown in FIG. 3 to implement a plurality of addends in a random calculation.
  • the input of the multi-addition adding circuit 300 is a plurality of first bit stream data A 0 -A N-1 representing a number in a random calculation, and the output is a second bit stream data S, wherein the first bit stream data A 0 -A N Both -1 and second bit stream data S can be represented by a unipolar polarization representation.
  • the multi-addition adding circuit 300 includes a calculating circuit 310 and a buffer circuit 320, wherein the buffer circuit 320 is configured to store the buffered input data R in for at least one cycle, and input the buffer output data R out to the computing circuit 310; the input of the computing circuit 310 is The first bit stream data A 0 -A N-1 and the buffer output data R out generated by the buffer circuit 320, the calculation circuit 310 inputs the plurality of first bit stream data A 0 -A N-1 and the buffer output data R out The summation and reduction are performed to generate a second bit stream data S and buffer input data R in .
  • the second bit stream data S is the reduced bit stream data
  • ie K is the preset reduction factor so that the output does not exceed the range of numbers that the bitstream can represent under the unipolar polarization representation.
  • the number of the first bit stream data having a value of 1 in the first bit stream data A 0 -A N-1 of each cycle is taken as the summed data m of each period, for example, the values of A 0 - A 3 are respectively When it is 0, 1, 1, 0, the sum data m is 2.
  • the value of the second bit stream data S is the quotient of the sum of the summation data m of the current cycle and the buffer output data R out divided by the reduction factor K, and the buffer input data R in is all cycles up to the current cycle.
  • the sum of the summation data m is divided by the remainder of K.
  • the number of bits of the summation data m is related to the reduction factor K. Specifically, the number of bits of the summation data m is
  • the period in the embodiment of the present invention is a period in which a plurality of first bit stream data A 0 -A N-1 are input. For example, each bit stream periodically inputs 1 bit of data every 2 ns, and the period is 2 ns.
  • any one of the input N first bit stream data may be represented as A i (j), where i may take 0 to N-1, and j may be taken. 0 to x, A i (j) represents the i-th bit stream data in the j-th cycle, and the value of A i (j) may be 0 or 1. Therefore, the summation data m of the jth cycle can be expressed as
  • the cached input data R in (j) can be expressed as which is Where K is the reduction factor and mod is the remainder operation. For example, A mod B is A divided by B.
  • the buffer circuit 320 Since the buffer circuit 320 stores the buffered input data R in generated by the calculation circuit 310 in each cycle and is used for the calculation of the next cycle, the calculation of the multi-addition addition circuit 300 in the current cycle is actually a plurality of first inputs.
  • the bit stream data A 0 -A N-1 is calculated separately from the buffered input data R in generated by the previous cycle calculation, instead of performing independent calculation on the plurality of first bit stream data A 0 -A N-1 of the current cycle. Therefore, the calculation error is reduced, and the calculation accuracy of the multi-addition adding circuit 300 is improved.
  • the minimum capacity of the cache circuit 320 is Bit to store the cached input data R in .
  • the cache circuit 320 can be a general purpose register or other circuit having a memory function, such as a random access memory (RAM).
  • the workflow of the multi-addition adder circuit 300 is illustrated by a specific example.
  • the input is 4 bit stream data A 0 -A 3 , where the bit stream A 0 is 01 00 (1/4) ), bit stream A 1 is 01 00 (1/4), bit stream A 2 is 00 10 (1/4), bit stream A 3 is 00 11 (2/4), and the lowest bit in each bit stream is first It is input to the calculation circuit 310.
  • the calculation circuit 310 includes a summing circuit 312, an adder circuit 314, a comparison circuit 316, and a subtraction circuit 318.
  • the summing circuit 312 receives the input plurality of first bit stream data A 0 -A N-1 , calculates the summed data m of the current period, and outputs the summed data m to the adding circuit 314, wherein the summed data m is a plurality of first bit stream data
  • the adding circuit 314 sets the summing circuit 312
  • the output summation data m is added to the buffer data R out outputted by the buffer circuit 320, and the calculation result Y is output;
  • the comparison circuit 316 compares the calculation result Y output by the addition circuit 314
  • the summing circuit 312 can be a parallel counter to perform the calculation of the summed data m for the current cycle.
  • the parallel counter can be implemented by a Look-Up Table (LUT) or other combinational logic.
  • the reduction factor K is an integer power of 2
  • the multi-addition adding circuit 300 shown in FIG. 5 is a more specific implementation for realizing the addition of four bit streams A 0 -A 3 in random computing, that is,
  • the workflow of the multi-addition summing circuit 300 is illustrated by a specific example, where the bit stream A 0 is 01 00 (1/4), the bit stream A 1 is 01 00 (1/4), and the bit stream A 2 is 00. 10 (1/4), the bit stream A 3 is 00 11 (2/4), and the lowest bit in each bit stream is first input to the calculation circuit 310, and the data in the buffer circuit 320 is 0.
  • the summing circuit 312 can be a parallel counter, or other combinational logic, to effect calculation of the number of inputs 1 to the summing circuit 312.
  • each bit in the summed data m output by the summing circuit 312 can be provided by the following logical expression, where the 0th bit of m
  • the second bit m[2] A 0 ⁇ A 1 ⁇ A 2 ⁇ A 3
  • the first bit m of m[1] Where m[i] is used to represent the value of the ith bit of m under the binary, Is the XOR operator.
  • the above logical expression can be implemented by combinational logic or a lookup table.
  • the comparison circuit 316 and the subtraction circuit 318 in the multi-addition addition circuit 300 can be realized by a simple circuit.
  • the comparison circuit 316 can directly select the highest bit Y of the output of the addition circuit 314. [2]
  • the subtraction circuit 318 directly selects the lower two bits Y[1:0] output from the addition circuit 314 as the output result R in .
  • multi-addition adder circuit 600 includes summing circuit 312, summing circuit 314, comparison circuit 316, subtraction circuit 318, and one or more buffer circuits 320.
  • the summing circuit 312 receives the input plurality of first bit stream data A 0 -A N-1 , calculates the summed data m and outputs the summed data m to the adding circuit 314 ; the adding circuit 314 outputs the summing data m of the summing circuit 312
  • the calculation result D generated by the subtraction circuit 318 is added, and the calculation result Y is output;
  • One or more cache circuits 320 in the multi-addition adder circuit 600 are configured to store at least one cache data for at least one cycle and output, wherein the cache data includes an adder circuit 314, a comparison circuit 316, and a subtraction circuit 318 generated during the calculation process. Data, the period is a period in which a plurality of first bit stream data A 0 -A N-1 are input.
  • the cache data may be the calculation result Y output by the addition circuit 314.
  • the buffer circuit 320 receives the calculation result Y as an input, buffers one or more cycles, and outputs the calculation result Y to the comparison circuit 316 and the subtraction circuit 318; It may be data generated by the addition circuit 314, the comparison circuit 316, and the subtraction circuit 318 in the calculation process.
  • the multi-addition adding circuit 600 shown in FIG. 6 is a specific implementation manner provided by an embodiment of the present invention, and is used to implement addition of four bit streams A 0 -A 3 in random computing, that is,
  • the buffer circuit 320 receives the calculation result Y output by the addition circuit 314, buffers the calculation result Y for one cycle, and outputs Y' to the comparison circuit 316 and the subtraction circuit 318.
  • the workflow of the multi-addition summing circuit 600 is illustrated by a specific example, wherein the bit stream A 0 is 01 00 (1/4), the bit stream A 1 is 01 00 (1/4), and the bit stream A 2 is 00. 10 (1/4), the bit stream A 3 is 00 11 (2/4), and the lowest bit in each bit stream is first input to the calculation circuit 310, and the data in the buffer circuit 320 is 0.
  • the random calculation of the multi-addition addition can also be implemented by the multi-stage circuit 700 as shown in FIG.
  • the input of the multi-stage circuit 700 is a plurality of bit streams A 0 -A N-1 representing a number in a random calculation, and the output is second bit stream data S representing a number in a random calculation, and Where K is the preset reduction factor so that the output does not exceed the range of numbers that the bitstream can represent.
  • the multi-stage circuit 700 includes a plurality of multi-addition adding circuits 710, 720, 730, etc., and the multi-addition adding circuit of each stage halve the input addend, wherein the multi-addition adding circuit 710 sets the first bit of the N inputs.
  • the stream data A 0 -A N-1 are added and N/2 bit stream data is obtained, and the multi-addition adding circuit 720 adds N/2 bit stream data and obtains N/4 bit streams, and finally passes through two inputs.
  • the addition circuit 730 obtains the second bit stream data S.
  • the multi-addition adding circuit 800 shown in FIG. 8 is a specific implementation of the multi-addition adding circuit 710 to add the input plurality of first bit stream data in the random calculation and halve the number of bit streams.
  • the input of the multi-addition adding circuit 800 is a plurality of first bit stream data A 0 -A N-1 representing a number in a random calculation, and the multi - addition adding circuit 800 pairs the input plurality of first bit stream data A 0 -A N -1 performs summation, and reduces the number of bitstream data to output a plurality of second bitstream data, wherein the number of the second bitstream data is the number of the first bitstream data divided by 2 and takes an integer upward Value, ie
  • the multi-addition addition circuit 800 includes a calculation circuit 810 and a buffer circuit 820, wherein the calculation circuit 810 receives the first bit stream data A 0 -A N-1 and the buffer output data T out generated by the buffer circuit 820, and the calculation circuit 810 pairs
  • the buffer circuit 820 stores the buffered input data T in for one cycle, and determines that the value of the output T out remains unchanged or flipped according to the value of the buffered input data T in , specifically, when T in is 0, the value of T out is output. It remains unchanged; when T in is 1, the value of the output T out is inverted.
  • the period in the embodiment of the present invention is a period in which a plurality of bit streams A 0 -A N-1 are input. For example, each first bit stream data periodically inputs 1 bit of data every 2 ns, and the period is 2 ns.
  • the multi-addition adding circuit 720, the multi-addition adding circuit 730, and the like can realize the function of multi-addition addition.
  • the number of bitstream data of 1 of the plurality of input first bit stream data A 0 -A N-1 is taken as summation data m
  • the buffer input data T in is the lowest bit of m under binary , that is, m[0] is the result of performing an exclusive OR operation on the input plurality of bit streams A 0 -A N-1 , for example, when the input bit stream is 4 bit streams A 0 , A 1 , A 2 , and A 3
  • the plurality of second bit stream data output by the calculation circuit 810 is N/2 bit streams, and when N is an odd number, N/2 takes an integer value upward.
  • the plurality of second bit stream data includes W 1 bit stream data having a value of 1, W t bit stream data having a value of T out , and W 0 bit stream data having a value of 0.
  • W 1 is the value of the summation data m divided by 2 and rounded down, ie W t is the remainder of the summation data m divided by 2, that is, m mod 2;
  • W 0 is the number of the second bit stream data minus the sum of W 1 and W t , that is, W 1 , W t and W 0 may each be 0.
  • Buffer circuit 820 requires a capacity of at least 1 bit, the calculation circuit 810 to output to determine T in the output of buffer circuit 820 T out if inverted.
  • Cache circuit 820 is typically a flip-flop, or other sequential circuit that has hold and flip functions depending on the value of the input signal.
  • the workflow of the multi-addition adder circuit 800 is illustrated by a specific example. For example, when the input is 4 bit streams A 0 -A 3 and the buffer output data T out of the buffer circuit 820 is 0. In the first cycle, the four bit streams A 0 -A 3 input to the calculation circuit 810 are 0110, and the bit stream output by the calculation circuit 810 is one 1 and one 0, respectively, that is, the two bit streams of the final output are 10 or 01. Therefore, the multi-addition addition circuit realizes converting 4 addends into 2 addends, that is, converting 0+1+1+0 into 0+1 or 1+0.
  • the buffer circuit 820 stores the buffered input data T in generated by the calculation circuit 810 in each cycle and is used for the calculation of the next cycle
  • the calculation of the multi-addition addition circuit 800 in the current cycle is actually a plurality of bit streams for the input.
  • a 0 -A N-1 is calculated separately from the buffered input data T in generated by the previous cycle calculation, instead of independent calculation of multiple bit streams A 0 -A N-1 of the current cycle, thus reducing the calculation The error improves the calculation accuracy of the multi-addition addition circuit 800.
  • the multi-addition addition circuit 800 shown in FIG. 9 is a more specific embodiment including a calculation circuit 810 and a buffer circuit 820.
  • the calculation circuit includes a summation circuit 811 and an output logic circuit 812.
  • the summing circuit 811 has the same function as the summing circuit 312, and is configured to receive a plurality of first bit stream data A 0 -A N-1 of the current period, calculate the summed data m, and output m[N-1: 1] to output logic circuit 812, and output m[0] to output logic circuit 812 and buffer circuit 820, where m[N-1:1] is the highest to the next lowest bit of the summed data m, ie, N-1 Bit to bit 1, m[0] is the lowest bit of the summed data m, ie bit 0.
  • the output logic circuit 812 is configured to receive m[N-1:1], m[0] generated by the summation circuit 811, and buffer output data Tout generated by the buffer circuit 8
  • the calculation circuit 810 includes a summation circuit 811 and an output logic circuit 812, wherein the summation circuit 811 receives the input plurality of bit streams A 0 -A 3 and calculates the number of 1 out of 4 bits input at the same time, and the calculation result is m represents a binary number; output logic circuit 812 receives the output of the summing circuit 811 m [2: 1], m [0] and the output buffer circuit 820 buffers data T out, and outputs a bit stream S 0 and S 1 .
  • the buffer circuit 820 receives the buffered input data m[0] generated by the summation circuit 811, determines the buffered output data Tout according to the parity of m[0], and the buffered output data Tout is inverted when m is an odd number, when m is an even number When T out does not change.
  • the summing circuit 811 can be a parallel counter, or other combinational logic, to effect the calculation of the number of inputs 1 to the summing circuit 811. Specifically, the output of each bit of the summing circuit 811 can be provided by the following logical expression:
  • the cache circuit 820 is a flip trigger to determine whether to flip the buffer output data T out according to the current cache input data m[0].
  • Output logic 812 can be configured as different combinational logic for different output situations.
  • the output truth table 1000 shown in FIG. 10 is a possible output case, where m is the number of 1s at the same time in the input bit stream A 0 -A 3 , that is, the summation data, S 0 and S 1
  • Tout is the buffered output data generated by the buffer circuit 820.
  • the values of S 0 and S 1 in the truth table can be interchanged to form different truth tables, corresponding to different output situations, so the output corresponding to the output truth table 1000 is not unique. of.
  • the difference in the truth table results in a difference in the combinational logic structure in the output logic circuit 812, which in turn causes the output results S 0 and S 1 to be expressed differently, but has no effect on the final calculation result of the multi-addition addition circuit 800, such as the output result.
  • the logical expressions of the outputs S 0 and S 1 vary according to the truth table.
  • the operation of the multi-addition adder circuit 800 and the specific logic functions implemented by the output logic circuit 812 are illustrated by the output relationship in the output truth table 1000 shown in FIG.
  • the bit stream A 0 is 01 00 (1/4)
  • the bit stream A 1 is 01 00 (1/4)
  • the bit stream A 2 is 00 10 (1).
  • the bit stream A 3 is 00 11 (2/4)
  • the lowest bit in each bit stream is first input to the calculation circuit 810, the initial value in the buffer circuit 820 is 0, and the lowest bit priority is entered into the summation. Circuit 811.
  • T out 0
  • the values of the input 4 bit streams A 0 -A 3 are 0, 0, 0, 1, respectively
  • S 0 0
  • bit stream S 0 output by the calculation circuit 810 is 00 00
  • bit stream S 1 is 01 10
  • the calculation accuracy of the multi-addition adding circuit 800 is improved.
  • the multi-addition adder circuit 800 shown in FIG. 11 is a more specific embodiment including a calculation circuit 810 and a buffer circuit 820.
  • the output corresponding to the multi-addition adding circuit 800 is an output truth table 1200 as shown in FIG. 12, wherein the summed data m is the number of 1s at the same time in the input bit stream A 0 -A 3 , that is, And data, S 0 and S 1 are the reduced addends, that is, the output bit stream, and T out is the buffer output data generated by the buffer circuit 820.
  • the values of S 0 and S 1 in the truth table can be interchanged to form different truth tables, so the output truth table 1200 is only one possible truth table.
  • the output of the truth table 1200 T out can only occur in the bit stream S 1 can not appear in the bitstream S 0, so the output of the logic truth table 1200 corresponding to the calculating circuit 810
  • the circuit structure is simpler. Specifically, the specific logic functions implemented are:
  • the multi-additive adder circuit 800 of the same reference numeral in the embodiment of the present invention has the same function, but may have a different internal circuit structure.
  • the multi-addition adding circuit 800 in FIG. 8 and the multi-additive adding circuit 800 in FIG. 11 can add the first bit streams of the plurality of inputs and halve the number of bit streams, but output the bit stream.
  • the number of the different numbers causes the corresponding output truth table to be different, so the internal structure of the multi-addition circuit circuit 800 is not completely the same.
  • the apparatus and method disclosed in the above embodiments may be implemented in other manners.
  • the embodiments described above are merely illustrative.
  • the division of different circuits is only a logical function division.
  • multiple circuits or circuits may be combined or integrated.
  • the mutual coupling relationship or communication connection relationship between the circuits discussed in the above embodiments may be through mutual coupling or communication connection between some interfaces, devices or circuits, or may be other electrical methods or other means.
  • the various functional circuits in various embodiments of the present invention may be integrated in one processing circuit or may be present in separate separate circuits.
  • the above integrated circuit can be implemented in the form of hardware or in the form of software.
  • the integrated circuitry, if implemented in the form of a software functional circuit and sold or used as a standalone product, may be stored in a computer readable storage medium.
  • the technical solution of the present invention which is essential or contributes to the prior art, or all or part of the technical solution, may be embodied in the form of a software product stored in a storage medium.
  • a number of instructions are included to cause a computer device (which may be a personal computer, server or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk, and the like. .

Abstract

一种多加数加法电路,用于随机计算中极化表示法下的多加数加法,涉及数字电路领域。多加数加法电路包括缓存电路和计算电路,其中缓存电路用于将待缓存的数据存储至少一个周期并输出;计算电路用于对多个比特流数据和缓存数据进行处理,输出一个比特流数据和待缓存的数据。其中,输出的一个比特流数据为求和数据与缓存数据的和除以缩减系数得到的商的值;输出的待缓存的数据为截止到当前周期的所有求和数据的和除以缩减系数得到的余数,其中求和数据为多个第一比特流数据中值为1的比特流的个数。通过缓存电路来保存每个周期的部分计算结果,提高了多加数加法电路的计算精度。

Description

用于随机计算的多加数加法电路 技术领域
本发明涉及随机计算领域,尤其涉及一种多加数加法电路。
背景技术
在随机计算中,输入数据和输出数据通常为极化表示法下的比特流。例如,在单极(Unipolar)极化表示法中,对于一个长度为N位的比特流X,若其中包含N 1个1以及N 0(N 0=N-N 1)个0,则该比特流X表示了数字P x=N 1/N。以一个8位的比特流0100 1001为例,在单极极化表示法中,它代表数字3/8。对于常见的计算,例如多加数加法的计算,极化表示法下的比特流可以通过简单的逻辑电路来实现。
如图1所示的是一种用于随机计算的多加数加法电路100,包括多个两输入加法电路110。多加数加法电路100接收随机计算中代表数字的多个比特流A 0-A N-1,并产生一个比特流S,其中:
Figure PCTCN2018113353-appb-000001
两输入加法电路110为两输入选择器,其数据输入端接收两个输入的比特流,信号选择端接收极化表示法下的值为0.5的选择比特流,例如采用单极极化表示法的比特流01011100。两输入加法电路110通过对两个输入的比特流进行概率为50%的随机选择,从而实现两输入加法电路的功能。多加数加法电路100通过多个呈树形结构的两输入加法电路110实现多个比特流A 0-A N-1相加,其中每一级两输入加法电路110将输入的比特流的数量减半,最终得到一个比特流S。由于采用选择比特流随机选择输入的比特流以实现两输入加法的计算,因此可能引起较大的计算误差,导致多加数加法电路100的计算精度降低。
发明内容
本发明的实施例提供了一种用于随机计算的多加数加法电路,以提高多加数加法电路的计算精度。
为了更清楚的描述本发明实施例,将使用以下术语、缩写或符号:
m[i]:数据m在二进制下的第i比特的数值;
Figure PCTCN2018113353-appb-000002
对数据m在二进制下的第i比特求反得到的数值;
m[i:j]:数据m在二进制下的第i比特至第j比特的数值,例如,当m为二进制下的0100,则m[2:1]为二进制下的10;
Figure PCTCN2018113353-appb-000003
异或运算符,表示将两个数据进行异或运算;
Figure PCTCN2018113353-appb-000004
向上取整符,表示将数值x进行向上取整,例如
Figure PCTCN2018113353-appb-000005
Figure PCTCN2018113353-appb-000006
向下取整符,表示将数值x进行向下取整,例如
Figure PCTCN2018113353-appb-000007
第一方面,在本发明实施例中提供一种用于随机计算的多加数加法电路,包括缓存电路和计算电路,其中,缓存电路用于将缓存输入数据存储至少一个周期,并作为缓存输出数据输入至计算电路;计算电路用于对多个第一比特流数据和缓存输出数据进行计算,输 出第二比特流数据和缓存输入数据,其中,缓存输入数据为截止到当前周期的所有周期的求和数据的和除以缩减系数得到的余数,所述求和数据为每个周期的多个第一比特流数据中值为1的第一比特流数据的个数,第二比特流数据为每个周期的求和数据与缓存输出数据的和除以缩减系数得到的商。第一比特流数据和第二比特流数据均为极化表示法下的数据,所述缩减系数为预设的参数,所述周期为多个第一比特流数据输入的周期。
由于缓存电路将每个周期中计算电路产生的缓存输入数据进行存储,并用于下个周期的计算,多加数加法电路在当前周期的计算实际上是对输入的多个第一比特流数据和上一个周期计算所产生的缓存输入数据进行计算,因此减小了计算误差,提高了多加数加法电路的计算精度。
在一种可能的实施方式中,将第一比特流数据表示为A i(j),其中i可以取0~N-1,j可以取0~x,A i(j)表示在第j个周期的第i个比特流数据。则第j个周期的求和数据
Figure PCTCN2018113353-appb-000008
缓存输入数据
Figure PCTCN2018113353-appb-000009
第二比特流数据S(j)可以表示为S(j)=[m(j)+R in(j)]/K,其中K为缩减系数,mod为取余数运算。
在一种可能的实施方式中,计算电路包括求和电路,其中,求和电路用于接收多个第一比特流数据,并产生第一中间数据,其中第一中间数据为求和数据。
在一种可能的实施方式中,计算电路还包括加法电路,其中加法电路用于接收第一中间数据和缓存输出数据,并产生第二中间数据,其中第二中间数据为第一中间数据和缓存输出数据的和。
在一种可能的实施方式中,计算电路还包括比较电路,其中比较电路用于接收第二中间数据,将第二中间数据与缩减系数比较并产生第二比特流数据,其中,当第二中间数据大于或等于缩减系数时,第二比特流数据为1,否则第二比特流数据为0。
在一种可能的实施方式中,计算电路还包括减法电路,其中减法电路用于接收第二中间数据和第二比特流数据,并产生缓存输入数据,其中,当第二比特流数据为1时,缓存输入数据为第二中间数据与缩减系数的差,当第二比特流数据为0时,缓存输入数据为第二中间数据。
在一种可能的实施方式中,缓存电路的容量的比特数至少为以2为底的缩减系数的对数。
在一种可能的实施方式中,缓存电路为寄存器。
在一种可能的实施方式中,求和电路为并行计数器。
在一种可能的实施方式中,当缩减系数为2的整数次幂时,比较电路产生的第二比特流数据为第二中间数据的最高位,其中第二中间数据为二进制表示的数据。在上述情况下,比较电路的电路结构得到简化。
在一种可能的实施方式中,当缩减系数为2的整数次幂时,减法电路产生的当前周期的缓存数据为第二中间数据的次高位至最低位,其中第二中间数据为二进制表示的数据。在上述情况下,减法电路的电路结构得到简化。
第二方面,在本发明实施例中提供一种用于随机计算的多加数加法电路,包括:求和电路、加法电路、比较电路、减法电路和一个或多个缓存电路。其中,求和电路用于接收多个第一比特流数据,计算每个周期的多个第一比特流数据中值为1的第一比特流数据的 个数,并产生第一中间数据;加法电路将第一中间数据和第三中间数据相加,产生第二中间数据,其中第三中间数据为减法电路的输出;比较电路接收第二中间数据,产生第二比特流数据,其中,当第二中间数据大于或等于缩减系数,则第二比特流数据为1,否则第二比特流数据为0;多个第一比特流数据和第二比特流数据均为极化表示法下的数据,缩减系数为预设的参数;减法电路接收第二中间数据和第二比特流,产生第三中间数据,其中,当第二比特流数据为1时,第三中间数据为第二中间数据与缩减系数的差,当第二比特流数据为0时,所三中间数据为第二中间数据;一个或多个缓存电路用于将至少一个缓存数据存储至少一个周期并输出,缓存数据包括加法电路、比较电路和减法电路接收和产生的数据,以及在计算过程中产生的数据,所述周期为多个第一比特流数据输入的周期。
由于缓存电路将每个周期中的上述缓存数据进行存储,并用于下个周期的计算,多加数加法电路在当前周期的计算实际上包括对上一个周期存储在缓存电路中的缓存数据的计算,因此减小了计算误差,提高了多加数加法电路的计算精度。
在一种可能的实施方式中,一个或多个缓存电路将加法电路产生的第二中间数据存储至少一个所述周期,并输出至所述减法电路和所述比较电路。
在一种可能的实施方式中,缓存电路为寄存器。
在一种可能的实施方式中,求和电路为并行计数器。
在一种可能的实施方式中,当缩减系数为2的整数次幂时,比较电路产生的第二比特流数据为第二中间数据的最高位,其中第二中间数据为二进制表示的数据。在上述情况下,比较电路的电路结构得到简化。
在一种可能的实施方式中,当缩减系数为2的整数次幂时,减法电路产生的当前周期的缓存数据为第二中间数据的次高位至最低位,其中第二中间数据为二进制表示的数据。在上述情况下,减法电路的电路结构得到简化。
第三方面,在本发明实施例中提供一种用于随机计算的多加数加法电路,包括:缓存电路和计算电路,其中缓存电路用于将缓存输入数据存储一个周期,并产生缓存输出数据,当缓存输入数据为0时,缓存输出数据的值保持不变,当缓存输入数据为1时,缓存输出数据的值发生翻转;计算电路用于对多个第一比特流数据和缓存输出数据进行计算,输出多个第二比特流数据和输入缓存数据;其中,缓存输入数据为多个第一比特流数据进行异或运算得到的值,多个第二比特流数据的个数为多个第一比特流数据的个数除以2并向上取整数值,多个第二比特流数据包括W 1个值为1的比特流数据、W t个值为缓存输出数据的比特流数据以及W 0个值为0的比特流数据,其中,W 1为求和数据除以2并向下取整的值,即
Figure PCTCN2018113353-appb-000010
W t为所述求和数据除以2的余数,即m mod 2;W 0为所述多个第二比特流数据的个数减去W 1与W t的和,即
Figure PCTCN2018113353-appb-000011
多个第一比特流数据和多个第二比特流数据为极化表示法下的数据,周期为多个第一比特流数据输入的周期。
由于缓存电路将每个周期中计算电路产生的缓存输入数据进行存储,并用于下个周期的计算,多加数加法电路在当前周期的计算实际上是对输入的多个第一比特流数据和上一个周期计算所产生的缓存输入数据进行计算,因此减小了计算误差,提高了多加数加法电路的计算精度。
在一种可能的实施方式中,缓存电路为翻转触发器。
在一种可能的实施方式中,计算电路包括求和电路和输出逻辑电路。其中,求和电路 用于接收当前周期的多个第一比特流数据,计算求和数据,并产生第一中间数据和第二中间数据,其中第一中间数据为求和数据的最低位,第二中间数据为求和数据的最高位至次低位,求和数据为二进制表示的数据;输出逻辑电路用于接收第一中间数据、第二中间数据和第一缓存数据,产生第二比特流数据。
在一种可能的实施方式中,求和电路为并行计数器。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍:
图1为现有技术中一种多加数加法电路的示意图;
图2为现有技术中一种具体的多加数加法电路的示意图;
图3为本发明实施例中一种多加数加法电路的示意图;
图4为本发明实施例中一种具体的多加数加法电路的示意图;
图5为本发明实施例中一种更为具体的多加数加法电路的示意图;
图6为本发明实施例中另一种多加数加法电路的示意图;
图7为本发明实施例中一种多级电路的示意图;
图8为本发明实施例中又一种多加数加法电路的示意图;
图9为本发明实施例中又一种具体的多加数加法电路的示意图;
图10为本发明实施例中一种输出真值表;
图11为本发明实施例中又一种具体的多加数加法电路的示意图;
图12为本发明实施例中另一种输出真值表。
具体实施方式
随机计算中,比特流在极化表示法下进行计算,根据不同的极化表示法,同一个比特流可以表示不同的数字。例如,在单极(Unipolar)极化表示法中,对于一个长度为N位的比特流X,若其中包含N 1个1以及N 0(N 0=N-N 1)个0,则该比特流X表示了数字P x=N 1/N。以一个8位的比特流0100 1001为例,在单极极化表示法中,它代表数字3/8。在双极(Bipolar)极化表示法中,对于一个长度为N位的比特流X,若其中包含N 1个1以及N 0(N 0=N-N 1)个0,则该比特流X表示了数字P x=(N 1-N 0)/N。如8位的比特流0100 1001,在双极极化表示法中,它代表数字-1/8。为了便于理解,本发明的所有实施例中的比特流都采用单极极化表示法来表示,但需要注意的是,根据本发明的所有实施例中的比特流也可以采用双极极化表示法或其他的极化表示法来表示。
如图2所示的是现有技术中多加数加法电路100的一种具体的例子,其中多加数加法电路100对输入的多个第一比特流数据A 0-A 3进行多加数加法计算,得到第二比特流数据S,其中:
Figure PCTCN2018113353-appb-000012
多加数加法电路100包括两输入选择器112、两输入选择器114和两输入选择器116,其中,两输入选择器112将比特流A 0-A 1进行求和并缩减,其输出
Figure PCTCN2018113353-appb-000013
两输入选择器114将比特流A 2-A 3进行求和并缩减,其输出
Figure PCTCN2018113353-appb-000014
两输入选择器116将S 0和S 1进行求和并缩减,得到第二比特流S。
以具体的例子说明多加数加法电路100的工作流程,其中,比特流A 0为01 00(1/4),比特流A 1为01 00(1/4),比特流A 2为00 10(1/4),比特流A 3为00 11(2/4),而选择信号r均为00 11(2/4),每个比特流中的最低位先被输入至多加数加法电路200中。在第一个周期,输入的4个比特流A 0-A 3的值分别为0、0、0、1,选择信号r为1,则S 0=0,S 1=1,S=1;在第二个周期,A 0-A 3的值分别为0、0、1、1,选择信号r为1,则S 0=0,S 1=1,S=1;在第三个周期,A 0-A 3的值分别为1、1、0、0,选择信号r为0,则S 0=1,S 1=0,S=1;在第四个周期,A 0-A 3的值分别为0、0、0、0,选择信号r为0,则S 0=0,S 1=0,S=0。因此,多加数加法电路100输出的第二比特流数据S为01 11,即实际计算结果S=3/4,而理论计算结果
Figure PCTCN2018113353-appb-000015
实际计算结果与理论计算结果相差7/16。由于采用选择信号r以50%的概率随机选择输入的两个比特流,而选择信号r不能与输入的两个比特流同时保持独立,因此多加数加法电路100的计算精度较低。
因此,本发明实施例提供一种如图3所示的多加数加法电路300,以实现随机计算中的多个加数相加。多加数加法电路300的输入为在随机计算中代表数字的多个第一比特流数据A 0-A N-1,输出为第二比特流数据S,其中第一比特流数据A 0-A N-1和第二比特流数据S均可以采用单极极化表示法表示。
多加数加法电路300包括计算电路310和缓存电路320,其中缓存电路320用于将缓存输入数据R in存储至少一个周期,并作为缓存输出数据R out输入至计算电路310;计算电路310的输入为第一比特流数据A 0-A N-1和缓存电路320产生的缓存输出数据R out,计算电路310对输入的多个第一比特流数据A 0-A N-1和缓存输出数据R out进行求和并缩减,产生一个第二比特流数据S和缓存输入数据R in。其中第二比特流数据S为经过缩减的比特流数据,即
Figure PCTCN2018113353-appb-000016
K为预设的缩减系数,使输出不超出单极极化表示法下比特流可表示的数字范围。将每个周期的第一比特流数据A 0-A N-1中值为1的第一比特流数据的个数作为每个周期的求和数据m,例如,A 0-A 3的值分别为0、1、1、0,则求和数据m为2。在一个周期中,第二比特流数据S的值为当前周期的求和数据m与缓存输出数据R out的和除以缩减系数K的商,缓存输入数据R in为截止到当前周期的所有周期的求和数据m的和除以K的余数。求和数据m的位数与缩减系数K有关,具体来说,求和数据m的位数为
Figure PCTCN2018113353-appb-000017
本发明实施例中的周期为多个第一比特流数据A 0-A N-1输入的周期,例如,每个比特流周期性地每2ns输入1比特数据,则周期为2ns。
具体的,当前周期为第x个周期,则输入的N个第一比特流数据中的任意一个比特流数据可以表示为A i(j),其中i可以取0~N-1,j可以取0~x,A i(j)表示在第j个周期的第i个比特流数据,A i(j)的值可以为0或者1。因此,第j个周期的求和数据m可以表示为
Figure PCTCN2018113353-appb-000018
缓存输入数据R in(j)可以表示为
Figure PCTCN2018113353-appb-000019
Figure PCTCN2018113353-appb-000020
其中K为缩减系数,mod为取余数运算,例如A mod B为A除以B取余数。第二比特流数据S(j)可以表示为S(j)=[m(j)+R in(j)]/K。
由于缓存电路320将每个周期中计算电路310产生的缓存输入数据R in进行存储,并用于下个周期的计算,多加数加法电路300在当前周期的计算实际上是对输入的多个第一比 特流数据A 0-A N-1和上一个周期计算所产生的缓存输入数据R in进行计算,而不是对当前周期的多个第一比特流数据A 0-A N-1进行独立的计算,因此减小了计算误差,提高了多加数加法电路300的计算精度。
缓存电路320的最小容量为
Figure PCTCN2018113353-appb-000021
比特,以存储缓存输入数据R in。缓存电路320可以是通用寄存器,或其他具有存储功能的电路,例如随机存取存储器(Random Access Memory,RAM)。
以具体的例子说明多加数加法电路300的工作流程。例如,当缩减系数K=4,且缓存电路320中存储的缓存输入数据R in为0,输入为4个比特流数据A 0-A 3,其中,比特流A 0为01 00(1/4),比特流A 1为01 00(1/4),比特流A 2为00 10(1/4),比特流A 3为00 11(2/4),每个比特流中的最低位先被输入至计算电路310中。在第一个周期,输入的4个比特流A 0-A 3的值分别为0、0、0、1,则S为(0+0+0+1+0)/4的商,即S=0,R in为(0+0+0+1+0)/4的余数,即R in=1;在第二个周期,R out=1,A 0-A 3的值分别为0、0、1、1,则S为(0+0+1+1+1)/4的商,即S=0,R in=3;在第三个周期,R out=3,A 0-A 3的值分别为1、1、0、0,则S为(1+1+0+0+3)/4的商,即S=1,R in=1;在第四个周期,R out=1,A 0-A 3的值分别为0、0、0、0,则S为(0+0+0+0+1)/4的商,即S=0,R in=1。计算电路310输出的第二比特流数据S为01 00,即S=1/4,与理论计算结果
Figure PCTCN2018113353-appb-000022
相差1/16,因此,多加数加法电路300的计算精度得到了提高。
图4所示的是多加数加法电路300的一种具体的实现方式,其中计算电路310包括求和电路312、加法电路314、比较电路316和减法电路318。求和电路312接收输入的多个第一比特流数据A 0-A N-1,计算当前周期的求和数据m并输出至加法电路314,其中求和数据m为多个第一比特流数据A 0-A N-1中1的个数,例如第一比特流数据A 0-A 3分别为0、1、1、0,则求和数据m=2;加法电路314将求和电路312输出的求和数据m与缓存电路320输出的缓存数据R out相加,输出计算结果Y;比较电路316将加法电路314输出的计算结果Y与预设的缩减系数K进行比较,当Y≥K时输出计算结果S=1,否则输出计算结果S=0;减法电路318的输入为加法电路314输出的计算结果Y和比较电路316输出的计算结果S,当S=1时减法电路318输出缓存数据R in=Y-K,当S=0时输出缓存数据R in=Y。
求和电路312可以是并行计数器,以完成对当前周期的求和数据m的计算。并行计数器可以通过查找表(Look-Up Table,LUT)或者其他组合逻辑电路来实现。当缩减系数K为2的整数次幂时,比较电路316和减法电路318可以通过较为简单的电路来实现。例如,当缩减系数K=32,则比较电路650的输出S为其输入Y的最高位,即第6位,而减法电路318的输出R in为其输入Y的次高位至最低位,即第5位至第1位。
图5所示的多加数加法电路300是一种更为具体的实现方式,用于实现随机计算中4个比特流A 0-A 3的加法运算,即
Figure PCTCN2018113353-appb-000023
以具体的例子来说明多加数加法点路300的工作流程,其中,比特流A 0为01 00(1/4),比特流A 1为01 00(1/4),比特流A 2为00 10(1/4),比特流A 3为00 11(2/4),每个比特流中的最低位先被输入至计算电路310中,缓存电路320中的数据为0。在第一个周期,输入的4个比特流A 0-A 3的值分别为0、0、0、1,则m=1,R out=0,则Y=1,S=0,R in=1;在第二个周期,A 0-A 3的值分别为0、0、1、1,则m=2,R out=1,则Y=3,S=0,R in=3;在第三个周期,A 0-A 3的值分别为 1、1、0、0,则m=2,R out=3,则Y=5,S=1,R in=1;在第四个周期,A 0-A 3的值分别为0、0、0、0,则m=0,R out=1,则Y=1,S=0,R in=1。计算电路310输出的第二比特流数据S为01 00,即S=1/4,与理论计算结果
Figure PCTCN2018113353-appb-000024
相差1/16,因此,多加数加法电路300的计算精度得到了提高。
在如图5所示的多加数加法电路300中,求和电路312可以是并行计数器,或者其他组合逻辑,以实现对输入到求和电路312中1的个数的计算。具体地,求和电路312输出的求和数据m中的的各个比特可以由以下逻辑表达式来提供,其中m的第0位
Figure PCTCN2018113353-appb-000025
Figure PCTCN2018113353-appb-000026
的第2位m[2]=A 0·A 1·A 2·A 3,m的第1位m[1]=
Figure PCTCN2018113353-appb-000027
其中用m[i]表示m在二进制下的第i比特的数值,
Figure PCTCN2018113353-appb-000028
为异或运算符。以上逻辑表达式可以通过组合逻辑,或者查找表来实现。由于缩减系数K=4为2的整数次幂,多加数加法电路300中的比较电路316和减法电路318可以通过简单的电路来实现,例如比较电路316可以直接选取加法电路314输出的最高位Y[2]作为输出结果S,而减法电路318直接选取加法电路314输出的较低两位Y[1:0]作为输出结果R in
在另一种实现方式中,多加数加法电路600包括求和电路312、加法电路314、比较电路316、减法电路318和一个或多个缓存电路320。其中,求和电路312接收输入的多个第一比特流数据A 0-A N-1,计算求和数据m并输出至加法电路314;加法电路314将求和电路312输出的求和数据m与减法电路318产生的计算结果D相加,输出计算结果Y;比较电路316将加法电路314输出的计算结果Y与预设的缩减系数K进行比较,当Y≥K时输出计算结果S=1,否则输出计算结果S=0;减法电路318的输入为加法电路314输出的计算结果Y和比较电路316输出的计算结果S,当S=1时减法电路318输出计算结果D=Y-K,当S=0时输出计算结果D=Y。多加数加法电路600中的一个或多个缓存电路320用于将至少一个缓存数据存储至少一个周期并输出,其中,缓存数据包括加法电路314、比较电路316和减法电路318在计算过程中产生的数据,所述周期为多个第一比特流数据A 0-A N-1输入的周期。例如,缓存数据可以为加法电路314输出的计算结果Y,此时缓存电路320接收计算结果Y作为输入,缓存一个或多个周期并输出计算结果Y至比较电路316和减法电路318;缓存数据还可以为加法电路314、比较电路316和减法电路318在计算过程中产生的数据。
如图6所示的多加数加法电路600为本发明实施例提供的一种具体的实施方式,用于实现随机计算中4个比特流A 0-A 3的加法运算,即
Figure PCTCN2018113353-appb-000029
其中,缓存电路320接收加法电路314输出的计算结果Y,将计算结果Y缓存一个周期并输出Y’至比较电路316和减法电路318。
以具体的例子来说明多加数加法点路600的工作流程,其中,比特流A 0为01 00(1/4),比特流A 1为01 00(1/4),比特流A 2为00 10(1/4),比特流A 3为00 11(2/4),每个比特流中的最低位先被输入至计算电路310中,缓存电路320中的数据为0。在第一个周期,输入的4个比特流A 0-A 3的值分别为0、0、0、1,则Y’=0,S=0,D=0,m=1,因此Y=1;在第二个周期,A 0-A 3的值分别为0、0、1、1,则Y’=1,S=0,D=1,m=2,因此Y=3;在第三个周期,A 0-A 3的值分别为1、1、0、0,则Y’=3,S=0,D=3,m=2,因此Y=5;在第四个周期,A 0-A 3的值分别为0、0、0、0,则Y’=5,S=1,D=1,m=0,因此Y=1;在第五 个周期,Y’=1,S=0,D=1。在第二个周期至第五个周期,多加数加法电路600输出的第二比特流数据S为01 00,即S=1/4,与理论计算结果
Figure PCTCN2018113353-appb-000030
相差1/16,因此,多加数加法电路300的计算精度得到了提高。
多加数加法的随机计算也可以通过如图7所示的多级电路700来实现。多级电路700的输入为在随机计算中代表数字的多个比特流A 0-A N-1,输出为在随机计算中代表数字的第二比特流数据S,且
Figure PCTCN2018113353-appb-000031
其中K为预设的缩减系数,使输出结果不超出比特流可表示的数字范围。多级电路700包括多个多加数加法电路710、720、730等,每一级的多加数加法电路将输入的加数逐级减半,其中多加数加法电路710将N个输入的第一比特流数据A 0-A N-1相加并得到N/2个比特流数据,多加数加法电路720将N/2个比特流数据相加并得到N/4个比特流,最终通过一个两输入加法电路730得到第二比特流数据S。
图8所示的多加数加法电路800为多加数加法电路710的一种具体的实施方式,以实现随机计算中将输入的多个第一比特流数据相加,并将比特流的数量减半。多加数加法电路800的输入为在随机计算中代表数字的多个第一比特流数据A 0-A N-1,多加数加法电路800对输入的多个第一比特流数据A 0-A N-1进行求和,并将比特流数据的个数缩减后输出多个第二比特流数据,其中第二比特流数据的个数为第一比特流数据的个数除以2并向上取整数值,即
Figure PCTCN2018113353-appb-000032
多加数加法电路800包括计算电路810和缓存电路820,其中,计算电路810接收第一比特流数据A 0-A N-1和缓存电路820产生的缓存输出数据T out,计算电路810对A 0-A N-1和T out进行求和并缩减第一比特流数据的个数,最后输出计算结果和T in。缓存电路820将缓存输入数据T in存储一个周期,并根据缓存输入数据T in的值决定输出的T out的值保持不变或者翻转,具体地,当T in为0时,输出T out的值保持不变;当T in为1时,输出T out的值发生翻转。本发明实施例中的周期为多个比特流A 0-A N-1输入的周期,例如,每个第一比特流数据周期性地每2ns输入1比特数据,则周期为2ns。同样的,在相应的改变多加数加法电路800的输入的比特流个数和输出的比特流个数后,多加数加法电路720、多加数加法电路730等均可以实现多加数加法的功能。
在同一周期,将输入的多个第一比特流数据A 0-A N-1中1的比特流数据的个数作为求和数据m,而缓存输入数据T in为m在二进制下的最低位,即m[0]为输入的多个比特流A 0-A N-1进行异或运算的结果,例如当输入的比特流是4个比特流A 0、A 1、A 2和A 3时,
Figure PCTCN2018113353-appb-000033
Figure PCTCN2018113353-appb-000034
计算电路810输出的多个第二比特流数据为N/2个比特流,当N为奇数时,N/2向上取整数值。具体来说,多个第二比特流数据包括W 1个值为1的比特流数据、W t个值为T out的比特流数据以及W 0个值为0的比特流数据。其中,W 1为求和数据m除以2并向下取整的值,即
Figure PCTCN2018113353-appb-000035
W t为求和数据m除以2的余数,即m mod 2;W 0为第二比特流数据的个数减去W 1与W t的和,即
Figure PCTCN2018113353-appb-000036
W 1、W t和W 0均可以为0。
缓存电路820需要的容量至少为1比特,以根据计算电路810输出的T in来判断缓存电路820的输出T out是否翻转。缓存电路820通常为翻转触发器,或者其他的能根据输入信号取值的不同而具有保持和翻转功能的时序电路。
以具体的例子说明多加数加法电路800的工作流程。例如,当输入为4个比特流A 0-A 3,且缓存电路820的缓存输出数据T out为0。在第1个周期,输入到计算电路810的4个比特 流A 0-A 3为0110,计算电路810输出的比特流分别为1个1以及1个0,即最终输出的两个比特流为10或01。因此,多加数加法电路实现了将4个加数转换为2个加数,即,将0+1+1+0转换为0+1或1+0。
由于缓存电路820将每个周期中计算电路810产生的缓存输入数据T in进行存储,并用于下个周期的计算,多加数加法电路800在当前周期的计算实际上是对输入的多个比特流A 0-A N-1和上一个周期计算所产生的缓存输入数据T in进行计算,而不是对当前周期的多个比特流A 0-A N-1进行独立的计算,因此减小了计算误差,提高了多加数加法电路800的计算精度。
图9所示的多加数加法电路800为一种更为具体的实施方式,包括计算电路810和缓存电路820,计算电路包括求和电路811和输出逻辑电路812。其中,求和电路811的功能与求和电路312相同,用于接收当前周期的多个第一比特流数据A 0-A N-1,计算求和数据m,并输出m[N-1:1]至输出逻辑电路812,以及输出m[0]至输出逻辑电路812和缓存电路820,其中m[N-1:1]为求和数据m的最高位至次低位,即第N-1位至第1位,m[0]为求和数据m的最低位,即第0位。输出逻辑电路812用于接收求和电路811产生的m[N-1:1]、m[0],以及缓存电路820产生的缓存输出数据T out,经过计算产生第二比特流S 0和S 1
以具体的例子来说明多加数加法电路800的工作流程。如图9所示,多加数加法电路800将输入的4个比特流A 0-A 3转化为2个比特流S 0和S 1,实现功能
Figure PCTCN2018113353-appb-000037
Figure PCTCN2018113353-appb-000038
此时的缩减系数K=2。计算电路810包括求和电路811和输出逻辑电路812,其中求和电路811接收输入的多个比特流A 0-A 3,并计算同一时刻输入的4个比特中1的个数,将计算结果用二进制数字m表示;输出逻辑电路812分别接收求和电路811的输出结果m[2:1]、m[0]和缓存电路820的输出缓存数据T out,并输出比特流S 0和S 1。缓存电路820接收求和电路811产生的缓存输入数据m[0],根据m[0]的奇偶性确定缓存输出数据T out,当m为奇数时缓存输出数据T out发生翻转,当m为偶数时T out不变。求和电路811可以是并行计数器,或者其他组合逻辑,以实现对输入到求和电路811中1的个数的计算。具体地,求和电路811的各个比特的输出可以由以下逻辑表达式来提供:
Figure PCTCN2018113353-appb-000039
缓存电路820为翻转触发器,以实现根据当前的缓存输入数据m[0]来判断是否翻转缓存输出数据T out
对于不同的输出情况,输出逻辑电路812可以被配置成不同的组合逻辑。如图10所示的输出真值表1000为一种可能的输出情况,其中m为输入的比特流A 0-A 3中同一时刻的1的个数,即求和数据,S 0和S 1为缩减后的加数,即输出的多个第二比特流数据,T out为缓存电路820产生的缓存输出数据。当m的值不变时,真值表中的S 0和S 1的值可以互换,以形成不同的真值表,对应不同的输出情况,因此输出真值表1000对应的输出情况不是唯一的。真值表的不同导致输出逻辑电路812中的组合逻辑结构的不同,进而导致输出结果S 0和S 1的表达方式不同,但是对多加数加法电路800的最终计算结果没有影响,例如输出的结果是S 0+S 1=0+1或S 0+S 1=1+0,但二者都表示相同的数值,即1。对于输出真值表1000,其实现的具体逻辑功能为S 0=T out·m[0]·m[1]+m[2],S 1=T out·m[0]+m[1]+m[2]。 对于其他可能的真值表,输出S 0与S 1的逻辑表达式根据真值表而变化。
以图10所示的输出真值表1000中的输出关系来说明多加数加法电路800的工作原理和输出逻辑电路812实现的具体逻辑功能。例如,输入的四个比特流A 0-A 3中,比特流A 0为01 00(1/4),比特流A 1为01 00(1/4),比特流A 2为00 10(1/4),比特流A 3为00 11(2/4),每个比特流中的最低位先被输入至计算电路810中,缓存电路820中的初值为0,最低位优先进入求和电路811。在第一个周期,T out=0,输入的4个比特流A 0-A 3的值分别为0、0、0、1,则求和数据m在二进制下表示为001,m[0]=T in=1,此时根据输出真值表1000得出S 0=0,S 1=T out=0,即值为1的比特流个数W 1=0,值为T out的比特流个数W t=1,值为0的比特流个数W 0=1;在第二个周期,由于上一周期的T in=1,因此T out=1,A 0-A 3的值分别为0、0、1、1,则求和数据m在二进制下表示为010,m[0]=T in=0,此时根据输出真值表1000得出S 0=0,S 1=1,即值为1的比特流个数W 1=1,值为T out的比特流个数W t=0,值为0的比特流个数W 0=1;在第三个周期,由于上一周期的T in=0,因此T out=1,A 0-A 3的值分别为1、1、0、0,则求和数据m在二进制下表示为010,m[0]=T in=0,此时根据输出真值表1000得出S 0=0,S 1=1,即值为1的比特流个数W 1=1,值为T out的比特流个数W t=0,值为0的比特流个数W 0=1;在第四个周期,由于上一周期的T in=0,因此T out=1,A 0-A 3的值分别为0、0、0、0,则求和数据m在二进制下表示为000,m[0]=T in=0,此时根据输出真值表1000得出S 0=0,S 1=0,即值为1的比特流个数W 1=0,值为T out的比特流个数W t=0,值为0的比特流个数W 0=2。
因此计算电路810输出的比特流S 0为00 00,比特流S 1为01 10,即
Figure PCTCN2018113353-appb-000040
与理论计算结果
Figure PCTCN2018113353-appb-000041
相差
Figure PCTCN2018113353-appb-000042
提高了多加数加法电路800的计算精度。
图11所示的多加数加法电路800为一种更为具体的实施方式,包括计算电路810和缓存电路820。其中,多加数加法电路800对应的输出情况为如图12所示的输出真值表1200,其中求和数据m为输入的比特流A 0-A 3中同一时刻的1的个数,即求和数据,S 0和S 1为缩减后的加数,即输出比特流,T out为缓存电路820产生的缓存输出数据。在同一个m值中,真值表中的S 0和S 1的值可以互换,以形成不同的真值表,因此输出真值表1200仅为一种可能的真值表。相对于输出真值表1000来说,输出真值表1200的T out只能出现在比特流S 1中而不能出现在比特流S 0中,因此输出真值表1200对应的计算电路810的逻辑电路结构更为简单,具体来说,其实现的具体逻辑功能为:
Figure PCTCN2018113353-appb-000043
需要注意的是,本发明实施例中的引用相同标记的多加数加法电路电路800具有相同的功能,但可以具有不同的内部电路结构。例如图8中的多加数加法电路800和图11中的多加数加法电路800均可以将多个输入的第一比特流相加并将比特流的数量减半后输出,但由于输入的比特流个数不同,导致对应的输出真值表不同,因此多加数加法电路电路800的内部结构不完全相同。
以上所述的实施例中揭露的装置和方法可以通过其他的方式实现。例如,以上所描述的实施例仅仅是示意性的,例如不同电路的划分,仅仅是一种逻辑功能划分,实际实现时可以有另外的划分方式,例如可以将多个电路或电路结合或集成到另一个系统。另外,上述实施例所讨论的电路之间的相互耦合关系或通信连接关系可以是通过一些接口、装置或电路之间的相互耦合或通信连接,也可以是其他电学方式或其他方式。
本发明各个实施例中的各个功能电路可以集成在一个处理电路中,也可以存在于分离的单独电路中。上述集成的电路既可以采用硬件的形式实现,也可以采用软件的形式实现。所述集成的电路如果以软件功能电路的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。

Claims (20)

  1. 一种用于随机计算的多加数加法电路,其特征在于,包括:
    缓存电路和计算电路;
    其中,所述缓存电路用于将缓存输入数据存储至少一个周期,并作为缓存输出数据输入至所述计算电路;
    所述计算电路用于对输入至所述计算电路的多个第一比特流数据和所述缓存输出数据进行计算,输出第二比特流数据和所述缓存输入数据;
    其中,所述缓存输入数据为截止到当前周期的所有周期的求和数据的和除以缩减系数得到的余数,其中,每个周期的所述求和数据为每个周期的所述多个第一比特流数据中值为1的第一比特流数据的个数,所述第二比特流数据为所述每个周期的所述求和数据与所述缓存输出数据的和除以所述缩减系数得到的商,所述多个第一比特流数据和所述第二比特流数据为极化表示法下的数据,所述缩减系数为预设的参数,所述周期为所述多个第一比特流数据输入的周期。
  2. 根据权利要求1所述的一种用于随机计算的多加数加法电路,其特征在于,所述计算电路包括求和电路,其中,所述求和电路用于接收所述多个第一比特流数据,并产生第一中间数据,所述第一中间数据为所述求和数据。
  3. 根据权利要求1或2所述的一种用于随机计算的多加数加法电路,其特征在于,所述计算电路还包括加法电路,其中所述加法电路用于接收所述求和电路产生的所述第一中间数据和所述缓存电路产生的所述缓存输出数据,并产生第二中间数据,所述第二中间数据为所述第一中间数据和所述缓存输出数据的和。
  4. 根据权利要求1至3任意一项所述的一种用于随机计算的多加数加法电路,其特征在于,所述计算电路还包括比较电路,其中,所述比较电路用于接收所述加法电路产生的所述第二中间数据,与所述缩减系数比较并产生所述第二比特流数据,其中,当所述第二中间数据大于或等于所述缩减系数,所述第二比特流数据为1,当所述第二中间数据小于所述缩减系数,所述第二比特流数据为0。
  5. 根据权利要求1至4任意一项所述的一种用于随机计算的多加数加法电路,其特征在于,所述计算电路还包括减法电路,其中,所述减法电路用于接收所述加法电路产生的所述第二中间数据和所述比较电路产生的所述第二比特流数据,产生所述缓存输入数据,其中,当所述第二比特流数据为1时,所述缓存输入数据为所述第二中间数据与所述缩减系数的差,当所述第二比特流数据为0时,所述缓存输入数据为所述第二中间数据。
  6. 根据权利要求1至5任意一项所述的一种用于随机计算的多加数加法电路,其特征在于,所述缓存电路的容量的比特数至少为以2为底的所述缩减系数的对数。
  7. 根据权利要求1至6任意一项所述的一种用于随机计算的多加数加法电路,其特征在于,所述缓存电路为寄存器。
  8. 根据权利要求2至7任意一项所述的一种用于随机计算的多加数加法电路,其特征在于,所述求和电路为并行计数器。
  9. 根据权利要求4至8任意一项所述的一种用于随机计算的多加数加法电路,其特征在于,当所述缩减系数为2的整数次幂时,所述比较电路产生的所述第二比特流数据为所 述第二中间数据的最高位,其中所述第二中间数据为二进制表示的数据。
  10. 根据权利要求5至9任意一项所述的一种用于随机计算的多加数加法电路,其特征在于,当所述缩减系数为2的整数次幂时,所述减法电路产生的所述当前周期的缓存数据为所述第二中间数据的次高位至最低位,其中所述第二中间数据为二进制表示的数据。
  11. 一种用于随机计算的多加数加法电路,其特征在于,包括:
    求和电路、加法电路、比较电路、减法电路和一个或多个缓存电路;
    其中,所述求和电路用于接收多个第一比特流数据,计算每个周期的所述多个第一比特流数据中值为1的第一比特流数据的个数,并产生第一中间数据;
    所述加法电路将所述第一中间数据和第三中间数据相加,产生第二中间数据,所述第三中间数据为所述减法电路的输出;
    所述比较电路接收所述第二中间数据,产生第二比特流数据,其中,当所述第二中间数据大于或等于缩减系数,所述第二比特流数据为1,当所述第二中间数据小于所述缩减系数,所述第二比特流数据为0,所述多个第一比特流数据和所述第二比特流数据为极化表示法下的数据,所述缩减系数为预设的参数;
    所述减法电路接收所述第二中间数据和所述第二比特流,产生所述第三中间数据,其中,当所述第二比特流数据为1,所述第三中间数据为所述第二中间数据与所述缩减系数的差,当所述第二比特流数据为0,所述第三中间数据为所述第二中间数据;
    所述一个或多个缓存电路用于将至少一个缓存数据存储至少一个周期并输出,所述缓存数据包括所述加法电路、所述比较电路和所述减法电路接收和产生的数据,以及在计算过程中产生的数据,所述周期为所述多个第一比特流数据输入的周期。
  12. 根据权利要求11所述的一种用于随机计算的多加数加法电路,其特征在于,所述一个或多个缓存电路将所述加法电路产生的所述第二中间数据存储至少一个所述周期,并输出至所述减法电路和所述比较电路。
  13. 根据权利要求11或12所述的一种用于随机计算的多加数加法电路,其特征在于,所述缓存电路为寄存器。
  14. 根据权利要求11至13任意一项所述的一种用于随机计算的多加数加法电路,其特征在于,所述求和电路为并行计数器。
  15. 根据权利要求11至14任意一项所述的一种用于随机计算的多加数加法电路,其特征在于,当所述缩减系数为2的整数次幂时,所述比较电路产生的所述第二比特流数据为所述第二中间数据的最高位,其中所述第二中间数据为二进制表示的数据。
  16. 根据权利要求11至15任意一项所述的一种用于随机计算的多加数加法电路,其特征在于,当所述缩减系数为2的整数次幂时,所述减法电路产生的所述第三中间数据为所述第二中间数据的次高位至最低位,其中所述第二中间数据为二进制表示的数据。
  17. 一种用于随机计算的多加数加法电路,其特征在于,包括:
    缓存电路和计算电路;
    其中,所述缓存电路用于将缓存输入数据存储一个周期,并产生缓存输出数据,其中,所述缓存输入数据为0时,所述缓存输出数据的值保持不变,所述缓存输入数据为1时,所述缓存输出数据的值发生翻转;
    所述计算电路用于对输入至所述计算电路的多个第一比特流数据和所述缓存输出数 据进行计算,输出多个第二比特流数据和所述输入缓存数据;
    其中,所述缓存输入数据为所述多个第一比特流数据进行异或运算得到的值,所述多个第二比特流数据的个数为所述多个第一比特流数据的个数除以2并向上取整数值,所述多个第二比特流数据包括W 1个值为1的比特流数据、W t个值为所述缓存输出数据的比特流数据以及W 0个值为0的比特流数据,其中,W 1为所述求和数据除以2并向下取整的值,W t为所述求和数据除以2的余数,W 0为所述多个第二比特流数据的个数减去W 1与W t的和,所述多个第一比特流数据和所述多个第二比特流数据为极化表示法下的数据,所述周期为所述多个第一比特流数据输入的周期。
  18. 根据权利要求17所述的一种用于随机计算的多加数加法电路,其特征在于,所述缓存电路为翻转触发器。
  19. 根据权利要求17至18所述的一种用于随机计算的多加数加法电路,其特征在于,所述计算电路包括求和电路和输出逻辑电路;
    其中,所述求和电路用于接收当前周期的所述多个第一比特流数据,计算所述求和数据,并产生第一中间数据和第二中间数据,所述第一中间数据为所述求和数据的最低位,所述第二中间数据为所述求和数据的最高位至次低位,所述求和数据为二进制表示的数据;
    所述输出逻辑电路用于接收所述求和电路产生的所述第一中间数据、所述第二中间数据和所述输出缓存数据,产生所述多个第二比特流数据。
  20. 根据权利要求17至19任意一项所述的一种用于随机计算的多加数加法电路,其特征在于,所述求和电路为并行计数器
PCT/CN2018/113353 2018-03-15 2018-11-01 用于随机计算的多加数加法电路 WO2019174263A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US17/004,893 US11119732B2 (en) 2018-03-15 2020-08-27 Multi-addend adder circuit for stochastic computing

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810211813.3A CN110275693B (zh) 2018-03-15 2018-03-15 用于随机计算的多加数加法电路
CN201810211813.3 2018-03-15

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/004,893 Continuation US11119732B2 (en) 2018-03-15 2020-08-27 Multi-addend adder circuit for stochastic computing

Publications (1)

Publication Number Publication Date
WO2019174263A1 true WO2019174263A1 (zh) 2019-09-19

Family

ID=67907363

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/113353 WO2019174263A1 (zh) 2018-03-15 2018-11-01 用于随机计算的多加数加法电路

Country Status (3)

Country Link
US (1) US11119732B2 (zh)
CN (2) CN116822537A (zh)
WO (1) WO2019174263A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113792511B (zh) * 2021-09-03 2023-11-03 上海交通大学 一种高计算准确度、低硬件开销单变量随机电路及其配置方法

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105027076A (zh) * 2013-03-15 2015-11-04 高通股份有限公司 相加-比较-选择指令
CN105512724A (zh) * 2015-12-01 2016-04-20 中国科学院计算技术研究所 加法器装置、数据累加方法及数据处理装置
CN105718240A (zh) * 2014-12-12 2016-06-29 南京财经大学 一种基于总和增量调制的任意路输入信号的比特流加法器
US9496875B1 (en) * 2004-03-25 2016-11-15 Altera Corporation Omnibus logic element
CN205959185U (zh) * 2016-07-18 2017-02-15 北京集创北方科技股份有限公司 运算电路

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CA2166247A1 (en) * 1995-12-28 1997-06-29 Ravi Shankar Ananth Supervisory circuit
US6745219B1 (en) * 2000-06-05 2004-06-01 Boris Zelkin Arithmetic unit using stochastic data processing
US8458114B2 (en) * 2009-03-02 2013-06-04 Analog Devices, Inc. Analog computation using numerical representations with uncertainty
WO2011106308A2 (en) * 2010-02-23 2011-09-01 Navia Systems, Inc. Configurable circuitry for solving stochastic problems
US10520975B2 (en) * 2016-03-03 2019-12-31 Regents Of The University Of Minnesota Polysynchronous stochastic circuits
US10063255B2 (en) * 2016-06-09 2018-08-28 Regents Of The University Of Minnesota Stochastic computation using deterministic bit streams
US10891536B1 (en) * 2016-12-06 2021-01-12 The United States Of America As Represented By The Secretary Of The Air Force Artificial neural network for reservoir computing using stochastic logic

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9496875B1 (en) * 2004-03-25 2016-11-15 Altera Corporation Omnibus logic element
CN105027076A (zh) * 2013-03-15 2015-11-04 高通股份有限公司 相加-比较-选择指令
CN105718240A (zh) * 2014-12-12 2016-06-29 南京财经大学 一种基于总和增量调制的任意路输入信号的比特流加法器
CN105512724A (zh) * 2015-12-01 2016-04-20 中国科学院计算技术研究所 加法器装置、数据累加方法及数据处理装置
CN205959185U (zh) * 2016-07-18 2017-02-15 北京集创北方科技股份有限公司 运算电路

Also Published As

Publication number Publication date
CN116822537A (zh) 2023-09-29
CN110275693B (zh) 2023-08-22
US11119732B2 (en) 2021-09-14
CN110275693A (zh) 2019-09-24
US20200394018A1 (en) 2020-12-17

Similar Documents

Publication Publication Date Title
CN111832050B (zh) 用于联邦学习的基于FPGA芯片实现的Paillier加密方案
KR100756137B1 (ko) 제산 및 제곱근 연산 유닛
CN107305485B (zh) 一种用于执行多个浮点数相加的装置及方法
Krips et al. Hybrid model of fixed and floating point numbers in secure multiparty computations
WO2019057093A1 (zh) 乘法电路、片上系统及电子设备
CN110908635A (zh) 基于同源曲线的后量子密码学的高速模乘器及其模乘方法
JP2004326112A (ja) マルチプルモジュラス選択器、累算器、モンゴメリー掛け算器、マルチプルモジュラス発生方法、部分掛け発生方法、累算方法、掛け算方法、モジュラス選択器、およびブースレコーダ
WO2023134130A1 (zh) 伽罗华域乘法器及纠删编解码系统
US6847986B2 (en) Divider
WO2019174263A1 (zh) 用于随机计算的多加数加法电路
KR20230141045A (ko) 암호 프로세서 장치 및 이를 채용하는 데이터 처리 장치
US10230376B2 (en) Apparatus and method for performing division
Hong et al. Radix-4 modular multiplication and exponentiation algorithms for the RSA public-key cryptosystem
US7366745B1 (en) High-speed function approximation
CN107015783B (zh) 一种浮点角度压缩实现方法及装置
CN115526131A (zh) 多级编码近似计算Tanh函数的方法及装置
JPH09138792A (ja) ログの近似値の計算方法およびその回路
Strollo et al. A 430 MHz, 280 mW Processor for the Conversion of Cartesian to Polar Coordinates in 0.25$\mu\hbox {m} $ CMOS
KR100946256B1 (ko) 다정도 캐리 세이브 가산기를 이용한 듀얼필드상의확장성있는 몽고매리 곱셈기
Selianinau Efficient implementation of Chinese remainder theorem in minimally redundant residue number system
Itabashi et al. Efficient modular polynomial multiplier for NTT accelerator of Crystals-Kyber
Bello et al. A MRC Based RNS to binary converter using the moduli set {22n+ 1-1, 2n-1, 22n-1}
CN117200809B (zh) 用于纠两个误码的rs码的低功耗钱搜索和错误估值电路
JP2008158855A (ja) 相関演算器及び相関演算方法
Zhang et al. Efficient Configurable Modular Multiplier For RNS

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18909629

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18909629

Country of ref document: EP

Kind code of ref document: A1