Download, install and configure SLiCAP¶
Download and Install SLiCAP¶
SLiCAP is available under the following license:
SLiCAP by Anton Montagne is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. Based on a work at: http://www.analog-electronics.eu/slicap/slicap.html
Install SLiCAP¶
SLiCAP consists of a set of MATLAB® and MuPAD® scripts, symbols for schematic capture programs (LTspice and gSchem), style sheets for HTML pages and device library files. These files can be downloaded and installed from within MATLAB®.
- Download installSLiCAP.p.
- Simply run it in MATLAB®, it will ask for the ‘SLiCAP_INSTALLPATH’ and copy all the files to it.
In order to run SLiCAP you must have a valid license for running MATLAB® and its Symbolic Math Toolbox, version R2014a or later.
You can test the installation by typing:
- ‘path’ in the MATLAB® command window. This should display the MATLAB® search paths and the SLiCAP installation path should be included.
- ‘Help’ (with capital ‘H’) in the MATLAB® command window. The MATLAB® browser should then display the SLiCAP help file.
File extensions¶
The file extension for SLiCAP netlist files is "cir"; it cannot be changed.
Use metric prefixes¶
The following metric prefixes can be used:
| name | Symbol | Base 10 value |
|---|---|---|
| peta | P | \(10^{15}\) |
| tera | T | \(10^{12}\) |
| giga | G | \(10^9\) |
| mega | M | \(10^6\) |
| kilo | k | \(10^3\) |
| mili | m | \(10^{-3}\) |
| micro | u | \(10^{-6}\) |
| nano | n | \(10^{-9}\) |
| pico | p | \(10^{-12}\) |
| femto | f | \(10^{-15}\) |
| atto | a | \(10^{-18}\) |
Please notice that these prefixes are case sensitive and differ from standard SPICE syntax.
From version 0.4 build 1350 the expression syntax checker can handle parameter names identical to metric prefixes. View the netlist syntax section for more information.
Initialize a SLiCAP project¶
Starting a SLiCAP project is as simple creating a project m-file that you store in some project directory. This m-file starts with:
% Save this file in your project directory
% Always run it from this directory
%
clear all;
initProject('myProject', mfilename('fullpath'));
% Here you can insert calls to m-files that belong to this project
stophtml();
Running this file will:
- Create the required sub directory structure
- Create the MuPAD® startup file
SLiCAPsettings.muin the project directory - Copy the html style files to their required locations.
The MATLAB response to this code is:
+==========================================================+
| SLiCAP_V06_2030 released or installed: 2020-10-09 22:12 |
| Creative Commons 4.0 International License. |
| Type "Help" for help, or visit: |
| www.analog-electronics.eu/slicap/slicap.html. |
+----------------------------------------------------------+
| An open source (python) version of SLiCAP is available! |
| Please visit https://github.com/Lenty/SLiCAP_python and |
| www.analog-electronics.eu/slicap/slicap.html. |
| for more information about SLiCAP_python. |
| Developments and support of this MATLAB version will end |
| in 2021. |
| You are kindly requested to migrate to SLiCAP_python. |
+----------------------------------------------------------+
| Book: Structured Electronic Design. |
| SLiCAP (c) 2009-2020 Anton J.M. Montagne. |
+==========================================================+
* Running project: myProject *
Each time you run the above script after the directory structure has been created, the html style files will be overwritten. See section: HTML site structure for more information on html documentation.
After initialization of the project you will find the SLiCAPsettings.mu MuPAD script file in your project directory. This file can be edited, its contents will be described below.
The project files and the file SLiCAPsettings.mu will not be overwritten.
Configure SLiCAP options¶
The main part of SLiCAP has been written in the script language of the Symbolic Math Toolbox MuPAD®. All MuPAD® functions, except those required for the initialization have been put together in the file SLiCAP.mu in the MuPAD subdirectory in the SLiCAP install path.
Knowledge of the MuPAD® scripting language is not required when working with SLiCAP.
You can change the project-specific settings in the SLiCAP_settings.mu file in your project directory as described below.
SLiCAPsettings.mu¶
// MuPAD settings, this MuPAD file should be edited with care!
MATHJAXLOCAL := FALSE: // TRUE if mathJax has been installed locally in the
// SLiCAP installation path, else FALSE.
// User options:
FMAX := 1E13: // Maximum absolute value of the frequency of poles
// and zeros in rad/s. This suppresses false poles
// and zeros generated by rounding errors.
DISP := 4: // Number of significant digits to be displayed.
CALC := 20: // Number of significant digits for calculation.
MAXSUBS := 10: // Maximum number of nested substitutions.
LTSPICE_XU2X := TRUE: // Converts element identifier "XU" to "X".
GLOBAL_DEFS := [k = 1.38064852e-23, q = 1.60217662e-19, T = 300, U_T = k*T/q ,
epsilon_0 = 1/c^2/mu_0, epsilon_SiO2 = 3.9, mu_0=4*PI*1e-7,
c = 2.99792458e+08]:
// SLiCAP search path settings:
// "" = project directory.
// "subdir/" = subdirectory "subdir" in project directory.
CIRPATH := "": // Search path for schematics and netlist files:
// (.asc, .cir, .net, sch).
TXTPATH := "": // Search path for text include files (file2html.m).
CSVPATH := "": // Search path for CSV include files (csv2html.m).
IMGPATH := "": // Search path for image include files (img2html.m).
MathJax¶
SLiCAP uses MathJax to render LaTeX embedded in html. LaTeX is used for expressions. By default MathJax rendering of equations requires an Internet connection. The scripts of the MathJax CDN will then be used for this purpose. If you want to use MathJax without a web connection, you need to install it on the computer that needs to display your mathematical expressions. It should be installed in the directory: < SLiCAP_INSTALLPATH >/MathJax-latest/. In that case you also need to change the setting of MATHJAXLOCAL to TRUE. The best performance is obtained if you also install the MathJax fonts on your computer.
For proper rendering of equations you need to have JavaScript enabled in your browser.
Digits for calculation¶
You can set the number of digits for floating point calculation by changing the value of CALC. Its default value is 20. This number is only used after a number has been converted from a rational to a float. MuPAD® calculates in rationals with a very high precision.
Digits for displaying¶
You can change the number of digits for displaying floating point numbers by changing the value of DISP. This number defaults to 4.
Global parameters¶
SLiCAP has a number of built-in parameters. These parameters and their definitions are collected in the GLOBAL_DEFS list of variables.
You can change the values of these parameters or add other global parameters and their definitions to this list. The built-in parameters are described in the table below:
| name | Description | symbol | value | units |
|---|---|---|---|---|
| F | Frequency | \(F\) | Hz | |
| k | Boltzmann constant | \(k\) | \(1.38064852{\cdot}10^{-23}\) | J/K |
| q | Unit charge | \(q\) | \(1.60217662{\cdot}10^{-19}\) | C |
| T | Ambient temperature | \(T\) | \(300\) | K |
| c | Speed of light | \(c\) | \(2.9979245{\cdot}10^8\) | m/s |
| mu_0 | Permeability of vacuum | \({\mu_0}\) | \(4{\pi}{\cdot}10^{-7}\) | H/m |
| epsilon_0 | Permittivity of vacuum | \({\epsilon_0}\) | \(\frac{1}{c^2{\mu_0}}\) | F/m |
| epsilon_SiO2 | Relative permittivity of SiO2 | \({\epsilon_{\mathrm{SiO_2}}}\) | \(3.9\) | |
| U_T | Thermal voltage | \(U_T\) | \(\frac{kT}{q}\) | V |
These parameters are used in subcircuits in the slicap.lib library file. The parameter F is used in noise analysis. You can add global parameters in the GLOBAL_DEFS list. Deleting or changing existing parameter definitions may result in errors.
Path settings¶
Below the list of path settings:
CIRPATH
By default, SLiCAP looks for circuit files (.asc, .sch, .net and .cir) in the project directory. This search path is defined by the variable CIRPATH. Its value can be modified: use forward slashes and terminate the path string with a forward slash ‘/’ as shown in the example below.
CIRPATH := "cir/": // Search path for schematics and netlist files:
// (.asc, .cir, .net, sch).
- TXTPATH: sets the path for text files to be included on the HTML page (file2html.m).
- CSVPATH: sets the path for .csv files to be included on the HTML page (csv2html.m).
- IMGPATH: sets the path for image files to be included on the HTML page (img2html.m).
Way of working¶
The preferred way of working with SLiCAP is:
- For each project create a project file.
- From that file you call scripts in the project directory that perform the actual analysis.
Hence, you always execute the project file. This will properly update all html output files.
The project file has the following structure:
clear all;
initProject('myProject', mfilename('fullpath'));
scriptFile1();
scriptFile2();
.
.
.
stophtml(); % This closes the project index page with a foottext and proper HTML tags.
% Uncomment the last line if you have python-sphinx
% with the sphinx_bootstrap_theme installed.
% This will compile the REstructured text files into a website with navigation bars.
%system('sphinx-build rst/ sphinx/');
A script file scriptFileN.m has the following structure:
% The following line is used for checking a netlist and converting it into matrix equations.
checkCircuit('CircuitFileNameWithoutFileExtension'):
% Start an HTML page for displaying results:
htmlPage('Some title for a HTML page');
%
% SLiCAP and MATLAB instructions
%
% Close the current HTML with a foottext and proper HTML tags and start a new one:
htmlPage('A title for a new HTML page')
%
% SLiCAP and MATLAB instructions
%
stophtml(); % This closes the last HTML with a foottext and proper HTML tags.
Getting Help¶
Help is offered in three ways:
- Type ‘Help’ in the Matlab Command Window will display the HTML documentation in your browser.
- Type ‘help’ < functionName > in the Matlab Command Window will display help information for a specific function in the Matlab Command Window.
Schematic capture¶
SLiCAP accepts SPICE-like netlists. Many schematic capture programs can be configured to generate such netlists. SLiCAP comes with symbol libraries for LTspice, gSchem and lepton-eda.
For manual netlist generation please view the Device Models section in the help file.
LTspice¶
LTspice can be used for netlist generation. LTspice symbols for SLiCAP are included in the LTspice subdirectory in the SLiCAP install path. LTspice works with Windows and Linux (under Wine). A version for MAC is also available. Go to LTspice for the latest version.
For an overview of SLiCAP symbols for LTspice, please view the LTSpice section in the help file.
Gschem¶
The open source gschem package can also be used in conjunction with SLiCAP. This package is used by the author and symbols for SLiCAP built-in devices have been included in the SLiCAP zip file.
For an overview of SLiCAP symbols for gSchem, please view the gSchem section in the help file.
The improved gnet-spice-noqsi spice netlister should be used for netlist generation. SLiCAP has a built-in instruction for netlist generation with gschem and this netlister.
The application of gschem as front-end for SLiCAP has been tested under Linux and under Windows.
- Under Linux you can install it with the package manager. Please visit gEDA for more information.
- A windows installer for gschem can be downloaded from: gEDA-20130122.zip.
- The improved spice netlister can be downloaded from: gnet-spice-noqsi.
Linux installation
Linux installation of gschem and the gnet-spice-noqsi is well documented and straightforward.
After installation of gschem you need to create or modify the file: .gEDA/gafrc in your home directory with the contents:
(reset-component-library)
(component-library "<path to SLiCAP symbol Library>" "SLiCAP")
The component-library is found in the extracted SLiCAP_VXX_xxxx.zip file; in the subdirectory gschem/symbols/. Enter the complete path in the .gEDA/gafrc file.
If you wish to have a light background you can create or modify the file .gEDA/gschemrc in your home directory with the contents:
(load (build-path geda-rc-path "gschem-colormap-lightbg")) ; light background
Windows installation
Windows installation of gschem is straightforward: simply extract the gEDA-20130122.zip file and run the Windows installer. In the drop down menu of the “Select Components” dialog box select “Program only”, for the rest accept default settings.
The netlister is installed by copying the file gnet-spice-noqsi.scm from the extracted gnet-spice-noqsi.zip to: C:\Program Files (x86)\gEDA\gEDA\share\gEDA\scheme\gnet-spice-noqsi.
You need to create or modify the file gafrc in the C:\Users\<userName>\.gEDA\ directory. It should have the following content:
(reset-component-library)
(component-library "C:/Program Files (x86)/gEDA/gEDA/share/gEDA/sym/slicap")
The component library is found in the in the subdirectory gschem/symbols/ in the SLiCAP install path. Create a directory C:\Program Files (x86)\gEDA\gEDA\share\gEDA\sym\slicap and copy the component library to this directory.
If you wish to have a light background you can create or modify the file gschemrc in the C:\Users\<userName>\.gEDA\ directory. Its contents must be:
(load (build-path geda-rc-path "gschem-colormap-lightbg")) ; light background
Be sure you save these two files gafrc and gschemrc without any file extension.
Lepton-eda¶
Lepton-eda is a fork of geda-gaf. Please visit https://github.com/lepton-eda/lepton-eda for more information.
Linux information
The schematic symbols, the netlister and configuration information are located in the lepton-eda/ subdirectory of the SLiCAP install path. The netlister can also be downloaded from: https://github.com/noqsi/gnet-spice-noqsi.
For compact node names (important for use in symbolic expressions) you need to reconfigure the default net name prefix.
This is how it should be done under Ubuntu-based Linux systems:
sudo lepton-cli config --system "netlist" "default-net-name" ""
Display schematics on html pages¶
With LTspice you can print schematics to a .PDF file using a PDF printer.
With gschem running under MSwindows you can write your schematic file to a .PDF file.
For proper display of schematics on html pages these .PDF files need to be be converted to .SVG files, you can use pdf2svg for this purpose. Under Linux and Mac OS you need to install ‘psd2svg’ to make this work.
With gschem running under Linux or Mac OS you can write your schematic file to a .EPS file.
.EPS files can be converted into .PDF files using the epstopdf command.
Ghostscript is often available in the package manager of Linux distributions. Otherwise Ghostscript versions can be downloaded from: Ghostscript.
With lepton-eda running under Linux you can print to pdf or svg.
Inkscape .svg editor¶
When printing a schematic from LTspice with a PDF printer, the full path of the file will be listed at the bottom of the page. After the .PDF file has been converted into a .SVG file (see above), you can use inkscape to edit this SVG file and delete the footer.
Inkscape runs under Windows, Linux and Mac OS. Inkscape versions can be downloaded from: inkscape.org.