# Stochastic-Based Spin-Programmable Gate Array with Emerging MTJ Device Technology
## 7 Error Analysis
A MTJ's switching probability \(P_{\text{sw}}\) mainly depends on critical current \(I_{\text{c0}}\) and thermal stability parameter \(\sigma\), therefore the variation of these two parameters need to be considered. Because the switching probability of a MTJ can be defined as \(P_{\text{sw}}(I)=1-\exp(-\tau_{\text{p}}\exp(-\Delta(1-I/I_{\text{c0}})))\), the \(l^{2}\) norm least square error of a given switching probability can be written as as \(e_{\text{m}}=\int_{0}^{n}|P_{\text{sw}}-P_{\text{measure}}|^{2}dI_{n}\), where the \(P_{\text{measure}}\) is the measured probability of switching. Using the above error model to analyze the impact of variation of electrical parameter on MTJ device, as shown in Figure 16a, the matching between the model simulation and theoretical results is very high. The paper [26] proposed similar architecture of true random number generator fabricated on the chip. The results experimentally demonstrates true random number generator based on the stochastic switching behavior of MTJ device. The true random number generator based on the stochastic switching behavior of MTJ device enhance the reliability, speed and power consumption to generate the true bit stream. The random bit fluctuation error (\(e_{\text{r}}\)) is due to the bit flips in a stream. In this paper, since the number of ones in the bit stream will be used to compute the value of stochastic FPGA, the error of bit fluctuations will affect the stochastic FPGA. The bit stream \(B_{i}\) with \(i=1,2,\cdots\), \(n\) has \(L\) length bit stream. The number of ones in a bit stream is converted to a deterministic value \(T\) through the  
Figure 16: (**a**) Simulation of theoretical and simulated results; (**b**) Random bit stream error with different bit length. Figure 15: (**a**) The mean square error (MSE) simulation of stochastic bit stream with increasing of bit flip error rate both in analytical and simulation method; (**b**) The MSE simulation of stochastic bit stream with different probability both in analytical and simulation method [43]. integrated circuit. Because \(T=\frac{1}{L}\sum_{i=0}^{L}B_{i}\), the expected value is \(T_{\text{e}}\). However, due to the random fluctuation error, the exact output \(T\) value is different from the excepted value \(T_{\text{e}}\). The random fluctuation \(e_{r}\) can therefore be written as \(e_{\text{r}}=|T-T_{\text{e}}|\approx\sqrt{\frac{T_{\text{e}}(1-T_{\text{e}})}{ L}}\). In this paper, the expected value \(T_{\text{e}}\) is calculated from the measurements of the output bit stream. The relationship between different probability and different length of random samples is shown in Figure 16b. Finally, we consider the error due to DW integration. The DW integration determines the number of ones in a given bit stream. According to the experimental work reported in [44], the reliability of a typical domain wall device is excellent. For example, a Co/Ni wire can achieve a 10-year retention time at 150 degrees and \(1\times 10^{14}\) times write. In addition, the experiments in [44] have also shown that the domain wall velocity and critical current are not sensitive to external magnetic field or temperature.