EE5393, Circuits, Computation, and Biology Computing with Probabilities a = 6/8 A B c = 3/8 1,1,0,1,0,1,1,1 1,1,0,0,0,0,1,0 C 1,1,0,0,1,0,1,0 b = 4/8 AND Sequential Constructs What about complex functions such as tanh, exp, and abs? Sequential Constructs Sequential Constructs 1 Original tanh function FSM approximation Y 0.5 0 -0.5 -1 -1 y -0.5 e e N x 2 N x 2 e e 0 X N x 2 N x 2 0.5 1 Sequential Constructs 1 Original linear gain function FSM approximation Y 0.5 0 when 0 PX -0.5 when -1 -1 when PK , 1 PK PY 0 ; PK 1 PX , 1 PK 1 PK 1-0.5 PX 1, 1 PK 0P X Y PY 1. 1 PK P PX K ; 1 PK 1 PK 0.5 1 Sequential Constructs 1 Original Function 8-State FSM Approximation 16-State FSM Approximation 32-State FSM Approximation 64-State FSM Approximation 0.9 0.8 0.7 Y 0.6 0.5 0.4 0.3 ye 0.2 0.1 0 -1 -0.8 -0.6 -0.4 -0.2 2 G| x| 0 X 0.2 0.4 0.6 0.8 1 Sequential Constructs 1 Original Function 8-State FSM Approximation 16-State FSM Approximation 32-State FSM Approximation 64-State FSM Approximation 0.9 0.8 0.7 Y 0.6 0.5 0.4 0.3 y | x | 0.2 0.1 0 -1 -0.8 -0.6 -0.4 -0.2 0 X 0.2 0.4 0.6 0.8 1 Sensing Applications Median Filter-Based Image Noise Reduction Sensing Applications Frame Difference-Based Image Segmentation if P Xt PX t1 PThreshold then PY 0; else PY 1; Sensing Applications Image Contrast Enhancing 510 a b PK , 510 a b ab PC 510 Sensing Applications Kernel Density EstimationBased Image Segmentation Comparison of Encoding Binary Radix Encoding Circuit Area Error Tolerance Delay Large Bad Short (Positional, Weighted) (Positional) (Compact, Efficient) Binary Radix Encoding Stochastic Encoding Small (Uniform) (Uniform, Good Long Stream) Long (Not compact, Long Stream) Stochastic Encoding Spectrum of Encoding Future Directions Spectrum of Encoding Binary Radix Encoding (Compact, Positional) ? Stochastic Encoding (Not compact, Uniform) Possible encodings in the middle with the advantages of both? General Random Bit Generators pdf of R pdf of R Random Source R R C R probability to be one < Constant Value C Comparator 1,0,1,… If R < C, output a one; If R ≥ C, output a zero. Types of Random Sources • Pseudorandom Number Generator Linear Feedback Shift Register Random Source < Constant Value (expensive) • Physical Random Source Thermal Noises (cheap) Challenge with Physical Random Sources cheap Random Source < Voltage Regulators expensive Constant Value expensive Suppose many different probabilities are needed: {0.2, 0.78, 0.2549, 0.43, 0.671, 0.012, 0.82, …}. It is costly to generate them directly. (many expensive constant values required.) pdf of R C1 C C2 R Opportunity with Physical Random Sources cheap expensive Random Source Random Random Source Source < < < Constant Value • Independent • Same probability pdf of R C 1,1,0,0,0, … 0,1,0,1,0, … 0,0,1,0,1, … R Solution When we need many different probabilities: {0.2, 0.78, 0.2549, 0.43, 0.671, 0.012, 0.82, …} • Generate a few source probabilities directly from random bit generators. • Synthesize combinational logic to generate other probabilities. Probability: Probability of a signal being logical one Basic Problem Set S of Input Probabilities {p11 , p22} … p2 … p1 p1 Random Bit p1 Independent Generators p2 p2 Other Probabilities Needed p1 p1 p1 Logic p2 Circuit p2 q1 q2 q3 q4 p2 • Synthesize Logic Circuit? • Choose Set S ? (|S| small) Example … … 0.4 0.4 0.5 0.5 Logic Circuit 0.6 0.2 P(x = 1) = 0.4 0,1,0,1,0,0,1,1,0,0 P(z = 1) = 0.2 x P(z = 1) = 0.6 P(x = 1) = 0.4 z yx z 0,0,0,1,0,0,1,0,0,0 1,0,1,1,0,1,0,0,0,0 0,1,0,0,1,0,1,1,1,1 1,0,1,1,0,0,1,0,0,1 AND P(y = 1) = 0.5 P(z = 1) = P(x = 0) P(z = 1) = P(x = 1) P(y = 1) Generating Decimal Probabilities Choose Set S = {p1, p2, p3} … … |S| Small! … Independent p1 p1 p2 p2 p3 p3 Arbitrary Decimal Probabilities Logic Circuit • Found Set S for |S| = 2 |S| = 1 q1 q2 q3 q4 Generating Decimal Probabilities Theorem: With S = {0.4, 0.5}, we can synthesize arbitrary decimal output probabilities. • Constructive proof. • Derived a synthesis algorithm. Algorithm Example: Synthesize q = 0.757 from S = {0.4, 0.5} 0.4 0.757 1− 1− 1− ×0.5 ×0.5 ×0.4 0.14 1 − 0.86 ×0.5 0.6 0.3 0.7 0.35 1− 1− ×0.5 ×0.5 0.243 ×0.40.6075 0.43 0.3925 0.785 0.215 (Black dots are inverters) 0.4 0.5 0.5 0.4 0.5 0.5 0.5 0.4 0.6 AND 0.7 AND 0.35 0.86 AND AND 0.43 AND 0.785 AND 0.6075 AND 0.757 For a probability value with n digits, need at most 3n AND gates.