In the post titled Simulating the Knowm M-MSS Memristor Model Pulse Response with Qucs-S and Xyce, I presented the dynamic behavior of the M-MSS
model’s response to a square wave pulse with various pulse configurations while introducing some more advanced features of Qucs-S
and Xyce
integration. In this post I will discuss extensions to Qucs-S that have been added to support the Knowm JSpice
SPICE-inspired simulator to run transient simulations of a memristor using the M-MSS
(Mean Meta-Stable Switch Memristor Model). I will be comparing the simulation results of the M-MSS model’s response to a rectangular square wave pulse using while varying the pulse pulse width and duty cycle. The I will adding an Octave
script to perform post analysis of the simulated data to extract resistance and conductance values and plot these values vs. the incremental pulse values to evaluate the incremental pulse response of the model.
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 example Qucs-S
/Xyce
/JSpice
compatible project knowm_mr_pulse_j
experiment will be covered in this tutorial.
Prerequisites
Update to the latest release candidate rc5
of the Knowm OSS EDA Stack
. It is available for macOS 10.12 Sierra
and Ubuntu 16.04 LTS (Xenial Xerus)
. This post covers installation and use on macOS and support for Xyce (Serial) simulations only. JSpice
is being delivered as an executable Java Archive .jar
file. You will need to have Java installed on your computer before you can use the JSpice simulator. The provided versions of Qucs-S (0.0.19S) and Xyce 6.7 include libraries for amd64 architectures. Support for other architectures and operating systems are under development and will be released when available.
Please follow the detailed tutorial Comparing Simulation Results for the Knowm M-MSS Model in Xyce and JSpice Using Qucs-S to download the latest version of the Qucs-S, Xyce and JSpice binaries and get them configured properly. Running the example project circuits there will verify that everything is working properly.
Additional Software Installation
The following assumes you have downloaded the pre-built bundles for the Qucs-S, Xyce and JSpice.
Install GNU Octave – Scientific Programming Language
Octave provides powerful mathematics-oriented syntax with built-in plotting and visualization tools.
The Octave syntax is largely compatible with Matlab. The Octave interpreter can be run in GUI mode, as a console, or invoked as part of a shell script. It is accessed in Qucs by selecting View
->Octave Window
.
NOTE: Octave is not currently provided with the Knowm Opensource EDA Stack MacOS release so you will need to install it from the Octave site. We have tested with an older stable Octave version 4.0.3 for use with Qucs-S so it is recommended that you install this version for now. We will soon be updating to version 4.2.1 in the future which is available for MacOS from Homebrew and aptitude from Ubuntu Linux.
MacOS 10.12 Sierra Install
- To download the MacOS installer package from Source Forge go to the Octave 4.0.3 project wiki https://wiki.octave.org/Octave_for_macOS_X
-
On the Octave wiki site, under
Installing a Mac OS X Bundle
click on the linkdownload Octave 4.0.3 with graphical user interface (OS X 10.9+)
-
Double-click on the downloaded
.dmg
package and follow the steps in the Octave 4.0.3 installer to complete the installation of Octave. -
Verify Octave is found in the
/Applications/Octave.app
folder. -
You can test the install from the terminal console by typing:
1 2 |
% /Applications/Octave.app/Contents/Resources/usr/bin/octave --version |
Debian Linux Install – Ubuntu LTS (Xenial Xerus)
-
To install Octave 4.0.0 using
aptitude
you will need to open a terminal window. -
Type the following command at the shell prompt:
1 2 |
$ sudo apt install octave |
-
Answer
Y
to the prompt to begin the Octave installation. -
Verify Octave is installed correctly by typing at shell prompt:
1 2 |
$ which octave |
- You should get the response
1 2 |
$ /usr/bin/octave |
- You can test the install from the terminal console by typing:
1 2 |
$ /usr/bin/octave --version |
Launch Qucs-S
-
Click on the Qucs app icon on the Launcher Bar.
NOTE: the first time Qucs is started is will inform you that no default simulator has been selected.
-
Click
Ok
and then selectXyce (serial)
as the default if prompted.
Qucs-S Application Settings
-
Select
File
->Application Settings...
from the menu. -
Click the
Locations
tab.NOTE: The
Qucs Home
will be a folder named.qucs
in your user$HOME/
directory. This is where all projects will be stored for your installation. Each project will be stored in a separate sub-directory with the_prj
suffix appended to the name you specify. Other directories such as thespice4qucs
directory will also be created which will store the data and netlist information for your Xyce and JSpice simulations.
Save the Application Settings
-
Click
Apply
to save the settings. -
Click
OK
to exit the settings dialog.
Open the KnowmMemristor_J_prj Examples Project File
-
Select the
Projects
tab on the left of the Main Dock. -
Double click the
KnowmMemristor_J_prj
to automatically open theContent
tab.
Select the Schematic diagram
-
Double click on the
knowm_mr_pulse_j.sch
from theSchematics
list in the Main Dock.NOTE: We will be referring to the multiple components of this schematic in the following sections to familiarize you with the basic settings required to perform the transient simulation using Xyce and JSpice. You may want to consult the Qucs-S documentation and Xyce Reference Manual or the JSpice documentation on the Knowm JSpice Github page for more information on available settings.
-
Notice the
MR Memristor
has been placed on the schematic and the MRM5 model has been assigned to the MR1 component instance. -
The .Model directive for the MRM5 model has been selected from a newly added
Knowm Memristor Technology
library found under theLibraries
tab of the Main Dock.NOTE: This library will be the repository in Qucs-S for any new models developed and provided by Knowm.org and the Knowm Developer Community. The models and updates will also be featured on the
memristor-models-4-all
Github repository. -
The Rectangle Voltage source has been selected from the
sources
drop-down list and the parameters set for a 10us Pulse Width and 20us Period.(TH + TL = Period)
.NOTE: The voltage is set to
1 V
which will produce a pulse starting at0 V
for theTL
time then it will transition to1 V
for the specifiedTH
time.
Save the Schematic Diagram File
-
The filename
knowm_mr_pulse_j.sch
has been used for this example schematic and will be used in future tutorials. -
Click the
Save
button on the toolbar to save the schematic file.
Select Xyce (Serial) as the Default Simulator
-
Select
Simulation
->Select default simulator
. -
Verify the
Xyce (Serial) executable location
is set to/Applications/xyce/bin/runxyce
. -
Select
Xyce (Serial)
from theDefault simulator
drop-down-list. -
Click
Apply changes
.NOTE: After changing the default simulator you will receive a warning to restart Qucs. This is not always necessary unless you want to make the selected simulator the new default for the project. For now just proceed and we will discuss this in more detail below in the
General Notes on Usage
.
Run a Xyce Simulation
-
Press
Simulation
->Simulate
on the main menu or selectSimulate
button on the toolbar. -
Check simulation for
errors
orwarnings
. See the status bar at the bottom of the Qucs windowlower right corner
. -
You can save the current netlist by clicking the
Save Netlist
button on the simulation window.NOTE: The
F6
key orShow Last Netlist
from the Simulations menu currently only displays the last netlist for the latest
Qucsator simulation. If you save the netlist using the button on the simulation window then you can open the.cir
file underOthers
list in the project tree. -
Click the
Exit
button to close theSimulation
window. -
You can view and messages written by the Xyce simulator by clicking the
F5
key or selectingShow Last Messages
from the Simulations menu. -
The
Qucs
data fileknowm_mr_pulse_j.dat.xyce
produced by the transient simulation will be automatically created in the$HOME/.qucs/KnowmMemristor_prj/
directory.
Modifying the Experiment
Set Rectangle Pulse Voltage Source properties
-
Double click on the
Rectangular Voltage
symbol to open the parameters for the source. -
Leave the
1 V
amplitude for theU
parameter unchanged for the pulse. -
Select the
TL
row in the properties table. -
Change the
duration of low pulses
from10 us
to20 us
. -
Verify the
display in schematic
checkbox is selected. -
Click
Apply
to set theTL
value. -
Click
OK
to exit the properties dialog.
Save the Schematic Diagram File
-
Click the
Save
button on the toolbar to save changes to theknowm_mr_pulse_j.sch
schematic file.
Run the Modified Xyce Simulation
-
Press
Simulation
->Simulate
on the main menu 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. -
The
Qucs
data fileknowm_mr_pulse_j.dat.xyce
produced by the transient simulation will be automatically created in the$HOME/.qucs/KnowmMemristor_J_prj/
directory.
View the Tabular Results
-
Check the
Tabular
results.
Cartesian Plot of Memristor I,V vs. Time Results
-
You should also observe the results in the specified Xyce I,V vs. Time plot defined in the schematic.
NOTE: The results contain
0 V
to1 V
with the pulse width10 us
at1 V
and20 us
pulse width at0 V
with a combined period of30 us
and duty cycle33.3%
.
Select JSpice as the Default Simulator
-
Verify the
JSpice executable location
is set to/Applications/jspice/runjspice
. -
Select
Simulation
->Select default simulator
. -
Select
JSpice
from theDefault simulator
drop-down-list. -
Click
Apply Changes
.NOTE: After changing the default simulator you will receive a warning to restart Qucs. This is not always necessary unless you want to make the selected simulator the new default for the project. For now just proceed and we will discuss this in more detail below in the
General Notes on Usage
. -
Click
OK
.
Run a JSpice Simulation
-
Select
Simulation
->Simulate
on the main menu or selectSimulate
button on the toolbar. -
Check simulation for
errors
orwarnings
. See the status bar at the bottom of the Qucs windowlower right corner
. -
Again, if you want to save the current netlist, use the
Save netlist
button on the external simulator window to open the file save dialog. Specify the name of the netlist to save, typically the schematic’s filename with the extension.cir
instead of.sch
. The resulting file will be saved in the project folder and you can open the.cir
file under theOthers
list in the project tree.NOTE: The
F6
key orShow Last Netlist
from the Simulations menu currently only displays the last netlist for the lastest Qucsator simulation. -
Click the
Exit
button to close theSimulation
window. -
You can view any messages written by the simulator by clicking the
F5
key or selectingShow Last Messages
from the Simulations menu. -
The
Qucs
data fileknowm_mr_pulse_j.dat.jspice
produced by the transient simulation will be automatically created in the$HOME/.qucs/KnowmMemristor_J_prj/
directory.
Cartesian Plot of Memristor I,V vs. Time Results
-
You should also observe the results in the specified JSpice I,V vs. Time plot defined in the schematic.
NOTE: The results again contain
0 V
to1 V
with the pulse width10 us
at1 V
and20 us
pulse width at0 V
with a combined period of30 us
and duty cycle33.3%
. These results closely agree with the Xyce simulation results above.
Calculate R(MR) and G(MR) vs. Pulse Number using Octave
For a detailed description of Octave script stuctures in Qucs-S and how to write and execute an Octave script to extract data from the simulation results read the post Using GNU Octave Scripts for Post-Analysis of Xyce Simulation Results within Qucs-S Graphical User Interface.
Set Document Settings
Only one of the two Qucs-S/Octave
simulation data post-processing methods can be active at any one time. To select which check the correct boxes in the Edit File Properties
window located under File
->Document Settings
. For example when box open data display after simulation is ticked and box run script after simulation is NOT ticked then the Manual method is selected. Reversing which box is ticked results in selection of the Automatic method of Octave post-simulation data processing.
- Right click on the schematic and select
Document Settings...
-
Select
Simulation
tab. -
Uncheck
open data display after simulation
checkbox in the dialog. -
Check the
run script after simulation
checkbox in the dialog. -
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 theknowm_mr_pulse_j.sch
schematic file.
Open Octave Window
The Octave interpreter can be run in Qucs-S GUI mode, as a console, or invoked as part of a shell script.
- Select
View
->Octave Window
from the Main Menu.NOTE: This should open the Octave console window at the bottom of the screen and start the Octave command interpreter.
Run a Xyce Simulation
-
Press
Simulation
->Simulate
on the main menu or selectSimulate
button on the toolbar. -
Check simulation for
errors
orwarnings
. See the status bar at the bottom of the Qucs windowlower right corner
. -
You can save the current netlist by clicking the
Save Netlist
button on the simulation window.NOTE: The
F6
key orShow Last Netlist
from the Simulations menu currently only displays the last netlist for the latest
Qucsator simulation. If you save the netlist using the button on the simulation window then you can open the.cir
file underOthers
list in the project tree. -
Click the
Exit
button to close theSimulation
window.
View Octave Window Output
The Octave interpreter should now be configured to automatically execute the knowm_mr_pulse_j.m
script, and write debug output to the Octave console output window.
- The Octave console window should display the output of the script. You should observe the text
parsing data . .. ...
-
Once the data is parsed the debug output will be displayed in the
Octave console
. -
Next (2) plot windows should be created by the
Qt
plot subsystem.NOTE: These plot windows may not be visible due to the fact that the Qucs-S interface may regain focus. You can switch the window focus to the
octave-gui
process by using the key sequence Command ⌘-Tab. -
The first plot is the Memristor Resistance vs. the Pulse number.
-
The second plot is the Memristor Conductance vs. the Pulse number.
NOTE: The Octave script will require modification to support the JSpice simulation data. The Octave script included in this project works with Xyce simulation data only. Additional features will be added to JSpice in the future that will allow a single Octave script to work with both simulators. More information will be available soon in another blog post. Check back with us for further developments regarding JSpice features.
JSpice
is still under development and we will be adding features that are most useful to our mission to provide OSS EDA tools to those of you who are interested in developing neuromorphic circuits using memristor-based synapses. We will be accepting feedback and will be building a wish list for additional requested features for JSpice that may be found in other SPICE compatible simulators. Please leave a comment or send us e-mail through the knowm.org site’s contact page.
1 2 |
Please consider joining the KDC `Knowm Developer Community` or become a `Knowm OSS EDA Contributor` to help build out these and other features you would like to see implemented in the tools. |
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.
References
- Comparing Simulation Results for the Knowm M-MSS Model in Xyce and JSpice Using Qucs-S
- JSpice GitHub repository
- 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/
General Notes on Usage
Default simulator selection
When selecting a new default simulator, if you want the change to be persistent after closing Qucs-S then you need to do the following steps.
- Select
Simulation
->Select default simulator
. -
Select the simulator in the
Default simulator
drop-down list. -
Click
Apply changes
. -
Select
File
->Application Settings
. -
Click
Apply
to save the settings. -
Click
OK
to exit the dialog. -
Select
Qucs
->Quit Qucs
.NOTE: Several of the features of the Qucs-S user interface are displayed based on the
Default simulator
which is saved in theQucsSettings
file updated when you save theApplication Settings
for the program. If you don’t perform the steps outlined above before closing Qucs-S then theDefault simulator
selection will not be saved and the will not be set when reopening Qucs-S. This issue should be corrected in a future version of the software.
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
Subscribe To Our Newsletter
Join our low volume mailing list to receive the latest news and updates from our team.