openMemristorPDK Guide
Guide · Section 6 · about 15 min · 33 steps

Add a new device

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.

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

Delete the device

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.

1

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.

2

Delete it

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

3

Confirm

openPDKcreator lists every file it will delete: model, symbol, layout, chip file, netlists. Click Yes.

CarefulThis really deletes the files. That's fine here, because you'll rebuild the device in the next parts, and the original is safe in git. Don't delete devices you haven't saved somewhere.
4

It's gone

The bar at the bottom says Deleted cell 'memristor_hfo2_al', and the cell has disappeared from the list.

Part 2 · about 3 minutes

Rebuild the model

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.

5

New cell

Click New Cell....

6

Same name as before

Type memristor_hfo2_al and click OK.

7

Verilog-A first

Click Verilog-A.

8

Write the model

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
EOF
What it doesWrites the file user_models/veriloga/memristor_hfo2_al.va, replacing the empty one. Nothing is printed: that means it worked.
9

Open the model

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

10

Read it, then close it

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.

user_models/veriloga/memristor_hfo2_al.vathe whole file
// 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
Von, Voff
The thresholds: above +0.8 V the memory turns on (SET), below −0.6 V it turns off (RESET). In between, nothing changes.
electrical dx
A hidden extra wire, like in the Joglekar model of Add a model: its voltage stores how far the memory has moved since the start.
x = ...
The memory: the start value x0 plus how far it has moved, kept between 0 and 1.
dxdt
How fast the memory moves: zero between the thresholds, faster the further past them.
if (x >= 1.0 ...)
Once the memory is fully on (1) or fully off (0), it stops moving that way. So it can switch back as soon as the voltage turns around.
tau
How quickly it switches once past a threshold (the testbench uses 1 ms).
Rmem = Roff * exp(...)
The resistance falls exponentially from Roff (50 kΩ, off) to Ron (500 Ω, on) as the memory goes from 0 to 1: a thin conducting filament growing through the HfO₂.
11

It compiles

A box says Compilation performed correctly. Click OK.

Part 3 · about 2 minutes

Rebuild the symbol

The symbol is what you place in a circuit drawing in xschem: a box with two pins, BE and TE.

12

Create the symbol

On the Symbol row, click Create. openPDKcreator makes an empty symbol file.

13

Draw it with a command

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 {}
EOF
What it doesWrites the file libraries/openmemristorpdk_pr/memristor_hfo2_al.sym, replacing the empty one. Nothing is printed: that means it worked.
K {type=n ...}
How the symbol turns into a netlist line, n1 BE TE mm. The n tells ngspice it's a compiled model.
B 5 ... {name=BE}
The two pins: BE on the left, TE on the right.
L 4 ...
Six straight lines: the two leads and the four sides of the box.
14

Look at it in xschem

On the Symbol row, click Open in xschem and wait for the window.

15

The new symbol

Here it is: a box with a lead and a red pin square on each side. Nothing to change.

16

Close xschem

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

Part 4 · about 4 minutes

Rebuild the layout

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.

17

Create the layout

On the Magic Layout row, click Create.

18

Draw it with a command

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
What it doesWrites the file libraries/openmemristorpdk_pr/memristor_hfo2_al.mag, replacing the empty one. Nothing is printed: that means it worked.
<< be_au >>
The gold bottom electrode: one rectangle, rect 0 0 1 1.
<< mem_hfo2 >>
The HfO₂ switching layer, exactly on top of it.
<< te_al >>
The aluminium top electrode, on top of that.
rlabel ... BE / TE
The two connection points, matching the symbol's pins.
19

Check it: Run DRC

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.

20

It's clean

The window title says CLEAN: no rule broken. Click Close.

21

Open the chip file

A new GDS/Layout row appeared with the chip file. Click Open in KLayout.

22

The rebuilt device

In the Layers list (red box), the three layers this device uses are bold: BE_Au, MEM_HfO2 and TE_Al.

And VIA1?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.
23

Close KLayout

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

Part 5 · about 4 minutes

Test it

Last piece: a testbench that drives the rebuilt device with a sine wave and plots its current.

24

Create the testbench

On the Schematic row, click Create.

25

Draw it with a command

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
"}
EOF
What it doesWrites the file libraries/openmemristorpdk_pr/memristor_hfo2_al.sch, replacing the empty one. Nothing is printed: that means it worked.
C {.../memristor_hfo2_al.sym}
Places the symbol you made in part 3, as n1.
sin(0 1.2 25)
A sine wave between +1.2 V and −1.2 V, 25 times per second: past both thresholds.
.model mm ...
The model from part 2 and its numbers.
tran 20u 0.08
Simulate 0.08 seconds (two waves).
26

Open it

On the Schematic row, click Open in xschem.

27

The testbench

Your symbol, wired to the sine source, with the simulation code below. Nothing to change.

28

Click Netlist

Click Netlist and wait until it turns green.

29

Click Simulate

Click Simulate and wait about 10 seconds.

30

The HfO₂ memristor at work

The plot window shows the rebuilt device switching on and off.

How to read it Starting at 0 V the device is off: almost no current (the flat part). Past +0.8 V it switches on (SET) and the current jumps to about 2.4 mA. It stays on all the way back through 0 V (the straight line through the middle) until, past −0.6 V, it switches off again (RESET). Switching off takes a moment: the current first keeps growing, peaks at about −1.3 mA, then drops to almost nothing as the resistance climbs back to 50 kΩ. The simulation runs two full swings, and both draw the same loop: the device switches on and off every time. Sharp jumps instead of the smooth TiO₂ loop: a different material, a different model.
31

Close the plot

Click Quit in the plot window.

32

Close the simulator

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

33

Close xschem

Click the X at the top-right of the xschem window. You changed nothing in it, so it closes straight away.

What you rebuiltThe model, symbol, layout, chip file and testbench of 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.