CN111428195A - Subtraction function approximate calculation device based on random calculation - Google Patents
Subtraction function approximate calculation device based on random calculation Download PDFInfo
- Publication number
- CN111428195A CN111428195A CN202010234266.8A CN202010234266A CN111428195A CN 111428195 A CN111428195 A CN 111428195A CN 202010234266 A CN202010234266 A CN 202010234266A CN 111428195 A CN111428195 A CN 111428195A
- Authority
- CN
- China
- Prior art keywords
- random
- bit stream
- unit
- random number
- output
- Prior art date
- Legal status (The legal status 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 status listed.)
- Pending
Links
- 238000004364 calculation method Methods 0.000 title claims abstract description 29
- 238000013507 mapping Methods 0.000 claims abstract description 6
- 238000000034 method Methods 0.000 abstract description 4
- 238000010586 diagram Methods 0.000 description 4
- 230000003247 decreasing effect Effects 0.000 description 2
- 238000012886 linear function Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F17/00—Digital computing or data processing equipment or methods, specially adapted for specific functions
- G06F17/10—Complex mathematical operations
- G06F17/17—Function evaluation by approximation methods, e.g. inter- or extrapolation, smoothing, least mean square method
Landscapes
- Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Mathematical Analysis (AREA)
- Mathematical Optimization (AREA)
- Pure & Applied Mathematics (AREA)
- Computational Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Mathematical Physics (AREA)
- Theoretical Computer Science (AREA)
- Algebra (AREA)
- Databases & Information Systems (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Mobile Radio Communication Systems (AREA)
Abstract
The invention discloses a subtracting function approximate calculation device based on random calculation. The device comprises an input shifting unit, a special value generating unit, a random number generating unit, a logic gate unit and an output counting unit, wherein the input shifting unit obtains an integer part p and a decimal part q obtained after an input independent variable x is shifted to the left by m bits, and the special value generating unit respectively generates lambda and the decimal part q by a logical mapping methodIn approximation, three random number generating units respectively generate λ,And q is converted into a random bit stream, the logic gate unit carries out bitwise logic operation on the random bit stream through the NAND gate and the AND gate and outputs a corresponding result bit stream, and the output counting unit is used for counting the number of 1 in the bit stream and converting the number into a binary real number for output. Method for device based on random calculation and segment approximationThe method can realize approximate calculation of the subtraction function of input and output in the interval [0, 1], and greatly reduce the power consumption and area overhead of a hardware framework while keeping high precision.
Description
Technical Field
The invention relates to the field of design of very large scale integrated circuits, in particular to a hardware device for calculating a subtraction function with high precision and low hardware overhead.
Background
The basic idea of random computation is to convert real numbers lying on the interval [0,1) into a random bit stream by means of a random number generator SNG, the probability of a 1 occurring in the bit stream representing the magnitude of the value. Given a kbit binary number B, the SNG generates a kbit random number R in each clock cycle and compares the size of the random number R with B to obtain 1bit in the random bit stream. After N clock cycles a random bit stream of length N is obtained, with a probability of 1 per bit of p (x) B/2k. Complex arithmetic functions can be mapped to simple bitwise logical operations using random representations.
The realization of multiplication requires very high hardware cost in the aspects of area AND power consumption, AND the multiplication can be realized by using an AND gate AND in unipolar random calculation (x is more than or equal to 0 AND less than 1) or using an XOR gate XNOR in bipolar random calculation (x is more than or equal to 1 AND less than 1). NOT can be used for realizing (1-x) operation in unipolar calculation AND (-x) operation in bipolar calculation.NAND gate can be used for realizing (1-ax) operation, wherein a ∈ [0, 1] the simple logic operations greatly reduce the area AND power consumption overhead of hardware design.
For example, the Cos function is a common trigonometric function, the value range of the Cos function is [ -1,1], and in the interval of [0,1), the Cos function is a monotone decreasing function.
Disclosure of Invention
The invention aims to provide a hardware device for reducing function approximate calculation based on random calculation, which realizes the purposes of high calculation precision, less power consumption and smaller area.
The technical scheme adopted by the invention is as follows:
a subtracting function approximate calculation device based on random calculation comprises an input shift unit, a special value generation unit, a random number generation unit, a logic gate unit and an output counting unit; the input shift unit is used for changing the multiplication operation x to 2mConverting into a shift operation, and extracting an integer part p and a decimal part q generated after an independent variable x is shifted left by m bits, wherein m is the number of sections of the independent variable x on an interval [0, 1); the special value generation unit is used for logically mapping the values of the integer part p to respectively obtain a special value lambda (f) (ph) and a special valueWherein h is 2-m(ii) a The random number generation unit is used for generating a special value lambda,And the fractional part q is converted into random bit streams respectively; the logic gate unit is used for generatingAnd the random bit stream of the fractional part q is represented by performing a bitwise nand operationA bit stream of (a); then will beBit stream and lambda bit stream are bitwise AND-operated to obtain representationA bit stream of (a); the counting unit is used for calculatingThe corresponding binary real value is the output calculation result of the number of 1 in the bit stream.
Further, the random number generation unit comprises a linear feedback shift register and a comparator, wherein the linear feedback shift register generates a pseudo random number y in each clock cycle, the comparator compares the pseudo random number y with input binary data z, and if z is larger than y, the random number generation unit outputs 1; if z < y, the random number generation unit outputs 0.
Further, the logic gate unit comprises a NAND gate and an AND gate, wherein the input of the NAND gate is a special valueAnd fractional part q are respectively obtained by two random bit streams through random number generating units, and the output of the two random bit streams is representationA bit stream of (a); the input of the AND gate is a random bit stream and representation obtained by a random number generation unit from lambda (f) (ph)The output of which is a representationThe bit stream of (a).
The device for calculating the approximation value of the subtraction function, disclosed by the invention, combines truncation Taylor expansion and piecewise approximation calculation, uses combinational logic mapping and logic gate operation, and avoids the consumption of a large number of lookup tables and multiplier resources, so that the hardware has smaller occupied area and lower power consumption under the condition of keeping the precision of the result of the quasi-total calculation ideal, and has remarkable advantages on a key path, and the device is suitable for the calculation of a continuous and slightly unipolar subtraction function with any input and output positioned in an interval [0,1 ].
Drawings
FIG. 1 is an architectural diagram of the apparatus of the present invention;
FIG. 2 is a schematic diagram of a linear shift feedback register L FSR;
fig. 3 is a schematic diagram of the random number generation unit SNG.
Detailed Description
The invention is described in further detail below with reference to the figures and the detailed description.
This embodiment approximates the subtraction function using the following formula:
where x is a function argument, x ∈ [0,1), f (x) where x is x0Is developed, and is delta x-x0. Dividing [0,1) into S-segment subintervals, where S-2mThe length of the subinterval is h 2-mEach segment interval may be represented as being [ α ]i-1,αi) Where i is 1,2, …, S. On subintervals, the truncated taylor expansion is used to determine an approximate linear function, and equation (1) can be approximated as:
f*(x)=f(x0)+f′(x0)·Δx=f(x0)+f′(x0)·(x-x0) (2)
the value of the subinterval index i may be determined by the following equation:
since i ═ p +1, equation (4) can be converted to:
according to equations (4) (5), the following variables are defined:
λ=f(ph) (6)
then equation (5) can be written as:
since f (x) is a decreasing function over [0, 1], q isThe fractional part of (A), therefore 0 < lambda < 1,0 < q < 1, so equation (9) can be computed randomly with a single polarity.
In the apparatus for approximate calculation of a subtraction function based on random calculation according to this embodiment, the value range of the input x is [0, 1], and the value range of the output function result is [0, 1). The overall hardware architecture diagram is shown in fig. 1, and mainly includes five modules working in the following orderRespectively an input shift unit, two special value generating unitsThree random number generating units (SNG), a logic gate unit and an output counting unit (Counter). The input shift unit takes the high m bits of the kbit binary input argument as the value of p, takes the low (k-m) bits as the value of q, and sets the multiplication operation x to 2mIt is converted into a shift operation (x < m), m being the number of segments of x over the interval [0,1 ]. The special value generation unit maps each bit of p into combinational logic in a logic mapping mode to obtain lambda (f), (ph) sum in binary representationThe value of each bit, thereby obtaining the sum ofAn approximation of (d). A random number generation unit for generating a random number,And q is converted to length 2kOf the random bit stream. Logic gate unit for calculatingThe unit realizes two times of multiplication and one time of addition operation by adopting one NAND gate and one AND gate, avoids the use of a multiplier and an adder, and greatly reduces the power consumption, the area and the time delay of a hardware architecture. The counting unit is used for countingThe number of 1's in the bit stream is converted to a binary output. The function and the specific implementation process of each unit are explained in detail as follows:
as shown in FIG. 1, the input x in this embodiment is a fixed point number of 10 bits, x ∈ [0,1), 10 bits are both fractional parts, at [0, 1]]The number of the sub-intervals divided up is S-2mThe length of the subinterval beingFirst, in the input shift unit, calculateAndi.e. p and q are eachThe integer part and the fractional part of (c). And alsoIn a hardware implementation, the multiplication may be replaced by a shift operation, so the high m bits of the input x may be assigned to p and the low (10-m) bits to q.
The data after the above processing is 10bit fixed point number without sign bit. The special value generation unit obtains lambda sum according to p through a logical mapping modeAn approximation of (d). According to λ andthe truth table of mbit of each bit and p in binary representation decimal is arranged into a logic function expression which is mapped into a combinational logic consisting of a series of AND gates, OR gates and NOT gates to generate lambda sumApproximate the corresponding bits of the unit so that the unit generates λ sum quicklyThe value simultaneously occupies little hardware resource. In this example, take λ (i) andof fractional partThe upper 10 bits are used as the output of the special value generating unit, and when i is 0,1,2 … 7, take Cos function and m is 8 as an example, λ (i) and λ (i) are addedThe values are listed below:
in this example, take λ (i) andthe upper 10 bits of the fractional part are taken as the output of the special value generating unit. 10 bits λ (i) and when k is 0,1,2 … 7The expression of the logic function corresponding to each bit of 3 bits of m is as follows: wherein A ═ m [2 ]]、B=m[1]、C=m[0]Three bits each representing the value of m,three bits respectively representing m values, n]Andrespectively represent lambda andthe nth bit of (1).
As shown in FIG. 2, the random number generation unit includes a linear shift feedback register L FSR and a comparator, the initial state is first set for the linear shift feedback register, the previous state output is reused as input at each clock cycle, k registers can generate kbit binary pseudo-random number y, passing through 2kOne cycle later, the present embodiment generates a 10bit pseudo-random number y with 10bi input per clock cycle L FSRthe binary number x of t is compared with the value, if z is more than y, 1 is output, and if z is less than y, 0 is output; through 210After 1024 clock cycles, a random bit stream of length 1024 is generated. Three random number generating units are respectively used for generating lambda,And q corresponding random bit streams.
The logic gate unit consists of a NAND gate and an AND gate, and the input of the NAND gate isAnd 1bit at the same position in the q random bit stream, the output is1bit in the bitstream; the inputs of the AND gate are respectively a lambda random bit stream and the output of the NAND gate; over 1024 cycles, the output of the AND gate is representativeA bit stream of length 1024.
Output counting unit for statistical representationAnd is converted into a binary output. Judging the 1bit number generated by the logic gate unit in each clock period: if the value is 1, adding 1 to the value in the counter; if it is 0, the value in the counter remains unchanged. The output result is between [0,1), and the 10-bit binary fixed point number corresponding to the counter value represents the decimal part of the output result.
The present embodiment takes the robot arm control of a tandem robot as an example to illustrate how the present device is applied in practical applications. The mechanical arm is a main execution part of the series robot, the flexibility degree of the mechanical arm plays a crucial role in the working capacity of the robot, and a large amount of Cos function operation is needed when the moving angle of the mechanical arm is calculated. The subtracting function approximate calculation device based on random calculation is applied to a robot control chip, so that the power consumption expense can be reduced, and the calculation precision can be improved.
Claims (3)
1. A subtracting function approximate calculation device based on random calculation comprises an input shift unit, a special value generation unit, a random number generation unit, a logic gate unit and an output counting unit,
the input shift unit is used for changing the multiplication operation x to 2mConverting into a shift operation, and extracting an integer part p and a decimal part q generated after an independent variable x is shifted left by m bits, wherein m is the number of sections of the independent variable x on an interval [0, 1);
the special value generation unit is used for logically mapping the values of the integer part p to respectively obtain a special value lambda (f) (ph) and a special valueWherein h is 2-m;
The random number generation unit is used for generating a special value lambda,And the fractional part q is converted into random bit streams respectively;
the logic gate unit is used for generatingAnd the random bit stream of the fractional part q is represented by performing a bitwise nand operationA bit stream of (a); then will beBit stream and lambda bit stream are bitwise AND-operated to obtain representationA bit stream of (a);
2. The apparatus according to claim 1, wherein the random number generation unit comprises a linear feedback shift register for generating a pseudo random number y in each clock cycle, and a comparator for comparing the pseudo random number y with an input binary data z, and if z > y, the random number generation unit outputs 1; if z < y, the random number generation unit outputs 0.
3. The device of claim 1, wherein the logic gate unit comprises a nand gate and an and gate, and the input of the nand gate is a special valueAnd fractional part q are respectively obtained by two random bit streams through random number generating units, and the output of the two random bit streams is representationA bit stream of (a); the input of the AND gate is a random bit stream and representation obtained by a random number generation unit from lambda (f) (ph)The output of which is a representationThe bit stream of (a).
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010234266.8A CN111428195A (en) | 2020-03-30 | 2020-03-30 | Subtraction function approximate calculation device based on random calculation |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010234266.8A CN111428195A (en) | 2020-03-30 | 2020-03-30 | Subtraction function approximate calculation device based on random calculation |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111428195A true CN111428195A (en) | 2020-07-17 |
Family
ID=71551662
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010234266.8A Pending CN111428195A (en) | 2020-03-30 | 2020-03-30 | Subtraction function approximate calculation device based on random calculation |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111428195A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113312862A (en) * | 2021-06-04 | 2021-08-27 | 上海交通大学 | LFSR-based random circuit hardware overhead minimization design method |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104038770A (en) * | 2014-06-05 | 2014-09-10 | 中国科学技术大学 | Discrete cosine transform (DCT) implementation method and system based on randomized computation |
CN110879697A (en) * | 2019-10-29 | 2020-03-13 | 南京大学 | Device for approximately calculating tanh function |
-
2020
- 2020-03-30 CN CN202010234266.8A patent/CN111428195A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104038770A (en) * | 2014-06-05 | 2014-09-10 | 中国科学技术大学 | Discrete cosine transform (DCT) implementation method and system based on randomized computation |
CN110879697A (en) * | 2019-10-29 | 2020-03-13 | 南京大学 | Device for approximately calculating tanh function |
Non-Patent Citations (1)
Title |
---|
ZIDI QIN 等: "A Universal Approximation Method and Optimized Hardware Architectures for Arithmetic Functions Based on Stochastic Computing", 《IEEE ACCESS》 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113312862A (en) * | 2021-06-04 | 2021-08-27 | 上海交通大学 | LFSR-based random circuit hardware overhead minimization design method |
CN113312862B (en) * | 2021-06-04 | 2022-04-05 | 上海交通大学 | LFSR-based random circuit hardware overhead minimization design method |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10740686B2 (en) | Stochastic computation using pulse-width modulated signals | |
Akhter et al. | Modified binary multiplier circuit based on Vedic mathematics | |
Zhang et al. | Parallel hybrid stochastic-binary-based neural network accelerators | |
Najafi et al. | Power and area efficient sorting networks using unary processing | |
CN111428195A (en) | Subtraction function approximate calculation device based on random calculation | |
Qian | Application of CORDIC algorithm to neural networks VLSI design | |
US11275563B2 (en) | Low-discrepancy deterministic bit-stream processing using Sobol sequences | |
Xu et al. | Hardware design of a kind of grid multi-scroll chaotic system based on a MSP430f169 chip | |
Rafiq et al. | An efficient architecture of modified booth multiplier using hybrid adder | |
CN111666063B (en) | Function increasing implementation device based on random calculation | |
Daud et al. | Hybrid modified booth encoded algorithm-carry save adder fast multiplier | |
Yu et al. | Approximate divider design based on counting-based stochastic computing division | |
CN110837624A (en) | Approximate calculation device for sigmoid function | |
Akhtar et al. | Stochastic computing: Systems, applications, challenges and solutions | |
US11475288B2 (en) | Sorting networks using unary processing | |
Qian et al. | A survey of computation-driven data encoding | |
Nandal et al. | Booth multiplier using reversible logic with low power and reduced logical complexity | |
CN111428196A (en) | Non-monotonic function approximate calculation device based on random calculation | |
Shriram et al. | Power Efficient Approximate Divider Architecture for Error Resilient Applications | |
PV et al. | Design and implementation of efficient stochastic number generator | |
CN114840173A (en) | Method and device for calculating mixed probability logic | |
Mousavi et al. | Pipelined Residue Logarithmic Numbers System for general modules set {2 n-1, 2 n, 2 n+ 1} | |
Vijaya Vardhan et al. | Ultra-Low-Power Modulo Adder with Thermometer Coding for Uncertain RNS Applications | |
Jayashree et al. | Design Approaches for Resource and Performance Optimization of Reversible BCD Addition and Unified BCD Addition/Subtraction Circuits | |
Thakral et al. | Comparative study and implementation of BCD adders for reversible logic based ALU |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200717 |