636 lines
57 KiB
TeX
636 lines
57 KiB
TeX
\hypertarget{spice_spicePres}{}\section{Presentation}\label{spice_spicePres}
|
|
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
|
|
\hypertarget{spice_spiceAutrhos}{}\subsection{Author}\label{spice_spiceAutrhos}
|
|
Damien Dupuis\+: damien.\+dupuis(at)lip6(.)fr\hypertarget{spice_spiceDB}{}\section{Stand alone database structure}\label{spice_spiceDB}
|
|
The database consists in several objects\+:
|
|
\begin{DoxyItemize}
|
|
\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}}
|
|
\end{DoxyItemize}\hypertarget{spice_spiceParser}{}\subsection{Using the parser}\label{spice_spiceParser}
|
|
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}
|
|
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}
|
|
\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}
|
|
The following code ({\ttfamily parse\+Spice.\+cpp}) is an example of how to parse a S\+P\+I\+CE file using C++ library.
|
|
\begin{DoxyCodeInclude}
|
|
\textcolor{preprocessor}{#include <cstdlib>}
|
|
\textcolor{preprocessor}{#include <iostream>}
|
|
\textcolor{preprocessor}{#include <string>}
|
|
\textcolor{preprocessor}{#include <map>}
|
|
\textcolor{preprocessor}{#include <vector>}
|
|
\textcolor{keyword}{using namespace }\mbox{\hyperlink{namespacestd}{std}};
|
|
|
|
\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);
|
|
\}
|
|
|
|
\mbox{\hyperlink{class_s_p_i_c_e_1_1_circuit}{SPICE::Circuit}}* circuit = NULL;
|
|
\textcolor{keywordflow}{try} \{
|
|
circuit = \mbox{\hyperlink{class_s_p_i_c_e_1_1_circuit_aa8294fe7d9ceddb5653d08ecae3eaf36}{SPICE::Circuit::readFromFile}}(file);
|
|
\} \textcolor{keywordflow}{catch} (\mbox{\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->\mbox{\hyperlink{class_s_p_i_c_e_1_1_circuit_ad19721dd878c04c854a72af12d785741}{getTitle}}() << endl;
|
|
\textcolor{comment}{// INCLUDES}
|
|
vector<string> includes = circuit->\mbox{\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->\mbox{\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->\mbox{\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->\mbox{\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->\mbox{\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++) \{
|
|
\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;
|
|
\}
|
|
|
|
\}
|
|
\textcolor{comment}{// SUBCKTS}
|
|
vector<SPICE::Subckt*> subs = circuit->\mbox{\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++) \{
|
|
\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()) \{
|
|
cerr << \textcolor{stringliteral}{" param:"};
|
|
\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)
|
|
cerr << \textcolor{stringliteral}{" "} << (*it).first << \textcolor{stringliteral}{"="} << (*it).second;
|
|
\}
|
|
cerr << endl;
|
|
\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}}();
|
|
\textcolor{keywordflow}{if} (dynamic\_cast<SPICE::Mosfet*>(inst)) \{
|
|
\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}}();
|
|
\textcolor{keywordtype}{int} k = 0;
|
|
\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, 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)) \{
|
|
\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}}();
|
|
\} \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (dynamic\_cast<SPICE::Capacitor*>(inst)) \{
|
|
\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}}();
|
|
\} \textcolor{keywordflow}{else} \{
|
|
\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}}();
|
|
\textcolor{keywordtype}{int} l = 0;
|
|
\textcolor{keywordflow}{for} (map<string, string>::const\_iterator it = inst->
|
|
\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++) \{
|
|
\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->\mbox{\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++) \{
|
|
\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}}();
|
|
\textcolor{keywordflow}{if} (dynamic\_cast<SPICE::Mosfet*>(inst)) \{
|
|
\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}}();
|
|
\textcolor{keywordtype}{int} j = 0;
|
|
\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++) \{
|
|
\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)) \{
|
|
\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}}();
|
|
\} \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (dynamic\_cast<SPICE::Capacitor*>(inst)) \{
|
|
\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}}();
|
|
\} \textcolor{keywordflow}{else} \{
|
|
\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}}();
|
|
\textcolor{keywordtype}{int} l = 0;
|
|
\textcolor{keywordflow}{for} (map<string, string>::const\_iterator it = inst->
|
|
\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++) \{
|
|
\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}
|
|
This C++ code ({\ttfamily drive\+Spice.\+cpp}) generates an my\+O\+T\+A.\+spi file equivalent to the included one.
|
|
\begin{DoxyCodeInclude}
|
|
\textcolor{preprocessor}{#include <string>}
|
|
\textcolor{keyword}{using namespace }\mbox{\hyperlink{namespacestd}{std}};
|
|
|
|
\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[]) \{
|
|
\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"});
|
|
|
|
\textcolor{comment}{// PARAMS}
|
|
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"});
|
|
|
|
\textcolor{comment}{// SUBCKTS}
|
|
\textcolor{comment}{// CurrentMirror}
|
|
\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}{"
|
|
psvt"});
|
|
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}{"
|
|
psvt"});
|
|
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);
|
|
|
|
\textcolor{comment}{// DifferentialPair}
|
|
\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
|
|
"});
|
|
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
|
|
"});
|
|
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);
|
|
|
|
\textcolor{comment}{//INSTANCES}
|
|
\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}{"
|
|
psvt"});
|
|
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);
|
|
|
|
\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}{"
|
|
nsvt"});
|
|
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);
|
|
|
|
\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}{"
|
|
nsvt"});
|
|
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);
|
|
|
|
\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}{"
|
|
nsvt"});
|
|
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);
|
|
|
|
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"}));
|
|
|
|
circuit->writeToFile(\textcolor{stringliteral}{"./myOTA.spi"});
|
|
\textcolor{keywordflow}{return} 0;
|
|
\}
|
|
|
|
\end{DoxyCodeInclude}
|
|
|
|
|
|
\begin{DoxyNote}{Note}
|
|
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\+:
|
|
\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}
|
|
The following python script ({\ttfamily parse\+Spice.\+py}) is an example of how to parse a S\+P\+I\+CE file using python module.
|
|
\begin{DoxyCodeInclude}
|
|
\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()
|
|
|
|
\end{DoxyCodeInclude}
|
|
\hypertarget{spice_spiceDrivePython}{}\subsubsection{Driver}\label{spice_spiceDrivePython}
|
|
This python script ({\ttfamily drive\+Spice.\+py}) generates an my\+O\+T\+A.\+spi file equivalent to the included one.
|
|
\begin{DoxyCodeInclude}
|
|
\textcolor{keyword}{from} SPICE \textcolor{keyword}{import} *
|
|
|
|
circuit = \mbox{\hyperlink{class_circuit}{Circuit}}()
|
|
|
|
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}
|
|
iCM = \mbox{\hyperlink{class_instance}{Instance}}(\textcolor{stringliteral}{"CM"}, \textcolor{stringliteral}{"currentMirrorPMOS"});
|
|
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);
|
|
|
|
iDP = \mbox{\hyperlink{class_instance}{Instance}}(\textcolor{stringliteral}{"DP"}, \textcolor{stringliteral}{"diffPairNMOS"});
|
|
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"});
|
|
\end{DoxyCodeInclude}
|
|
|
|
|
|
\begin{DoxyNote}{Note}
|
|
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.
|
|
\end{DoxyNote}
|