In a recent post titled Simulating the Knowm M-MSS Memristor Model Pulse Response with Qucs-S and Xyce, I presented circuit simulations that focus on the dynamic behavior of the M-MSS model’s incremental conductance response to applied square wave pulses. In this post I will continue to explore this behavior by creating basic logic cicuits (i.e. 2-input AND, 2-input OR gates) and perform simulations using discrete memristor elements and sub-circuit models which implement neuromemristive synapses (i.e. AHaH kT-Synapses). I will demonstrate how to configure mixed mode simulations using a 2-output pattern generator contained in the Qucs-S Xyce Digital
library to configure square wave pulses with specific pulse timing to produce the truth table inputs to the logic circuits. As part of this tutorial we will also be exploring some additional advanced features of Qucs-S and Xyce for displaying timing diagrams and measuring the power across the memristor elements during the transient simulation. The new Knowm_AHaH
library included in the latest release candidate #3 of the Knowm OSS EDA Stack provides AHaH synapse node configurations implemented as sub-circuits to simplify building netlists for simulating the same basic logic circuits designed using discrete memristor components. This new library will be used in future simulations of neuromemristive circuits and machine learning algorithms in hardware.
An example Qucs-S project has been created to perform various experiments that we will later set up on actual memristor devices using the Knowm Memristor Discovery board and associated extender modules. The following experiments are included in the example Qucs-S project AHaH_Logic_prj
available in the examples_knowm_oss-eda-0.0.19s-rc3
bundle.
Memristor Experiments Included in the Accompanying Examples
-
ahah_mr_AND2_pl2
(2) Rectangular Pulse sources with positive pulse amplitude of 1V with transient analysis simulating an AHaH 1-2 synapse using discrete memristor elements configured to produce the logic states of a 2-input AND gate.
-
ahah_mr_AND2
Xyce 2-output pattern generator with positive pulse amplitude of 1V with transient analysis simulating an AHaH 1-2 synapse using discrete memristor elements configured to produce the logic states of a 2-input AND gate.
-
ahah_mr_OR2
Xyce 2-output pattern generator with positive pulse amplitude of 1V with transient analysis simulating an AHaH 1-2 synapse using discrete memristor elements configured to produce the logic states of a 2-input OR gate.
-
ahah1-2_synapse_AND2
Xyce 2-output pattern generator with positive pulse amplitude of 1V with transient analysis simulating an AHaH 1-2 synapse using the AHaH 1-2 synapse subcircuit configured to produce the logics state of a 2-input AND gate.
-
ahah1-2i_synapse_OR2
Xyce 2-output pattern generator with positive pulse amplitude of 1V with transient analysis simulating an AHaH 1-2 synapse using the AHaH 1-2i (inverted) synapse subcircuit configured to produce the logic states of a 2-input OR gate.
NOTE: We will be covering the AND2 examples and the AHaH 1-2i Synapse OR2 circuit in this tutorial. The other OR2 circuits are almost identical and can be explored using the same steps as presented here for the corresponding AND2 circuits.
Prerequisites
- Please follow the detailed tutorial Simulating the Knowm M-MSS Memristor Model Using Qucs-S with Xyce to learn the basics of creating a Qucs-S schematic file for use with Xyce to perform a transient simulation of the M-MSS model using an AC sinusoidal waveform.
-
Please follow the installation and configuration of your OSS EDA Environment Simulating the Knowm M-MSS Memristor Model Pulse Response with Qucs-S and Xyce.
NOTE: The instructions there should be almost identical to the ones necessary for installing release candidate #3 used for this tutorial.
- Update to the latest release candidate #3 of the
Knowm OSS EDA Stack
. It is available formacOS 10.12 Sierra
andUbuntu 16.04 LTS (Xenial Xerus)
. This post covers installation and use on macOS and support for Xyce (Serial) simulations only. The included versions of Qucs-S (0.0.19S) and Xyce 6.6 include libraries for amd64 architectures. Support for other architectures and operating systems are under development and will be released when available.
Download and install the latest release candidate #3 from these links.
MacOS Sierra 10.12 QUCs
MacOS Sierra 10.12 Knowm Examples
MacOS Sierra 10.12 Xyce
Linux QUCs
Linux Knowm Examples
Linux Xyce
Overview
The following discussion of simulation of memristor logic circuits was developed based on the results of a paper presented by Frey, et. al. titled: “Investigating Power Characteristics of Memristor-based Logic Gates and Their Applications in a Security Primitive”. You may want to review this paper before or concurrently while working through this tutorial. The following configurations are the inspiration for the circuits we have configured here.
- We will also be using AHaH nodes which will be introduced in a following section. The basic configuration of the AND and OR gate presented use the AHaH 1-2 configuration.
Open the AHaH Discrete Memristor AND2 Schematic diagram
-
Double click the
AHaH_Logic_prj
to automatically open theContent
tab. -
Select the
ahah_mr_AND2_2pl.sch
from theSchematics
list in the Contents tab of the Main Dock.NOTE: We are using the AHaH 1-2 synapse
AND
configuration from the diagram above and the .Model directiveMRM5
, and the M-MSS model from theKnowm_Memristor_Technology
library has been assigned for both theMR1
andMR2
memristor symbols. We have increased the ratio for the Ron and Roff parameter values in the models as discussed in the Frey paper in order to the minimum and maximum values as measured at the output voltage across the divider network.
Pulse Voltage Source properties
-
Double click
V1
symbol on the schematic to open the parameters and review the settings for theRectangle pulse
source. -
Select the
U
row in the properties table. -
The voltage is set to
1 V
so the output will be from 0V to 1V. -
Select the
TH
row in the properties table determine the time duration of the high pulses. -
We’ve set this value to
10 ms
to specify a 10 mspulse width
. -
Similarly the
TL
row in the properties table determine the time duration of the low pulses. I have set this also to10 ms
to specify a 20msperiod
. -
Click
Apply
to set the frequency value. -
Click
OK
to exit the properties dialog. -
Similarly you can double click
V2
symbol on the schematic to open the parameters and review the settings for second theRectangle pulse
source.
NOTE: The parameters for V2
are set to be half of the period of V1
. This will give us twice the number of pulses on the input of the memristor MR2
and allow use to generate the truth table for the gate inputs.
Other Schematic Components
- We have configured two
current probes
namedPr1
andPr2
that are used to measure the current flowing through each memristor as the pulses are applied to the circuit. -
There are also the
Name
nodesw1
andw2
which will provide the voltage measured across the two memristors MR1 and MR2 respectively and represent the change of the weights and the memristor states based on the change in the conductance in each branch of the synapse. -
The
out
named node provides the positive voltage for the voltage divider at the junction of theMR1
amdMR2
memristors which defines the logic state of the synapse which should should0 V
or1 V
at the maximum pulse values.
Transient Simulation Settings
-
Double click on the
transient simulation
symbol to open the setup parameters dialog. -
I have entered
20 ms
in thestop
field to coincide with the settings for the rectangle pulse sources total period. -
Entering
101
in the number value field to set a 200 us step size. -
Click
Apply
to save the changes. -
Click
OK
to exit the properties dialog.
Save the Schematic Diagram File
-
The filename
ahah_mr_AND2_2pl.sch
has been used for this example schematic. -
Click the
Save
button on the toolbar to save the schematic file.
Run a Simulation
- Press
F2
or selectSimulate
button on the toolbar.
-
Check simulation for
errors
orwarnings
. See the status bar at the bottom of the Qucs windowlower right corner
. -
Click the
Exit
button to close theSimulation
window.
View the Tabular Results
-
Check the
Tabular
results.
Cartesian Plot of Memristor-based AND2 Gate ( V vs. Time ) Results
-
You should also observe the results in the specified Cartesian plot defined in the schematic.
NOTE: The results contain multiple pulses of the
1V
amplitudes forw1
andw2
we defined in theRectangle Pulse
settings. This provides the 4 states of the AND gate for the following truth table. -
In the first 5 ms both p1 and p2 are positive
1 V
so theout
state is also positive1 V
or logic 1. -
In the next 5 ms both p1 is positive
1 V
but p2 is0V
so theout
state is0 V
or logic 0. -
In the next 5 ms both p1 is
0 V
but p2 is1 V
so theout
state is still0 V
or logic 0. -
In the last 5 ms both p1 and p2 are positive
0 V
so theout
state is also positive0 V
or logic 0.
Open the Schematic diagram
-
Double click the
AHaH_Logic_prj
to automatically open theContent
tab. -
Select the
ahah_mr_AND2.sch
from theSchematics
list in the Contents tab of the Main Dock.NOTE: Again we are using is the AHaH 1-2 synapse
AND
configuration from the diagram above and the .Model directiveMRM5
, the M-MSS model from theKnowm_Memristor_Technology
library has been assigned for both theMR1
andMR2
memristor symbols.
Configure the 2-Pattern Pulse Gererator Voltage Source
-
The
PATGENX2
was added to replace the 2 rectangle pulse sources in the schematic. This is a component found in theXyce Digital
library components list. -
Double click
PG
symbol on the schematic to open the parameters and review the settings for thePATGENX2
pulse generator source.NOTE: The definition of the component specifies the
x2
source output to be 0.5 the period ofx1
. -
The frequency of the pulse generator is set using
PulseFreq = 5e1
. Setting the frequency to5e1
will give us a 20 ms period on thex1
source output. -
We have set the parameter
ScaleFactor = 1
will set the voltage on x1 and x2 outputs to1 V
so both will transition from 0 V to 1 V for their low and high output states. -
Click
Apply
to set the frequency value. -
Click
OK
to exit the properties dialog. -
The updated parameters for the X1 Sub-circuit are displayed for the PATGENX2 component.
NOTE: Again the parameters for x2
are set to be half of the period of x1
. This will give us twice the number of pulses on the input of the memristor MR2
and allow use to generate the truth table for the gate inputs.
- Select .Model directive
DMOD
, from theXyce Digital Technology
library model from theKnowm_Memristor_TTL_Technology
library to assign for it to thePATGEN2X
pulse generator symbol.NOTE: The .Model directive for all
Xyce Digital
components use the modelDMOD
which is of typeDIG
as defined in the digital library model source.
Configure the Transient Simulation in the XYCE Script
-
The
XYCE script
component symbol has been added to the schematic to define the transient analysis and variables to be output by the Xyce .PRINT statement. -
The
.TRAN
start and end time have been set to1n
and20 ms
repectively. -
Notice that we have also introduced a new powerful feature of the Xyce script
.MEASURE
. This provides a means of calculating a analytical quantity during each time step of the transient simulation. Here we have defined the equationEQN {V(W1)*I(VPR1)}
andEQN {V(W2)*I(VPR2)}
which will compute the powerPMR1
andPMR2
through each memristor during the simulation and put result in an output array that can be plotted or used in post-analysis routines. -
Click
Apply
to save the changes. -
Click
OK
to exit the properties dialog.
Save the Schematic Diagram File
- Click the
Save
button on the toolbar to save changes to theahah_mr_AND2.sch
schematic file.
Run a Simulation
-
Press
F2
or selectSimulate
button on the toolbar.
-
Check simulation for
errors
orwarnings
. See the status bar at the bottom of the Qucs windowlower right corner
. -
Click the
Exit
button to close theSimulation
window.
View the Tabular Results
-
Check the
Tabular
results.
Timing Diagram of Memristor-based AND2 Gate ( V vs. Time ) Results
-
You can display the timing results in the specified
Timing Diagram
placed from thediagrams
in the Components tab of the Main Dock.
Cartesian Plot of Memristor-based AND2 Gate ( V vs. Time ) Results
-
You should also observe the results in the specified Cartesian plot defined in the schematic.
NOTE: The results contain multiple pulses of the
1V
amplitudes forw1
andw2
we defined in thePATGENX2
settings. This plot not only provides the 4 states of the AND gate as shown before but we have also plotted the calculated powerPMR1
andPRM2
vsV(OUT)
and provided those quantites on the Y2 axis of the plot.
Open the AHaH 1-2 Synapse AND2 Schematic diagram
-
Double click the
AHaH_Logic_prj
to automatically open theContent
tab. -
Select the
ahah1-2_synapse_AND2.sch
fromSchematics
in the Contents tab of the Main Dock. -
We have selected the
AHaH1-2
symbol from theKnowm_AHaH
library and placed it on the schematic. -
The sub-circuit
X2
defines the sub-circuit provided for theAHaH1-2 synapse
and replaces the two discrete memristors MR1 and MR2 from the last exercise.NOTE: Again we are using is the AHaH 1-2 synapse
AND
configuration from the diagram above and the .Model directiveMRM5
, the M-MSS model from theKnowm_Memristor_Technology
library has been assigned for both theX2
sub-circuit memristor symbols. -
The parameters for the AHaH1-2 component are already set so no further setup is necessary other than specifying the
Rinit
parameter using the.PARAM
component from the SPICE specfic sections drop-down list in the Components tab of the Main Dock.
Save the Schematic Diagram File
- Click the
Save
button on the toolbar to save changes to theahah1-2_synapse_AND2.sch
schematic file.
Run a Simulation
- Press
F2
or selectSimulate
button on the toolbar.
-
Check simulation for
errors
orwarnings
. See the status bar at the bottom of the Qucs windowlower right corner
. -
Click the
Exit
button to close theSimulation
window.
View the Tabular Results
-
Check the
Tabular
results.
Cartesian Plot of Memristor-based AND2 Gate ( V vs. Time ) Results
-
You should also observe the results in the specified Cartesian plot defined in the schematic.
NOTE: Again the results are the same as shown before using the discrete memristors and contain multiple pulses of the
1V
amplitudes forw1
andw2
we defined in thePATGENX2
settings. This plot not only provides the 4 states of the AND gate as shown before but we have also plotted the calculated powerPMR1
,PRM2
vsV(W1)
,V(W2)
respectively.
Open the AHaH 1-2i Synapse OR2 Schematic diagram
-
Double click the
AHaH_Logic_prj
to automatically open theContent
tab. -
Select the
ahah_1-2i_synapse_OR2.sch
from theSchematics
list in the Contents tab of the Main Dock. -
For this example we are using is the AHaH 1-2i (inverted) synapse
OR
configuration from the diagram above and the .Model directiveMRM5
, the M-MSS model from theKnowm_Memristor_Technology
library has been assigned for both theMR1
andMR2
memristor symbols.
Observe the 2-Pattern Pulse Gererator Voltage Source
-
The
PATGENX2
was introduced in the previous AND2 schematic to replace the 2 rectangle pulse sources in the schematic. Again, for the OR2 schematic this is a component found in theXyce Digital
library components list. -
Again the
PG
symbol on the schematic is associated with sub-circuit X1 and the parameters have been set for thePATGENX2
pulse generator source. -
The frequency of the pulse generator is set using
PulseFreq = 5e1
. Setting the frequency to5e1
will give us a 20 ms period on thex1
source output. -
We have set the parameter
ScaleFactor = 1
will set the voltage on x1 and x2 outputs to1 V
so both will transition from 0 V to 1 V for their low and high output states.NOTE: The definition of the component specifies the
x2
source output to be 0.5 the period ofx1
.
Again the parameters forx2
are set to be half of the period ofx1
. This will give us twice the
number of pulses on the input of the memristorMR2
and allow use to generate the truth table for
the gate inputs. -
The .Model directive
DMOD
, has been selected from theXyce Digital Technology
library model to assign for it to thePATGEN2X
pulse generator symbol.NOTE: The .Model directive for all
Xyce Digital
components use the modelDMOD
which is of typeDIG
as defined in the digital library model source.
Transient Simulation Configuration in the XYCE Script
-
The
XYCE script
component symbol has been added to the schematic to define the transient analysis and variables to be output by the Xyce .PRINT statement. -
The
.TRAN
start and end time have been set to1n
and20 ms
repectively. -
Notice that we have again included the
.MEASURE
lines. This provides a means of calculating a analytical quantity during each time step of the transient simulation. Here we have defined the equationEQN {V(W1)*I(VPR1)}
andEQN {V(W2)*I(VPR2)}
which will compute the powerPMR1
andPMR2
through each memristor during the simulation and put result in an output array that can be plotted or used in post-analysis routines.
Save the Schematic Diagram File
- Click the
Save
button on the toolbar to save changes to theahah_1-2i_synapse_OR2.sch
schematic file.
Run a Simulation
- Press
F2
or selectSimulate
button on the toolbar.
-
Check simulation for
errors
orwarnings
. See the status bar at the bottom of the Qucs windowlower right corner
. -
Click the
Exit
button to close theSimulation
window.
View the Tabular Results
-
Check the
Tabular
results.
AHaH 1-2i OR2 Gate Cartesian Plot ( V vs. Time ) Results
-
Observe the results in the specified Cartesian plot defined in the schematic.
NOTE: The results contain multiple pulses of the
1V
amplitudes forw1
andw2
we defined in thePATGENX2
settings. This plot not only provides the 4 states of the AND gate as shown before but we have also plotted the calculated powerPMR1
andPRM2
vsV(OUT)
and provided those quantites on the Y2 axis of the plot. -
In the first 5 ms both p1 and p2 are positive
1 V
so theout
state is also positive1 V
or logic 1. -
In the next 5 ms both p1 is positive
1 V
but p2 is0V
so theout
state is1 V
or logic 1. -
In the next 5 ms both p1 is
0 V
but p2 is1 V
so theout
state is still1 V
or logic 1. -
In the last 5 ms both p1 and p2 are positive
0 V
so theout
state is also positive0 V
or logic 0.
That completes this tutorial. Try some of the other example schematic files available in the AHaH_Logic_prj project. All of these experiments use common features presented here. In our next tutorial we will explore more circuits using AHaH nodes that we’ve presented here to simulate machine learning methods.
You should also checkout the documentation and other examples listed in the Qucs 0.0.19 and Qucs-S 0.0.19 documentation available on the web at the following URLs.
- Qucs 0.0.19 Help: https://qucs-help.readthedocs.io/en/0.0.19/subcircuit.html
- Qucs-S 0.0.19 Help: https://qucs-help.readthedocs.io/en/spice4qucs/SPICEComp.html
- Qucs-S Bugtracker: https://github.com/ra3xdh/qucs/issues
- Qucs-S Sub-project Home Webpage: https://ra3xdh.github.io/
Other References
- What is Qucs?
- What can all be installed from Sourceforge?
- Qucs Website: http://qucs.sourceforge.net/
- Main Repository: https://sourceforge,net/p/qucs/git/ci/master/tree/
- Mirror Repository: https://github.com/Qucs/qucs
- Mailing lists: http://sourceforge.net/p/qucs/mailman/
- Forum: http://sourceforge.net/p/qucs/discussion/
- Bug trackers:
- Source code documentation:
- Wiki: https://github.com/Qucs/qucs/wiki
Further Resources
- Knowm Memristors
- The Generalized Metastable Switch Memristor Model
- Simulating the Knowm M-MSS Memristor Model Using Qucs-S with Xyce
- The Problem is Not HP’s Memristor–It’s How They Want To Use It
- The Joglekar Resistance Switch Memristor Model in LTSpice
- Build Xyce from Source for ADMS Verilog-A Model Integration
- The Pershin Voltage Threshold Memristor Model in NGSpice
- memristor-models-4-all Project on Github
Subscribe To Our Newsletter
Join our low volume mailing list to receive the latest news and updates from our team.