openMemristorPDK Guide
Guide · Section 7 · about 15 min · 41 steps

Corners and Monte Carlo

No two devices from a factory are exactly alike. Read the PDK's process corners, simulate the typical and the slow memristor, then build 20 random memristors in one Monte Carlo run and find out which manufacturing spread matters most. You only ever need to click whatever is inside the red box, or type exactly what is in a black box.

Do Your first simulation first: this section uses the same moves (Netlist, Simulate, Quit, quit). Start with openPDKcreator open.

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

What the factory promises

A real factory never makes two devices exactly alike: the oxide comes out a little thicker here, the metal a little rougher there. So the PDK doesn't give one value for Ron and Roff, it gives corners: the typical case and the two extremes a designer must survive. Here they live in one file, openmemristorpdk_corners.lib, and openPDKcreator shows them in a table.

1

Open the PDK tab

Click the PDK tab at the top.

2

Simulation

Click Simulation.

3

Corners

You are on ngspice Models, with the file openmemristorpdk_corners.lib already chosen. Click the small Corners tab.

4

The three corners

Three rows (1): TT, FF and SS. TT is selected, and its values are in the box at the bottom right (2).

TT · typical
What most devices look like: ron_tio2_au = 100 Ω and roff_tio2_au = 16k (16 000 Ω).
FF · fast
Every resistance 20 % lower: more current, faster circuits.
SS · slow
Every resistance 20 % higher: less current, slower circuits.
tio2_au, tio2_ti, hfo2_al
One pair of numbers per memristor in the PDK. This section uses the Au/TiO₂/Au one, the same as in Your first simulation.
5

Look at FF

Click the FF row.

6

Lower resistances

The box now shows the FF values: ron_tio2_au = 80 and roff_tio2_au = 12.8k, both 20 % below TT. Don't change anything here.

Part 2 · about 3 minutes

Simulate the typical corner

A testbench picks one corner with a single word. You'll run the typical one first.

7

Library Manager

Click the Library Manager tab.

8

The corners testbench

Click the library openmemristorpdk_pr (1) if it isn't selected yet, then the cell memristor_tio2_au_corners_tb (2).

9

Open it

Click Open in xschem on the Schematic row.

10

Read the code block

The same circuit as in Your first simulation: a sine-wave source and one memristor. The difference is in the code block at the bottom. The line boxed in red picks the corner.

code block s1what ngspice reads
* Process corner: TT (typical), FF (fast) or SS (slow).
* To try another corner, change the last word of the .lib line.
.lib /foss/designs/openMemristorPDK/data/openmemristorpdk/libs.tech/ngspice/models/openmemristorpdk_corners.lib TT
.model mm memristor_tio2_au ron={ron_tio2_au} roff={roff_tio2_au} d=10n uv=1e-14 x0=0
.control
pre_osdi /foss/designs/openMemristorPDK/user_models/veriloga/memristor_tio2_au.osdi
tran 300u 3.34
let peak = maximum(-i(V1)) * 1e6
echo Ron = $&@mm[ron] Ohm   Roff = $&@mm[roff] Ohm   peak current = $&peak uA
plot -i(V1) vs v(te) retraceplot ylimit -110u 110u title 'Memristor I-V loop at one corner' xlabel 'Voltage (V)' ylabel 'Current (A)'
.endc
.lib ... TT
Read the corners file, but only the TT part. The last word is the corner.
ron={ron_tio2_au}
The curly brackets mean "use the value from the corner". With TT that is 100 Ω; with SS it would be 120 Ω.
echo
Prints Ron, Roff and the highest current in the ngspice window, so you can compare corners with numbers.
ylimit -110u 110u
Fixes the plot's height, so a smaller loop really looks smaller.
11

Click Netlist

Click Netlist and wait until it turns green.

12

Click Simulate

Click Simulate and wait about 10 seconds.

13

The typical memristor

The plot shows the pinched loop of a typical device, and the last line in the ngspice window gives its numbers.

Write it down Ron = 100 Ω, Roff = 16 000 Ω. Peak current: 78.9 µA (µA = millionths of an ampere). Remember this number: the next corner will beat it or lose to it.
14

Close the plot

Click Quit in the plot window.

15

Close the simulator

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

Part 3 · about 3 minutes

Switch to the slow corner

Same testbench, one word changed: TT becomes SS.

16

Edit the code block

Double-click the code block text.

17

Find the .lib line

The Edit Properties window opens. The .lib line is too long to see its end. Click anywhere on it.

18

Go to the end of the line

Press End. The text slides left and the cursor stops right after TT.

19

TT becomes SS

Press Backspace twice, type SS (1) and click OK (2).

Capital lettersType SS in capitals: the corner names in the file are capitals.
20

Netlist, then Simulate

Click Netlist (1), wait for green, then Simulate (2).

21

The slow memristor

A thinner loop: less current flows.

Compare SS: Ron = 120 Ω, Roff = 19 200 Ω, peak 65.8 µA. TT gave 78.9 µA. Resistances 20 % higher, current about 17 % lower. A circuit built with these memristors must still work with this weaker current.
Try FF yourselfClose the plot and ngspice (steps 14–15), then repeat steps 16–20 with FF. You should get a peak of 98.6 µA.
22

Close plot and simulator

Same as before: Quit in the plot window, then quit + Enter in the ngspice window.

23

Close xschem

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

24

Don't save

xschem asks UNSAVED data: want to exit? Click OK. The testbench keeps TT for next time.

Part 4 · about 4 minutes

Monte Carlo: 20 different memristors

Corners show the extremes. Monte Carlo shows what a real batch looks like: ngspice builds 20 memristors, each with its own random Ron, Roff and oxide thickness D, and simulates them one after another. The name comes from the casino in Monaco: it's all about random numbers.

25

The Monte Carlo testbench

In the Library Manager, click memristor_tio2_au_mc_tb.

26

Open it

Click Open in xschem.

27

Read the code block

Same circuit, a longer code block. The three lines boxed in red are where the randomness comes from.

code block s1what ngspice reads
* Monte Carlo: simulate 20 memristors, each one a little different,
* like 20 devices from a real factory. agauss(typical, spread, 1)
* draws a random value around the typical one (a bell curve).
.param ron_mc  = agauss(100, 10, 1)
.param roff_mc = agauss(16k, 1.6k, 1)
.param d_mc    = agauss(10n, 0.5n, 1)
.model mm memristor_tio2_au ron={ron_mc} roff={roff_mc} d={d_mc} uv=1e-14 x0=0
.options interp
.control
pre_osdi /foss/designs/openMemristorPDK/user_models/veriloga/memristor_tio2_au.osdi
* setseed: the same 20 random memristors every time (the ones in the guide)
setseed 16
let runs = 20
let ron = vector(runs)
let roff = vector(runs)
let dnm = vector(runs)
let peak = vector(runs)
set curves = ( )
let n = 0
dowhile n < runs
  reset
  tran 1m 3.34
  let ron[n] = @mm[ron]
  let roff[n] = @mm[roff]
  let dnm[n] = @mm[d] * 1e9
  let imem = -i(V1)
  let peak[n] = maximum(imem) * 1e6
  set curves = ( $curves {$curplot}.imem )
  let n = n + 1
end
setplot const
let n = 0
dowhile n < runs
  let r1 = ron[n]
  let r2 = roff[n]
  let dd = dnm[n]
  let pk = peak[n]
  echo memristor $&n :  Ron $&r1  Roff $&r2  D $&dd nm  peak $&pk uA
  let n = n + 1
end
plot $curves vs tran1.v(te) retraceplot title '20 memristors (Monte Carlo)' xlabel 'Voltage (V)' ylabel 'Current (A)'
.endc
agauss(100, 10, 1)
A random number around 100, usually between 90 and 110 (a bell curve). Ron varies by about 10 %, Roff by 10 %, and D (normally 10 nm) by 5 %.
setseed 16
Random numbers start from a seed. With the same seed you get the same 20 memristors as in these screenshots. Change 16 to another number for a new batch.
dowhile n < runs ... end
A loop: the lines inside run 20 times, with n = 0, 1, 2 ... 19.
reset
Loads the circuit again, which draws new random values: a new memristor.
let ron[n] = @mm[ron]
Writes down the Ron this memristor got. Same for Roff, D and the peak current.
echo memristor ...
At the end, prints one line per memristor: a table.
plot $curves ...
Draws all 20 loops in one plot.
28

Netlist, then Simulate

Click Netlist (1), wait for green, then Simulate (2). Twenty simulations take about 20 seconds.

29

One memristor is different

Nineteen loops are so small they lie flat along the zero line. One of them shoots up to almost 5 mA.

How to read it Each colour is one memristor. The legend calls them tran1.imem ... tran20.imem: run 1 to run 20. The blue one, tran2, has switched on: the steep line through the middle is its low Ron. The current is 60 times bigger than the others. The plot's scale is now mA (thousandths), not µA.
30

Bring the table to the front

The plot covers part of the ngspice window. Click the ngspice window's title bar to bring it to the front.

31

The table of 20 memristors

One line per memristor, numbered from 0. Memristor 0 is run 1, memristor 1 is run 2 (the blue one), and so on.

memristor 1
Peak 4729 µA. It has the lowest Roff of the batch (12 073 Ω) and a thin oxide (9.45 nm). More current pushes the memory faster, and a thinner oxide needs less push to fill up, so it switched on.
memristor 4
The thinnest oxide (8.91 nm) but a high Roff (18 820 Ω): too little current, it didn't switch (67 µA).
memristor 2
Almost the same low Roff as memristor 1, but a thick oxide (10.5 nm): no switch either (117 µA).
What it tells a designerSmall differences between devices can change how a circuit behaves completely. A Monte Carlo run finds those surprises before the chip is made.
Warning: No job ... definedThe last two lines are a harmless warning from xschem asking ngspice to run once more after the code block. All 20 simulations already ran. Ignore it.
32

Close the plot

Click Quit in the plot window.

33

Close the simulator

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

Part 5 · about 3 minutes

A perfect oxide

What if the factory could make the oxide exactly 10 nm every time? Set D's spread to zero and run the batch again.

34

Edit the code block

Double-click the code block text.

35

Find the spread of D

On the line .param d_mc = agauss(10n, 0.5n, 1), click right after 0.5n, before the comma.

36

Make it zero

Press Backspace 4 times to delete 0.5n, type 0 (1). The line now reads agauss(10n, 0, 1). Click OK (2).

If the line looks wrongClick Cancel and start again from step 34. Nothing is changed until you click OK.
37

Netlist, then Simulate

Click Netlist (1), wait for green, then Simulate (2), and wait about 20 seconds.

38

Twenty well-behaved memristors

Now every loop is visible: twenty pinched loops, all between about 60 and 130 µA. None switches on.

What changedEvery memristor has D = 10 nm. Ron and Roff still vary, which is why the loops fan out a little. The widest one, green, is the memristor with the lowest Roff.
The lessonThe oxide thickness was what made one memristor out of 20 behave completely differently. If you made memristor chips, controlling that thickness is where you'd spend your money.
39

Close plot and simulator

Quit in the plot window, then quit + Enter in the ngspice window (bring it to the front first).

40

Close xschem

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

41

Don't save

Click OK on UNSAVED data: want to exit? The testbench keeps the 0.5n spread.

What you didYou read the PDK's process corners, simulated the typical and the slow corner, ran a Monte Carlo batch of 20 memristors and found out which manufacturing spread matters most. That's exactly what chip designers do before sending a design to the factory.