# Performing Arithmetic Operations with Locally Homogeneous Spiking Neural P Systems
## 3 An Locally Homogeneous Spiking Neural P System for Addition
### An LHSNP System with 1 Input Neuron for \(n\)-addition
At \(nk+3\) time slice, the highest bit of \(n\) addend calculation results is output to the environment. 6. Adder The process of implementing the addition operation in \(\Pi_{Add3}\) by the addition operator \(\sigma_{Add}\) is as follows: There are a total of seven rules in \(\sigma_{Add}\), of which four are: \(a^{4}\to cralambda\); \(a^{5}\to a\); \(a^{6}\to a^{4}\); \(a^{7}\to a^{4}\) is used to detect whether the highest bit of two binary addends participates in the calculation of \(\sigma_{Add}\) and whether the calculation result overflows. The implementation of the seven rules in \(\sigma_{Add}\) is as follows:1. Rule \(a\to a\) represents executing equation \(1_{2}+0_{2}=1_{2}\). It consume one spiking in \(\sigma_{Add}\) and send one spiking outward, which is the calculation result. 2. \(a^{2}/a\to crlambda\) indicates the execution of equation \(1_{2}+1_{2}=10_{2}\). One spiking retainedin \(\sigma_{Add}\) indicating carry 1, and zero spikings sent outward indicating the operation result 0. 3. \(a^{3}/a^{2}\to a\) indicates the execution of equation \(1_{2}+1_{2}+1_{2}=11_{2}\). One spiking retain in \(\sigma_{Add}\) indicates carry 1, and one spiking sent outward indicates the operation result 1. 4. \(a^{4}\to crlambda\) indicates; \(a^{5}\to a\); \(a^{6}\to a^{4}\); \(a^{7}\to a^{4}\) is used to perform the highest order operation. \(a^{4}\to crlambda\) indicates that the highest order calculation performed is \(0_{2}+0_{2}=0_{2}\). \(a^{5}\to a\) indicates that the highest order calculation performed is \(1_{2}+0_{2}=1_{2}\). \(a^{6}\to a^{4}\) indicates that the highest bit calculation performed is \(1_{2}+1_{2}=10_{2}\), which indicates that data overflow and sends out 4 spikings. \(a^{7}\to a^{4}\) indicates that the highest bit calculation performed is \(1_{2}+1_{2}+1_{2}=11_{2}\), which indicates that data overflow. \(\sigma_{Add}\) sends 4 spikings outward. 5. Data Overflow Monitoring \(\sigma_{aux_{4}}\) send spiking to \(\sigma_{Add}\) to mark the highest bit of each addition operation in \(\sigma_{Add}\). Pass 4 rules in \(\sigma_{Add}\): \(a^{4}\to crlambda\); \(a^{5}\to a\); \(a^{6}\to a^{4}\); \(a^{7}\to a^{4}\) detects whether the highest bit calculation result overflows. If the calculation result overflows, \(\sigma_{Add}\) sends 4 spikings outward. If the environment received 4 spikings, it indicates that data overflow. After receiving 4 spikings in \(\sigma_{\rm OF}\), 4 spikings are sent to each neuron \(\sigma_{aux_{1}}\) (\(0\leq i\leq k+1\)), \(\sigma_{aux_{2}j}\) (\(0\leq i\leq k-3\)), \(\sigma_{Add}\) and \(\sigma_{addend}\) to cut off the transmission of spiking in \(\Pi_{Add3}\), causing the system to stop running. The process of data overflow monitoring is as follows: 1. \(t=1\) to \(k+1\), there is no spiking input in \(\sigma_{aux_{4}}\). 2. \(t=(i-1)\,k+2\) to \(ik+1\) (\(2\leq i\leq n\)), \(\sigma_{aux_{4}}\) receives 1 spiking sent by \(\sigma_{aux_{2}1}\) at each time slice, and these spikings are stacked in \(\sigma_{aux_{4}}\). At \(t=ik+2\) (\(1\leq i\leq n\)) time slice, \(\sigma_{aux_{4}}\) is fired using rule \(a^{k}\to a\) send 4 spikings to \(\sigma_{Add}\). In summary, the above \(\Pi_{Add3}\) can perform any \(n\)\(k\)-bit binary number addition operations with one input neuron. \(\square\)  
To illustrate the operation process of \(\Pi_{Add3}\) shown in Figure 2, take the sum of three natural numbers 134, 134, and 1 as an example for illustration. The binary form of these three natural numbers is 10000110\({}_{2}\), 10000110\({}_{2}\), and 00000001\({}_{2}\). In \(\Pi_{Add3}\), \(n\) is 3 and the system is 8-bit, which means \(k\) is 8. Table 2 shows the number of spiking in all neurons at each time slice in \(\Pi_{Add3}\). In Table 2, \"\(t\)\" represents the time slice. \"\(int\)\" represents the number of spiking in neuron \(\sigma_{in}\). \"\(aux_{1,i}\) (\(0\leq i\leq k+1\))\", \"\(aux_{2,i}\) (\(0\leq i\leq 1\))\" and \"\(aux_{3}\)\" represents the number of spiking in the auxiliary neuron.