# Stochastic-Based Spin-Programmable Gate Array with Emerging MTJ Device Technology
## 3 Stochastic-Based Logic Block (SLB)
### Stochastic Switching with MTJ Devices  
Emerging spintronic devices can exhibit complex switching behaviors due to the shifting of their intrinsic magnetic moment (spin) of electrons. For example, in MgO-based magnetic tunneling junctions (MTJs) (depicted in Figure 4a) [23], the switching characteristic of their spin-torque switching is highly stochastic and exhibits a well-defined probability as shown in Figure 4b. Several recent studies have discovered that MTJ's switching probability, \(P_{\text{sw}}\), mainly depends on its intrinsic switching current and a thermal stability parameter (\(\Delta\)), where the \(\Delta=E_{u}/k_{\text{B}}T\), \(E_{u}\), \(k_{\text{B}}\), and \(T\) are uni-axial  
Figure 3: (**a**) Logic diagram of a 4:2 encoder; (**b**) Truth table; (**c**) Encoded inputs and outputs; (**d**) Logic curve interpretation. magnetic anisotropy energy, Boltzmann's constant, and temperature, respectively. In fact, if assuming the initial state of MTJ is parallel and one bit current information is stored in the MTJ, a write current signal \(I_{\mathrm{w}}\) applied during time \(t\) can exhibit a switching probability defined by \(p_{\mathrm{w}}=1-\exp(-t/\tau_{\mathrm{p}})\), where \(\tau_{\mathrm{p}}\) is the switching time constant. According to [24], its switching probability \(P_{\mathrm{sw}}\) can be controlled by changing the applied pulse width and amplitude [25] and can be concisely formulated as \(P_{\mathrm{sw}}(I)=1-\exp(-\frac{t}{\tau_{\mathrm{p}}}\exp(-\Delta(1-I/I_{ \mathrm{c0}})))\), where \(I_{\mathrm{c0}}\) is the critical switching current at \(0\,\mathrm{K}\). Therefore, by controlling the critical current \(I_{\mathrm{c}}\) and the duration of applied pulse current \(\tau_{\mathrm{p}}\), one can accurately predict the switching probability of a given MTJ device. In Figure 4c, we have plotted some of our experimental and analytical results of switching probability vs. the pulse duration for different voltages [6; 22]. In Figure 5, we present our design of a reconfigurable random sample generator with two MTJ devices. Its key idea is to exploit the stochastic switching of a MTJ device at different input currents under a fixed pulse duration. Compared with the conventional LFSR-based random number generation, such a MTJ-based methodology can provide not only true randomness but also ultra-fast generation speed. In its configuration mode (Figure 5a), depending on the precomputed STL weights,  
Figure 4: (**a**) Structure of an MTJ device given from [21]; (**b**) Our SPICE (Simulation Program with Integrated Circuit Emphasis) simulation results of random signal generation; (**c**) Experimental and analytical results of switching probability vs. the pulse duration at different voltages [6; 22]. the MTJ-based memristor is configured with its resistance set in order to produce the required current. The probability of spin-torque switching model \(P_{\text{sw}}(I)\) according to the current \(I\) is given by  
\[P_{\text{sw}}(I)=1-\exp(-\tau_{\text{P}}\exp(-\Delta(1-I/I_{\text{c0}}))) \tag{1}\]  
where \(I\) is applied current, \(\tau_{\text{P}}\) is the pulse width normalized by the attempt time. In its operation mode (Figure 5b), depending on the applied logic input, a \"0\" or \"1\" value is first written into the right MTJ. Subsequently, a stochastic reading current will be used to perform a read operation on the right MTJ device. The logic output values, i.e., the random samples, are completely determined by both the logic value stored and the reading success probability, which in turn is determined by the magnitude of the reading current \(I\). Note that, by controlling the reading current \(I\) and fixing \(I_{\text{c0}}\), \(\Delta\), and \(\tau_{\text{P}}\), we can match a specific logic weight with a predefined probability value. Finally, the magnitude of reading current \(I\) is determined by the reading voltage that is controlled by the resistance of the left MTJ device. The sensing circuit is based on previous MTJ-based true random generator scheme.