# Spiking Neural P Systems for Basic Arithmetic Operations
## 3 Arithmetic Operation in Spiking Neural P Systems
### Binary Multiplication in SNP Systems
Finally, the correct operation result is obtained. The operation process of the SNPS multiplier shown in Figure 7 can be divided into the following three parts:  
* Input the natural number X;
* Compute each bit of Z in parallel while inputting Y;
* Output each bit of Z from low to high in turn. The execution process of \(\Pi_{\mathbf{BMSNP}}\) is as follows:  
* From t = 0 to t = k + 1, the regular execution of \(\Pi_{\mathbf{BMSNP}}\) and the change of spikes in each neuron include:
* \(\sigma_{Input}\) accepts \(sp\)-\(x_{i}\) (\(0\leq i\leq k-1\)) and applies the corresponding rules to send \(sp\)-\(x_{i}\) to \(\sigma_{aux5}\). During this period, \(\sigma_{aux5}\) can only receive the spikes sent by \(\sigma_{Input}\), and apply the rules to send the received spikes to \(\sigma\)cand1 in turn. Similarly, \(\sigma_{candj}\) (\(1\leq j\leq k-2\)) sends the received spikes to \(\sigma_{candj+1}\) and \(\sigma_{bitj}\) respectively. * \(\sigma_{aux6}\) accepts the spikes sent by \(\sigma_{Input}\), if \(sp\)-\(x_{i}\) (\(0\leq i\leq k-1\)) = \(\{a\}\), use the rule \(a\)\(\rightarrow\)\(\lambda\) to forget this spike. * \(\sigma_{bitj}\) (\(1\leq j\leq k-2\)) accepts spikes sent by \(\sigma_{candj}\) (\(1\leq j\leq k-2\)) and forgets them using the rule \(a\)\(\rightarrow\)\(\lambda\). * \(\sigma_{aux1}\) and \(\sigma_{aux2}\) (starting to work at t = 1) each maintain one spike, and \(\sigma_{aux3}\) and \(\sigma_{aux4}\) each maintain k spikes at t = k + 1. * \(\sigma_{aux3}\) use the rule \(a^{k}\)\(\rightarrow\)\(a^{2}\) to send two spikes to \(\sigma_{aux6}\), and \(\sigma_{aux4}\) use the rule \(a^{k}\)\(\rightarrow\)\(a^{2}\) to send two spikes to \(\sigma_{aux5}\) and \(\sigma_{candj}\) (\(1\leq j\leq k\)) respectively. \(\sigma_{Input}\) accepts \(sp\)-\(y_{0}\) and sends \(sp\)-\(y_{0}\) to \(\sigma_{aux6}\) according to the corresponding rules. * There is no spike in \(\sigma_{add}\), \(\sigma_{multi}\) (\(1\leq i\leq k\)). * \(\text{t}=\text{k}+2\), the rule execution of \(\Pi_{\mathbf{BMSNP}}\) and the change of spikes in each neuron include:
* \(\sigma_{Input}\) accepts \(sp\)-\(y_{1}\) and sends \(sp\)-\(y_{0}\) to \(\sigma_{aux5}\), \(\sigma_{aux6}\) respectively. \(\sigma_{aux5}\) sends \(sp\)-\(x_{k-1}\) to \(\sigma_{cand1}\) while receiving \(sp\)-\(y_{0}\) and \(\{a^{2}\}\) from \(\sigma_{aux4}\). \(\sigma_{candj}\) (\(1\leq j\leq k-1\)) accepts \(sp\)-\(x_{k-j}\) and sends \(sp\)-\(x_{k-j-1}\), and \(\sigma_{candk}\) accepts \(sp\)-\(x_{0}\). \(\sigma_{candj}\) (\(1\leq j\leq k\)) receives the two spikes sent by \(\sigma_{aux4}\), and \(\sigma_{candj}\)(\(1\leq j\leq k\)) use the rule \(a^{3}\)\(\rightarrow\)\(a^{2}\) or \(a\)\(\rightarrow\)\(\lambda\) to send \(sp\)-\(x_{j-1}\) to \(\sigma_{bitj}\). * \(\sigma_{aux6}\) forgets \(sp\)-\(x_{k-1}\) accepts both \(sp\)-\(y_{0}\) (from \(\sigma_{Input}\)) and \(\{a^{2}\}\) (from \(\sigma_{aux3}\)). * \(\sigma_{aux1}\) holds one spike, \(\sigma_{aux2}\) gets three spikes (one spike from \(\sigma_{aux1}\), two spikes from \(\sigma_{aux4}\)), \(\sigma_{aux3}\) and \(\sigma_{aux4}\) hold one spike. * There is no spike in \(\sigma_{add}\), \(\sigma_{multi}\) (\(1\leq i\leq k\)). At this point, the multiplicand has been input into the multiplicand cache neuron group, and we can get Figure 8, which shows the spikes contained in each neuron in the pattern \(C_{k+2}\). * \(\text{t}=\text{k}+3\), the multiplicand has been input into the multiplicand neuron group, and the spike changes in each neuron of \(\Pi_{\mathbf{BMSNP}}\) are shown in Figure 9:
* \(\sigma_{Input}\) accepts \(sp\)-\(y_{2}\) and sends \(sp\)-\(y_{1}\) to \(\sigma_{aux5}\) and \(\sigma_{aux6}\), respectively. * There are no spikes in \(\sigma_{aux1}\) and four spikes in \(\sigma_{aux4}\). * \(\sigma_{aux3}\) and \(\sigma_{aux4}\) maintain one spike each. * \(\sigma_{aux5}\) receives the \(sp\)-\(y_{1}\) sent by \(\sigma_{Input}\), and use the corresponding rules in \(\sigma_{aux5}\) to forget \(sp\)-\(y_{0}\).