Computing Arithmetic Functions Using Stochastic Logic by Series Expansion

Stochastic logic implementations of complex arithmetic functions, such as trigonometric, exponential, and sigmoid, are derived based on truncated versions of their Maclaurin series expansions. This paper makes three contributions. First, it is shown that a polynomial can be implemented using multiple levels of NAND gates based on Horner’s rule, if the coefficients are alternately positive and negative and their magnitudes are monotonically decreasing. Truncated Maclaurin series expansions of arithmetic functions are used to generate polynomials which satisfy these constraints. The input and output in these functions are represented by unipolar representation. Functions including sine, cosine, tangent hyperbolic, logarithm and exponential can be implemented using this method. Second, for a polynomial that does not satisfy these constraints, it still can be implemented based on Horner’s rule if each factor of the polynomial satisfies these constraints. It is shown that functions such as <inline-formula><tex-math notation="LaTeX">$\sin \pi x/\pi$</tex-math><alternatives><inline-graphic xlink:href="parhi-ieq1-2618750.gif"/></alternatives></inline-formula>, <inline-formula><tex-math notation="LaTeX">$e^{-ax}$</tex-math><alternatives><inline-graphic xlink:href="parhi-ieq2-2618750.gif"/></alternatives></inline-formula>, <inline-formula><tex-math notation="LaTeX">$\tanh ax$</tex-math><alternatives><inline-graphic xlink:href="parhi-ieq3-2618750.gif"/></alternatives></inline-formula> and <inline-formula><tex-math notation="LaTeX">$\text{sigmoid}(ax3)$</tex-math><alternatives><inline-graphic xlink:href="parhi-ieq4-2618750.gif"/></alternatives></inline-formula> (for values of <inline-formula><tex-math notation="LaTeX">$a>1$</tex-math><alternatives><inline-graphic xlink:href="parhi-ieq5-2618750.gif"/></alternatives></inline-formula>) can be implemented using stochastic logic using factorization in combination with Horner’s rule. Third, format conversion is proposed for arithmetic functions with input and output represented in different formats, such as <inline-formula><tex-math notation="LaTeX">$\text{cos}\,\pi x$</tex-math><alternatives><inline-graphic xlink:href="parhi-ieq6-2618750.gif"/></alternatives></inline-formula> given <inline-formula><tex-math notation="LaTeX">$x\in [0,1]$</tex-math><alternatives><inline-graphic xlink:href="parhi-ieq7-2618750.gif"/></alternatives></inline-formula> and <inline-formula><tex-math notation="LaTeX">$\text{sigmoid(x)}$</tex-math><alternatives><inline-graphic xlink:href="parhi-ieq8-2618750.gif"/></alternatives></inline-formula> given <inline-formula><tex-math notation="LaTeX">$x\in [-1,1]$</tex-math><alternatives><inline-graphic xlink:href="parhi-ieq9-2618750.gif"/></alternatives></inline-formula>. Polynomials are transformed to equivalent forms that naturally exploit format conversions. The proposed stochastic logic circuits outperform the well-known Bernstein polynomial based and finite-state-machine (FSM) based implementations. Furthermore, the hardware complexity and the critical path of the proposed implementations are less than the well-known Bernstein polynomial based and FSM based implementations for most cases.