# Simulation of memristor device in qspice

## I have tried to simulate a memristor model which already working well on LTspice. but gives a syntax error in qspice. can anyone help debug?

• Knowm Mean Metastable Switch Memristor SPICE Model

• Copyright Tim Molter Knowm Inc. 2017

• Connections:

• TE: Top electrode

• BE: Bottom electrode

• XSV: External connection to plot state variable

•  that is not used otherwise

.SUBCKT MEM_KNOWM TE BE XSV

• Ron: Minimum device resistance
• Roff: Maximum device resistance
• Von: Threshold voltage to turn device on
• Voff: Threshold voltage to turn device off
• TAU: Time constant
• T: Temperature

.params Ron=500 Roff=1500 Voff=0.27 Von=0.27 TAU=0.0001 T=298.5 x0=0

• Function G(V(t)) - Describes the device threshold
.func G(V) = V/Ron+(1-V)/Roff

• Function F(V(t),x(t)) - Describes the SV motion
.func F(V1,V2) = (1/TAU)((1/(1+exp(-1/(Tboltz/echarge)(V1-Von))))(1-V2)-(1-(1/(1+exp(-1/(Tboltz/echarge)(V1+Voff)))))*V2

• Memristor I-V Relationship
.func IVRel(V1,V2) = V1*G(V2)

• Circuit to determine state variable

• dx/dt = F(V(t),x(t))*G(V(t))
Cx XSV 0 {1}
.ic V(XSV) = x0
Gx 0 XSV value={F(V(TE,BE),V(XSV,0))}

• Current source for memristor IV response
Gmem TE BE value={IVRel(V(TE,BE),V(XSV,0))}

.ENDS MEM_KNOWM