Simulate the same bit the way digital designers do: a short Verilog description, Icarus Verilog, and waveforms in GTKWave. You only ever need to click whatever is inside the red box, or type exactly what is in a black box.
Do Store a bit first: this part gives the same answers without volts.
click hereClick any screenshot to see it full sizeKeys in the player: ←→SpaceEsc
About 10 minutes
Step by step
Digital designers don't simulate currents: a chip has millions of bits, far too many for ngspice. They use a digital twin, a short description in Verilog that only says what the memristor does with ones and zeros. You'll simulate one with Icarus Verilog and look at the result in GTKWave.
1
The twin
This is the whole twin, in openMemristorPDK/digital/memristor_bit/memristor_bit.v. Nothing to type: it's already there. You can also open it from the Library Manager: cell memristor_bit (and memristor_bit_tb for the test), Verilog row, View.
memristor_bit.vVerilog
// memristor_bit.v -- a digital twin of the Au/HfO2/Al memristor used
// as a 1-bit memory. No voltages or currents: only what a digital
// designer needs to know about it.
//
// set = 1 : a write pulse above +0.8 V -> the bit becomes 1
// reset = 1 : a write pulse below -0.6 V -> the bit becomes 0
// read = 1 : a small 0.2 V read -> q shows the bit
//
// A write only works if its pulse lasts at least T_SWITCH (15 ns, about
// what the ngspice simulation of the real model needs). When nothing
// happens the bit stays where it is: no power needed.
`timescale 1ns/1ps
module memristor_bit #(parameter T_SWITCH = 15) (
input wire set,
input wire reset,
input wire read,
output wire q
);
reg stored = 1'b0; // x0 = 0: the memristor starts off
// A SET pulse: wait T_SWITCH, then switch on if the pulse is still there.
always @(posedge set) begin
#(T_SWITCH);
if (set) stored = 1'b1;
end
// A RESET pulse: the same, switching off.
always @(posedge reset) begin
#(T_SWITCH);
if (reset) stored = 1'b0;
end
// While reading, q shows the bit; otherwise q is disconnected (z).
assign q = read ? stored : 1'bz;
endmodule
input, output
The wires of the block: three going in (set, reset, read) and one coming out (q). Each is 0 or 1.
reg stored
The bit inside the memristor. It starts at 0, like x0=0 in xschem.
always @(posedge set)
"Every time set goes from 0 to 1". Then #(T_SWITCH) waits 15 ns, and the bit becomes 1 only if set is still on: a pulse that is too short does nothing.
assign q = read ? stored : 1'bz
While reading, q shows the bit. Otherwise it is z: not connected, neither 0 nor 1.
The testA second file, memristor_bit_tb.v, does the same as the xschem testbench of Store a bit: read, write 1, read, write 0, read. Then one more write 1 that lasts only 5 ns, and a last read.
2
Open a terminal
In the container desktop (the browser window), click the terminal icon in the bottom panel. A black terminal window opens at the top left.
3
Go to the twin's folder
Click inside the terminal and type these two commands, pressing Enter after each. ls lists the folder: the twin, its test and a GTKWave file.
$ cd openMemristorPDK/digital/memristor_bit
$ ls
Type, don't pasteThis terminal is inside the container, so pasting from your own computer may not work. Type the commands. Press Tab halfway through a file name and the terminal finishes it for you.
4
Compile
Icarus Verilog turns the two files into a program you can run. Nothing is printed: that means it worked.
The simulation takes a blink. It prints the four reads.
$ vvp memristor_bit_tb
What it shows0, 1, 0: the same answers as the real ngspice simulation in Store a bit, without a single volt or microamp.The last read is 0 too: the 5 ns write was too short, just like the 0.7 V write in A write that is too weak was too weak.
6
Open the waveforms
The run also saved every signal in memristor_bit_tb.vcd. Open it in GTKWave. It starts zoomed in too far: click Zoom Fit, the first of the three magnifier buttons.
Now the whole 700 ns fit in the window. Time goes left to right; each row is one signal.
How to read itset goes up at 100 ns; 15 ns later stored goes up too: the bit is 1.reset goes up at 300 ns; 15 ns later stored drops back to 0.The tiny set blip at 500 ns is only 5 ns long: stored doesn't move.q only shows the bit while read is up. In between it is z, drawn as a yellow line in the middle.
8
Close GTKWave
Click the X at the top-right of the GTKWave window.