2018-06-06 11:42:26 -05:00
\hypertarget { spice_ spicePres} { } \section { Presentation} \label { spice_ spicePres}
2018-08-19 06:27:09 -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\- C\- E} for more informations).\par
2018-06-06 11:42:26 -05:00
\hypertarget { spice_ spiceAutrhos} { } \subsection { Author} \label { spice_ spiceAutrhos}
2018-08-19 06:27:09 -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-08-19 06:27:09 -05:00
\item \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit} { S\- P\- I\- C\- E\- ::\- Circuit}
\item \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ spice_ exception} { S\- P\- I\- C\- E\- ::\- Spice\- Exception}
\item \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt} { S\- P\- I\- C\- E\- ::\- Subckt}
\item \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { S\- P\- I\- C\- E\- ::\- Instance}
\item \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet} { S\- P\- I\- C\- E\- ::\- Mosfet}
\item \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor} { S\- P\- I\- C\- E\- ::\- Capacitor}
\item \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor} { S\- P\- I\- C\- E\- ::\- Resistor}
\item \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ source} { S\- P\- I\- C\- E\- ::\- Source}
\item \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ voltage} { S\- P\- I\- C\- E\- ::\- Voltage}
\item \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}
2018-08-19 06:27:09 -05:00
Simply load an Spice netlist file using the static function S\- P\- I\- C\- E\- ::\- Circuit\- ::read\- From\- File().\hypertarget { spice_ spiceDriver} { } \subsection { Using the driver} \label { spice_ spiceDriver}
Using the driver is very simple, user has to create a \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit} { S\- P\- I\- C\- E\- ::\- Circuit} object and simply add others Spice objects like \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt} { S\- P\- I\- C\- E\- ::\- Subckt} or \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 \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\- S\- I S\- A\- P\- D 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\- C\- E file using C++ or Python. The S\- P\- I\- C\- E file considered describes a simple Miller O\- T\- A\- : { \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-08-19 06:27:09 -05:00
The following code ({ \ttfamily parse\- Spice.\- cpp} ) is an example of how to parse a S\- P\- I\- C\- E 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-08-19 06:27:09 -05:00
\textcolor { keyword} { using namespace } 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);
\}
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit} { SPICE::Circuit} * circuit = NULL;
\textcolor { keywordflow} { try} \{
circuit = SPICE::Circuit::readFromFile(file);
\} \textcolor { keywordflow} { catch} (\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ spice_ exception} { SPICE::SpiceException} & e) \{
cerr << e.what() << endl;
exit(48);
\}
\textcolor { comment} { // if (!circuit) cerr << "circuit is NULL !!" << endl;}
\textcolor { comment} { // TITLE}
cerr << \textcolor { stringliteral} { "+ "} << circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ ad19721dd878c04c854a72af12d785741} { getTitle} () << endl;
\textcolor { comment} { // INCLUDES}
vector<string> includes = circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a312beaf640e84589e6644820355c8ed6} { getIncludes} ();
\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}
vector<pair<string, string> > libs = circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a3e6a71a711e4796470f1a2a1dc42aef6} { getLibraries} ();
\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}
map<string, string> params = circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a4c46676f9ead2db537a0dd963b4f08f1} { getParameters} ();
\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}
map<string, string> opts = circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a4ee11ef79ef893c5621e0e7d26a7f9a7} { getOptions} ();
\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}
vector<SPICE::Source*> sources = circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ ac18caa525ed386c44874ee643c88e27b} { getSources} ();
\textcolor { keywordflow} { if} (sources.size()) \{
cerr << \textcolor { stringliteral} { "| + sources"} << endl;
\textcolor { keywordflow} { for} (\textcolor { keywordtype} { size\_ t} i = 0 ; i < sources.size() ; i++) \{
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ source} { SPICE::Source} * s = sources[i];
cerr << \textcolor { stringliteral} { "| | "} << s->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ source_ ac0fc966d4386ddb71d99361e3fccb311} { getName} () << \textcolor { stringliteral} { " "} << s->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ source_ a1adb347b9a2c2da556e4417ab0eec0e1} { getPositive} () << \textcolor { stringliteral} { " "} << s->
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ source_ a8b4ab73ed1d99c533aa22af0a37ebb0d} { getNegative} () << \textcolor { stringliteral} { " "} << s->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ source_ a4c052cb2622c580a250b2c783a436882} { getValue} () << endl;
\}
\}
\textcolor { comment} { // SUBCKTS}
vector<SPICE::Subckt*> subs = circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ adcc4ca0de68f8ee05f0d5db3b7604930} { getSubckts} ();
\textcolor { keywordflow} { if} (subs.size()) \{
cerr << \textcolor { stringliteral} { "| + subckts"} << endl;
\textcolor { keywordflow} { for} (\textcolor { keywordtype} { size\_ t} i = 0 ; i < subs.size() ; i++) \{
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt} { SPICE::Subckt} * sub = subs[i];
cerr << \textcolor { stringliteral} { "| | + "} << sub->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ af55b1fe10eacd22c7ff3544b5ed32ef3} { getName} ();
\textcolor { keywordflow} { for} (\textcolor { keywordtype} { size\_ t} j = 0 ; j < sub->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ a5df00fe6eb5e287abef28c76ce88bd1e} { getInterfaces} ().size() ; j++)
cerr << \textcolor { stringliteral} { " "} << sub->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ a5df00fe6eb5e287abef28c76ce88bd1e} { getInterfaces} ()[j];
\textcolor { keywordflow} { if} (sub->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} ().size()) \{
cerr << \textcolor { stringliteral} { " param:"} ;
\textcolor { keywordflow} { for} (map<string, string>::const\_ iterator it = sub->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} ().begin() ;
it != sub->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} ().end() ; ++it)
cerr << \textcolor { stringliteral} { " "} << (*it).first << \textcolor { stringliteral} { "="} << (*it).second;
\}
cerr << endl;
\textcolor { keywordflow} { for} (\textcolor { keywordtype} { size\_ t} j = 0 ; j < sub->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ a8e6e58ffab876152a740092520c35d73} { getInstances} ().size() ; j++) \{
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} * inst = sub->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ a8e6e58ffab876152a740092520c35d73} { getInstances} ()[j];
cerr << \textcolor { stringliteral} { "| | | + "} << inst->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ ac0fc966d4386ddb71d99361e3fccb311} { getName} ();
\textcolor { keywordflow} { if} (dynamic\_ cast<SPICE::Mosfet*>(inst)) \{
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet} { SPICE::Mosfet} * mos = \textcolor { keyword} { static\_ cast<} \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet} { SPICE::Mosfet} *\textcolor { keyword} { >} (inst);
cerr << \textcolor { stringliteral} { " "} << mos->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet_ a7265f0565b8368070a3f09c6197a4e9b} { getDrain} () << \textcolor { stringliteral} { " "} << mos->
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet_ a796d77755aac0828419f55ba2226bf15} { getGrid} () << \textcolor { stringliteral} { " "} << mos->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet_ a1791f52b6b5043823c6f3376e8453e3a} { getSource} () << \textcolor { stringliteral} { " "} << mos->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet_ a56484a169335450d6043ee20086ead93} { getBulk} () << \textcolor { stringliteral} { " "} << mos->
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ afc74cbe93df9c473a53db83a325f8f9d} { getModel} ();
\textcolor { keywordtype} { int} k = 0;
\textcolor { keywordflow} { for} (map<string, string>::const\_ iterator it =mos->
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} ().begin() ; it != mos->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} ().end(); ++it, k++) \{
\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)) \{
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor} { SPICE::Resistor} * res = \textcolor { keyword} { static\_ cast<}
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor} { SPICE::Resistor} *\textcolor { keyword} { >} (inst);
cerr << \textcolor { stringliteral} { " "} << res->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor_ ab57aa52f48a5a56c89dd49eae66c1a0f} { getFirst} () << \textcolor { stringliteral} { " "} << res->
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor_ a9665313821b2fca41e14b9865133af7f} { getSecond} () << \textcolor { stringliteral} { " "} << res->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor_ a4c052cb2622c580a250b2c783a436882} { getValue} ();
\} \textcolor { keywordflow} { else} \textcolor { keywordflow} { if} (dynamic\_ cast<SPICE::Capacitor*>(inst)) \{
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor} { SPICE::Capacitor} * capa = \textcolor { keyword} { static\_ cast<}
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor} { SPICE::Capacitor} *\textcolor { keyword} { >} (inst);
cerr << \textcolor { stringliteral} { " "} << capa->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor_ a1adb347b9a2c2da556e4417ab0eec0e1} { getPositive} () << \textcolor { stringliteral} { " "} << capa->
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor_ a8b4ab73ed1d99c533aa22af0a37ebb0d} { getNegative} () << \textcolor { stringliteral} { " "} << capa->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor_ a4c052cb2622c580a250b2c783a436882} { getValue} ();
\} \textcolor { keywordflow} { else} \{
\textcolor { keywordflow} { for} (\textcolor { keywordtype} { size\_ t} k = 0 ; k < inst->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ acce8940edeaa3d79c522006f987e0711} { getConnectors} ().size() ; k++)
cerr << \textcolor { stringliteral} { " "} << inst->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ acce8940edeaa3d79c522006f987e0711} { getConnectors} ()[k];
cerr << \textcolor { stringliteral} { " "} << inst->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ afc74cbe93df9c473a53db83a325f8f9d} { getModel} ();
\textcolor { keywordtype} { int} l = 0;
\textcolor { keywordflow} { for} (map<string, string>::const\_ iterator it = inst->
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} ().begin() ; it != inst->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} ().end() ; ++it, l++) \{
\textcolor { keywordflow} { if} (l%6 == 0)
cerr << endl << \textcolor { stringliteral} { "| | | | +"} ;
cerr << \textcolor { stringliteral} { " "} << (*it).first << \textcolor { stringliteral} { "="} << (*it).second;
\}
\}
cerr << endl;
\}
\}
\}
\textcolor { comment} { // INSTANCES}
vector<SPICE::Instance*> insts = circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a8e6e58ffab876152a740092520c35d73} { getInstances} ();
\textcolor { keywordflow} { if} (insts.size()) \{
cerr << \textcolor { stringliteral} { "| + instances"} << endl;
\textcolor { keywordflow} { for} (\textcolor { keywordtype} { size\_ t} i = 0 ; i < insts.size() ; i++) \{
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} * inst = insts[i];
cerr << \textcolor { stringliteral} { "| | + "} << inst->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ ac0fc966d4386ddb71d99361e3fccb311} { getName} ();
\textcolor { keywordflow} { if} (dynamic\_ cast<SPICE::Mosfet*>(inst)) \{
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet} { SPICE::Mosfet} * mos = \textcolor { keyword} { static\_ cast<} \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet} { SPICE::Mosfet} *\textcolor { keyword} { >} (inst);
cerr << \textcolor { stringliteral} { " "} << mos->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet_ a7265f0565b8368070a3f09c6197a4e9b} { getDrain} () << \textcolor { stringliteral} { " "} << mos->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet_ a796d77755aac0828419f55ba2226bf15} { getGrid} () << \textcolor { stringliteral} { " "} << mos->
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet_ a1791f52b6b5043823c6f3376e8453e3a} { getSource} () << \textcolor { stringliteral} { " "} << mos->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ mosfet_ a56484a169335450d6043ee20086ead93} { getBulk} () << \textcolor { stringliteral} { " "} << mos->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ afc74cbe93df9c473a53db83a325f8f9d} { getModel} ();
\textcolor { keywordtype} { int} j = 0;
\textcolor { keywordflow} { for} (map<string, string>::const\_ iterator it =mos->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} ().begin() ; it
!= mos->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} ().end(); ++it, j++) \{
\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)) \{
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor} { SPICE::Resistor} * res = \textcolor { keyword} { static\_ cast<}
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor} { SPICE::Resistor} *\textcolor { keyword} { >} (inst);
cerr << \textcolor { stringliteral} { " "} << res->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor_ ab57aa52f48a5a56c89dd49eae66c1a0f} { getFirst} () << \textcolor { stringliteral} { " "} << res->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor_ a9665313821b2fca41e14b9865133af7f} { getSecond} () << \textcolor { stringliteral} { " "} << res->
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ resistor_ a4c052cb2622c580a250b2c783a436882} { getValue} ();
\} \textcolor { keywordflow} { else} \textcolor { keywordflow} { if} (dynamic\_ cast<SPICE::Capacitor*>(inst)) \{
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor} { SPICE::Capacitor} * capa = \textcolor { keyword} { static\_ cast<}
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor} { SPICE::Capacitor} *\textcolor { keyword} { >} (inst);
cerr << \textcolor { stringliteral} { " "} << capa->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor_ a1adb347b9a2c2da556e4417ab0eec0e1} { getPositive} () << \textcolor { stringliteral} { " "} << capa->
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor_ a8b4ab73ed1d99c533aa22af0a37ebb0d} { getNegative} () << \textcolor { stringliteral} { " "} << capa->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ capacitor_ a4c052cb2622c580a250b2c783a436882} { getValue} ();
\} \textcolor { keywordflow} { else} \{
\textcolor { keywordflow} { for} (\textcolor { keywordtype} { size\_ t} k = 0 ; k < inst->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ acce8940edeaa3d79c522006f987e0711} { getConnectors} ().size() ; k++)
cerr << \textcolor { stringliteral} { " "} << inst->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ acce8940edeaa3d79c522006f987e0711} { getConnectors} ()[k];
cerr << \textcolor { stringliteral} { " "} << inst->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ afc74cbe93df9c473a53db83a325f8f9d} { getModel} ();
\textcolor { keywordtype} { int} l = 0;
\textcolor { keywordflow} { for} (map<string, string>::const\_ iterator it = inst->
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} ().begin() ; it != inst->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ aee7d59083b78d31ac5c19ab508da91e0} { getParameters} ().end() ; ++it, l++) \{
\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-08-19 06:27:09 -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-08-19 06:27:09 -05:00
\textcolor { keyword} { using namespace } 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[]) \{
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit} { SPICE::Circuit} * circuit = \textcolor { keyword} { new} \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit} { SPICE::Circuit} ();
circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a798df9ebd558e22c85eeceb5202e3123} { setTitle} (\textcolor { stringliteral} { "* Single-ended two-stage amplifier"} );
\textcolor { comment} { // PARAMS}
circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} (\textcolor { stringliteral} { "CC\_ VALUE"} , \textcolor { stringliteral} { "2.8794pF"} );
circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} (\textcolor { stringliteral} { "L\_ VALUE"} , \textcolor { stringliteral} { "0.340e-6"} );
\textcolor { comment} { // SUBCKTS}
\textcolor { comment} { // CurrentMirror}
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt} { SPICE::Subckt} * CM = circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a0d1352e46d4537ce1e5f651de40e91a6} { addSubckt} (\textcolor { stringliteral} { "currentMirrorPMOS"} );
CM->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} (\textcolor { stringliteral} { "d1"} );
CM->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} (\textcolor { stringliteral} { "d2"} );
CM->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} (\textcolor { stringliteral} { "s1"} );
CM->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} (\textcolor { stringliteral} { "s2"} );
CM->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} (\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "0.0"} );
CM->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} (\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "0.0"} );
CM->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} (\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "1"} );
CM->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} (\textcolor { stringliteral} { "aeq\_ val"} , \textcolor { stringliteral} { "100e-6"} );
CM->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} (\textcolor { stringliteral} { "temp\_ val"} , \textcolor { stringliteral} { "27"} );
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} * cmP3 = \textcolor { keyword} { new} \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} { "
psvt"} );
cmP3->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "l"} , \textcolor { stringliteral} { "l\_ val"} );
cmP3->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "wf"} , \textcolor { stringliteral} { "\{ w\_ val/nf\_ val\} "} );
cmP3->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "nf"} , \textcolor { stringliteral} { "nf\_ val"} );
cmP3->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "aeq"} , \textcolor { stringliteral} { "aeq\_ val"} );
cmP3->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "tempsimu"} , \textcolor { stringliteral} { "temp\_ val"} );
CM->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} (cmP3);
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} * cmP4 = \textcolor { keyword} { new} \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} { "
psvt"} );
cmP4->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "l"} , \textcolor { stringliteral} { "l\_ val"} );
cmP4->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "wf"} , \textcolor { stringliteral} { "\{ w\_ val/nf\_ val\} "} );
cmP4->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "nf"} , \textcolor { stringliteral} { "nf\_ val"} );
cmP4->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "aeq"} , \textcolor { stringliteral} { "aeq\_ val"} );
cmP4->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "tempsimu"} , \textcolor { stringliteral} { "temp\_ val"} );
CM->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} (cmP4);
\textcolor { comment} { // DifferentialPair}
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt} { SPICE::Subckt} * DP = circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a0d1352e46d4537ce1e5f651de40e91a6} { addSubckt} (\textcolor { stringliteral} { "diffPairNMOS"} );
DP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} (\textcolor { stringliteral} { "d1"} );
DP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} (\textcolor { stringliteral} { "d2"} );
DP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} (\textcolor { stringliteral} { "g1"} );
DP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} (\textcolor { stringliteral} { "g2"} );
DP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} (\textcolor { stringliteral} { "s"} );
DP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ac162264683fa3d9b3384d3e8cc291fa2} { addInterface} (\textcolor { stringliteral} { "b"} );
DP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} (\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "0.0"} );
DP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} (\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "0.0"} );
DP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} (\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "1"} );
DP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} (\textcolor { stringliteral} { "aeq\_ val"} , \textcolor { stringliteral} { "100e-6"} );
DP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ ab3ab147a16bc490ce96db905a4ca271c} { addParameter} (\textcolor { stringliteral} { "temp\_ val"} , \textcolor { stringliteral} { "27"} );
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} * dpN1 = \textcolor { keyword} { new} \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
"} );
dpN1->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "l"} , \textcolor { stringliteral} { "l\_ val"} );
dpN1->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "wf"} , \textcolor { stringliteral} { "\{ w\_ val/nf\_ val\} "} );
dpN1->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "nf"} , \textcolor { stringliteral} { "nf\_ val"} );
dpN1->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "aeq"} , \textcolor { stringliteral} { "aeq\_ val"} );
dpN1->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "tempsimu"} , \textcolor { stringliteral} { "temp\_ val"} );
DP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} (dpN1);
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} * dpN2 = \textcolor { keyword} { new} \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
"} );
dpN2->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "l"} , \textcolor { stringliteral} { "l\_ val"} );
dpN2->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "wf"} , \textcolor { stringliteral} { "\{ w\_ val/nf\_ val\} "} );
dpN2->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "nf"} , \textcolor { stringliteral} { "nf\_ val"} );
dpN2->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "aeq"} , \textcolor { stringliteral} { "aeq\_ val"} );
dpN2->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "tempsimu"} , \textcolor { stringliteral} { "temp\_ val"} );
DP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ subckt_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} (dpN2);
\textcolor { comment} { //INSTANCES}
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} * iCM = \textcolor { keyword} { new} \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} (\textcolor { stringliteral} { "CM"} , \textcolor { stringliteral} { "currentMirrorPMOS"} );
iCM->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} (\textcolor { stringliteral} { "1"} );
iCM->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} (\textcolor { stringliteral} { "2"} );
iCM->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} (\textcolor { stringliteral} { "vdd"} );
iCM->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} (\textcolor { stringliteral} { "vdd"} );
iCM->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
iCM->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "3.889618e-06"} );
iCM->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "2"} );
circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} (iCM);
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} * iDP = \textcolor { keyword} { new} \hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} (\textcolor { stringliteral} { "DP"} , \textcolor { stringliteral} { "diffPairNMOS"} );
iDP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} (\textcolor { stringliteral} { "1"} );
iDP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} (\textcolor { stringliteral} { "2"} );
iDP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} (\textcolor { stringliteral} { "vim"} );
iDP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} (\textcolor { stringliteral} { "vip"} );
iDP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} (\textcolor { stringliteral} { "3"} );
iDP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ af9aeca34e780851a2b024df7c5ff5b54} { addConnector} (\textcolor { stringliteral} { "vss"} );
iDP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
iDP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "7.683346e-07"} );
iDP->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "4"} );
circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} (iDP);
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} * iP6 = \textcolor { keyword} { new} \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} { "
psvt"} );
iP6->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
iP6->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "3.558995e-05"} );
iP6->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "20"} );
circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} (iP6);
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} * iN5 = \textcolor { keyword} { new} \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} { "
nsvt"} );
iN5->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
iN5->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "2.536703e-06"} );
iN5->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "4"} );
circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} (iN5);
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} * iN7 = \textcolor { keyword} { new} \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} { "
nsvt"} );
iN7->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
iN7->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "1.069083e-05"} );
iN7->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "16"} );
circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} (iN7);
\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance} { SPICE::Instance} * iN8 = \textcolor { keyword} { new} \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} { "
nsvt"} );
iN8->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
iN8->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "2.536703e-06"} );
iN8->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ instance_ a8d69bbbea5ece0949e100c464e412f20} { addParameter} (\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "4"} );
circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} (iN8);
circuit->\hyperlink { class_ s_ p_ i_ c_ e_ 1_ 1_ circuit_ a7bb4a4532643568ab1ac2c229185a88e} { addInstance} (\textcolor { keyword} { new} \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"} ));
circuit->writeToFile(\textcolor { stringliteral} { "./myOTA.spi"} );
\textcolor { keywordflow} { return} 0;
\}
\end { DoxyCodeInclude}
\begin { DoxyNote} { Note}
2018-08-19 06:27:09 -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\- O\- P 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-08-19 06:27:09 -05:00
The following python script ({ \ttfamily parse\- Spice.\- py} ) is an example of how to parse a S\- P\- I\- C\- E file using python module.
2018-06-06 11:42:26 -05:00
\begin { DoxyCodeInclude}
2018-08-19 06:27:09 -05:00
1 \textcolor { keyword} { import} sys
2
3 \textcolor { keyword} { from} SPICE \textcolor { keyword} { import} *
4
5 \textcolor { keyword} { def } printContents(circuit):
6 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "+"} , circuit.title
7
8 \textcolor { keywordflow} { if} len(circuit.getIncludes()):
9 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| + includes"}
10 \textcolor { keywordflow} { for} include \textcolor { keywordflow} { in} circuit.getIncludes():
11 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| |"} , include
12
13 \textcolor { keywordflow} { if} len(circuit.getLibraries()):
14 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| + libraries"}
15 \textcolor { keywordflow} { for} (lib, typ) \textcolor { keywordflow} { in} circuit.getLibraries():
16 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| |"} , lib, typ
17
18 \textcolor { keywordflow} { if} len(circuit.getParameters()):
19 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| + parameters"}
20 \textcolor { keywordflow} { for} (name, value) \textcolor { keywordflow} { in} circuit.getParameters().items():
21 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| | %s=%s"}%(name, value)
22
23 \textcolor { keywordflow} { if} len(circuit.getOptions()):
24 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| + options"}
25 \textcolor { keywordflow} { for} (name, value) \textcolor { keywordflow} { in} circuit.getOptions().items():
26 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| | %s=%s"}%(name, value)
27
28 \textcolor { keywordflow} { if} len(circuit.getSources()):
29 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| + sources"}
30 \textcolor { keywordflow} { for} source \textcolor { keywordflow} { in} circuit.getSources():
31 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| |"} , source.getName(), source.getPositive(), source.getNegative(), source.getValue()
32
33 \textcolor { keywordflow} { if} len(circuit.getSubckts()):
34 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| + subckts"}
35 \textcolor { keywordflow} { for} sub \textcolor { keywordflow} { in} circuit.getSubckts():
36 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| | +"} , sub.getName(),
37 \textcolor { keywordflow} { for} interf \textcolor { keywordflow} { in} sub.getInterfaces():
38 \textcolor { keywordflow} { print} interf,
39 \textcolor { keywordflow} { if} len(sub.getParameters()):
40 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "param:"} ,
41 \textcolor { keywordflow} { for} (name, value) \textcolor { keywordflow} { in} sub.getParameters().items():
42 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "%s=%s"}%(name,value),
43 \textcolor { keywordflow} { print}
44 \textcolor { keywordflow} { for} inst \textcolor { keywordflow} { in} sub.getInstances():
45 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| | | +"} , inst.getName(),
46 \textcolor { keywordflow} { if} isinstance(inst, Mosfet):
47 \textcolor { keywordflow} { print} inst.getDrain(), inst.getGrid(), inst.getSource(), inst.getBulk(), inst.getModel(),
48 i = 0
49 \textcolor { keywordflow} { for} (name, value) \textcolor { keywordflow} { in} inst.getParameters().items():
50 \textcolor { keywordflow} { if} i%6 == 0:
51 \textcolor { keywordflow} { print}
52 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| | | | +"} ,
53 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "%s=%s"}%(name, value),
54 i += 1
55 \textcolor { keywordflow} { elif} isinstance(inst, Resistor):
56 \textcolor { keywordflow} { print} inst.getFirst(), inst.getSecond(), inst.getValue(),
57 \textcolor { keywordflow} { elif} isinstance(inst, Capacitor):
58 \textcolor { keywordflow} { print} inst.getPositive(), inst.getNegative(), inst.getValue(),
59 \textcolor { keywordflow} { else} :
60 \textcolor { keywordflow} { for} conn \textcolor { keywordflow} { in} inst.getConnectors():
61 \textcolor { keywordflow} { print} conn,
62 \textcolor { keywordflow} { print} inst.getModel(),
63 i = 0
64 \textcolor { keywordflow} { for} (name, value) \textcolor { keywordflow} { in} inst.getParameters().items():
65 \textcolor { keywordflow} { if} i%6 == 0:
66 \textcolor { keywordflow} { print}
67 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| | | | +"} ,
68 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "%s=%s"}%(name, value),
69 i += 1
70 \textcolor { keywordflow} { print}
71
72 \textcolor { keywordflow} { if} len(circuit.getInstances()):
73 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| + instances"}
74 \textcolor { keywordflow} { for} inst \textcolor { keywordflow} { in} circuit.getInstances():
75 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| | | +"} , inst.getName(),
76 \textcolor { keywordflow} { if} isinstance(inst, Mosfet):
77 \textcolor { keywordflow} { print} inst.getDrain(), inst.getGrid(), inst.getSource(), inst.getBulk(), inst.getModel(),
78 i = 0
79 \textcolor { keywordflow} { for} (name, value) \textcolor { keywordflow} { in} inst.getParameters().items():
80 \textcolor { keywordflow} { if} i%6 == 0:
81 \textcolor { keywordflow} { print}
82 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| | | | +"} ,
83 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "%s=%s"}%(name, value),
84 i += 1
85 \textcolor { keywordflow} { elif} isinstance(inst, Resistor):
86 \textcolor { keywordflow} { print} inst.getFirst(), inst.getSecond(), inst.getValue(),
87 \textcolor { keywordflow} { elif} isinstance(inst, Capacitor):
88 \textcolor { keywordflow} { print} inst.getPositive(), inst.getNegative(), inst.getValue(),
89 \textcolor { keywordflow} { else} :
90 \textcolor { keywordflow} { for} conn \textcolor { keywordflow} { in} inst.getConnectors():
91 \textcolor { keywordflow} { print} conn,
92 \textcolor { keywordflow} { print} inst.getModel(),
93 i = 0
94 \textcolor { keywordflow} { for} (name, value) \textcolor { keywordflow} { in} inst.getParameters().items():
95 \textcolor { keywordflow} { if} i%6 == 0:
96 \textcolor { keywordflow} { print}
97 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "| | | | +"} ,
98 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "%s=%s"}%(name, value),
99 i += 1
100 \textcolor { keywordflow} { print}
101
102 \textcolor { keyword} { def } usage():
103 \textcolor { keywordflow} { print} \textcolor { stringliteral} { "usage:"} , sys.argv[0], \textcolor { stringliteral} { "[filename]"}
104 sys.exit(48)
105
106 \textcolor { keyword} { def } main():
107 \textcolor { keywordflow} { if} len(sys.argv) == 1:
108 filename = \textcolor { stringliteral} { "./OTA\_ miller.spi"}
109 \textcolor { keywordflow} { elif} len(sys.argv) == 2:
110 filename = sys.argv[1]
111 \textcolor { keywordflow} { else} :
112 usage()
113
114 circuit = Circuit.readFromFile(filename)
115 printContents(circuit)
116
117
118 \textcolor { keywordflow} { if} \_ \_ name\_ \_ == \textcolor { stringliteral} { "\_ \_ main\_ \_ "} :
119 main()
120
2018-06-06 11:42:26 -05:00
\end { DoxyCodeInclude}
\hypertarget { spice_ spiceDrivePython} { } \subsubsection { Driver} \label { spice_ spiceDrivePython}
2018-08-19 06:27:09 -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-08-19 06:27:09 -05:00
1 \textcolor { keyword} { from} SPICE \textcolor { keyword} { import} *
2
3 circuit = Circuit()
4
5 circuit.title = \textcolor { stringliteral} { '* Single-ended two-stage amplifier'}
6
7 \textcolor { comment} { # PARAMS}
8 circuit.addParameter(\textcolor { stringliteral} { "CC\_ VALUE"} , \textcolor { stringliteral} { "2.8794pF"} );
9 circuit.addParameter(\textcolor { stringliteral} { "L\_ VALUE"} , \textcolor { stringliteral} { "0.340e-6"} );
10
11 \textcolor { comment} { # SUBCKTS}
12 \textcolor { comment} { # CurrentMirror}
13 CM = circuit.addSubckt(\textcolor { stringliteral} { "currentMirrorPMOS"} );
14 CM.addInterface(\textcolor { stringliteral} { "d1"} );
15 CM.addInterface(\textcolor { stringliteral} { "d2"} );
16 CM.addInterface(\textcolor { stringliteral} { "s1"} );
17 CM.addInterface(\textcolor { stringliteral} { "s2"} );
18 CM.addParameter(\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "0.0"} );
19 CM.addParameter(\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "0.0"} );
20 CM.addParameter(\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "1"} );
21 CM.addParameter(\textcolor { stringliteral} { "aeq\_ val"} , \textcolor { stringliteral} { "100e-6"} );
22 CM.addParameter(\textcolor { stringliteral} { "temp\_ val"} , \textcolor { stringliteral} { "27"} );
23
24 cmP3 = Mosfet(\textcolor { stringliteral} { "P3"} , \textcolor { stringliteral} { "d1"} , \textcolor { stringliteral} { "d1"} , \textcolor { stringliteral} { "s1"} , \textcolor { stringliteral} { "s1"} , \textcolor { stringliteral} { "psvt"} );
25 cmP3.addParameter(\textcolor { stringliteral} { "l"} , \textcolor { stringliteral} { "l\_ val"} );
26 cmP3.addParameter(\textcolor { stringliteral} { "wf"} , \textcolor { stringliteral} { "\{ w\_ val/nf\_ val\} "} );
27 cmP3.addParameter(\textcolor { stringliteral} { "nf"} , \textcolor { stringliteral} { "nf\_ val"} );
28 cmP3.addParameter(\textcolor { stringliteral} { "aeq"} , \textcolor { stringliteral} { "aeq\_ val"} );
29 cmP3.addParameter(\textcolor { stringliteral} { "tempsimu"} , \textcolor { stringliteral} { "temp\_ val"} );
30 CM.addInstance(cmP3);
31
32 cmP4 = Mosfet(\textcolor { stringliteral} { "P4"} , \textcolor { stringliteral} { "d2"} , \textcolor { stringliteral} { "d1"} , \textcolor { stringliteral} { "s2"} , \textcolor { stringliteral} { "s2"} , \textcolor { stringliteral} { "psvt"} );
33 cmP4.addParameter(\textcolor { stringliteral} { "l"} , \textcolor { stringliteral} { "l\_ val"} );
34 cmP4.addParameter(\textcolor { stringliteral} { "wf"} , \textcolor { stringliteral} { "\{ w\_ val/nf\_ val\} "} );
35 cmP4.addParameter(\textcolor { stringliteral} { "nf"} , \textcolor { stringliteral} { "nf\_ val"} );
36 cmP4.addParameter(\textcolor { stringliteral} { "aeq"} , \textcolor { stringliteral} { "aeq\_ val"} );
37 cmP4.addParameter(\textcolor { stringliteral} { "tempsimu"} , \textcolor { stringliteral} { "temp\_ val"} );
38 CM.addInstance(cmP4);
39
40 \textcolor { comment} { # DifferentialPair}
41 DP = circuit.addSubckt(\textcolor { stringliteral} { "diffPairNMOS"} );
42 DP.addInterface(\textcolor { stringliteral} { "d1"} );
43 DP.addInterface(\textcolor { stringliteral} { "d2"} );
44 DP.addInterface(\textcolor { stringliteral} { "g1"} );
45 DP.addInterface(\textcolor { stringliteral} { "g2"} );
46 DP.addInterface(\textcolor { stringliteral} { "s"} );
47 DP.addInterface(\textcolor { stringliteral} { "b"} );
48 DP.addParameter(\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "0.0"} );
49 DP.addParameter(\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "0.0"} );
50 DP.addParameter(\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "1"} );
51 DP.addParameter(\textcolor { stringliteral} { "aeq\_ val"} , \textcolor { stringliteral} { "100e-6"} );
52 DP.addParameter(\textcolor { stringliteral} { "temp\_ val"} , \textcolor { stringliteral} { "27"} );
53
54 dpN1 = Mosfet(\textcolor { stringliteral} { "N1"} , \textcolor { stringliteral} { "d1"} , \textcolor { stringliteral} { "g1"} , \textcolor { stringliteral} { "s"} , \textcolor { stringliteral} { "b"} , \textcolor { stringliteral} { "nsvt"} );
55 dpN1.addParameter(\textcolor { stringliteral} { "l"} , \textcolor { stringliteral} { "l\_ val"} );
56 dpN1.addParameter(\textcolor { stringliteral} { "wf"} , \textcolor { stringliteral} { "\{ w\_ val/nf\_ val\} "} );
57 dpN1.addParameter(\textcolor { stringliteral} { "nf"} , \textcolor { stringliteral} { "nf\_ val"} );
58 dpN1.addParameter(\textcolor { stringliteral} { "aeq"} , \textcolor { stringliteral} { "aeq\_ val"} );
59 dpN1.addParameter(\textcolor { stringliteral} { "tempsimu"} , \textcolor { stringliteral} { "temp\_ val"} );
60 DP.addInstance(dpN1);
61
62 dpN2 = Mosfet(\textcolor { stringliteral} { "N2"} , \textcolor { stringliteral} { "d2"} , \textcolor { stringliteral} { "g2"} , \textcolor { stringliteral} { "s"} , \textcolor { stringliteral} { "b"} , \textcolor { stringliteral} { "nsvt"} );
63 dpN2.addParameter(\textcolor { stringliteral} { "l"} , \textcolor { stringliteral} { "l\_ val"} );
64 dpN2.addParameter(\textcolor { stringliteral} { "wf"} , \textcolor { stringliteral} { "\{ w\_ val/nf\_ val\} "} );
65 dpN2.addParameter(\textcolor { stringliteral} { "nf"} , \textcolor { stringliteral} { "nf\_ val"} );
66 dpN2.addParameter(\textcolor { stringliteral} { "aeq"} , \textcolor { stringliteral} { "aeq\_ val"} );
67 dpN2.addParameter(\textcolor { stringliteral} { "tempsimu"} , \textcolor { stringliteral} { "temp\_ val"} );
68 DP.addInstance(dpN2);
69
70 \textcolor { comment} { # INSTANCES}
71 iCM = Instance(\textcolor { stringliteral} { "CM"} , \textcolor { stringliteral} { "currentMirrorPMOS"} );
72 iCM.addConnector(\textcolor { stringliteral} { "1"} );
73 iCM.addConnector(\textcolor { stringliteral} { "2"} );
74 iCM.addConnector(\textcolor { stringliteral} { "vdd"} );
75 iCM.addConnector(\textcolor { stringliteral} { "vdd"} );
76 iCM.addParameter(\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
77 iCM.addParameter(\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "3.889618e-06"} );
78 iCM.addParameter(\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "2"} );
79 circuit.addInstance(iCM);
80
81 iDP = Instance(\textcolor { stringliteral} { "DP"} , \textcolor { stringliteral} { "diffPairNMOS"} );
82 iDP.addConnector(\textcolor { stringliteral} { "1"} );
83 iDP.addConnector(\textcolor { stringliteral} { "2"} );
84 iDP.addConnector(\textcolor { stringliteral} { "vim"} );
85 iDP.addConnector(\textcolor { stringliteral} { "vip"} );
86 iDP.addConnector(\textcolor { stringliteral} { "3"} );
87 iDP.addConnector(\textcolor { stringliteral} { "vss"} );
88 iDP.addParameter(\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
89 iDP.addParameter(\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "7.683346e-07"} );
90 iDP.addParameter(\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "4"} );
91 circuit.addInstance(iDP);
92
93 iP6 = Mosfet(\textcolor { stringliteral} { "P6"} , \textcolor { stringliteral} { "vout"} , \textcolor { stringliteral} { "2"} , \textcolor { stringliteral} { "vdd"} , \textcolor { stringliteral} { "vdd"} , \textcolor { stringliteral} { "psvt"} );
94 iP6.addParameter(\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
95 iP6.addParameter(\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "3.558995e-05"} );
96 iP6.addParameter(\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "20"} );
97 circuit.addInstance(iP6);
98
99 iN5 = Mosfet(\textcolor { stringliteral} { "N5"} , \textcolor { stringliteral} { "3"} , \textcolor { stringliteral} { "4"} , \textcolor { stringliteral} { "vss"} , \textcolor { stringliteral} { "vss"} , \textcolor { stringliteral} { "nsvt"} );
100 iN5.addParameter(\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
101 iN5.addParameter(\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "2.536703e-06"} );
102 iN5.addParameter(\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "4"} );
103 circuit.addInstance(iN5);
104
105 iN7 = Mosfet(\textcolor { stringliteral} { "N7"} , \textcolor { stringliteral} { "vout"} , \textcolor { stringliteral} { "4"} , \textcolor { stringliteral} { "vss"} , \textcolor { stringliteral} { "vss"} , \textcolor { stringliteral} { "nsvt"} );
106 iN7.addParameter(\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
107 iN7.addParameter(\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "1.069083e-05"} );
108 iN7.addParameter(\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "16"} );
109 circuit.addInstance(iN7);
110
111 iN8 = Mosfet(\textcolor { stringliteral} { "N8"} , \textcolor { stringliteral} { "4"} , \textcolor { stringliteral} { "4"} , \textcolor { stringliteral} { "vss"} , \textcolor { stringliteral} { "vss"} , \textcolor { stringliteral} { "nsvt"} );
112 iN8.addParameter(\textcolor { stringliteral} { "l\_ val"} , \textcolor { stringliteral} { "L\_ VALUE"} );
113 iN8.addParameter(\textcolor { stringliteral} { "w\_ val"} , \textcolor { stringliteral} { "2.536703e-06"} );
114 iN8.addParameter(\textcolor { stringliteral} { "nf\_ val"} , \textcolor { stringliteral} { "4"} );
115 circuit.addInstance(iN8);
116
117 capa = Capacitor(\textcolor { stringliteral} { "C1"} , \textcolor { stringliteral} { "vout"} , \textcolor { stringliteral} { "2"} , \textcolor { stringliteral} { "CC\_ VALUE"} )
118 circuit.addInstance(capa);
119
120 circuit.writeToFile(\textcolor { stringliteral} { "./myOTA.spi"} );
2018-06-06 11:42:26 -05:00
\end { DoxyCodeInclude}
\begin { DoxyNote} { Note}
2018-08-19 06:27:09 -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\- T\- H variable points to the directory containing S\- P\- I\- C\- E.\- so module.
2018-06-06 11:42:26 -05:00
\end { DoxyNote}