Realization of Artificial Neurons and Synapses Based on STDP Designed by an MTJ Device

As the third-generation neural network, the spiking neural network (SNN) has become one of the most promising neuromorphic computing paradigms to mimic brain neural networks over the past decade. The SNN shows many advantages in performing classification and recognition tasks in the artificial intelligence field. In the SNN, the communication between the pre-synapse neuron (PRE) and the post-synapse neuron (POST) is conducted by the synapse. The corresponding synaptic weights are dependent on both the spiking patterns of the PRE and the POST, which are updated by spike-timing-dependent plasticity (STDP) rules. The emergence and growing maturity of spintronic devices present a new approach for constructing the SNN. In the paper, a novel SNN is proposed, in which both the synapse and the neuron are mimicked with the spin transfer torque magnetic tunnel junction (STT-MTJ) device. The synaptic weight is presented by the conductance of the MTJ device. The mapping of the probabilistic spiking nature of the neuron to the stochastic switching behavior of the MTJ with thermal noise is presented based on the stochastic Landau–Lifshitz–Gilbert (LLG) equation. In this way, a simplified SNN is mimicked with the MTJ device. The function of the mimicked SNN is verified by a handwritten digit recognition task based on the MINIST database.


Introduction
Over the past decade, the spiking neural network (SNN) has become one of the most popular architectures to simulate the brain neural network.Considered as the thirdgeneration neural network, the SNN shows many advantages.The artificial neural network (ANN) is considered as the second-generation neural network.Compared with the ANN, the SNN is more plausible biologically and achieves better performance in pattern recognition tasks [1].The ANN often uses fairly perfect integrators and a non-linear activation function.The cortical neurons behave as leaky integrations that use conductance-based synapses.Furthermore, the standard training method in the ANN is back propagation, in which each neuron is fed its specific error signal for updating the weight matrix during training.But this kind of learning based on neuron-specific error signals is unlikely to be achieved in the cerebral cortex, where the learning methods are closer to unsupervised learning methods, such as the spike-timing-dependent plasticity (STDP) mechanism [2].In the SNN, the neural information is stored in the neuron in the form of spike training.When there is an external signal, the neuron is used to integrate the input and the leakage, while the weight of the synapse connecting each neuron is updated based on the STDP mechanism.
The STDP learning process includes the following stages.The first is the adjustment of the connection strengths (i.e., synaptic weights) based on the relative timing of a particular neuron's output and input states.The second stage is the hardware implementation of the SNN trained by STDP.In the implementation, the neuron is needed to generate the spiking signal and the synapse for the adjustment of the weight in real time.In the SNN, it shows huge benefits related to its asynchronous processing and massively parallel architecture [1,2].Recent developments in neuromorphics aim to implement the SNN in hardware to fully exploit its potential in terms of low energy consumption.Nevertheless, the general-purpose computing platforms and the custom hardware architectures implemented using standard CMOS technology cannot rival the power efficiency of the human brain.Hence, there is a need for novel nanoelectronic devices that can efficiently model the neurons and synapses constituting the SNN.
As an emerging non-volatile memory, magnetic random-access memory (MRAM) has many advantages, such as non-volatile data, low power consumption, high integration, strong durability, compatibility with the CMOS process, radiation hardness, etc., and is considered as one of the most promising next-generation memories [3][4][5][6][7][8].MRAM opens the door to the new computing paradigm, which is different from the traditional Von Neumann architecture.As the core device of MRAM, the magnetic tunnel junction (MTJ) device shows promising properties [9].At present, it is applied in many fields, including memory, sensors, and neural networks [8][9][10][11][12][13][14].
Current digital implementations of neuromorphic computing rely on large numbers of CMOS transistors, which commonly need a large area and consume a lot of energy.A cutting-edge neuromorphic circuit with a superior architecture is highly needed.For example, the sheer number of synapses for a few-node neural network requires intricate connections and routings, which would be relatively expensive with a CMOS-only solution.
The MTJ device can be used to represent the biological neuron and the synapse on a oneto-one basis to mimic the computational dynamics in the human brain [15].In this sense, the MTJ device offers a compact and energy-efficient solution to take the place of the traditional CMOS-based neural network [16,17].
In the paper, a dynamic model of the MTJ device is established first.Based on the operation mechanism of the MTJ device, a high resemblance is shown between the magnetization dynamics of the MTJ device and the STDP mechanism observed in biological synapses.Also, there exists a high resemblance between the magnetization dynamics of the MTJ device and the characteristics observed in biological neurons.Finally, a demo SNN based on the MTJ synapse and the MTJ neuron is constructed, which is used to solve the image recognition problem in the paper.Compared with other works, a different neuron structure is adopted in the paper.The detailed explanation of how to convert pixel information into presynaptic spikes is shown.The corresponding neuron reset circuit is designed to implement STDP in hardware.
The rest of the paper is organized as follows.Section 2 introduces the MTJ model strategies.Section 3 presents the similar characteristics between the MTJ device and the biological synapse.Section 4 presents the similar characteristics between the MTJ device and the biological neuron.In Section 5, the SNN is mimicked by the MTJ device and is applied to distinguish the two types of handwritten digit images.Finally, conclusions are made in Section 6.

Dynamic Model of the STT-MTJ Device for Simulation
The model of the STT-MTJ device was constructed based on the Landau-Lifshitz-Gilbert (LLG) equation [15][16][17]: where → m is the unit magnetic vector of the free layer; → m p is the unit magnetic vector of the pinned layer; J STT is the current density of the MTJ device and J STT = I STT /Area; → H e f f is the effective magnetic field, including the demagnetization field; and K STT = µ 0 γP /2et FL is the STT term.Other parameters are listed in Table 1 [18].TMR ratio for 0 bias 1.8 Considering the probabilistic switching behavior of the MTJ device, two stochastic aspects are included in the MTJ model.The first one is the angle between the stochastic initial magnetization vector and the easy axis.The second aspect is the stochastic thermal fluctuation field caused by thermal noise.For these two additional stochastic effects of the MTJ device, two corresponding stochastic terms are included in the LLGS equation to simulate the influence on the probabilistic characteristics of the MTJ device.
The other stochastic term is the random thermal fluctuation field, The three components of → H f in the x, y, and z directions follow a Gaussian distribution as follows [23]: ∆t is the time step of the simulation.The LLGS equation with stochastic terms is generally named the SLLGS equation.
The typical sandwich structure of the STT-MTJ device is shown in Figure 1a, including the free layer, oxide layer, and reference layer, respectively [3].The magnetization direction of the reference layer is fixed at (0, 0, 1), and the magnetization of the free layer can store information.As shown in Figure 1, with θ 0 = 5 • , when I STT = 5 µA, the STT moment is not large enough and → m remains at (0, 0, 1) due to the damping term.At this time, the MTJ device is in the P state.When I STT = 200 µA, the MTJ device is switched to the AP state.At this time, → m is changed to be (0, 0, −1).

Design of the STT-MTJ-Based Synapse
There exists a high resemblance between the STT-MTJ device and the biological synapse.In biology, the synapse acts as the bridge between the neurons.The neuron emitting a signal is called the presynaptic neuron (PRE), and the neuron receiving the signal is called the post neuron (POST).The synapse is used to connect the PRE with the POST.Based on the STDP mechanism, the update of the synaptic weight depends on the spiking time modes of the PRE and the POST.If the PRE spike is ahead of the POST, the synaptic weight will be increased.On the contrary, if the PRE spike lags after the POST, the synaptic weight will be decreased accordingly.The mathematical expression of the STDP mechanism is as follows [2]: where w Δ is the relative change of the synaptic weight and A+, A−, τ+, and τ− are the constants.
t Δ is the time difference between the PRE and the POST spikes.
, and tPRE is the moment when the PRE is activated, while tPOST is the moment when the POST is activated.
The synaptic weight is increased with the positive time windows (with t Δ > 0); this is called long-term potentiation (LTP).For the negative time windows (with t Δ < 0), the synaptic weight is decreased, which is called long-term depression (LTD).According to the STDP mechanism, the synaptic weight can be programmed in situ based on the spiking timing information transmitted between the spiking neurons.
A similar adjustment mechanism is also observed in the MTJ device in terms of the device conductance.For the perpendicular MTJ device (P-MTJ), its conductance can be adjusted by controlling the pulse width of the voltage.With the positive write current flowing from the free layer to the pinned layer, the resistance of the MTJ is increased.On the contrary, with the negative write current flowing from the pinned layer to the free layer, the resistance is decreased.
Figure 2 shows the designed synapse based on the STT-MTJ device.The structure is shown in Figure 2a.The 1T-1MTJ cell is used as the synaptic connection between the PRE

Design of the STT-MTJ-Based Synapse
There exists a high resemblance between the STT-MTJ device and the biological synapse.In biology, the synapse acts as the bridge between the neurons.The neuron emitting a signal is called the presynaptic neuron (PRE), and the neuron receiving the signal is called the post neuron (POST).The synapse is used to connect the PRE with the POST.Based on the STDP mechanism, the update of the synaptic weight depends on the spiking time modes of the PRE and the POST.If the PRE spike is ahead of the POST, the synaptic weight will be increased.On the contrary, if the PRE spike lags after the POST, the synaptic weight will be decreased accordingly.The mathematical expression of the STDP mechanism is as follows [2]: where ∆w is the relative change of the synaptic weight and A +, A −, τ +, and τ − are the constants.∆t is the time difference between the PRE and the POST spikes.∆t = t PRE − t POST , and t PRE is the moment when the PRE is activated, while t POST is the moment when the POST is activated.
The synaptic weight is increased with the positive time windows (with ∆t > 0); this is called long-term potentiation (LTP).For the negative time windows (with ∆t < 0), the synaptic weight is decreased, which is called long-term depression (LTD).According to the STDP mechanism, the synaptic weight can be programmed in situ based on the spiking timing information transmitted between the spiking neurons.
A similar adjustment mechanism is also observed in the MTJ device in terms of the device conductance.For the perpendicular MTJ device (P-MTJ), its conductance can be adjusted by controlling the pulse width of the voltage.With the positive write current flowing from the free layer to the pinned layer, the resistance of the MTJ is increased.On the contrary, with the negative write current flowing from the pinned layer to the free layer, the resistance is decreased.
Figure 2 shows the designed synapse based on the STT-MTJ device.The structure is shown in Figure 2a.The 1T-1MTJ cell is used as the synaptic connection between the PRE and the POST.The gate voltage of the NMOS, V G , is controlled by the membrane potential of the PRE, while the node voltage at the top of the MTJ, V T , is controlled by the membrane potential of the POST. Figure 2b shows the schematic of the time sequences of V G and V T under the 1T-1MTJ structure, which are controlled by the PRE and the POST, separately.When ∆t > 0, V T+ is overlapped with V G .In this condition, the internal current flows from the fixed layer to the free layer in the MTJ device, driving the MTJ to be switched to the P state.So, the conductance of the MTJ device is increased.When Δt > 0, VT+ is overlapped with VG.In this condition, the internal current flows from the fixed layer to the free layer in the MTJ device, driving the MTJ to be switched to the P state.So, the conductance of the MTJ device is increased.On the contrary, when Δt < 0, VT− is overlapped with VG.The current in the MTJ device flows from the free layer to the fixed layer, driving the MTJ to the AP state.So, the conductance of the MTJ device is decreased.
Since the MTJ device in the AP state has a low conductance, while the MTJ in the P state has a high conductance, the MTJ device in the AP state is used to mimic the synapse with a weight of 'zero', and the P state is used to mimic the synapse with a weight of 'one'.Based on the designed structure in Figure 2, the MTJ device can be used to simulate the STDP mechanism.
Next, the behavior of the MTJ synapses was investigated with the implementation of the handwritten digit images in the MNIST database [24,25].Figure 3 shows one of the images used in the paper.As shown in Figure 3a, the image of the handwritten digit "4" is a 28 × 28 matrix, with 784 pixels in total.In the SNN field, the image is transformed into a current pulse sequence, which is named a presynaptic pulse sequence.During the changing process, the basic principle is that the pixel in the pure black area is noted as '0′, while the pixel in the pure white area is noted as '1′.As show in Figure 3b, these pixels are converted to a series of current pulses, where the pixels close to '0′ are converted into a negative current pulse and the pixels close to '1′ are converted into a positive current pulse.On the contrary, when ∆t < 0, V T− is overlapped with V G .The current in the MTJ device flows from the free layer to the fixed layer, driving the MTJ to the AP state.So, the conductance of the MTJ device is decreased.
Since the MTJ device in the AP state has a low conductance, while the MTJ in the P state has a high conductance, the MTJ device in the AP state is used to mimic the synapse with a weight of 'zero', and the P state is used to mimic the synapse with a weight of 'one'.Based on the designed structure in Figure 2, the MTJ device can be used to simulate the STDP mechanism.
Next, the behavior of the MTJ synapses was investigated with the implementation of the handwritten digit images in the MNIST database [24,25].Figure 3 shows one of the images used in the paper.As shown in Figure 3a, the image of the handwritten digit "4" is a 28 × 28 matrix, with 784 pixels in total.In the SNN field, the image is transformed into a current pulse sequence, which is named a presynaptic pulse sequence.During the changing process, the basic principle is that the pixel in the pure black area is noted as '0 , while the pixel in the pure white area is noted as '1 .As show in Figure 3b, these pixels are converted to a series of current pulses, where the pixels close to '0 are converted into a negative current pulse and the pixels close to '1 are converted into a positive current pulse.For the generated presynaptic pulse sequence in Figure 3b, the reconstructed synapse is shown in Figure 4b.It can be seen that the reconstructed image is hard to read.The 784pixel information in the image is transformed into the corresponding 784 current pulse sequences (also known as presynaptic pulse sequences).As shown in Figure 4b, the 784 For the generated presynaptic pulse sequence in Figure 3b, the reconstructed synapse is shown in Figure 4b.It can be seen that the reconstructed image is hard to read.The 784-pixel information in the image is transformed into the corresponding 784 current pulse sequences (also known as presynaptic pulse sequences).As shown in Figure 4b, the 784 random magnetic vector angles are generated based on the uniform distribution, θ.This indicates that the initial state of the MTJ synapse is random, making it difficult to distinguish the image's content.To improve its quality, repetitive training is needed.As shown in Figure 4c, 10 training steps were conducted on the 784 synapses, i.e., with repeated writing of the presynaptic sequences 10 times.It can be seen that the results gradually tended to stabilize, with the numbers gradually becoming clear and readable.In the corresponding handwritten digital image, the pixels in the black area are close to zero, with the MTJ device in the AP state and a weight of 1.On the contrary, the pixels in the white area correspond to the MTJ device in the P state and a weight of 0. For the generated presynaptic pulse sequence in Figure 3b, the reconstructed synapse is shown in Figure 4b.It can be seen that the reconstructed image is hard to read.The 784pixel information in the image is transformed into the corresponding 784 current pulse sequences (also known as presynaptic pulse sequences).As shown in Figure 4b, the 784 random magnetic vector angles are generated based on the uniform distribution, θ.This indicates that the initial state of the MTJ synapse is random, making it difficult to distinguish the image's content.To improve its quality, repetitive training is needed.As shown in Figure 4c, 10 training steps were conducted on the 784 synapses, i.e., with repeated writing of the presynaptic sequences 10 times.It can be seen that the results gradually tended to stabilize, with the numbers gradually becoming clear and readable.In the corresponding handwritten digital image, the pixels in the black area are close to zero, with the MTJ device in the AP state and a weight of 1.On the contrary, the pixels in the white area correspond to the MTJ device in the P state and a weight of 0.

STT-MTJ-Based Neuron
The similar properties of the STT-MTJ device and the biological neuron are studied in this section.Figure 5 shows a schematic diagram of the membrane potential of a biological neuron, in which the spike and the leakage of the input are integrated together.The neuron would be activated when the membrane potential exceeds the threshold voltage [7].

STT-MTJ-Based Neuron
The similar properties of the STT-MTJ device and the biological neuron are studied in this section.Figure 5 shows a schematic diagram of the membrane potential of a biological neuron, in which the spike and the leakage of the input are integrated together.The neuron would be activated when the membrane potential exceeds the threshold voltage [7].
close to '0' are converted into a negative current pulse, and pixels close to '1' are converted into a positive current pulse.
For the generated presynaptic pulse sequence in Figure 3b, the reconstructed synapse is shown in Figure 4b.It can be seen that the reconstructed image is hard to read.The 784 pixel information in the image is transformed into the corresponding 784 current pulse sequences (also known as presynaptic pulse sequences).As shown in Figure 4b, the 784 random magnetic vector angles are generated based on the uniform distribution, θ.This indicates that the initial state of the MTJ synapse is random, making it difficult to distin guish the image's content.To improve its quality, repetitive training is needed.As shown in Figure 4c, 10 training steps were conducted on the 784 synapses, i.e., with repeated writing of the presynaptic sequences 10 times.It can be seen that the results gradually tended to stabilize, with the numbers gradually becoming clear and readable.In the cor responding handwritten digital image, the pixels in the black area are close to zero, with the MTJ device in the AP state and a weight of 1.On the contrary, the pixels in the white area correspond to the MTJ device in the P state and a weight of 0.

STT-MTJ-Based Neuron
The similar properties of the STT-MTJ device and the biological neuron are studied in this section.Figure 5 shows a schematic diagram of the membrane potential of a bio logical neuron, in which the spike and the leakage of the input are integrated together The neuron would be activated when the membrane potential exceeds the threshold volt age [7].The first two terms on the right-hand side of the LLGS equation described in Equation ( 1) are related to the leakage ones of the membrane potential in the magnetization dynamics, while the last term is related to the input pulse applied on the MTJ neuron.Figure 6 shows the integration process and the activation process of the m z in the STT-MTJ device.As shown in Figure 6, the input pulse with a 1 ns period and a 0.55 ns pulse width is adopted as the input pulse signal of the neuron.The precession of m z is simulated and four periods are shown in Figure 6a.It can be seen that m z can exhibit the integrated function, showing the accumulation effect of the multiple inputs and the leakages.Based on the integration function, the pulse has an obvious influence on the value of m z , with m z being increased with a pulse and decreased without a pulse.
tion based on the MTJ model in Section 2. The stochastic magnetic simulation was carried out based on the P-MTJ device with the p m  = (0, 0, −1).The states of the MTJ in the mag- netic dynamic model can be characterized by the mz, which is the z-component of m  , with mz = cosθ.The term mz can be used to stand for the membrane potential of the biological neuron in the STT-MTJ-based SNN structure.
The first two terms on the right-hand side of the LLGS equation described in Equation (1) are related to the leakage ones of the membrane potential in the magnetization dynamics, while the last term is related to the input pulse applied on the MTJ neuron.Figure 6 shows the integration process and the activation process of the mz in the STT-MTJ device.As shown in Figure 6, the input pulse with a 1 ns period and a 0.55 ns pulse width is adopted as the input pulse signal of the neuron.The precession of mz is simulated and four periods are shown in Figure 6a.It can be seen that mz can exhibit the integrated function, showing the accumulation effect of the multiple inputs and the leakages.Based on the integration function, the pulse has an obvious influence on the value of mz, with mz being increased with a pulse and decreased without a pulse.The activation of the neuron occurs when the membrane potential exceeds the threshold.In the MTJ neuron, the activation corresponds to the switching behavior of the MTJ device and is also presented by mz.As shown in Figure 6b, mz is switched from −1 to +1 successfully with six-cycle pulses as the input, which means that the MTJ neuron can be activated successfully.Due to the non-volatile property of the STT-MTJ device, mz can be kept at +1 even without the input pulse.Therefore, a reset circuit must be designed to reset the activated MTJ neuron.The reset period is similar to the refractory period observed in the biological neuron.The reset neuron cannot be activated again for a short time after being activated.The activation of the neuron occurs when the membrane potential exceeds the threshold.In the MTJ neuron, the activation corresponds to the switching behavior of the MTJ device and is also presented by m z .As shown in Figure 6b, m z is switched from −1 to +1 successfully with six-cycle pulses as the input, which means that the MTJ neuron can be activated successfully.Due to the non-volatile property of the STT-MTJ device, m z can be kept at +1 even without the input pulse.Therefore, a reset circuit must be designed to reset the activated MTJ neuron.The reset period is similar to the refractory period observed in the biological neuron.The reset neuron cannot be activated again for a short time after being activated.
The operation of the MTJ neurons can be divided into three stages, namely, the write stage, the read stage, and the reset stage.As shown in Figure 7, in the writing stage, V WRITE is high.The input synaptic current, I, is transmitted through the heavy metal layer.The MTJ neuron is driven by the input current.The state of the MTJ device is switched from the P state to the AP state.So, the neuron is activated.In the reading phase, V READ is high, and the state of the MTJ device is determined by the node voltage, V SPIKE , between the reference MTJ and the MTJ neuron.The read V SPIKE corresponds to a low-level MTJ in the P state, while the read V SPIKE corresponds to a high-level MTJ in the AP state.In the reset stage, if V SPIKE is high, a reset operation is initiated.Reverse current flows through the heavy metal layer, causing the MTJ neuron to be switched from the AP state to the P state, terminating the activation state.
Micromachines 2023, 14, x FOR PEER REVIEW 8 of 12 The operation of the MTJ neurons can be divided into three stages, namely, the write stage, the read stage, and the reset stage.As shown in Figure 7, in the writing stage, VWRITE is high.The input synaptic current, I, is transmitted through the heavy metal layer.The MTJ neuron is driven by the input current.The state of the MTJ device is switched from the P state to the AP state.So, the neuron is activated.In the reading phase, VREAD is high, and the state of the MTJ device is determined by the node voltage, VSPIKE, between the reference MTJ and the MTJ neuron.The read VSPIKE corresponds to a low-level MTJ in the P state, while the read VSPIKE corresponds to a high-level MTJ in the AP state.In the reset stage, if VSPIKE is high, a reset operation is initiated.Reverse current flows through the heavy metal layer, causing the MTJ neuron to be switched from the AP state to the P state, terminating the activation state.Besides the integration of the input and the leakage, probabilistic activation is another characteristic of the biological neuron.The probability of neuron dynamics [26] mainly comes from the randomness of ion channel switching and the randomness of neurotransmitter releasing.The switching behavior of the MTJ device is also probabilistic in nature.The switching probability of the MTJ (from AP to P or P to AP) is increased with the magnitude of the input current.Therefore, the switching probability of the MTJ device can be mapped with the activation probability of the biological neuron [27].The activation probability of the biological neuron typically varies non-linearly with the input synaptic current [2,28], which is similar to the non-linear variation of the switching probability of the MTJ device with the applied current.
The switching probability of the MTJ neuron can be adjusted by many factors.As shown in Figure 8, the switching probability can be changed with the variations of the MTJ free layer thickness, tFL, and the duration of the input current, tpw.The applied input current, I, is a square wave signal with tpw width.It can be seen that the switching probability of the MTJ device is decreased with increasing tFL (as shown in Figure 8a), while it is decreased with decreasing tpw (as shown in Figure 8b).By controlling tFL, tpw, or other factors, the activation function of the MTJ neuron can be adjusted by the changing of the switching probability.So, the MTJ neuron can be designed to be sensitive to specific inputs and to be inactivated with other inputs.Besides the integration of the input and the leakage, probabilistic activation is another characteristic of the biological neuron.The probability of neuron dynamics [26] mainly comes from the randomness of ion channel switching and the randomness of neurotransmitter releasing.The switching behavior of the MTJ device is also probabilistic in nature.The switching probability of the MTJ (from AP to P or P to AP) is increased with the magnitude of the input current.Therefore, the switching probability of the MTJ device can be mapped with the activation probability of the biological neuron [27].The activation probability of the biological neuron typically varies non-linearly with the input synaptic current [2,28], which is similar to the non-linear variation of the switching probability of the MTJ device with the applied current.
The switching probability of the MTJ neuron can be adjusted by many factors.As shown in Figure 8, the switching probability can be changed with the variations of the MTJ free layer thickness, t FL , and the duration of the input current, t pw .The applied input current, I, is a square wave signal with t pw width.It can be seen that the switching probability of the MTJ device is decreased with increasing t FL (as shown in Figure 8a), while it is decreased with decreasing t pw (as shown in Figure 8b).By controlling t FL , t pw , or other factors, the activation function of the MTJ neuron can be adjusted by the changing of the switching probability.So, the MTJ neuron can be designed to be sensitive to specific inputs and to be inactivated with other inputs.where tFL is kept as 1 nm.It should be noted that the 0.2 ns pulse width is very short, so a large current is needed for certain switching.

MTJ Mimics the SNN with Application in Image Recognition
Figure 9 shows the application scenario of the SNN for handwritten digit image recognition.Only the connections for one neuron are shown in the illustration in Figure 9.The information of the input handwritten digit images is transferred to neurons through synapses.The neurons receive the postsynaptic current pulses.The synapses and the excitatory neurons are mimicked by the MTJ devices, as introduced in Section 3 and Section 4. The role of the inhibitory neuron is equivalent to the peripheral reset circuit, which prevents the neuron from being activated repetitively within a short limited period of time, simulating the refractory period of the biological neurons.
Figure 10 shows ten images of handwritten digits, including five images of "1" and five images of "0".The images were used as the input samples for the MTJ-based image recognition.The switching probability of the MTJ device is decreased with increasing t FL , while t pw is kept as 1 ns.(b) The switching probability of the MTJ device is decreased when t pw decreases, where t FL is kept as 1 nm.It should be noted that the 0.2 ns pulse width is very short, so a large current is needed for certain switching.

MTJ Mimics the SNN with Application in Image Recognition
Figure 9 shows the application scenario of the SNN for handwritten digit image recognition.Only the connections for one neuron are shown in the illustration in Figure 9. where tFL is kept as 1 nm.It should be noted that the 0.2 ns pulse width is very short, so a large current is needed for certain switching.

MTJ Mimics the SNN with Application in Image Recognition
Figure 9 shows the application scenario of the SNN for handwritten digit image recognition.Only the connections for one neuron are shown in the illustration in Figure 9.The information of the input handwritten digit images is transferred to neurons through synapses.The neurons receive the postsynaptic current pulses.The synapses and the excitatory neurons are mimicked by the MTJ devices, as introduced in Section 3 and Section 4. The role of the inhibitory neuron is equivalent to the peripheral reset circuit, which prevents the neuron from being activated repetitively within a short limited period of time, simulating the refractory period of the biological neurons.
Figure 10 shows ten images of handwritten digits, including five images of "1" and five images of "0".The images were used as the input samples for the MTJ-based image recognition.The information of the input handwritten digit images is transferred to neurons through synapses.The neurons receive the postsynaptic current pulses.The synapses and the excitatory neurons mimicked by the MTJ devices, as introduced in Sections 3 and 4. The role of the inhibitory neuron is equivalent to the peripheral reset circuit, which prevents the neuron from being activated repetitively within a short limited period of time, simulating the refractory period of the biological neurons.
Figure 10 shows ten images of handwritten digits, including five images of "1" and five images of "0".The images were used as the input samples for the MTJ-based image recognition.It should be noted that the 0.2 ns pulse width is very short, so a large current is needed for certain switching.

MTJ Mimics the SNN with Application in Image Recognition
Figure 9 shows the application scenario of the SNN for handwritten digit image recognition.Only the connections for one neuron are shown in the illustration in Figure 9.The information of the input handwritten digit images is transferred to neurons through synapses.The neurons receive the postsynaptic current pulses.The synapses and the excitatory neurons are mimicked by the MTJ devices, as introduced in Section 3 and Section 4. The role of the inhibitory neuron is equivalent to the peripheral reset circuit, which prevents the neuron from being activated repetitively within a short limited period of time, simulating the refractory period of the biological neurons.
Figure 10 shows ten images of handwritten digits, including five images of "1" and five images of "0".The images were used as the input samples for the MTJ-based image recognition.Figures 11 and 12 show the recognition processes for the handwritten digits "1" and "0" based on the MTJ synapses and the MTJ neuron, respectively.Each set of figures includes the original image, the random initial synapses with the training process for the synapses repeated ten times, the post-synapse current pulse, and the m z of the MTJ neurons.The same MTJ neurons are used in Figures 11 and 12.The switching probability function of the MTJ neuron is adjusted so that it is sensitive to the input of the handwritten digit "0", while it is not activated when the images of the handwritten digit "1" are inputted.The recognition function is achieved.
Figures 11 and 12 show the recognition processes for the handwritten digits "1" and "0" based on the MTJ synapses and the MTJ neuron, respectively.Each set of figures includes the original image, the random initial synapses with the training process for the synapses repeated ten times, the post-synapse current pulse, and the mz of the MTJ neurons.The same MTJ neurons are used in Figures 11 and 12.The switching probability function of the MTJ neuron is adjusted so that it is sensitive to the input of the handwritten digit "0", while it is not activated when the images of the handwritten digit "1" are inputted.The recognition function is achieved.show the recognition processes for the handwritten digits "1" and "0" based on the MTJ synapses and the MTJ neuron, respectively.Each set of figures includes the original image, the random initial synapses with the training process for the synapses repeated ten times, the post-synapse current pulse, and the mz of the MTJ neurons.The same MTJ neurons are used in Figures 11 and 12.The switching probability function of the MTJ neuron is adjusted so that it is sensitive to the input of the handwritten digit "0", while it is not activated when the images of the handwritten digit "1" are inputted.The recognition function is achieved.The recognition process for the handwritten digit "0" based on the MTJ synapses and the MTJ neuron.According (a-e), it can be seen that the input of the handwritten digit "0" activates the MTJ neuron.Each set of figures includes the original image, the random initial synapses, the training process for the synapses repeated ten times, the post-synapse current pulse, and the m z of the MTJ neurons.Different columns correspond to the samples shown in Figure 10.

Conclusions
Neuroscience verifies that the signals in the brain are transmitted in the form of spikes between neurons via synapses.The SNN shows a more biologically realistic perspective and has become the most popular computing model for implementing low-power and high-accuracy recognition.In the paper, a novel SNN was designed based on the STT-MTJ device to differentiate images of handwritten digits in the MINIST database.Based on the micromagnetic simulation of the STT-MTJ device, both the similar characteristics of the MTJ device and biological synapses, as well as the similar characteristics between the MTJ device and biological neurons, were presented.By using the designed MTJ-based synapse and the MTJ-based neuron for image recognition, the average accuracy can reach up to 95%, which is very close to the typical SNN network accuracy.Owing to the characteristics of the MTJ device, the memory power consumption in standby mode is almost zero, which is better than the CMOS device.The proposed MTJ-based neural network shows remarkably promising power and area efficiency.This is a promising candidate for a neural network, with the benefits of easy manipulation, low energy consumption, and high accuracy.

Figure 1 .
Figure 1.(a) The typical sandwich structure of the MTJ device.The left MTJ device is in the antiparallel (AP) state, while the right MTJ device is in the parallel (P) state.(b) With the values of m = (sin 5°, 0, cos 5°) and ISTT = 5 µA, the spin transfer torque is not large enough to switch the device because of the damping effect.At this time, m = (0, 0, 1), the MTJ device is in the P state.(c) With the values of m = (sin 5°, 0, cos 5°) and ISTT = 200 µA, the MTJ device is switched to the AP state at this time and m = (0, 0, −1).

Figure 1 .
Figure 1.(a) The typical sandwich structure of the MTJ device.The left MTJ device is in the antiparallel (AP) state, while the right MTJ device is in the parallel (P) state.(b) With the values of m = (sin 5 • , 0, cos 5 • ) and I STT = 5 µA, the spin transfer torque is not large enough to switch the device because of the damping effect.At this time, m = (0, 0, 1), the MTJ device is in the P state.(c) With the values of m = (sin 5 • , 0, cos 5 • ) and I STT = 200 µA, the MTJ device is switched to the AP state at this time and m = (0, 0, −1).

Micromachines 2023 ,
14,  x FOR PEER REVIEW 5 of 12 and the POST.The gate voltage of the NMOS, VG, is controlled by the membrane potential of the PRE, while the node voltage at the top of the MTJ, VT, is controlled by the membrane potential of the POST.Figure2bshows the schematic of the time sequences of VG and VT under the 1T-1MTJ structure, which are controlled by the PRE and the POST, separately.

Figure 2 .
Figure 2. The designed synapse based on the STT-MTJ device.(a) The 1T-1MTJ device can be used to mimic the synapse.The NMOS transistor is used as the communication between the PRE and the POST.(b) The STDP-based pulsed signal.The time information of the VG pulse is controlled by the membrane potential of the PRE.The VT pulse is controlled by the membrane potential of the POST.The pulse timing information determines the positive and negative of the time window, which in turn determines the current of the MTJ device, resulting in a corresponding change in the conductance of the MTJ device.

Figure 2 .
Figure 2. The designed synapse based on the STT-MTJ device.(a) The 1T-1MTJ device can be used to mimic the synapse.The NMOS transistor is used as the communication between the PRE and the POST.(b) The STDP-based pulsed signal.The time information of the V G pulse is controlled by the membrane potential of the PRE.The V T pulse is controlled by the membrane potential of the POST.The pulse timing information determines the positive and negative of the time window, which in turn determines the current of the MTJ device, resulting in a corresponding change in the conductance of the MTJ device.

Figure 3 .
Figure 3. (a) The image of the handwritten digit "4".(b) The pixels of the handwritten digit are converted to the current pulse sequence, which is named the presynaptic pulse sequence.The pixels close to '0' are converted into a negative current pulse, and pixels close to '1' are converted into a positive current pulse.

Figure 3 .
Figure 3. (a) The image of the handwritten digit "4".(b) The pixels of the handwritten digit are converted to the current pulse sequence, which is named the presynaptic pulse sequence.The pixels close to '0' are converted into a negative current pulse, and pixels close to '1' are converted into a positive current pulse.

Figure 3 .
Figure 3. (a) The image of the handwritten digit "4".(b) The pixels of the handwritten digit are converted to the current pulse sequence, which is named the presynaptic pulse sequence.The pixels close to '0' are converted into a negative current pulse, and pixels close to '1' are converted into a positive current pulse.

Figure 5 .
Figure 5. Schematic diagram of the membrane potential of a biological neuron.

Figure 5 .
Figure 5. Schematic diagram of the membrane potential of a biological neuron.

Figure 5 .
Figure 5. Schematic diagram of the membrane potential of a biological neuron.The similar characteristics of the MTJ device were shown by micromagnetic simulation based on the MTJ model in Section 2. The stochastic magnetic simulation was carried out based on the P-MTJ device with the → m p = (0, 0, −1).The states of the MTJ in the magnetic dynamic model can be characterized by the m z , which is the z-component of → m, with m z = cosθ.The term m z can be used to stand for the membrane potential of the biological neuron in the STT-MTJ-based SNN structure.

Figure 6 .
Figure 6.(a)The integration function of mz in the STT-MTJ device.mz shows the precession tendency due to the application of the input pulses.The precession starts due to the applied pulse and then starts to leak when the pulse is removed.(b) The activation function of mz in the STT-MTJ device.mz precesses due to the application of the input pulses.The precession starts due to the applied pulse and then starts to leak after the pulse is removed.After mz reaches the threshold, it remains in the activated state due to the non-volatility of the MTJ device.

Figure 6 .
Figure 6.(a) The integration function of m z in the STT-MTJ device.m z shows the precession tendency due to the application of the input pulses.The precession starts due to the applied pulse and then starts to leak when the pulse is removed.(b) The activation function of m z in the STT-MTJ device.m z precesses due to the application of the input pulses.The precession starts due to the applied pulse and then starts to leak after the pulse is removed.After m z reaches the threshold, it remains in the activated state due to the non-volatility of the MTJ device.

Figure 7 .
Figure 7. Reset circuit of the MTJ neuron.When the MTJ neuron is activated, the VSPIKE is high during the reading period, initiating a reset.The reverse current flows through the heavy metal layer, resetting the MTJ neuron back to the P state.

Figure 7 .
Figure 7. Reset circuit of the MTJ neuron.When the MTJ neuron is activated, the V SPIKE is high during the reading period, initiating a reset.The reverse current flows through the heavy metal layer, resetting the MTJ neuron back to the P state.

Figure 8 .
Figure 8.The switching probabilities of the MTJ device are varied non-linearly with the input current, I.The probabilistic switching can be directly mapped with the stochastic activation properties of the neuron.(a) The switching probability of the MTJ device is decreased with increasing tFL, while tpw is kept as 1 ns.(b)The switching probability of the MTJ device is decreased when tpw decreases, where tFL is kept as 1 nm.It should be noted that the 0.2 ns pulse width is very short, so a large current is needed for certain switching.

Figure 9 .
Figure 9. Schematic of the SNN for handwritten digit image recognition.The input includes the pixel information of the handwritten digit image.

Figure 10 .
Figure 10.Ten images of the handwritten digits "0" and "1" used for the MTJ-based image recognition.

Figure
FigureThe switching probabilities of the MTJ device are varied non-linearly with the input current, I.The probabilistic switching can be directly mapped with the stochastic activation properties of the neuron.(a) The switching probability of the MTJ device is decreased with increasing t FL , while t pw is kept as 1 ns.(b) The switching probability of the MTJ device is decreased when t pw decreases, where t FL is kept as 1 nm.It should be noted that the 0.2 ns pulse width is very short, so a large current is needed for certain switching.

Figure 8 .
Figure 8.The switching probabilities of the MTJ device are varied non-linearly with the input current, I.The probabilistic switching can be directly mapped with the stochastic activation properties of the neuron.(a) The switching probability of the MTJ device is decreased with increasing tFL, while tpw is kept as 1 ns.(b)The switching probability of the MTJ device is decreased when tpw decreases, where tFL is kept as 1 nm.It should be noted that the 0.2 ns pulse width is very short, so a large current is needed for certain switching.

Figure 9 .
Figure 9. Schematic of the SNN for handwritten digit image recognition.The input includes the pixel information of the handwritten digit image.

Figure 10 .
Figure 10.Ten images of the handwritten digits "0" and "1" used for the MTJ-based image recognition.

Figure 9 .
Figure 9. Schematic of the SNN for handwritten digit image recognition.The input includes the pixel information of the handwritten digit image.

Figure 8 .
Figure 8.The switching probabilities of the MTJ device are varied non-linearly with the input current, I.The probabilistic switching can be directly mapped with the stochastic activation properties of the neuron.(a) The switching probability of the MTJ device is decreased with increasing tFL, while tpw is kept as 1 ns.(b)The switching probability of the MTJ device is decreased when tpw decreases, where tFL is kept as 1 nm.It should be noted that the 0.2 ns pulse width is very short, so a large current is needed for certain switching.

Figure 9 .
Figure 9. Schematic of the SNN for handwritten digit image recognition.The input includes the pixel information of the handwritten digit image.

Figure 10 .
Figure 10.Ten images of the handwritten digits "0" and "1" used for the MTJ-based image recognition.

Figure 10 .
Figure10.images of the handwritten digits "0" and "1" used for the MTJ-based image recognition.

Figure 11 .Figure 11 .
Figure11.The recognition process for the handwritten digit "1" based on the MTJ synapses and the MTJ neuron.According (a-e),it can be seen that the input of the handwritten digit "1" does not activate the MTJ neuron.Each set of figures includes the original image, the random initial synapses, the training process for the synapses repeated ten times, the post-synapse current pulse, and the mz of the MTJ neurons.Different columns correspond to the samples shown in Figure10.

Figures 11 and 12
Figures 11 and 12  show the recognition processes for the handwritten digits "1" and "0" based on the MTJ synapses and the MTJ neuron, respectively.Each set of figures includes the original image, the random initial synapses with the training process for the synapses repeated ten times, the post-synapse current pulse, and the mz of the MTJ neurons.The same MTJ neurons are used in Figures11 and 12.The switching probability function of the MTJ neuron is adjusted so that it is sensitive to the input of the handwritten digit "0", while it is not activated when the images of the handwritten digit "1" are inputted.The recognition function is achieved.

Figure 11 .
Figure11.The recognition process for the handwritten digit "1" based on the MTJ synapses and the MTJ neuron.According (a-e),it can be seen that the input of the handwritten digit "1" does not activate the MTJ neuron.Each set of figures includes the original image, the random initial synapses, the training process for the synapses repeated ten times, the post-synapse current pulse, and the mz of the MTJ neurons.Different columns correspond to the samples shown in Figure10.

Figure 12 .
Figure12.The recognition process for the handwritten digit "0" based on the MTJ synapses and the MTJ neuron.According (a-e), it can be seen that the input of the handwritten digit "0" activates the

Author Contributions:
Material preparation, data collection and analysis, drafting of the manuscript, Y.Y. and M.W. (equal contributions).Supervision, directing, discussing the results, reviewing the article, Y.J.All authors have read and agreed to the published version of the manuscript.Funding: This work was supported by the National Natural Science Foundation of China (NSFC) with grant no.61774078.