openMemristorPDK Guide
Guide · Section 5 · about 15 min · 24 steps

Add a model

Give the PDK a brand-new memristor model, the HP memristor with a Joglekar window, then swap it into the testbench and compare its loop with the first one. You only ever need to click whatever is inside the red box, or type exactly what is in a black box.

Start with openPDKcreator open, as after steps 1–4 of Your first simulation. You'll also use the laptop's terminal once.

click here Click any screenshot to see it full size Keys in the player: ← → Space Esc
Part 1 · about 3 minutes

Make a place for the model

A model is the recipe that tells the simulator how a device behaves. In openPDKcreator every model belongs to a cell in the Library Manager. You'll create a new cell and give it an empty Verilog-A model.

1

Open the Library Manager

In openPDKcreator, click the Library Manager tab.

2

Pick the library

Click openmemristorpdk_pr (real) in the Libraries list.

3

Make a new cell

Click New Cell..., above the Cells list.

4

Name it

A small box asks for the cell name. Type memristor_joglekar exactly like that, then click OK.

Why that name?The model is the classic HP memristor with a Joglekar window, named after the scientist who proposed it. The name has to be exactly the same as the module inside the file you write in step 7.
5

Choose Verilog-A

A list asks what to create first. Click Verilog-A.

6

The empty model is ready

The new cell memristor_joglekar is selected, and its Verilog-A row now has a file. openPDKcreator made an empty model for you:

openMemristorPDK/user_models/veriloga/memristor_joglekar.vawhat Create wrote
`include "disciplines.vams"

module memristor_joglekar();

analog begin
  // TODO: real compact-model equations here
end
endmodule
Part 2 · about 3 minutes

Write the model

Now the empty model gets its real equations. The easiest way is one command in the laptop's terminal: the project folder is shared with the container, so openPDKcreator sees the new file straight away.

7

Write the model file

Go to the laptop's terminal, the one from step 1 of Your first simulation, not the browser. Click Copy below, paste into the terminal with Ctrl + Shift + V, and press Enter. Nothing is printed: that means it worked.

cat > ~/Documentos/rodrigo/openPDKcreator/openMemristorPDK/user_models/veriloga/memristor_joglekar.va <<'EOF'
// memristor_joglekar.va -- the HP memristor with a Joglekar window:
// the memory x still moves with the current, but slows down near its
// two ends (x = 0 and x = 1) instead of crashing into them.
`include "disciplines.vams"

module memristor_joglekar(BE, TE);
inout BE, TE;
electrical BE, TE;
electrical dx;   // hidden node: how far x has moved from x0

parameter real Ron  = 100   from (0:inf);  // fully "on" resistance (ohm)
parameter real Roff = 16e3  from (0:inf);  // fully "off" resistance (ohm)
parameter real D    = 10n   from (0:inf);  // oxide thickness (m)
parameter real uv   = 5e-15 from (0:inf);  // how easily the memory moves
parameter real x0   = 0.3   from [0:1];    // memory at the start
parameter real p    = 2     from [1:inf);  // window shape

real x, Rmem, i, f;

analog begin
  x = min(max(x0 + V(dx), 0.0), 1.0);                   // the memory, 0..1
  Rmem = Ron * x + Roff * (1.0 - x);                    // today's resistance
  i = V(BE, TE) / Rmem;                                 // Ohm's law
  I(BE, TE) <+ i;
  f = 1.0 - pow((2.0 * x - 1.0) * (2.0 * x - 1.0), p);  // the window
  I(dx) <+ ddt(V(dx)) - (uv * Ron / (D * D)) * i * f;   // x moves with i*f
  I(dx) <+ 1e-12 * V(dx);                               // keeps dx defined at rest
end
endmodule
EOF
What it doescat > file <<'EOF' writes everything up to the line EOF into the model file, replacing the empty one.
8

Open the model

Back in openPDKcreator, on the Verilog-A row, click View.

9

Read it, then close it

Here is the model you just wrote. Have a look, then click Close.

openMemristorPDK/user_models/veriloga/memristor_joglekar.vathe whole file
// memristor_joglekar.va -- the HP memristor with a Joglekar window:
// the memory x still moves with the current, but slows down near its
// two ends (x = 0 and x = 1) instead of crashing into them.
`include "disciplines.vams"

module memristor_joglekar(BE, TE);
inout BE, TE;
electrical BE, TE;
electrical dx;   // hidden node: how far x has moved from x0

parameter real Ron  = 100   from (0:inf);  // fully "on" resistance (ohm)
parameter real Roff = 16e3  from (0:inf);  // fully "off" resistance (ohm)
parameter real D    = 10n   from (0:inf);  // oxide thickness (m)
parameter real uv   = 5e-15 from (0:inf);  // how easily the memory moves
parameter real x0   = 0.3   from [0:1];    // memory at the start
parameter real p    = 2     from [1:inf);  // window shape

real x, Rmem, i, f;

analog begin
  x = min(max(x0 + V(dx), 0.0), 1.0);                   // the memory, 0..1
  Rmem = Ron * x + Roff * (1.0 - x);                    // today's resistance
  i = V(BE, TE) / Rmem;                                 // Ohm's law
  I(BE, TE) <+ i;
  f = 1.0 - pow((2.0 * x - 1.0) * (2.0 * x - 1.0), p);  // the window
  I(dx) <+ ddt(V(dx)) - (uv * Ron / (D * D)) * i * f;   // x moves with i*f
  I(dx) <+ 1e-12 * V(dx);                               // keeps dx defined at rest
end
endmodule
BE, TE
The two wires, bottom and top electrode, the same as the memristor in Your first simulation.
electrical dx
A hidden extra wire inside the model. Its voltage stores how far the memory has moved since the start.
parameter ...
The numbers you can change from outside: resistances, thickness, how easily the memory moves (uv), the starting memory x0, and the window shape p.
x = ...
The memory: the start value plus how far it has moved, kept between 0 and 1.
Rmem, i
Today's resistance and Ohm's law, just like the first model.
f = 1 - ...
The window. It is 1 in the middle (the memory moves freely) and drops to 0 at the two ends (it slows down instead of crashing into them).
I(dx) <+ ddt(...)
Makes the memory move: the more current, the faster, multiplied by the window. The 1e-12 line only keeps the hidden wire well defined when nothing is happening.
10

It compiles

Because the file changed, closing it compiles it: openPDKcreator turns it into memristor_joglekar.osdi, the form the simulator loads. A box says Compilation performed correctly. Click OK.

If it says "Compilation errors"The file has a typo, usually from an incomplete copy. Do step 7 again, making sure you copied the whole command, then steps 8 and 9.
Part 3 · about 4 minutes

Try it in the testbench

The memristor's symbol only has two pins, so any memristor model fits it. You'll take the testbench from Your first simulation and swap its model for the new one, without changing anything else.

11

Pick the testbench

In the Cells list, click memristor_tio2_au_tb.

12

Open it in xschem

Click Open in xschem on the Schematic row.

13

Open the code block

Wait until xschem shows the drawing (up to half a minute). Then double-click on the code text at the bottom, inside the red box.

If a box called "Text input" opens insteadThe double-click missed the text. Click Cancel and double-click right on the words .control or .model.
14

Click before the model name

A box called Edit Properties opens with the code. In the line .model mm memristor_tio2_au ..., click once just before the m of memristor_tio2_au (inside the red box).

15

Replace the rest of the line

Press Shift + End: the rest of the line turns grey (selected). Now type memristor_joglekar. The line becomes .model mm memristor_joglekar.

Why delete the numbers too?The old numbers (ron=100, uv=1e-14...) were chosen for the old model. Without them, the new model uses its own values from the parameter lines in step 9.
16

Change the file name

In the pre_osdi line, double-click the word memristor_tio2_au near the end (in the red box) and type memristor_joglekar. The line now ends in memristor_joglekar.osdi: the file compiled in step 10.

17

Click OK

Check both lines, then click OK.

18

Click Netlist

In xschem's top bar, click Netlist and wait until it turns green.

19

Click Simulate

Click Simulate and wait about 10 seconds.

20

The new model's loop

The plot shows the new model. Still a pinched loop, so still a memristor, but a different one.

What changed The loop now reaches about ±113 µA, wider than the ±79 µA in Your first simulation. This model's memory starts at 0.3 and swings up to about 0.6, so its resistance drops further. The window keeps that swing smooth: if you made the memory move much faster (a bigger uv), it would slow down near 1 instead of stopping dead.
Part 4 · 1 minute

Tidy up

Close the windows and leave the testbench as it was. The new model stays in the PDK.

21

Close the plot

Click Quit in the plot window.

22

Close the simulator

Click inside the white ngspice window, type quit and press Enter.

23

Close xschem

Click the X at the top-right of the xschem window.

24

Exit without saving

xschem asks UNSAVED data: want to exit? Click OK. That throws away the swap you made in steps 14–17, so the testbench stays exactly as Your first simulation uses it.

What you added to the PDKThe cell memristor_joglekar with its model user_models/veriloga/memristor_joglekar.va. Its compiled .osdi is rebuilt automatically whenever openPDKcreator starts or you change the file.
Want to do this section again?Step 4 will refuse a name that already exists. Use another name (and the same name in step 7's command and the testbench), or delete memristor_joglekar.va from user_models/veriloga/ first.