3. LTSPICE Library Model [35] and analysis of the applied Memristor model
The main idea, utilized for construction of the LTSPICE [
33] memristor library model, is to build a simple and fast-operating equivalent circuit, corresponding to (6). Before realization of the current-voltage characteristics, the derivation of the state variable
x is needed. The memristor state variable is obtained by integration of the state differential equation with respect to time. This process is ensured by a capacitor; its current is set to be proportional to the time derivative of the state variable
x [
26,
31]. The current of the capacitor is generated by a voltage-controlled current source, according to the left-hand side of the state equation in (6). The initial voltage of the integrating capacitor is set to be equal to the starting value of the memristor state variable. The voltage across the integrating capacitor is directly proportional to the state variable in each moment in the time domain. To avoid rapid changes of the voltage across the capacitor, which could lead to convergence issues, a high-valued resistor could be attached in parallel to the capacitor [
31,
36]. Additional voltage-controlled current source is generating the memristor current, according to the right-hand side of the first equation in (6). The initial row of the LTSPICE code displays the memristor model identifier, indicated as
A14mod. The memristor terminals are denoted as top electrode (
te) and bottom electrode (
be). The optional terminal
Y is utilized for measuring the memristor state variable. The parameters of the model -
RON,
ROFF,
k,
m,
mm,
m0 and
vthr are presented in the next row. The coefficient m0 represents the initial value of the memristance. The integrating capacitor is connected between the terminal
Y and the ground electrode. Its capacitance is 1000 mF. The initial voltage of integrating element
C1, denoted as “.IC”, is expressed by the first equation of (6) [
35]. It is inversely proportional to the starting value of the memristance. The fifth row represents the additional resistor
Rad with a value of 100 GΩ, connected in parallel to
C1 and utilized for a partial avoidance of convergence problems. The dependent source
G2 presented in the sixth row expresses the time derivative of the state variable
x.
The controlled source G
1 expresses the current of the memristor element. In row 8, a differentiable and flat step-like function is presented. It is utilized for realization of the state equation, containing the memristor activation threshold
vthr. The code, presented below is finished with the command “ends” [
26,
33,
35].
- 1
.subckt A14mod te be Y
- 2
.params ron=100 roff=25e3 m0=300 k=10e4 m=5 vthr=0.2 mm=1e-24
- 3
C1 Y 0 {1}
- 4
.IC V(Y)={(m0-roff)/(ron-roff)}
- 5
R1 Y 0 100G
- 6
-
G2 0 Y value={((k*pow(V(te,be),m))*((pow(sin(pi*V(Y)),2)))*
(stpp((vthr-abs(V(te,be))),mm)))}
- 7
G1 te be value={V(te,be)*((1/(ron*(V(Y))+roff*(1-V(Y)))))}
- 8
.func stpp(x,p)={0.5*(1+(x/sqrt(pow(x,2)+p)))}
- 9
.ends A14mod
The parameter
mm determines the sharpness of the step-like function
stpp. For a quick and easier tuning of the initial value of the memristance
m0, the state variable of the memristor in the initial moment is expressed as a function of
m0 in the fourth row. After selecting the memristor model
A14mod in LTSPICE and placing on the plotting field, right-click on the memristor, in the SPICE row of the appeared window, write
m0=300, then place a tick in the right by double left mouse button click, to make
m0 visible and confirm by clicking OK. The considered LTSPICE code is included in a unified memristor model library, freely available for use and download at
https://github.com/mladenovvaleri/Advanced-Memristor-Modeling-in-LTSpise [
31]. This library contains many LTSPICE models of memristors and memristor-based electronic circuits, available for use and comparisons. The considered modified memristor model is analyzed with pulse and sine signals at a constant amplitude of 1.1 V and for different frequencies. In
Figure 3a, the testing circuit for memristor analysis is presented for its visual observation. In the present case, the additional electrode Y is not included for simplification of the electronic circuitry. The initial value of the memristance is set to be 5 kOhms. After obtaining the
i-v relationships of the memristor model for sinusoidal signals with amplitude of 1.1 V and different frequencies (100 kHz, 1 MHz and 10 MHz) in LTSPICE environment, they are presented in
Figure 3b–d for their visual comparison and for confirmation of the correct operation of the modified memristor model. It is visible that, when the signal’s frequency increases, then the surface of the
i-v loop decreases in accordance with the basic memristors’ properties and fingerprints [
24,
30].
Memristors, participating as synaptic weights, are tuned during the neural network training by positive or negative voltage pulses with a level, which absolute value is higher than the activation threshold
vthr [
35]. An example of synaptic weight adjustment is presented in
Figure 4. A simple electronic circuit, containing a pulse voltage source and a memristor, represented by the modified model
A14mod, is shown in
Figure 4a for a visual expression of its structure and operation. The voltage source generates a sequence of rectangular and positive pulses with a duration of 1 ns and a duty cycle of 50 %. The amplitude of the voltage is 1.1 V.
Figure 4b represents the time diagrams of the pulse voltage signal and the corresponding change of the memristance
M in LTSPICE. In this case the initial value of the memristance is
M1 = 10 kOhm, which corresponds to a synaptic weight of
w1 = 1. The final value of
M2 = 9 kOhm corresponds to a synaptic weight of
w2=1.1111. In this case, the change of memristance with
∆M = 1 kOhm corresponds to alteration of the synaptic weight with
∆w = 0.1111. The needed time interval for this memristance change, together with the pauses between the impulses, is about 28 ns. The effective duration of the voltage pulses for this time interval is about 14 ns.
Figure 4c represents the results, derived by a simulation in MATLAB, which have a very good coincidence to
Figure 4b and confirms the tuning process.
This result will be also mathematically confirmed by integration of the state differential equation of system (6), modified and represented here by (8):
In eq. (8), because the used voltage pulses are higher than the activation threshold
vthr, in the right hand side, the step function “
stp” is missed. Equation (8) is transformed to (9), where the state variable
x and the time variable
t are separated one to another:
According to the current-voltage relationship in system (6), the state variable
x is expressed as a function of the memristance
M by the next eq. (10):
Equation (9) is integrated between
x1 = 0.8251, corresponding to
M1 = 10 kOhm, and
x2 = 0.8427, related to
M2 = 9 kOhm, using (10), and the following eq. (11) is obtained:
Then, the effective duration of the applied pulses (a single pulse or a sequence of short impulses) is obtained as follows – formula (12):
The obtained time for synaptic weight adjustment corresponds to the derived simulation result and confirms the proper tuning the memristance by pulses. Another simulation is conducted with negative voltage pulses and the same circuit shown in
Figure 4a is used. The respective time diagram of the applied negative pulses and the corresponding memristance alteration in LTSPICE is presented in
Figure 5a.
Figure 5b represents the results, derived from analysis in MATLAB, which is in a good agreement with
Figure 5b and confirms the correctness of the adjustment process. The analysis starts with initial value of the memristance, equal to
M1 = 5 kOhms, related to a synaptic weight of
w1 = 2 and a state variable of
x1 = 0.9129. The final value of the memristance
M2 is 6 kOhms, corresponding to a synaptic weight with a value of
w2 = 1.6667 and a state variable
x2 = 0.8954. The change of the memristance with 1 kOhm in this case corresponds to alteration of synaptic weight with
∆w = 1.6667-2= - 0.3333. The effective duration of the pulse is about 79ns/2 = 39.5 ns.
The analytical confirmation of this result is as follows – formula (13):
For the future practical implementation of memristor-based synapses, the tuning process will be related to a measurement of the achieved memristance, until reaching the needed resistance and stopping the pulse sequence. According to the requirement for a quick change of the memristance and the corresponding synaptic weight, the applied modified memristor model
A14mod ensures a rapid alteration of the state variable and the memristance at applied voltage pulses. Its simple structure and low simulation time ensures the generation and analysis of complex neural networks with a high number of memristors in LTSPICE environment. Additional comparison of the applied memristor models, according to simulation time is conducted for two cases – decreasing and increasing of memristance, according to the analyses shown in
Figure 4 and
Figure 5. The results presented in
Table 2 express the faster operation of the applied modified model, according to Lehtonen-Laiho model. The simulations were conducted on a computer with 8 GB RAM, i5 Intel processor, and Microsoft Windows 10 Pro operating system. According to Joglekar and Biolek models, the modified model
A14mod has comparable simulation time and better switching properties.