2018-06-06 11:42:26 -05:00
\hypertarget { spice_ spicePres} { } \section { Presentation} \label { spice_ spicePres}
2018-10-18 11:10:01 -05:00
The { \bfseries Spice} format was developped at the University of California, Berkeley. This parser/driver consists in a subset of S\+ P\+ I\+ C\+ E3 netlist format. (see \href { http://en.wikipedia.org/wiki/SPICE} { \tt http\+ ://en.\+ wikipedia.\+ org/wiki/\+ S\+ P\+ I\+ CE} for more informations).~\newline
2018-06-06 11:42:26 -05:00
\hypertarget { spice_ spiceAutrhos} { } \subsection { Author} \label { spice_ spiceAutrhos}
2018-10-18 11:10:01 -05:00
Damien Dupuis\+ : damien.\+ dupuis(at)lip6(.)fr\hypertarget { spice_ spiceDB} { } \section { Stand alone database structure} \label { spice_ spiceDB}
The database consists in several objects\+ :
2018-06-06 11:42:26 -05:00
\begin { DoxyItemize}
2018-10-18 11:10:01 -05:00
\item \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit} { S\+ P\+ I\+ C\+ E\+ ::\+ Circuit} }
\item \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ spice_ exception} { S\+ P\+ I\+ C\+ E\+ ::\+ Spice\+ Exception} }
\item \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt} { S\+ P\+ I\+ C\+ E\+ ::\+ Subckt} }
\item \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { S\+ P\+ I\+ C\+ E\+ ::\+ Instance} }
\item \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet} { S\+ P\+ I\+ C\+ E\+ ::\+ Mosfet} }
\item \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor} { S\+ P\+ I\+ C\+ E\+ ::\+ Capacitor} }
\item \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor} { S\+ P\+ I\+ C\+ E\+ ::\+ Resistor} }
\item \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ source} { S\+ P\+ I\+ C\+ E\+ ::\+ Source} }
\item \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ voltage} { S\+ P\+ I\+ C\+ E\+ ::\+ Voltage} }
\item \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ current} { S\+ P\+ I\+ C\+ E\+ ::\+ Current} }
2018-06-06 11:42:26 -05:00
\end { DoxyItemize} \hypertarget { spice_ spiceParser} { } \subsection { Using the parser} \label { spice_ spiceParser}
2019-05-27 11:49:51 -05:00
Simply load an Spice netlist file using the static function \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ aa8294fe7d9ceddb5653d08ecae3eaf36} { S\+ P\+ I\+ C\+ E\+ ::\+ Circuit\+ ::read\+ From\+ File()} } .\hypertarget { spice_ spiceDriver} { } \subsection { Using the driver} \label { spice_ spiceDriver}
2018-10-18 11:10:01 -05:00
Using the driver is very simple, user has to create a \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit} { S\+ P\+ I\+ C\+ E\+ ::\+ Circuit} } object and simply add others Spice objects like \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt} { S\+ P\+ I\+ C\+ E\+ ::\+ Subckt} } or \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { S\+ P\+ I\+ C\+ E\+ ::\+ Instance} } to it. Includes, libraries and parameters can also be added to \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit} { S\+ P\+ I\+ C\+ E\+ ::\+ Circuit} } . Finally use the S\+ P\+ I\+ C\+ E\+ ::\+ Circuit\+ ::write\+ To\+ File() method to dump the database to file.\hypertarget { spice_ spiceExamples} { } \section { Examples} \label { spice_ spiceExamples}
As said is the global presentation, V\+ L\+ SI S\+ A\+ PD project provides C++ libraries and Python modules for each supported format. In this section we present simple code examples to parse and drive a S\+ P\+ I\+ CE file using C++ or Python. The S\+ P\+ I\+ CE file considered describes a simple Miller O\+ TA\+ : { \ttfamily O\+ T\+ A\+ \_ \+ miller.\+ spi}
2018-06-06 11:42:26 -05:00
\begin { DoxyCodeInclude}
* Single-ended two-stage amplifier
.PARAM CC\_ VALUE=2.8794pF
.PARAM L\_ VALUE=0.340e-6
.SUBCKT currentMirrorPMOS d1 d2 s1 s2 param: l\_ val=0.0 w\_ val=0.0 nf\_ val=1 aeq\_ val=100e-6 temp\_ val=27
MP3 d1 d1 s1 s1 psvt l=l\_ val wf=\{ w\_ val/nf\_ val\} nf=nf\_ val aeq=aeq\_ val tempsimu=temp\_ val
MP4 d2 d1 s2 s2 psvt l=l\_ val wf=\{ w\_ val/nf\_ val\} nf=nf\_ val aeq=aeq\_ val tempsimu=temp\_ val
.ENDS currentMirrorPMOS
.SUBCKT diffPairNMOS d1 d2 g1 g2 s b param: l\_ val=0.0 w\_ val=0.0 nf\_ val=1 aeq\_ val=100e-6 temp\_ val=27
MN1 d1 g1 s b nsvt l=l\_ val wf=\{ w\_ val/nf\_ val\} nf=nf\_ val aeq=aeq\_ val tempsimu=temp\_ val
MN2 d2 g2 s b nsvt l=l\_ val wf=\{ w\_ val/nf\_ val\} nf=nf\_ val aeq=aeq\_ val tempsimu=temp\_ val
.ENDS diffPairNMOS
XCM 1 2 vdd vdd currentMirrorPMOS l\_ val=L\_ VALUE w\_ val=3.889618e-06 nf\_ val=2
XDP 1 2 vim vip 3 vss diffPairNMOS l\_ val=L\_ VALUE w\_ val=7.683346e-07 nf\_ val=4
MP6 vout 2 vdd vdd psvt l\_ val=L\_ VALUE w\_ val=3.558995e-05 nf\_ val=20
MN5 3 4 vss vss nsvt l\_ val=L\_ VALUE w\_ val=2.536703e-06 nf\_ val=4
MN7 vout 4 vss vss nsvt l\_ val=L\_ VALUE w\_ val=1.069083e-05 nf\_ val=16
MN8 4 4 vss vss nsvt l\_ val=L\_ VALUE w\_ val=2.536703e-06 nf\_ val=4
CC1 vout 2 CC\_ VALUE
.END
\end { DoxyCodeInclude}
All source codes are available in the { \ttfamily examples} directory.\hypertarget { spice_ spiceC} { } \subsection { C++} \label { spice_ spiceC}
\hypertarget { spice_ spiceParseC} { } \subsubsection { Parser} \label { spice_ spiceParseC}
2018-10-18 11:10:01 -05:00
The following code ({ \ttfamily parse\+ Spice.\+ cpp} ) is an example of how to parse a S\+ P\+ I\+ CE file using C++ library.
2018-06-06 11:42:26 -05:00
\begin { DoxyCodeInclude}
\textcolor { preprocessor} { #include <cstdlib>}
\textcolor { preprocessor} { #include <iostream>}
\textcolor { preprocessor} { #include <string>}
\textcolor { preprocessor} { #include <map>}
\textcolor { preprocessor} { #include <vector>}
2018-10-18 11:10:01 -05:00
\textcolor { keyword} { using namespace } \mbox { \hyperlink { namespacestd} { std} } ;
2018-06-06 11:42:26 -05:00
\textcolor { preprocessor} { #include "vlsisapd/spice/Circuit.h"}
\textcolor { preprocessor} { #include "vlsisapd/spice/SpiceException.h"}
\textcolor { preprocessor} { #include "vlsisapd/spice/Sources.h"}
\textcolor { preprocessor} { #include "vlsisapd/spice/Subckt.h"}
\textcolor { preprocessor} { #include "vlsisapd/spice/Instances.h"}
\textcolor { keywordtype} { int} main(\textcolor { keywordtype} { int} argc, \textcolor { keywordtype} { char} * argv[]) \{
\textcolor { keywordtype} { string} file = \textcolor { stringliteral} { ""} ;
\textcolor { keywordflow} { if} (argc == 1)
file = \textcolor { stringliteral} { "./OTA.cir"} ;
\textcolor { keywordflow} { else} \textcolor { keywordflow} { if} (argc == 2)
file = argv[1];
\textcolor { keywordflow} { else} \{
cerr << \textcolor { stringliteral} { "Usage: parseSpice [filename]"} << endl;
exit(1);
\}
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit} { SPICE::Circuit} } * circuit = NULL;
2018-06-06 11:42:26 -05:00
\textcolor { keywordflow} { try} \{
2019-05-27 11:49:51 -05:00
circuit = \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ aa8294fe7d9ceddb5653d08ecae3eaf36} { SPICE::Circuit::readFromFile} } (file);
2018-10-18 11:10:01 -05:00
\} \textcolor { keywordflow} { catch} (\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ spice_ exception} { SPICE::SpiceException} } & e) \{
2018-06-06 11:42:26 -05:00
cerr << e.what() << endl;
exit(48);
\}
\textcolor { comment} { // if (!circuit) cerr << "circuit is NULL !!" << endl;}
\textcolor { comment} { // TITLE}
2018-10-18 11:10:01 -05:00
cerr << \textcolor { stringliteral} { "+ "} << circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ ad19721dd878c04c854a72af12d785741} { getTitle} } () << endl;
2018-06-06 11:42:26 -05:00
\textcolor { comment} { // INCLUDES}
2018-10-18 11:10:01 -05:00
vector<string> includes = circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a312beaf640e84589e6644820355c8ed6} { getIncludes} } ();
2018-06-06 11:42:26 -05:00
\textcolor { keywordflow} { if} (includes.size()) \{
cerr << \textcolor { stringliteral} { "| + includes"} << endl;
\textcolor { keywordflow} { for} (\textcolor { keywordtype} { size\_ t} i = 0 ; i < includes.size() ; i++)
cerr << \textcolor { stringliteral} { "| | "} << includes[i] << endl;
\}
\textcolor { comment} { // LIBRARIES}
2018-10-18 11:10:01 -05:00
vector<pair<string, string> > libs = circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a3e6a71a711e4796470f1a2a1dc42aef6} { getLibraries} } ();
2018-06-06 11:42:26 -05:00
\textcolor { keywordflow} { if} (libs.size()) \{
cerr << \textcolor { stringliteral} { "| + libraries"} << endl;
\textcolor { keywordflow} { for} (\textcolor { keywordtype} { size\_ t} i = 0 ; i < libs.size() ; i++)
cerr << \textcolor { stringliteral} { "| | "} << libs[i].first << \textcolor { stringliteral} { " "} << libs[i].second << endl;
\}
\textcolor { comment} { // PARAMETERS}
2018-10-18 11:10:01 -05:00
map<string, string> params = circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a4c46676f9ead2db537a0dd963b4f08f1} { getParameters} } ();
2018-06-06 11:42:26 -05:00
\textcolor { keywordflow} { if} (params.size()) \{
cerr << \textcolor { stringliteral} { "| + parameters"} << endl;
\textcolor { keywordflow} { for} (map<string, string>::const\_ iterator it = params.begin() ; it != params.end() ; ++it)
cerr << \textcolor { stringliteral} { "| | "} << (*it).first << \textcolor { stringliteral} { " = "} << (*it).second << endl;
\}
\textcolor { comment} { // OPTIONS}
2018-10-18 11:10:01 -05:00
map<string, string> opts = circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a4ee11ef79ef893c5621e0e7d26a7f9a7} { getOptions} } ();
2018-06-06 11:42:26 -05:00
\textcolor { keywordflow} { if} (opts.size()) \{
cerr << \textcolor { stringliteral} { "| + options"} << endl;
\textcolor { keywordflow} { for} (map<string, string>::const\_ iterator it = opts.begin() ; it != opts.end() ; ++it)
cerr << \textcolor { stringliteral} { "| | "} << (*it).first << \textcolor { stringliteral} { " = "} << (*it).second << endl;
\}
\textcolor { comment} { // SOURCES}
2018-10-18 11:10:01 -05:00
vector<SPICE::Source*> sources = circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ ac18caa525ed386c44874ee643c88e27b} { getSources} } ();
2018-06-06 11:42:26 -05:00
\textcolor { keywordflow} { if} (sources.size()) \{
cerr << \textcolor { stringliteral} { "| + sources"} << endl;
\textcolor { keywordflow} { for} (\textcolor { keywordtype} { size\_ t} i = 0 ; i < sources.size() ; i++) \{
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ source} { SPICE::Source} } * s = sources[i];
cerr << \textcolor { stringliteral} { "| | "} << s->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ source_ ac0fc966d4386ddb71d99361e3fccb311} { getName} } () << \textcolor { stringliteral} { " "} << s->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ source_ a1adb347b9a2c2da556e4417ab0eec0e1} { getPositive} } () << \textcolor { stringliteral} { " "} << s->
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ source_ a8b4ab73ed1d99c533aa22af0a37ebb0d} { getNegative} } () << \textcolor { stringliteral} { " "} << s->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ source_ a4c052cb2622c580a250b2c783a436882} { getValue} } () << endl;
2018-06-06 11:42:26 -05:00
\}
\}
\textcolor { comment} { // SUBCKTS}
2018-10-18 11:10:01 -05:00
vector<SPICE::Subckt*> subs = circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ adcc4ca0de68f8ee05f0d5db3b7604930} { getSubckts} } ();
2018-06-06 11:42:26 -05:00
\textcolor { keywordflow} { if} (subs.size()) \{
cerr << \textcolor { stringliteral} { "| + subckts"} << endl;
\textcolor { keywordflow} { for} (\textcolor { keywordtype} { size\_ t} i = 0 ; i < subs.size() ; i++) \{
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt} { SPICE::Subckt} } * sub = subs[i];
cerr << \textcolor { stringliteral} { "| | + "} << sub->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ af55b1fe10eacd22c7ff3544b5ed32ef3} { getName} } ();
\textcolor { keywordflow} { for} (\textcolor { keywordtype} { size\_ t} j = 0 ; j < sub->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ a5df00fe6eb5e287abef28c76ce88bd1e} { getInterfaces} } ().size() ; j++)
cerr << \textcolor { stringliteral} { " "} << sub->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ a5df00fe6eb5e287abef28c76ce88bd1e} { getInterfaces} } ()[j];
\textcolor { keywordflow} { if} (sub->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} } ().size()) \{
2018-06-06 11:42:26 -05:00
cerr << \textcolor { stringliteral} { " param:"} ;
2018-10-18 11:10:01 -05:00
\textcolor { keywordflow} { for} (map<string, string>::const\_ iterator it = sub->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} } ().begin() ;
it != sub->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} } ().end() ; ++it)
2018-06-06 11:42:26 -05:00
cerr << \textcolor { stringliteral} { " "} << (*it).first << \textcolor { stringliteral} { "="} << (*it).second;
\}
cerr << endl;
2018-10-18 11:10:01 -05:00
\textcolor { keywordflow} { for} (\textcolor { keywordtype} { size\_ t} j = 0 ; j < sub->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ a8e6e58ffab876152a740092520c35d73} { getInstances} } ().size() ; j++) \{
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} } * inst = sub->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ a8e6e58ffab876152a740092520c35d73} { getInstances} } ()[j];
cerr << \textcolor { stringliteral} { "| | | + "} << inst->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ ac0fc966d4386ddb71d99361e3fccb311} { getName} } ();
2018-06-06 11:42:26 -05:00
\textcolor { keywordflow} { if} (dynamic\_ cast<SPICE::Mosfet*>(inst)) \{
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet} { SPICE::Mosfet} } * mos = \textcolor { keyword} { static\_ cast<} \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet} { SPICE::Mosfet} } *\textcolor { keyword} { >} (inst);
cerr << \textcolor { stringliteral} { " "} << mos->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet_ a7265f0565b8368070a3f09c6197a4e9b} { getDrain} } () << \textcolor { stringliteral} { " "} << mos->
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet_ a796d77755aac0828419f55ba2226bf15} { getGrid} } () << \textcolor { stringliteral} { " "} << mos->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet_ a1791f52b6b5043823c6f3376e8453e3a} { getSource} } () << \textcolor { stringliteral} { " "} << mos->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet_ a56484a169335450d6043ee20086ead93} { getBulk} } () << \textcolor { stringliteral} { " "} << mos->
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ afc74cbe93df9c473a53db83a325f8f9d} { getModel} } ();
2018-06-06 11:42:26 -05:00
\textcolor { keywordtype} { int} k = 0;
\textcolor { keywordflow} { for} (map<string, string>::const\_ iterator it =mos->
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} } ().begin() ; it != mos->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} } ().end(); ++it, k++) \{
2018-06-06 11:42:26 -05:00
\textcolor { keywordflow} { if} (k%6 == 0)
cerr << endl << \textcolor { stringliteral} { "| | | | +"} ;
cerr << \textcolor { stringliteral} { " "} << (*it).first << \textcolor { stringliteral} { "="} << (*it).second;
\}
\} \textcolor { keywordflow} { else} \textcolor { keywordflow} { if} (dynamic\_ cast<SPICE::Resistor*>(inst)) \{
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor} { SPICE::Resistor} } * res = \textcolor { keyword} { static\_ cast<}
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor} { SPICE::Resistor} } *\textcolor { keyword} { >} (inst);
cerr << \textcolor { stringliteral} { " "} << res->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor_ ab57aa52f48a5a56c89dd49eae66c1a0f} { getFirst} } () << \textcolor { stringliteral} { " "} << res->
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor_ a9665313821b2fca41e14b9865133af7f} { getSecond} } () << \textcolor { stringliteral} { " "} << res->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor_ a4c052cb2622c580a250b2c783a436882} { getValue} } ();
2018-06-06 11:42:26 -05:00
\} \textcolor { keywordflow} { else} \textcolor { keywordflow} { if} (dynamic\_ cast<SPICE::Capacitor*>(inst)) \{
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor} { SPICE::Capacitor} } * capa = \textcolor { keyword} { static\_ cast<}
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor} { SPICE::Capacitor} } *\textcolor { keyword} { >} (inst);
cerr << \textcolor { stringliteral} { " "} << capa->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor_ a1adb347b9a2c2da556e4417ab0eec0e1} { getPositive} } () << \textcolor { stringliteral} { " "} << capa->
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor_ a8b4ab73ed1d99c533aa22af0a37ebb0d} { getNegative} } () << \textcolor { stringliteral} { " "} << capa->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor_ a4c052cb2622c580a250b2c783a436882} { getValue} } ();
2018-06-06 11:42:26 -05:00
\} \textcolor { keywordflow} { else} \{
2018-10-18 11:10:01 -05:00
\textcolor { keywordflow} { for} (\textcolor { keywordtype} { size\_ t} k = 0 ; k < inst->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ acce8940edeaa3d79c522006f987e0711} { getConnectors} } ().size() ; k++)
cerr << \textcolor { stringliteral} { " "} << inst->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ acce8940edeaa3d79c522006f987e0711} { getConnectors} } ()[k];
cerr << \textcolor { stringliteral} { " "} << inst->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ afc74cbe93df9c473a53db83a325f8f9d} { getModel} } ();
2018-06-06 11:42:26 -05:00
\textcolor { keywordtype} { int} l = 0;
\textcolor { keywordflow} { for} (map<string, string>::const\_ iterator it = inst->
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} } ().begin() ; it != inst->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} } ().end() ; ++it, l++) \{
2018-06-06 11:42:26 -05:00
\textcolor { keywordflow} { if} (l%6 == 0)
cerr << endl << \textcolor { stringliteral} { "| | | | +"} ;
cerr << \textcolor { stringliteral} { " "} << (*it).first << \textcolor { stringliteral} { "="} << (*it).second;
\}
\}
cerr << endl;
\}
\}
\}
\textcolor { comment} { // INSTANCES}
2018-10-18 11:10:01 -05:00
vector<SPICE::Instance*> insts = circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a8e6e58ffab876152a740092520c35d73} { getInstances} } ();
2018-06-06 11:42:26 -05:00
\textcolor { keywordflow} { if} (insts.size()) \{
cerr << \textcolor { stringliteral} { "| + instances"} << endl;
\textcolor { keywordflow} { for} (\textcolor { keywordtype} { size\_ t} i = 0 ; i < insts.size() ; i++) \{
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} } * inst = insts[i];
cerr << \textcolor { stringliteral} { "| | + "} << inst->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ ac0fc966d4386ddb71d99361e3fccb311} { getName} } ();
2018-06-06 11:42:26 -05:00
\textcolor { keywordflow} { if} (dynamic\_ cast<SPICE::Mosfet*>(inst)) \{
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet} { SPICE::Mosfet} } * mos = \textcolor { keyword} { static\_ cast<} \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet} { SPICE::Mosfet} } *\textcolor { keyword} { >} (inst);
cerr << \textcolor { stringliteral} { " "} << mos->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet_ a7265f0565b8368070a3f09c6197a4e9b} { getDrain} } () << \textcolor { stringliteral} { " "} << mos->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet_ a796d77755aac0828419f55ba2226bf15} { getGrid} } () << \textcolor { stringliteral} { " "} << mos->
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet_ a1791f52b6b5043823c6f3376e8453e3a} { getSource} } () << \textcolor { stringliteral} { " "} << mos->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet_ a56484a169335450d6043ee20086ead93} { getBulk} } () << \textcolor { stringliteral} { " "} << mos->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ afc74cbe93df9c473a53db83a325f8f9d} { getModel} } ();
2018-06-06 11:42:26 -05:00
\textcolor { keywordtype} { int} j = 0;
2018-10-18 11:10:01 -05:00
\textcolor { keywordflow} { for} (map<string, string>::const\_ iterator it =mos->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} } ().begin() ; it
!= mos->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} } ().end(); ++it, j++) \{
2018-06-06 11:42:26 -05:00
\textcolor { keywordflow} { if} (j%6 == 0)
cerr << endl << \textcolor { stringliteral} { "| | | | +"} ;
cerr << \textcolor { stringliteral} { " "} << (*it).first << \textcolor { stringliteral} { "="} << (*it).second;
\}
\} \textcolor { keywordflow} { else} \textcolor { keywordflow} { if} (dynamic\_ cast<SPICE::Resistor*>(inst)) \{
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor} { SPICE::Resistor} } * res = \textcolor { keyword} { static\_ cast<}
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor} { SPICE::Resistor} } *\textcolor { keyword} { >} (inst);
cerr << \textcolor { stringliteral} { " "} << res->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor_ ab57aa52f48a5a56c89dd49eae66c1a0f} { getFirst} } () << \textcolor { stringliteral} { " "} << res->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor_ a9665313821b2fca41e14b9865133af7f} { getSecond} } () << \textcolor { stringliteral} { " "} << res->
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor_ a4c052cb2622c580a250b2c783a436882} { getValue} } ();
2018-06-06 11:42:26 -05:00
\} \textcolor { keywordflow} { else} \textcolor { keywordflow} { if} (dynamic\_ cast<SPICE::Capacitor*>(inst)) \{
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor} { SPICE::Capacitor} } * capa = \textcolor { keyword} { static\_ cast<}
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor} { SPICE::Capacitor} } *\textcolor { keyword} { >} (inst);
cerr << \textcolor { stringliteral} { " "} << capa->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor_ a1adb347b9a2c2da556e4417ab0eec0e1} { getPositive} } () << \textcolor { stringliteral} { " "} << capa->
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor_ a8b4ab73ed1d99c533aa22af0a37ebb0d} { getNegative} } () << \textcolor { stringliteral} { " "} << capa->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor_ a4c052cb2622c580a250b2c783a436882} { getValue} } ();
2018-06-06 11:42:26 -05:00
\} \textcolor { keywordflow} { else} \{
2018-10-18 11:10:01 -05:00
\textcolor { keywordflow} { for} (\textcolor { keywordtype} { size\_ t} k = 0 ; k < inst->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ acce8940edeaa3d79c522006f987e0711} { getConnectors} } ().size() ; k++)
cerr << \textcolor { stringliteral} { " "} << inst->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ acce8940edeaa3d79c522006f987e0711} { getConnectors} } ()[k];
cerr << \textcolor { stringliteral} { " "} << inst->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ afc74cbe93df9c473a53db83a325f8f9d} { getModel} } ();
2018-06-06 11:42:26 -05:00
\textcolor { keywordtype} { int} l = 0;
\textcolor { keywordflow} { for} (map<string, string>::const\_ iterator it = inst->
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} } ().begin() ; it != inst->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} } ().end() ; ++it, l++) \{
2018-06-06 11:42:26 -05:00
\textcolor { keywordflow} { if} (l%6 == 0)
cerr << endl << \textcolor { stringliteral} { "| | | +"} ;
cerr << \textcolor { stringliteral} { " "} << (*it).first << \textcolor { stringliteral} { "="} << (*it).second;
\}
\}
cerr << endl;
\}
\}
\textcolor { keywordflow} { return} 0;
\}
\end { DoxyCodeInclude}
\hypertarget { spice_ spiceDriveC} { } \subsubsection { Driver} \label { spice_ spiceDriveC}
2018-10-18 11:10:01 -05:00
This C++ code ({ \ttfamily drive\+ Spice.\+ cpp} ) generates an my\+ O\+ T\+ A.\+ spi file equivalent to the included one.
2018-06-06 11:42:26 -05:00
\begin { DoxyCodeInclude}
\textcolor { preprocessor} { #include <string>}
2018-10-18 11:10:01 -05:00
\textcolor { keyword} { using namespace } \mbox { \hyperlink { namespacestd} { std} } ;
2018-06-06 11:42:26 -05:00
\textcolor { preprocessor} { #include "vlsisapd/spice/Circuit.h"}
\textcolor { preprocessor} { #include "vlsisapd/spice/Subckt.h"}
\textcolor { preprocessor} { #include "vlsisapd/spice/Instances.h"}
\textcolor { keywordtype} { int} main(\textcolor { keywordtype} { int} argc, \textcolor { keywordtype} { char} * argv[]) \{
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit} { SPICE::Circuit} } * circuit = \textcolor { keyword} { new} \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit} { SPICE::Circuit} } ();
circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a798df9ebd558e22c85eeceb5202e3123} { setTitle} } (\textcolor { stringliteral} { "* Single-ended two-stage amplifier"} );
2018-06-06 11:42:26 -05:00
\textcolor { comment} { // PARAMS}
2018-10-18 11:10:01 -05:00
circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} } (\textcolor { stringliteral} { "CC\_ VALUE"} , \textcolor { stringliteral} { "2.8794pF"} );
circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} } (\textcolor { stringliteral} { "L\_ VALUE"} , \textcolor { stringliteral} { "0.340e-6"} );
2018-06-06 11:42:26 -05:00
\textcolor { comment} { // SUBCKTS}
\textcolor { comment} { // CurrentMirror}
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt} { SPICE::Subckt} } * CM = circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a0d1352e46d4537ce1e5f651de40e91a6} { addSubckt} } (\textcolor { stringliteral} { "currentMirrorPMOS"} );
CM->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} } (\textcolor { stringliteral} { "d1"} );
CM->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} } (\textcolor { stringliteral} { "d2"} );
CM->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} } (\textcolor { stringliteral} { "s1"} );
CM->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} } (\textcolor { stringliteral} { "s2"} );
CM->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} } (\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "0.0"} );
CM->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} } (\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "0.0"} );
CM->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} } (\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "1"} );
CM->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} } (\textcolor { stringliteral} { "aeq\_ val"} , \textcolor { stringliteral} { "100e-6"} );
CM->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} } (\textcolor { stringliteral} { "temp\_ val"} , \textcolor { stringliteral} { "27"} );
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} } * cmP3 = \textcolor { keyword} { new} \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet} { SPICE::Mosfet} } (\textcolor { stringliteral} { "P3"} , \textcolor { stringliteral} { "d1"} , \textcolor { stringliteral} { "d1"} , \textcolor { stringliteral} { "s1"} , \textcolor { stringliteral} { "s1"} , \textcolor { stringliteral} { "
2018-06-06 11:42:26 -05:00
psvt"} );
2018-10-18 11:10:01 -05:00
cmP3->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "l"} , \textcolor { stringliteral} { "l\_ val"} );
cmP3->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "wf"} , \textcolor { stringliteral} { "\{ w\_ val/nf\_ val\} "} );
cmP3->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "nf"} , \textcolor { stringliteral} { "nf\_ val"} );
cmP3->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "aeq"} , \textcolor { stringliteral} { "aeq\_ val"} );
cmP3->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "tempsimu"} , \textcolor { stringliteral} { "temp\_ val"} );
CM->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} } (cmP3);
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} } * cmP4 = \textcolor { keyword} { new} \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet} { SPICE::Mosfet} } (\textcolor { stringliteral} { "P4"} , \textcolor { stringliteral} { "d2"} , \textcolor { stringliteral} { "d1"} , \textcolor { stringliteral} { "s2"} , \textcolor { stringliteral} { "s2"} , \textcolor { stringliteral} { "
2018-06-06 11:42:26 -05:00
psvt"} );
2018-10-18 11:10:01 -05:00
cmP4->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "l"} , \textcolor { stringliteral} { "l\_ val"} );
cmP4->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "wf"} , \textcolor { stringliteral} { "\{ w\_ val/nf\_ val\} "} );
cmP4->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "nf"} , \textcolor { stringliteral} { "nf\_ val"} );
cmP4->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "aeq"} , \textcolor { stringliteral} { "aeq\_ val"} );
cmP4->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "tempsimu"} , \textcolor { stringliteral} { "temp\_ val"} );
CM->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} } (cmP4);
2018-06-06 11:42:26 -05:00
\textcolor { comment} { // DifferentialPair}
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt} { SPICE::Subckt} } * DP = circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a0d1352e46d4537ce1e5f651de40e91a6} { addSubckt} } (\textcolor { stringliteral} { "diffPairNMOS"} );
DP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} } (\textcolor { stringliteral} { "d1"} );
DP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} } (\textcolor { stringliteral} { "d2"} );
DP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} } (\textcolor { stringliteral} { "g1"} );
DP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} } (\textcolor { stringliteral} { "g2"} );
DP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} } (\textcolor { stringliteral} { "s"} );
DP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} } (\textcolor { stringliteral} { "b"} );
DP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} } (\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "0.0"} );
DP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} } (\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "0.0"} );
DP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} } (\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "1"} );
DP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} } (\textcolor { stringliteral} { "aeq\_ val"} , \textcolor { stringliteral} { "100e-6"} );
DP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} } (\textcolor { stringliteral} { "temp\_ val"} , \textcolor { stringliteral} { "27"} );
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} } * dpN1 = \textcolor { keyword} { new} \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet} { SPICE::Mosfet} } (\textcolor { stringliteral} { "N1"} , \textcolor { stringliteral} { "d1"} , \textcolor { stringliteral} { "g1"} , \textcolor { stringliteral} { "s"} , \textcolor { stringliteral} { "b"} , \textcolor { stringliteral} { "nsvt
2018-06-06 11:42:26 -05:00
"} );
2018-10-18 11:10:01 -05:00
dpN1->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "l"} , \textcolor { stringliteral} { "l\_ val"} );
dpN1->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "wf"} , \textcolor { stringliteral} { "\{ w\_ val/nf\_ val\} "} );
dpN1->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "nf"} , \textcolor { stringliteral} { "nf\_ val"} );
dpN1->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "aeq"} , \textcolor { stringliteral} { "aeq\_ val"} );
dpN1->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "tempsimu"} , \textcolor { stringliteral} { "temp\_ val"} );
DP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} } (dpN1);
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} } * dpN2 = \textcolor { keyword} { new} \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet} { SPICE::Mosfet} } (\textcolor { stringliteral} { "N2"} , \textcolor { stringliteral} { "d2"} , \textcolor { stringliteral} { "g2"} , \textcolor { stringliteral} { "s"} , \textcolor { stringliteral} { "b"} , \textcolor { stringliteral} { "nsvt
2018-06-06 11:42:26 -05:00
"} );
2018-10-18 11:10:01 -05:00
dpN2->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "l"} , \textcolor { stringliteral} { "l\_ val"} );
dpN2->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "wf"} , \textcolor { stringliteral} { "\{ w\_ val/nf\_ val\} "} );
dpN2->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "nf"} , \textcolor { stringliteral} { "nf\_ val"} );
dpN2->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "aeq"} , \textcolor { stringliteral} { "aeq\_ val"} );
dpN2->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "tempsimu"} , \textcolor { stringliteral} { "temp\_ val"} );
DP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} } (dpN2);
2018-06-06 11:42:26 -05:00
\textcolor { comment} { //INSTANCES}
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} } * iCM = \textcolor { keyword} { new} \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} } (\textcolor { stringliteral} { "CM"} , \textcolor { stringliteral} { "currentMirrorPMOS"} );
iCM->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} } (\textcolor { stringliteral} { "1"} );
iCM->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} } (\textcolor { stringliteral} { "2"} );
iCM->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} } (\textcolor { stringliteral} { "vdd"} );
iCM->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} } (\textcolor { stringliteral} { "vdd"} );
iCM->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
iCM->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "3.889618e-06"} );
iCM->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "2"} );
circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} } (iCM);
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} } * iDP = \textcolor { keyword} { new} \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} } (\textcolor { stringliteral} { "DP"} , \textcolor { stringliteral} { "diffPairNMOS"} );
iDP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} } (\textcolor { stringliteral} { "1"} );
iDP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} } (\textcolor { stringliteral} { "2"} );
iDP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} } (\textcolor { stringliteral} { "vim"} );
iDP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} } (\textcolor { stringliteral} { "vip"} );
iDP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} } (\textcolor { stringliteral} { "3"} );
iDP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} } (\textcolor { stringliteral} { "vss"} );
iDP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
iDP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "7.683346e-07"} );
iDP->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "4"} );
circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} } (iDP);
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} } * iP6 = \textcolor { keyword} { new} \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet} { SPICE::Mosfet} } (\textcolor { stringliteral} { "P6"} , \textcolor { stringliteral} { "vout"} , \textcolor { stringliteral} { "2"} , \textcolor { stringliteral} { "vdd"} , \textcolor { stringliteral} { "vdd"} , \textcolor { stringliteral} { "
2018-06-06 11:42:26 -05:00
psvt"} );
2018-10-18 11:10:01 -05:00
iP6->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
iP6->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "3.558995e-05"} );
iP6->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "20"} );
circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} } (iP6);
2018-06-06 11:42:26 -05:00
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} } * iN5 = \textcolor { keyword} { new} \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet} { SPICE::Mosfet} } (\textcolor { stringliteral} { "N5"} , \textcolor { stringliteral} { "3"} , \textcolor { stringliteral} { "4"} , \textcolor { stringliteral} { "vss"} , \textcolor { stringliteral} { "vss"} , \textcolor { stringliteral} { "
2018-06-06 11:42:26 -05:00
nsvt"} );
2018-10-18 11:10:01 -05:00
iN5->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
iN5->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "2.536703e-06"} );
iN5->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "4"} );
circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} } (iN5);
2018-06-06 11:42:26 -05:00
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} } * iN7 = \textcolor { keyword} { new} \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet} { SPICE::Mosfet} } (\textcolor { stringliteral} { "N7"} , \textcolor { stringliteral} { "vout"} , \textcolor { stringliteral} { "4"} , \textcolor { stringliteral} { "vss"} , \textcolor { stringliteral} { "vss"} , \textcolor { stringliteral} { "
2018-06-06 11:42:26 -05:00
nsvt"} );
2018-10-18 11:10:01 -05:00
iN7->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
iN7->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "1.069083e-05"} );
iN7->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "16"} );
circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} } (iN7);
2018-06-06 11:42:26 -05:00
2018-10-18 11:10:01 -05:00
\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} } * iN8 = \textcolor { keyword} { new} \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet} { SPICE::Mosfet} } (\textcolor { stringliteral} { "N8"} , \textcolor { stringliteral} { "4"} , \textcolor { stringliteral} { "4"} , \textcolor { stringliteral} { "vss"} , \textcolor { stringliteral} { "vss"} , \textcolor { stringliteral} { "
2018-06-06 11:42:26 -05:00
nsvt"} );
2018-10-18 11:10:01 -05:00
iN8->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
iN8->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "2.536703e-06"} );
iN8->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} } (\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "4"} );
circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} } (iN8);
2018-06-06 11:42:26 -05:00
2018-10-18 11:10:01 -05:00
circuit->\mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} } (\textcolor { keyword} { new} \mbox { \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor} { SPICE::Capacitor} } (\textcolor { stringliteral} { "C1"} , \textcolor { stringliteral} { "vout"} , \textcolor { stringliteral} { "2"} , \textcolor { stringliteral} { "CC\_ VALUE"} ));
2018-06-06 11:42:26 -05:00
circuit->writeToFile(\textcolor { stringliteral} { "./myOTA.spi"} );
\textcolor { keywordflow} { return} 0;
\}
\end { DoxyCodeInclude}
\begin { DoxyNote} { Note}
2018-10-18 11:10:01 -05:00
In order to compile these codes, a C\+ Make\+ Lists.\+ txt file is provided. User must set the \$ \+ V\+ L\+ S\+ I\+ S\+ A\+ P\+ D\+ \_ \+ \+ T\+ OP variable before running these commands in the directory containing the C\+ Make\+ Lists.\+ txt file\+ :
2018-06-06 11:42:26 -05:00
\begin { DoxyCode}
%> mkdir build; cd build
%> cmake ..
%> make
\end { DoxyCode}
\end { DoxyNote}
\hypertarget { spice_ spicePython} { } \subsection { Python} \label { spice_ spicePython}
\hypertarget { spice_ spiceParsePython} { } \subsubsection { Parser} \label { spice_ spiceParsePython}
2018-10-18 11:10:01 -05:00
The following python script ({ \ttfamily parse\+ Spice.\+ py} ) is an example of how to parse a S\+ P\+ I\+ CE file using python module.
2018-06-06 11:42:26 -05:00
\begin { DoxyCodeInclude}
2018-10-18 11:10:01 -05:00
\textcolor { keyword} { import} sys
\textcolor { keyword} { from} SPICE \textcolor { keyword} { import} *
\textcolor { keyword} { def } printContents(circuit):
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "+"} , circuit.title
\textcolor { keywordflow} { if} len(circuit.getIncludes()):
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| + includes"}
\textcolor { keywordflow} { for} include \textcolor { keywordflow} { in} circuit.getIncludes():
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| |"} , include
\textcolor { keywordflow} { if} len(circuit.getLibraries()):
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| + libraries"}
\textcolor { keywordflow} { for} (lib, typ) \textcolor { keywordflow} { in} circuit.getLibraries():
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| |"} , lib, typ
\textcolor { keywordflow} { if} len(circuit.getParameters()):
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| + parameters"}
\textcolor { keywordflow} { for} (name, value) \textcolor { keywordflow} { in} circuit.getParameters().items():
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| | %s=%s"}%(name, value)
\textcolor { keywordflow} { if} len(circuit.getOptions()):
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| + options"}
\textcolor { keywordflow} { for} (name, value) \textcolor { keywordflow} { in} circuit.getOptions().items():
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| | %s=%s"}%(name, value)
\textcolor { keywordflow} { if} len(circuit.getSources()):
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| + sources"}
\textcolor { keywordflow} { for} source \textcolor { keywordflow} { in} circuit.getSources():
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| |"} , source.getName(), source.getPositive(), source.getNegative(), source.getValue()
\textcolor { keywordflow} { if} len(circuit.getSubckts()):
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| + subckts"}
\textcolor { keywordflow} { for} sub \textcolor { keywordflow} { in} circuit.getSubckts():
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| | +"} , sub.getName(),
\textcolor { keywordflow} { for} interf \textcolor { keywordflow} { in} sub.getInterfaces():
\textcolor { keywordflow} { print} interf,
\textcolor { keywordflow} { if} len(sub.getParameters()):
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "param:"} ,
\textcolor { keywordflow} { for} (name, value) \textcolor { keywordflow} { in} sub.getParameters().items():
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "%s=%s"}%(name,value),
\textcolor { keywordflow} { print}
\textcolor { keywordflow} { for} inst \textcolor { keywordflow} { in} sub.getInstances():
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| | | +"} , inst.getName(),
\textcolor { keywordflow} { if} isinstance(inst, Mosfet):
\textcolor { keywordflow} { print} inst.getDrain(), inst.getGrid(), inst.getSource(), inst.getBulk(), inst.getModel(),
i = 0
\textcolor { keywordflow} { for} (name, value) \textcolor { keywordflow} { in} inst.getParameters().items():
\textcolor { keywordflow} { if} i%6 == 0:
\textcolor { keywordflow} { print}
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| | | | +"} ,
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "%s=%s"}%(name, value),
i += 1
\textcolor { keywordflow} { elif} isinstance(inst, Resistor):
\textcolor { keywordflow} { print} inst.getFirst(), inst.getSecond(), inst.getValue(),
\textcolor { keywordflow} { elif} isinstance(inst, Capacitor):
\textcolor { keywordflow} { print} inst.getPositive(), inst.getNegative(), inst.getValue(),
\textcolor { keywordflow} { else} :
\textcolor { keywordflow} { for} conn \textcolor { keywordflow} { in} inst.getConnectors():
\textcolor { keywordflow} { print} conn,
\textcolor { keywordflow} { print} inst.getModel(),
i = 0
\textcolor { keywordflow} { for} (name, value) \textcolor { keywordflow} { in} inst.getParameters().items():
\textcolor { keywordflow} { if} i%6 == 0:
\textcolor { keywordflow} { print}
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| | | | +"} ,
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "%s=%s"}%(name, value),
i += 1
\textcolor { keywordflow} { print}
\textcolor { keywordflow} { if} len(circuit.getInstances()):
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| + instances"}
\textcolor { keywordflow} { for} inst \textcolor { keywordflow} { in} circuit.getInstances():
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| | | +"} , inst.getName(),
\textcolor { keywordflow} { if} isinstance(inst, Mosfet):
\textcolor { keywordflow} { print} inst.getDrain(), inst.getGrid(), inst.getSource(), inst.getBulk(), inst.getModel(),
i = 0
\textcolor { keywordflow} { for} (name, value) \textcolor { keywordflow} { in} inst.getParameters().items():
\textcolor { keywordflow} { if} i%6 == 0:
\textcolor { keywordflow} { print}
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| | | | +"} ,
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "%s=%s"}%(name, value),
i += 1
\textcolor { keywordflow} { elif} isinstance(inst, Resistor):
\textcolor { keywordflow} { print} inst.getFirst(), inst.getSecond(), inst.getValue(),
\textcolor { keywordflow} { elif} isinstance(inst, Capacitor):
\textcolor { keywordflow} { print} inst.getPositive(), inst.getNegative(), inst.getValue(),
\textcolor { keywordflow} { else} :
\textcolor { keywordflow} { for} conn \textcolor { keywordflow} { in} inst.getConnectors():
\textcolor { keywordflow} { print} conn,
\textcolor { keywordflow} { print} inst.getModel(),
i = 0
\textcolor { keywordflow} { for} (name, value) \textcolor { keywordflow} { in} inst.getParameters().items():
\textcolor { keywordflow} { if} i%6 == 0:
\textcolor { keywordflow} { print}
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "| | | | +"} ,
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "%s=%s"}%(name, value),
i += 1
\textcolor { keywordflow} { print}
\textcolor { keyword} { def } usage():
\textcolor { keywordflow} { print} \textcolor { stringliteral} { "usage:"} , sys.argv[0], \textcolor { stringliteral} { "[filename]"}
sys.exit(48)
\textcolor { keyword} { def } main():
\textcolor { keywordflow} { if} len(sys.argv) == 1:
filename = \textcolor { stringliteral} { "./OTA\_ miller.spi"}
\textcolor { keywordflow} { elif} len(sys.argv) == 2:
filename = sys.argv[1]
\textcolor { keywordflow} { else} :
usage()
circuit = Circuit.readFromFile(filename)
printContents(circuit)
\textcolor { keywordflow} { if} \_ \_ name\_ \_ == \textcolor { stringliteral} { "\_ \_ main\_ \_ "} :
main()
2018-06-06 11:42:26 -05:00
\end { DoxyCodeInclude}
\hypertarget { spice_ spiceDrivePython} { } \subsubsection { Driver} \label { spice_ spiceDrivePython}
2018-10-18 11:10:01 -05:00
This python script ({ \ttfamily drive\+ Spice.\+ py} ) generates an my\+ O\+ T\+ A.\+ spi file equivalent to the included one.
2018-06-06 11:42:26 -05:00
\begin { DoxyCodeInclude}
2018-10-18 11:10:01 -05:00
\textcolor { keyword} { from} SPICE \textcolor { keyword} { import} *
2019-05-27 11:49:51 -05:00
circuit = \mbox { \hyperlink { class_ circuit} { Circuit} } ()
2018-10-18 11:10:01 -05:00
circuit.title = \textcolor { stringliteral} { '* Single-ended two-stage amplifier'}
\textcolor { comment} { # PARAMS}
circuit.addParameter(\textcolor { stringliteral} { "CC\_ VALUE"} , \textcolor { stringliteral} { "2.8794pF"} );
circuit.addParameter(\textcolor { stringliteral} { "L\_ VALUE"} , \textcolor { stringliteral} { "0.340e-6"} );
\textcolor { comment} { # SUBCKTS}
\textcolor { comment} { # CurrentMirror}
CM = circuit.addSubckt(\textcolor { stringliteral} { "currentMirrorPMOS"} );
CM.addInterface(\textcolor { stringliteral} { "d1"} );
CM.addInterface(\textcolor { stringliteral} { "d2"} );
CM.addInterface(\textcolor { stringliteral} { "s1"} );
CM.addInterface(\textcolor { stringliteral} { "s2"} );
CM.addParameter(\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "0.0"} );
CM.addParameter(\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "0.0"} );
CM.addParameter(\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "1"} );
CM.addParameter(\textcolor { stringliteral} { "aeq\_ val"} , \textcolor { stringliteral} { "100e-6"} );
CM.addParameter(\textcolor { stringliteral} { "temp\_ val"} , \textcolor { stringliteral} { "27"} );
cmP3 = Mosfet(\textcolor { stringliteral} { "P3"} , \textcolor { stringliteral} { "d1"} , \textcolor { stringliteral} { "d1"} , \textcolor { stringliteral} { "s1"} , \textcolor { stringliteral} { "s1"} , \textcolor { stringliteral} { "psvt"} );
cmP3.addParameter(\textcolor { stringliteral} { "l"} , \textcolor { stringliteral} { "l\_ val"} );
cmP3.addParameter(\textcolor { stringliteral} { "wf"} , \textcolor { stringliteral} { "\{ w\_ val/nf\_ val\} "} );
cmP3.addParameter(\textcolor { stringliteral} { "nf"} , \textcolor { stringliteral} { "nf\_ val"} );
cmP3.addParameter(\textcolor { stringliteral} { "aeq"} , \textcolor { stringliteral} { "aeq\_ val"} );
cmP3.addParameter(\textcolor { stringliteral} { "tempsimu"} , \textcolor { stringliteral} { "temp\_ val"} );
CM.addInstance(cmP3);
cmP4 = Mosfet(\textcolor { stringliteral} { "P4"} , \textcolor { stringliteral} { "d2"} , \textcolor { stringliteral} { "d1"} , \textcolor { stringliteral} { "s2"} , \textcolor { stringliteral} { "s2"} , \textcolor { stringliteral} { "psvt"} );
cmP4.addParameter(\textcolor { stringliteral} { "l"} , \textcolor { stringliteral} { "l\_ val"} );
cmP4.addParameter(\textcolor { stringliteral} { "wf"} , \textcolor { stringliteral} { "\{ w\_ val/nf\_ val\} "} );
cmP4.addParameter(\textcolor { stringliteral} { "nf"} , \textcolor { stringliteral} { "nf\_ val"} );
cmP4.addParameter(\textcolor { stringliteral} { "aeq"} , \textcolor { stringliteral} { "aeq\_ val"} );
cmP4.addParameter(\textcolor { stringliteral} { "tempsimu"} , \textcolor { stringliteral} { "temp\_ val"} );
CM.addInstance(cmP4);
\textcolor { comment} { # DifferentialPair}
DP = circuit.addSubckt(\textcolor { stringliteral} { "diffPairNMOS"} );
DP.addInterface(\textcolor { stringliteral} { "d1"} );
DP.addInterface(\textcolor { stringliteral} { "d2"} );
DP.addInterface(\textcolor { stringliteral} { "g1"} );
DP.addInterface(\textcolor { stringliteral} { "g2"} );
DP.addInterface(\textcolor { stringliteral} { "s"} );
DP.addInterface(\textcolor { stringliteral} { "b"} );
DP.addParameter(\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "0.0"} );
DP.addParameter(\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "0.0"} );
DP.addParameter(\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "1"} );
DP.addParameter(\textcolor { stringliteral} { "aeq\_ val"} , \textcolor { stringliteral} { "100e-6"} );
DP.addParameter(\textcolor { stringliteral} { "temp\_ val"} , \textcolor { stringliteral} { "27"} );
dpN1 = Mosfet(\textcolor { stringliteral} { "N1"} , \textcolor { stringliteral} { "d1"} , \textcolor { stringliteral} { "g1"} , \textcolor { stringliteral} { "s"} , \textcolor { stringliteral} { "b"} , \textcolor { stringliteral} { "nsvt"} );
dpN1.addParameter(\textcolor { stringliteral} { "l"} , \textcolor { stringliteral} { "l\_ val"} );
dpN1.addParameter(\textcolor { stringliteral} { "wf"} , \textcolor { stringliteral} { "\{ w\_ val/nf\_ val\} "} );
dpN1.addParameter(\textcolor { stringliteral} { "nf"} , \textcolor { stringliteral} { "nf\_ val"} );
dpN1.addParameter(\textcolor { stringliteral} { "aeq"} , \textcolor { stringliteral} { "aeq\_ val"} );
dpN1.addParameter(\textcolor { stringliteral} { "tempsimu"} , \textcolor { stringliteral} { "temp\_ val"} );
DP.addInstance(dpN1);
dpN2 = Mosfet(\textcolor { stringliteral} { "N2"} , \textcolor { stringliteral} { "d2"} , \textcolor { stringliteral} { "g2"} , \textcolor { stringliteral} { "s"} , \textcolor { stringliteral} { "b"} , \textcolor { stringliteral} { "nsvt"} );
dpN2.addParameter(\textcolor { stringliteral} { "l"} , \textcolor { stringliteral} { "l\_ val"} );
dpN2.addParameter(\textcolor { stringliteral} { "wf"} , \textcolor { stringliteral} { "\{ w\_ val/nf\_ val\} "} );
dpN2.addParameter(\textcolor { stringliteral} { "nf"} , \textcolor { stringliteral} { "nf\_ val"} );
dpN2.addParameter(\textcolor { stringliteral} { "aeq"} , \textcolor { stringliteral} { "aeq\_ val"} );
dpN2.addParameter(\textcolor { stringliteral} { "tempsimu"} , \textcolor { stringliteral} { "temp\_ val"} );
DP.addInstance(dpN2);
\textcolor { comment} { # INSTANCES}
2019-05-27 11:49:51 -05:00
iCM = \mbox { \hyperlink { class_ instance} { Instance} } (\textcolor { stringliteral} { "CM"} , \textcolor { stringliteral} { "currentMirrorPMOS"} );
2018-10-18 11:10:01 -05:00
iCM.addConnector(\textcolor { stringliteral} { "1"} );
iCM.addConnector(\textcolor { stringliteral} { "2"} );
iCM.addConnector(\textcolor { stringliteral} { "vdd"} );
iCM.addConnector(\textcolor { stringliteral} { "vdd"} );
iCM.addParameter(\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
iCM.addParameter(\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "3.889618e-06"} );
iCM.addParameter(\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "2"} );
circuit.addInstance(iCM);
2019-05-27 11:49:51 -05:00
iDP = \mbox { \hyperlink { class_ instance} { Instance} } (\textcolor { stringliteral} { "DP"} , \textcolor { stringliteral} { "diffPairNMOS"} );
2018-10-18 11:10:01 -05:00
iDP.addConnector(\textcolor { stringliteral} { "1"} );
iDP.addConnector(\textcolor { stringliteral} { "2"} );
iDP.addConnector(\textcolor { stringliteral} { "vim"} );
iDP.addConnector(\textcolor { stringliteral} { "vip"} );
iDP.addConnector(\textcolor { stringliteral} { "3"} );
iDP.addConnector(\textcolor { stringliteral} { "vss"} );
iDP.addParameter(\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
iDP.addParameter(\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "7.683346e-07"} );
iDP.addParameter(\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "4"} );
circuit.addInstance(iDP);
iP6 = Mosfet(\textcolor { stringliteral} { "P6"} , \textcolor { stringliteral} { "vout"} , \textcolor { stringliteral} { "2"} , \textcolor { stringliteral} { "vdd"} , \textcolor { stringliteral} { "vdd"} , \textcolor { stringliteral} { "psvt"} );
iP6.addParameter(\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
iP6.addParameter(\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "3.558995e-05"} );
iP6.addParameter(\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "20"} );
circuit.addInstance(iP6);
iN5 = Mosfet(\textcolor { stringliteral} { "N5"} , \textcolor { stringliteral} { "3"} , \textcolor { stringliteral} { "4"} , \textcolor { stringliteral} { "vss"} , \textcolor { stringliteral} { "vss"} , \textcolor { stringliteral} { "nsvt"} );
iN5.addParameter(\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
iN5.addParameter(\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "2.536703e-06"} );
iN5.addParameter(\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "4"} );
circuit.addInstance(iN5);
iN7 = Mosfet(\textcolor { stringliteral} { "N7"} , \textcolor { stringliteral} { "vout"} , \textcolor { stringliteral} { "4"} , \textcolor { stringliteral} { "vss"} , \textcolor { stringliteral} { "vss"} , \textcolor { stringliteral} { "nsvt"} );
iN7.addParameter(\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
iN7.addParameter(\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "1.069083e-05"} );
iN7.addParameter(\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "16"} );
circuit.addInstance(iN7);
iN8 = Mosfet(\textcolor { stringliteral} { "N8"} , \textcolor { stringliteral} { "4"} , \textcolor { stringliteral} { "4"} , \textcolor { stringliteral} { "vss"} , \textcolor { stringliteral} { "vss"} , \textcolor { stringliteral} { "nsvt"} );
iN8.addParameter(\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
iN8.addParameter(\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "2.536703e-06"} );
iN8.addParameter(\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "4"} );
circuit.addInstance(iN8);
capa = Capacitor(\textcolor { stringliteral} { "C1"} , \textcolor { stringliteral} { "vout"} , \textcolor { stringliteral} { "2"} , \textcolor { stringliteral} { "CC\_ VALUE"} )
circuit.addInstance(capa);
circuit.writeToFile(\textcolor { stringliteral} { "./myOTA.spi"} );
2018-06-06 11:42:26 -05:00
\end { DoxyCodeInclude}
\begin { DoxyNote} { Note}
2018-10-18 11:10:01 -05:00
In order to run these two scripts ({ \ttfamily parse\+ Spice.\+ py} \& drive\+ Spice.\+ py), user must ensure that \$ \+ P\+ Y\+ T\+ H\+ O\+ N\+ P\+ A\+ TH variable points to the directory containing S\+ P\+ I\+ C\+ E.\+ so module.
2018-06-06 11:42:26 -05:00
\end { DoxyNote}