Open the Library Manager
In openPDKcreator, click the Library Manager tab.
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.
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.
In openPDKcreator, click the Library Manager tab.
Click openmemristorpdk_pr (real) in the Libraries list.
Click New Cell..., above the Cells list.
A small box asks for the cell name. Type memristor_joglekar exactly like that, then click OK.
A list asks what to create first. Click Verilog-A.
The new cell memristor_joglekar is selected, and its Verilog-A row now has a file. openPDKcreator made an empty model for you:
`include "disciplines.vams" module memristor_joglekar(); analog begin // TODO: real compact-model equations here end endmodule
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.
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
cat > file <<'EOF' writes everything up to the line EOF into the model file, replacing the empty one.Back in openPDKcreator, on the Verilog-A row, click View.
Here is the model you just wrote. Have a look, then click Close.
// 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
uv), the starting memory x0, and the window shape p.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.
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.
In the Cells list, click memristor_tio2_au_tb.
Click Open in xschem on the Schematic row.
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.
.control or .model.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).
Press Shift + End: the rest of the line turns grey (selected). Now type memristor_joglekar. The line becomes .model mm memristor_joglekar.
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.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.
Check both lines, then click OK.
In xschem's top bar, click Netlist and wait until it turns green.
Click Simulate and wait about 10 seconds.
The plot shows the new model. Still a pinched loop, so still a memristor, but a different one.
uv), it would slow down near 1 instead of stopping dead.
Close the windows and leave the testbench as it was. The new model stays in the PDK.
Click Quit in the plot window.
Click inside the white ngspice window, type quit and press Enter.
Click the X at the top-right of the xschem window.
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.
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.memristor_joglekar.va from user_models/veriloga/ first.