Pick the device
In the Library Manager, with openmemristorpdk_pr selected (steps 1–2 of Add a model), click memristor_hfo2_al in the Cells list.
Delete the Au/HfO₂/Al memristor completely, then rebuild every piece of it: its model, its symbol, its layout and a testbench, and watch it switch on and off. You only ever need to click whatever is inside the red box, or type exactly what is in a black box.
Do Add a model first: this section uses the same moves (New Cell, a terminal command, View and Close). Start with openPDKcreator open in the Library Manager.
A device is everything the PDK knows about one component: its model (how it behaves), its symbol (how it looks in a circuit drawing), its layout (how it is built on the chip) and a testbench to try it. You'll delete the Au/HfO₂/Al memristor completely, then build it back piece by piece.
In the Library Manager, with openmemristorpdk_pr selected (steps 1–2 of Add a model), click memristor_hfo2_al in the Cells list.
Click Delete Cell..., above the Cells list.
openPDKcreator lists every file it will delete: model, symbol, layout, chip file, netlists. Click Yes.
The bar at the bottom says Deleted cell 'memristor_hfo2_al', and the cell has disappeared from the list.
Same as in Add a model: a new cell with the same name, an empty Verilog-A model, then the real equations from one terminal command.
Click New Cell....
Type memristor_hfo2_al and click OK.
Click Verilog-A.
In the laptop's terminal, paste this command (Ctrl + Shift + V) and press Enter:
cat > ~/Documentos/rodrigo/openPDKcreator/openMemristorPDK/user_models/veriloga/memristor_hfo2_al.va <<'EOF'
// A real, minimal *bipolar threshold-switching* memristor compact
// model -- deliberately a genuinely different real model from
// memristor_tio2_au.va/memristor_tio2_ti.va's linear ion-drift form,
// not just a renamed copy with different parameters (per direct
// request: "two different verilog models... [for] material1... [and]
// material2"). HfO2-based RRAM is real, widely reported to switch by
// *filamentary* conduction (a real, localized conductive filament of
// oxygen vacancies forming/rupturing through the oxide), not the
// linear-drift *boundary-motion* picture the classical HP TiO2 model
// uses -- a real, qualitatively different physical picture, so a
// qualitatively different real model structure: a state variable that
// only moves once the real terminal voltage crosses a real threshold
// (SET/RESET), and an exponential (tunneling-like) state-to-resistance
// mapping instead of a linear one. This is a real, simplified,
// illustrative form of the general real threshold-switching structure
// widely used for filamentary RRAM compact models -- see e.g.
// Kvatinsky et al., "TEAM: ThrEshold Adaptive Memristor Model", IEEE
// TCAS-I 60(1), 211-221 (2013), and Yakopcic et al., "A Memristor
// Device Model", IEEE EDL 32(10), 1436-1438 (2011), for the real,
// general lineage this borrows its threshold-switching + exponential-
// conduction structure from -- not a literal reimplementation of
// either (both are considerably more elaborate; this stays a bare-
// minimum, from-scratch teaching model, same real scope as its TiO2
// sibling). Al top electrode: a real, common RRAM top-electrode metal
// choice (its own native oxide is itself sometimes exploited as part
// of a real bilayer RRAM stack elsewhere in the literature; here it's
// simply the third, distinct real top-electrode metal this PDK's own
// task called for, bottom electrode still always Au).
//
// State: x lives on a hidden node, dx = x - x0, integrated with
// ddt() so that (1) the starting value x0 really is the starting
// value (dx starts at 0), and (2) x stops at 0 and 1 instead of
// piling up past them. (An earlier version clamped idt()'s output
// from outside: the integral kept growing past 1, so switching back
// was delayed, and x0 was ignored.)
`include "disciplines.vams"
module memristor_hfo2_al(BE, TE);
inout BE, TE;
electrical BE, TE;
electrical dx; // hidden node: how far x has moved from x0
parameter real Ron = 500 from (0:inf);
parameter real Roff = 50e3 from (0:inf);
parameter real Von = 0.8;
parameter real Voff = -0.6 from (-inf:0);
parameter real tau = 5n from (0:inf);
parameter real x0 = 0.1 from [0:1];
real x, Rmem, dxdt;
analog begin
x = min(max(x0 + V(dx), 0.0), 1.0); // the memory, kept between 0 and 1
dxdt = 0.0; // below the thresholds: no change
if (V(BE, TE) > Von)
dxdt = (V(BE, TE) - Von) / tau; // SET: x grows
else if (V(BE, TE) < Voff)
dxdt = (V(BE, TE) - Voff) / tau; // RESET: x shrinks
if ((x >= 1.0 && dxdt > 0.0) || (x <= 0.0 && dxdt < 0.0))
dxdt = 0.0; // at an end: stop there
I(dx) <+ ddt(V(dx)) - dxdt; // x moves at dxdt
I(dx) <+ 1e-12 * V(dx); // keeps dx defined at rest
Rmem = Roff * exp(-x * ln(Roff / Ron));
I(BE, TE) <+ V(BE, TE) / Rmem;
end
endmodule
EOFuser_models/veriloga/memristor_hfo2_al.va, replacing the empty one. Nothing is printed: that means it worked.Back in openPDKcreator, click View on the Verilog-A row.
This model works differently from the TiO₂ one: its memory only moves when the voltage crosses a threshold. Click Close when you have read it.
// A real, minimal *bipolar threshold-switching* memristor compact
// model -- deliberately a genuinely different real model from
// memristor_tio2_au.va/memristor_tio2_ti.va's linear ion-drift form,
// not just a renamed copy with different parameters (per direct
// request: "two different verilog models... [for] material1... [and]
// material2"). HfO2-based RRAM is real, widely reported to switch by
// *filamentary* conduction (a real, localized conductive filament of
// oxygen vacancies forming/rupturing through the oxide), not the
// linear-drift *boundary-motion* picture the classical HP TiO2 model
// uses -- a real, qualitatively different physical picture, so a
// qualitatively different real model structure: a state variable that
// only moves once the real terminal voltage crosses a real threshold
// (SET/RESET), and an exponential (tunneling-like) state-to-resistance
// mapping instead of a linear one. This is a real, simplified,
// illustrative form of the general real threshold-switching structure
// widely used for filamentary RRAM compact models -- see e.g.
// Kvatinsky et al., "TEAM: ThrEshold Adaptive Memristor Model", IEEE
// TCAS-I 60(1), 211-221 (2013), and Yakopcic et al., "A Memristor
// Device Model", IEEE EDL 32(10), 1436-1438 (2011), for the real,
// general lineage this borrows its threshold-switching + exponential-
// conduction structure from -- not a literal reimplementation of
// either (both are considerably more elaborate; this stays a bare-
// minimum, from-scratch teaching model, same real scope as its TiO2
// sibling). Al top electrode: a real, common RRAM top-electrode metal
// choice (its own native oxide is itself sometimes exploited as part
// of a real bilayer RRAM stack elsewhere in the literature; here it's
// simply the third, distinct real top-electrode metal this PDK's own
// task called for, bottom electrode still always Au).
//
// State: x lives on a hidden node, dx = x - x0, integrated with
// ddt() so that (1) the starting value x0 really is the starting
// value (dx starts at 0), and (2) x stops at 0 and 1 instead of
// piling up past them. (An earlier version clamped idt()'s output
// from outside: the integral kept growing past 1, so switching back
// was delayed, and x0 was ignored.)
`include "disciplines.vams"
module memristor_hfo2_al(BE, TE);
inout BE, TE;
electrical BE, TE;
electrical dx; // hidden node: how far x has moved from x0
parameter real Ron = 500 from (0:inf);
parameter real Roff = 50e3 from (0:inf);
parameter real Von = 0.8;
parameter real Voff = -0.6 from (-inf:0);
parameter real tau = 5n from (0:inf);
parameter real x0 = 0.1 from [0:1];
real x, Rmem, dxdt;
analog begin
x = min(max(x0 + V(dx), 0.0), 1.0); // the memory, kept between 0 and 1
dxdt = 0.0; // below the thresholds: no change
if (V(BE, TE) > Von)
dxdt = (V(BE, TE) - Von) / tau; // SET: x grows
else if (V(BE, TE) < Voff)
dxdt = (V(BE, TE) - Voff) / tau; // RESET: x shrinks
if ((x >= 1.0 && dxdt > 0.0) || (x <= 0.0 && dxdt < 0.0))
dxdt = 0.0; // at an end: stop there
I(dx) <+ ddt(V(dx)) - dxdt; // x moves at dxdt
I(dx) <+ 1e-12 * V(dx); // keeps dx defined at rest
Rmem = Roff * exp(-x * ln(Roff / Ron));
I(BE, TE) <+ V(BE, TE) / Rmem;
end
endmodule
x0 plus how far it has moved, kept between 0 and 1.A box says Compilation performed correctly. Click OK.
The symbol is what you place in a circuit drawing in xschem: a box with two pins, BE and TE.
On the Symbol row, click Create. openPDKcreator makes an empty symbol file.
In the laptop's terminal, paste and press Enter:
cat > ~/Documentos/rodrigo/openPDKcreator/openMemristorPDK/libraries/openmemristorpdk_pr/memristor_hfo2_al.sym <<'EOF'
v {xschem version=3.4.6 file_version=1.2}
G {}
K {type=n
format="@name @pinlist @model"
template="name=n1 model=mm"}
V {}
S {}
E {}
B 5 -42 -2 -38 2 {name=BE dir=inout}
B 5 38 -2 42 2 {name=TE dir=inout}
L 4 -40 0 -20 0 {}
L 4 20 0 40 0 {}
L 4 -20 -10 20 -10 {}
L 4 20 -10 20 10 {}
L 4 20 10 -20 10 {}
L 4 -20 10 -20 -10 {}
EOFlibraries/openmemristorpdk_pr/memristor_hfo2_al.sym, replacing the empty one. Nothing is printed: that means it worked.n1 BE TE mm. The n tells ngspice it's a compiled model.On the Symbol row, click Open in xschem and wait for the window.
Here it is: a box with a lead and a red pin square on each side. Nothing to change.
Click the X at the top-right of the xschem window.
The layout is the device as the factory builds it, seen from above: three 1 µm squares stacked on top of each other, gold, then HfO₂, then aluminium.
On the Magic Layout row, click Create.
In the laptop's terminal, paste and press Enter:
cat > ~/Documentos/rodrigo/openPDKcreator/openMemristorPDK/libraries/openmemristorpdk_pr/memristor_hfo2_al.mag <<'EOF' magic tech openmemristorpdk magscale 1 2 timestamp 1787310491 << checkpaint >> rect 0 0 1 1 << be_au >> rect 0 0 1 1 << te_al >> rect 0 0 1 1 << mem_hfo2 >> rect 0 0 1 1 << labels >> rlabel be_au 0 0 1 1 0 BE port 0 nsew rlabel te_al 0 0 1 1 0 TE port 1 nsew << end >> EOF
libraries/openmemristorpdk_pr/memristor_hfo2_al.mag, replacing the empty one. Nothing is printed: that means it worked.rect 0 0 1 1.On the Magic Layout row, click Run DRC. DRC (Design Rule Check) makes the chip file (GDS) and checks the factory's rules, like minimum sizes. It takes about 10 seconds.
The window title says CLEAN: no rule broken. Click Close.
A new GDS/Layout row appeared with the chip file. Click Open in KLayout.
In the Layers list (red box), the three layers this device uses are bold: BE_Au, MEM_HfO2 and TE_Al.
VIA1 (solid red) is the via layer: a hole that joins a bottom-electrode wire straight to a top-electrode wire somewhere else on the chip. It only exists where someone draws one. A memristor has none: its current has to go through the oxide.Click the X at the top-right of the KLayout window.
Last piece: a testbench that drives the rebuilt device with a sine wave and plots its current.
On the Schematic row, click Create.
In the laptop's terminal, paste and press Enter:
cat > ~/Documentos/rodrigo/openPDKcreator/openMemristorPDK/libraries/openmemristorpdk_pr/memristor_hfo2_al.sch <<'EOF'
v {xschem version=3.4.8RC file_version=1.3}
G {}
K {}
V {}
S {}
F {}
E {}
T {HfO2 memristor testbench} -60 -300 0 0 0.6 0.6 {}
T {Press "Netlist", then "Simulate" (top-right of the menu bar).} -60 -240 0 0 0.3 0.3 {}
T {V1 swings between +1.2 V and -1.2 V, 25 times per second.} -60 -210 0 0 0.3 0.3 {}
N 40 -100 400 -100 {lab=te}
N 400 -40 400 -20 {lab=0}
C {/foss/designs/openMemristorPDK/libraries/openmemristorpdk_pr/memristor_hfo2_al.sym} 0 -100 0 1 {name=n1 model=mm}
C {gnd.sym} -40 -100 0 0 {name=l1 lab=0}
C {lab_wire.sym} 220 -100 0 0 {name=p1 sig_type=std_logic lab=te}
C {vsource.sym} 400 -70 0 0 {name=V1 value="dc 0 sin(0 1.2 25)" savecurrent=false}
C {gnd.sym} 400 -20 0 0 {name=l2 lab=0}
C {code_shown.sym} -60 40 0 0 {name=s1 only_toplevel=false value="
.model mm memristor_hfo2_al ron=500 roff=50k von=0.8 voff=-0.6 tau=1m x0=0.1
.control
pre_osdi /foss/designs/openMemristorPDK/user_models/veriloga/memristor_hfo2_al.osdi
tran 20u 0.08
plot -i(V1) vs v(te) retraceplot title 'HfO2 memristor I-V loop' xlabel 'Voltage (V)' ylabel 'Current (A)'
.endc
"}
EOFlibraries/openmemristorpdk_pr/memristor_hfo2_al.sch, replacing the empty one. Nothing is printed: that means it worked.n1.On the Schematic row, click Open in xschem.
Your symbol, wired to the sine source, with the simulation code below. Nothing to change.
Click Netlist and wait until it turns green.
Click Simulate and wait about 10 seconds.
The plot window shows the rebuilt device switching on and off.
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. You changed nothing in it, so it closes straight away.
memristor_hfo2_al. The old CDL/SPICE netlists, Liberty and Verilog views were for layout checks (LVS) and digital tools; you don't need them to simulate the device.