Memristor simulation with LTspice – a practical example!

Update: The examples can be found on my GitHub repo (MartyMacGyver/memristor-modeling)

Lately I’ve been getting back into the EE groove with some random electronics projects (such as an Arduino-based LED strip driver). I’ve also been dabbling with different circuit simulators like Micro-Cap (which I used back in college but which is VERY expensive for the regular version… still, it’s handy for quick little sims to learn new things, especially in the digital realm).

Memristors in the mix

Today I stumbled on LTspice from Linear Technology, which I found to be surprisingly intuitive (and given that it’s based on the venerable and powerful SPICE it’s that much more worth learning). It’s not as animation-friendly as Micro-Cap but it’s pretty easy to make custom components (and where else can you simulate the actual inner workings of a 555 timer or a 741 op-amp?) (And yes, the 741 is not something you’d reach for normally nowadays, but they are instructive nonetheless.)

Memristors have intrigued me since they made the news a few years back, when discoveries were made of practical memristive materials. You can read more about them on Wikipedia and so on, and though very subject is not without controversy I personally think they will prove to be a valuable technology going forward. I found them intriguing from both the EE and the MSE perspectives.

Side-note: if you find yourself wondering more about why a device does what it does (in my case, the humble MOSFET) than regurgitating Kirchoff’s Law and applying Thévenin’s theorem, you’re probably better off in Materials Science Engineering than Electrical Engineering. At least that’s what happened to me… that and a very grumpy EE prof who made it clear we’d all be obsolete, unemployed and grumpy like him soon anyway. And you can always fall back on CS when the semiconductor market tanks…

Given all that, today I decided to see if I could simulate a circuit with a memristor in it. Problem is, while some sims have memristors, LTspice does not, and apparently nobody out there has published a simple example that actually works (I found videos – who writes a text tutorial in a video? – and a broken webpage, but I never found a working sim). So, I made one… and after a few false starts I got it to work. Not bad for an evening at home!

To try my demo LTspice-based memristor simulation out, please visit my GitHub repo (MartyMacGyver/memristor-modeling) and follow the instructions there for how to install and use it.

And to reiterate, this is a demo based on the SPICE model of a memristor as described in one paper… this is for educational purposes only and no, I can’t help you with your homework. 😀

Update 2015-03-30: My goal was to create a simulation in LTspice using a memristor component… I did NOT write the SPICE model for the memristor component itself (it’s straight out of the paper by Biolek, Biolek, and Biolkova as noted in the Readme file). Due to the limitations of that model, this simulation only works in transient analysis mode. The parameters are “.tran 0 3s 0 3m uic” (uic used to be called skipbp).

To test all this, install the latest LTspice, install the files per the Readme, load up memristor_sim.asc, and run the simulation. I just tried it myself with version 4.22x and it still works.

Update 2016-02-08: I’ve moved the files for this to GitHub.


  1. Its great that u have developed a successful working ltspice version of the memristor. But I found the problem that when the memristor is energized with the pulse wave its resistance should be a triangular wave atleast(actually a curvy triangular one) but the same is not available from your code. If u are free just see that once..


    1. What you see is what I have – hopefully others will expand upon and refine this work over time.


  2. i need to know how can we get an access to memristor in LTspice IV
    actually i’m working on a project related to memristors.. i need to urgently know how to get it on LTspice


Leave a Reply

Your email address will not be published. Required fields are marked *