2018-06-06 11:42:26 -05:00
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN'>
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html;charset=utf-8" >
< title > VLSI SAPD Documentation< / title >
< link href = "stylesheet.css" rel = "stylesheet" type = "text/css" >
< / head >
< h1 id = "pagetop" class = "header" > VLSI SAPD Documentation< / h1 >
< center class = "header" >
< table class = "header" >
< tr >
< td > < a href = "index.html" > Presentation< / a > < / td >
< td > < a href = "agds.html" > AGDS< / a > < / td >
< td > < a href = "cif.html" > CIF< / a > < / td >
< td > < a href = "dtr.html" > DTR< / a > < / td >
< td > < a href = "openchams.html" > OPENCHAMS< / a > < / td >
< td > < a href = "spice.html" > SPICE< / a > < / td >
< td > < a href = "contact.html" > Links & Contact< / a > < / td >
< / tr >
< / table >
< / center >
< br >
< hr >
< body >
2018-08-19 06:27:09 -05:00
<!-- Generated by Doxygen 1.8.5 -->
2018-06-06 11:42:26 -05:00
< / div > <!-- top -->
< div class = "header" >
< div class = "headertitle" >
< div class = "title" > SPICE Format < / div > < / div >
< / div > <!-- header -->
< div class = "contents" >
< div class = "textblock" > < h1 > < a class = "anchor" id = "spicePres" > < / a >
Presentation< / h1 >
2018-08-19 06:27:09 -05:00
< p > The < b > Spice< / b > format was developped at the University of California, Berkeley. This parser/driver consists in a subset of SPICE3 netlist format. (see < a href = "http://en.wikipedia.org/wiki/SPICE" > http://en.wikipedia.org/wiki/SPICE< / a > for more informations).< br / >
2018-06-06 11:42:26 -05:00
< / p >
< h2 > < a class = "anchor" id = "spiceAutrhos" > < / a >
Author< / h2 >
< p > Damien Dupuis: damien.dupuis(at)lip6(.)fr< / p >
< h1 > < a class = "anchor" id = "spiceDB" > < / a >
Stand alone database structure< / h1 >
2018-08-19 06:27:09 -05:00
< p > The database consists in several objects:< / p >
< ul >
2018-06-06 11:42:26 -05:00
< li > < a class = "el" href = "class_s_p_i_c_e_1_1_circuit.html" > SPICE::Circuit< / a > < / li >
< li > < a class = "el" href = "class_s_p_i_c_e_1_1_spice_exception.html" > SPICE::SpiceException< / a > < / li >
< li > < a class = "el" href = "class_s_p_i_c_e_1_1_subckt.html" > SPICE::Subckt< / a > < / li >
< li > < a class = "el" href = "class_s_p_i_c_e_1_1_instance.html" > SPICE::Instance< / a > < / li >
< li > < a class = "el" href = "class_s_p_i_c_e_1_1_mosfet.html" > SPICE::Mosfet< / a > < / li >
< li > < a class = "el" href = "class_s_p_i_c_e_1_1_capacitor.html" > SPICE::Capacitor< / a > < / li >
< li > < a class = "el" href = "class_s_p_i_c_e_1_1_resistor.html" > SPICE::Resistor< / a > < / li >
< li > < a class = "el" href = "class_s_p_i_c_e_1_1_source.html" > SPICE::Source< / a > < / li >
< li > < a class = "el" href = "class_s_p_i_c_e_1_1_voltage.html" > SPICE::Voltage< / a > < / li >
< li > < a class = "el" href = "class_s_p_i_c_e_1_1_current.html" > SPICE::Current< / a > < / li >
< / ul >
< h2 > < a class = "anchor" id = "spiceParser" > < / a >
Using the parser< / h2 >
< p > Simply load an Spice netlist file using the static function SPICE::Circuit::readFromFile().< / p >
< h2 > < a class = "anchor" id = "spiceDriver" > < / a >
Using the driver< / h2 >
< p > Using the driver is very simple, user has to create a < a class = "el" href = "class_s_p_i_c_e_1_1_circuit.html" > SPICE::Circuit< / a > object and simply add others Spice objects like < a class = "el" href = "class_s_p_i_c_e_1_1_subckt.html" > SPICE::Subckt< / a > or < a class = "el" href = "class_s_p_i_c_e_1_1_instance.html" > SPICE::Instance< / a > to it. Includes, libraries and parameters can also be added to < a class = "el" href = "class_s_p_i_c_e_1_1_circuit.html" > SPICE::Circuit< / a > . Finally use the SPICE::Circuit::writeToFile() method to dump the database to file.< / p >
< h1 > < a class = "anchor" id = "spiceExamples" > < / a >
Examples< / h1 >
2018-08-19 06:27:09 -05:00
< p > As said is the global presentation, VLSI SAPD project provides C++ libraries and Python modules for each supported format. In this section we present simple code examples to parse and drive a SPICE file using C++ or Python. The SPICE file considered describes a simple Miller OTA: < code > OTA_miller.spi< / code > < / p >
< div class = "fragment" > < div class = "line" > * Single-ended two-stage amplifier< / div >
< div class = "line" > < / div >
< div class = "line" > .PARAM CC_VALUE=2.8794pF< / div >
< div class = "line" > .PARAM L_VALUE=0.340e-6< / div >
< div class = "line" > < / div >
< div class = "line" > .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< / div >
< div class = "line" > MP3 d1 d1 s1 s1 psvt l=l_val wf={w_val/nf_val} nf=nf_val aeq=aeq_val tempsimu=temp_val< / div >
< div class = "line" > MP4 d2 d1 s2 s2 psvt l=l_val wf={w_val/nf_val} nf=nf_val aeq=aeq_val tempsimu=temp_val< / div >
< div class = "line" > .ENDS currentMirrorPMOS< / div >
< div class = "line" > < / div >
< div class = "line" > .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< / div >
< div class = "line" > MN1 d1 g1 s b nsvt l=l_val wf={w_val/nf_val} nf=nf_val aeq=aeq_val tempsimu=temp_val< / div >
< div class = "line" > MN2 d2 g2 s b nsvt l=l_val wf={w_val/nf_val} nf=nf_val aeq=aeq_val tempsimu=temp_val< / div >
< div class = "line" > .ENDS diffPairNMOS< / div >
< div class = "line" > < / div >
< div class = "line" > XCM 1 2 vdd vdd currentMirrorPMOS l_val=L_VALUE w_val=3.889618e-06 nf_val=2< / div >
< div class = "line" > XDP 1 2 vim vip 3 vss diffPairNMOS l_val=L_VALUE w_val=7.683346e-07 nf_val=4< / div >
< div class = "line" > MP6 vout 2 vdd vdd psvt l_val=L_VALUE w_val=3.558995e-05 nf_val=20< / div >
< div class = "line" > MN5 3 4 vss vss nsvt l_val=L_VALUE w_val=2.536703e-06 nf_val=4 < / div >
< div class = "line" > MN7 vout 4 vss vss nsvt l_val=L_VALUE w_val=1.069083e-05 nf_val=16< / div >
< div class = "line" > MN8 4 4 vss vss nsvt l_val=L_VALUE w_val=2.536703e-06 nf_val=4 < / div >
< div class = "line" > < / div >
< div class = "line" > CC1 vout 2 CC_VALUE< / div >
< div class = "line" > < / div >
< div class = "line" > .END< / div >
< / div > <!-- fragment --> < p > All source codes are available in the < code > examples< / code > directory.< / p >
2018-06-06 11:42:26 -05:00
< h2 > < a class = "anchor" id = "spiceC" > < / a >
C++< / h2 >
< h3 > < a class = "anchor" id = "spiceParseC" > < / a >
Parser< / h3 >
2018-08-19 06:27:09 -05:00
< p > The following code (< code > parseSpice.cpp< / code > ) is an example of how to parse a SPICE file using C++ library. < / p >
< div class = "fragment" > < div class = "line" > < span class = "preprocessor" > #include < cstdlib> < / span > < / div >
< div class = "line" > < span class = "preprocessor" > #include < iostream> < / span > < / div >
< div class = "line" > < span class = "preprocessor" > #include < string> < / span > < / div >
< div class = "line" > < span class = "preprocessor" > #include < map> < / span > < / div >
< div class = "line" > < span class = "preprocessor" > #include < vector> < / span > < / div >
< div class = "line" > < span class = "keyword" > using namespace < / span > std;< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "preprocessor" > #include " vlsisapd/spice/Circuit.h" < / span > < / div >
< div class = "line" > < span class = "preprocessor" > #include " vlsisapd/spice/SpiceException.h" < / span > < / div >
< div class = "line" > < span class = "preprocessor" > #include " vlsisapd/spice/Sources.h" < / span > < / div >
< div class = "line" > < span class = "preprocessor" > #include " vlsisapd/spice/Subckt.h" < / span > < / div >
< div class = "line" > < span class = "preprocessor" > #include " vlsisapd/spice/Instances.h" < / span > < / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "keywordtype" > int< / span > main(< span class = "keywordtype" > int< / span > argc, < span class = "keywordtype" > char< / span > * argv[]) {< / div >
< div class = "line" > < span class = "keywordtype" > string< / span > file = < span class = "stringliteral" > " " < / span > ;< / div >
< div class = "line" > < span class = "keywordflow" > if< / span > (argc == 1)< / div >
< div class = "line" > file = < span class = "stringliteral" > " ./OTA.cir" < / span > ;< / div >
< div class = "line" > < span class = "keywordflow" > else< / span > < span class = "keywordflow" > if< / span > (argc == 2)< / div >
< div class = "line" > file = argv[1];< / div >
< div class = "line" > < span class = "keywordflow" > else< / span > {< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " Usage: parseSpice [filename]" < / span > < < endl;< / div >
< div class = "line" > exit(1);< / div >
< div class = "line" > }< / div >
< div class = "line" > < / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html" > SPICE::Circuit< / a > * circuit = NULL;< / div >
< div class = "line" > < span class = "keywordflow" > try< / span > {< / div >
< div class = "line" > circuit = SPICE::Circuit::readFromFile(file);< / div >
< div class = "line" > } < span class = "keywordflow" > catch< / span > (< a class = "code" href = "class_s_p_i_c_e_1_1_spice_exception.html" > SPICE::SpiceException< / a > & e) {< / div >
< div class = "line" > cerr < < e.what() < < endl;< / div >
< div class = "line" > exit(48);< / div >
< div class = "line" > }< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "comment" > // if (!circuit) cerr < < " circuit is NULL !!" < < endl;< / span > < / div >
< div class = "line" > < span class = "comment" > // TITLE< / span > < / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " + " < / span > < < circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#ad19721dd878c04c854a72af12d785741" > getTitle< / a > () < < endl;< / div >
< div class = "line" > < span class = "comment" > // INCLUDES< / span > < / div >
< div class = "line" > vector< string> includes = circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#a312beaf640e84589e6644820355c8ed6" > getIncludes< / a > ();< / div >
< div class = "line" > < span class = "keywordflow" > if< / span > (includes.size()) {< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " | + includes" < / span > < < endl;< / div >
< div class = "line" > < span class = "keywordflow" > for< / span > (< span class = "keywordtype" > size_t< / span > i = 0 ; i < includes.size() ; i++)< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " | | " < / span > < < includes[i] < < endl;< / div >
< div class = "line" > }< / div >
< div class = "line" > < span class = "comment" > // LIBRARIES< / span > < / div >
< div class = "line" > vector< pair< string, string> > libs = circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#a3e6a71a711e4796470f1a2a1dc42aef6" > getLibraries< / a > ();< / div >
< div class = "line" > < span class = "keywordflow" > if< / span > (libs.size()) {< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " | + libraries" < / span > < < endl;< / div >
< div class = "line" > < span class = "keywordflow" > for< / span > (< span class = "keywordtype" > size_t< / span > i = 0 ; i < libs.size() ; i++)< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " | | " < / span > < < libs[i].first < < < span class = "stringliteral" > " " < / span > < < libs[i].second < < endl;< / div >
< div class = "line" > }< / div >
< div class = "line" > < span class = "comment" > // PARAMETERS< / span > < / div >
< div class = "line" > map< string, string> params = circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#a4c46676f9ead2db537a0dd963b4f08f1" > getParameters< / a > ();< / div >
< div class = "line" > < span class = "keywordflow" > if< / span > (params.size()) {< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " | + parameters" < / span > < < endl;< / div >
< div class = "line" > < span class = "keywordflow" > for< / span > (map< string, string> ::const_iterator it = params.begin() ; it != params.end() ; ++it)< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " | | " < / span > < < (*it).first < < < span class = "stringliteral" > " = " < / span > < < (*it).second < < endl;< / div >
< div class = "line" > }< / div >
< div class = "line" > < span class = "comment" > // OPTIONS< / span > < / div >
< div class = "line" > map< string, string> opts = circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#a4ee11ef79ef893c5621e0e7d26a7f9a7" > getOptions< / a > ();< / div >
< div class = "line" > < span class = "keywordflow" > if< / span > (opts.size()) {< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " | + options" < / span > < < endl;< / div >
< div class = "line" > < span class = "keywordflow" > for< / span > (map< string, string> ::const_iterator it = opts.begin() ; it != opts.end() ; ++it)< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " | | " < / span > < < (*it).first < < < span class = "stringliteral" > " = " < / span > < < (*it).second < < endl;< / div >
< div class = "line" > }< / div >
< div class = "line" > < span class = "comment" > // SOURCES< / span > < / div >
< div class = "line" > vector< SPICE::Source*> sources = circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#ac18caa525ed386c44874ee643c88e27b" > getSources< / a > ();< / div >
< div class = "line" > < span class = "keywordflow" > if< / span > (sources.size()) {< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " | + sources" < / span > < < endl;< / div >
< div class = "line" > < span class = "keywordflow" > for< / span > (< span class = "keywordtype" > size_t< / span > i = 0 ; i < sources.size() ; i++) {< / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_source.html" > SPICE::Source< / a > * s = sources[i];< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " | | " < / span > < < s-> < a class = "code" href = "class_s_p_i_c_e_1_1_source.html#ac0fc966d4386ddb71d99361e3fccb311" > getName< / a > () < < < span class = "stringliteral" > " " < / span > < < s-> < a class = "code" href = "class_s_p_i_c_e_1_1_source.html#a1adb347b9a2c2da556e4417ab0eec0e1" > getPositive< / a > () < < < span class = "stringliteral" > " " < / span > < < s-> < a class = "code" href = "class_s_p_i_c_e_1_1_source.html#a8b4ab73ed1d99c533aa22af0a37ebb0d" > getNegative< / a > () < < < span class = "stringliteral" > " " < / span > < < s-> < a class = "code" href = "class_s_p_i_c_e_1_1_source.html#a4c052cb2622c580a250b2c783a436882" > getValue< / a > () < < endl;< / div >
< div class = "line" > }< / div >
< div class = "line" > < / div >
< div class = "line" > }< / div >
< div class = "line" > < span class = "comment" > // SUBCKTS< / span > < / div >
< div class = "line" > vector< SPICE::Subckt*> subs = circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#adcc4ca0de68f8ee05f0d5db3b7604930" > getSubckts< / a > ();< / div >
< div class = "line" > < span class = "keywordflow" > if< / span > (subs.size()) {< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " | + subckts" < / span > < < endl;< / div >
< div class = "line" > < span class = "keywordflow" > for< / span > (< span class = "keywordtype" > size_t< / span > i = 0 ; i < subs.size() ; i++) {< / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html" > SPICE::Subckt< / a > * sub = subs[i];< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " | | + " < / span > < < sub-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#af55b1fe10eacd22c7ff3544b5ed32ef3" > getName< / a > (); < / div >
< div class = "line" > < span class = "keywordflow" > for< / span > (< span class = "keywordtype" > size_t< / span > j = 0 ; j < sub-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#a5df00fe6eb5e287abef28c76ce88bd1e" > getInterfaces< / a > ().size() ; j++)< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " " < / span > < < sub-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#a5df00fe6eb5e287abef28c76ce88bd1e" > getInterfaces< / a > ()[j];< / div >
< div class = "line" > < span class = "keywordflow" > if< / span > (sub-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#aee7d59083b78d31ac5c19ab508da91e0" > getParameters< / a > ().size()) {< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " param:" < / span > ;< / div >
< div class = "line" > < span class = "keywordflow" > for< / span > (map< string, string> ::const_iterator it = sub-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#aee7d59083b78d31ac5c19ab508da91e0" > getParameters< / a > ().begin() ; it != sub-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#aee7d59083b78d31ac5c19ab508da91e0" > getParameters< / a > ().end() ; ++it)< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " " < / span > < < (*it).first < < < span class = "stringliteral" > " =" < / span > < < (*it).second;< / div >
< div class = "line" > }< / div >
< div class = "line" > cerr < < endl;< / div >
< div class = "line" > < span class = "keywordflow" > for< / span > (< span class = "keywordtype" > size_t< / span > j = 0 ; j < sub-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#a8e6e58ffab876152a740092520c35d73" > getInstances< / a > ().size() ; j++) {< / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html" > SPICE::Instance< / a > * inst = sub-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#a8e6e58ffab876152a740092520c35d73" > getInstances< / a > ()[j];< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " | | | + " < / span > < < inst-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#ac0fc966d4386ddb71d99361e3fccb311" > getName< / a > ();< / div >
< div class = "line" > < span class = "keywordflow" > if< / span > (dynamic_cast< SPICE::Mosfet*> (inst)) {< / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html" > SPICE::Mosfet< / a > * mos = < span class = "keyword" > static_cast< < / span > < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html" > SPICE::Mosfet< / a > *< span class = "keyword" > > < / span > (inst);< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " " < / span > < < mos-> < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html#a7265f0565b8368070a3f09c6197a4e9b" > getDrain< / a > () < < < span class = "stringliteral" > " " < / span > < < mos-> < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html#a796d77755aac0828419f55ba2226bf15" > getGrid< / a > () < < < span class = "stringliteral" > " " < / span > < < mos-> < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html#a1791f52b6b5043823c6f3376e8453e3a" > getSource< / a > () < < < span class = "stringliteral" > " " < / span > < < mos-> < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html#a56484a169335450d6043ee20086ead93" > getBulk< / a > () < < < span class = "stringliteral" > " " < / span > < < mos-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#afc74cbe93df9c473a53db83a325f8f9d" > getModel< / a > ();< / div >
< div class = "line" > < span class = "keywordtype" > int< / span > k = 0;< / div >
< div class = "line" > < span class = "keywordflow" > for< / span > (map< string, string> ::const_iterator it =mos-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#aee7d59083b78d31ac5c19ab508da91e0" > getParameters< / a > ().begin() ; it != mos-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#aee7d59083b78d31ac5c19ab508da91e0" > getParameters< / a > ().end(); ++it, k++) {< / div >
< div class = "line" > < span class = "keywordflow" > if< / span > (k%6 == 0)< / div >
< div class = "line" > cerr < < endl < < < span class = "stringliteral" > " | | | | +" < / span > ;< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " " < / span > < < (*it).first < < < span class = "stringliteral" > " =" < / span > < < (*it).second;< / div >
< div class = "line" > }< / div >
< div class = "line" > } < span class = "keywordflow" > else< / span > < span class = "keywordflow" > if< / span > (dynamic_cast< SPICE::Resistor*> (inst)) {< / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_resistor.html" > SPICE::Resistor< / a > * res = < span class = "keyword" > static_cast< < / span > < a class = "code" href = "class_s_p_i_c_e_1_1_resistor.html" > SPICE::Resistor< / a > *< span class = "keyword" > > < / span > (inst);< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " " < / span > < < res-> < a class = "code" href = "class_s_p_i_c_e_1_1_resistor.html#ab57aa52f48a5a56c89dd49eae66c1a0f" > getFirst< / a > () < < < span class = "stringliteral" > " " < / span > < < res-> < a class = "code" href = "class_s_p_i_c_e_1_1_resistor.html#a9665313821b2fca41e14b9865133af7f" > getSecond< / a > () < < < span class = "stringliteral" > " " < / span > < < res-> < a class = "code" href = "class_s_p_i_c_e_1_1_resistor.html#a4c052cb2622c580a250b2c783a436882" > getValue< / a > ();< / div >
< div class = "line" > } < span class = "keywordflow" > else< / span > < span class = "keywordflow" > if< / span > (dynamic_cast< SPICE::Capacitor*> (inst)) {< / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_capacitor.html" > SPICE::Capacitor< / a > * capa = < span class = "keyword" > static_cast< < / span > < a class = "code" href = "class_s_p_i_c_e_1_1_capacitor.html" > SPICE::Capacitor< / a > *< span class = "keyword" > > < / span > (inst);< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " " < / span > < < capa-> < a class = "code" href = "class_s_p_i_c_e_1_1_capacitor.html#a1adb347b9a2c2da556e4417ab0eec0e1" > getPositive< / a > () < < < span class = "stringliteral" > " " < / span > < < capa-> < a class = "code" href = "class_s_p_i_c_e_1_1_capacitor.html#a8b4ab73ed1d99c533aa22af0a37ebb0d" > getNegative< / a > () < < < span class = "stringliteral" > " " < / span > < < capa-> < a class = "code" href = "class_s_p_i_c_e_1_1_capacitor.html#a4c052cb2622c580a250b2c783a436882" > getValue< / a > ();< / div >
< div class = "line" > } < span class = "keywordflow" > else< / span > {< / div >
< div class = "line" > < span class = "keywordflow" > for< / span > (< span class = "keywordtype" > size_t< / span > k = 0 ; k < inst-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#acce8940edeaa3d79c522006f987e0711" > getConnectors< / a > ().size() ; k++)< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " " < / span > < < inst-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#acce8940edeaa3d79c522006f987e0711" > getConnectors< / a > ()[k];< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " " < / span > < < inst-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#afc74cbe93df9c473a53db83a325f8f9d" > getModel< / a > ();< / div >
< div class = "line" > < span class = "keywordtype" > int< / span > l = 0;< / div >
< div class = "line" > < span class = "keywordflow" > for< / span > (map< string, string> ::const_iterator it = inst-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#aee7d59083b78d31ac5c19ab508da91e0" > getParameters< / a > ().begin() ; it != inst-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#aee7d59083b78d31ac5c19ab508da91e0" > getParameters< / a > ().end() ; ++it, l++) {< / div >
< div class = "line" > < span class = "keywordflow" > if< / span > (l%6 == 0)< / div >
< div class = "line" > cerr < < endl < < < span class = "stringliteral" > " | | | | +" < / span > ;< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " " < / span > < < (*it).first < < < span class = "stringliteral" > " =" < / span > < < (*it).second;< / div >
< div class = "line" > }< / div >
< div class = "line" > }< / div >
< div class = "line" > cerr < < endl;< / div >
< div class = "line" > }< / div >
< div class = "line" > }< / div >
< div class = "line" > }< / div >
< div class = "line" > < span class = "comment" > // INSTANCES< / span > < / div >
< div class = "line" > vector< SPICE::Instance*> insts = circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#a8e6e58ffab876152a740092520c35d73" > getInstances< / a > ();< / div >
< div class = "line" > < span class = "keywordflow" > if< / span > (insts.size()) {< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " | + instances" < / span > < < endl;< / div >
< div class = "line" > < span class = "keywordflow" > for< / span > (< span class = "keywordtype" > size_t< / span > i = 0 ; i < insts.size() ; i++) {< / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html" > SPICE::Instance< / a > * inst = insts[i];< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " | | + " < / span > < < inst-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#ac0fc966d4386ddb71d99361e3fccb311" > getName< / a > ();< / div >
< div class = "line" > < span class = "keywordflow" > if< / span > (dynamic_cast< SPICE::Mosfet*> (inst)) {< / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html" > SPICE::Mosfet< / a > * mos = < span class = "keyword" > static_cast< < / span > < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html" > SPICE::Mosfet< / a > *< span class = "keyword" > > < / span > (inst);< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " " < / span > < < mos-> < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html#a7265f0565b8368070a3f09c6197a4e9b" > getDrain< / a > () < < < span class = "stringliteral" > " " < / span > < < mos-> < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html#a796d77755aac0828419f55ba2226bf15" > getGrid< / a > () < < < span class = "stringliteral" > " " < / span > < < mos-> < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html#a1791f52b6b5043823c6f3376e8453e3a" > getSource< / a > () < < < span class = "stringliteral" > " " < / span > < < mos-> < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html#a56484a169335450d6043ee20086ead93" > getBulk< / a > () < < < span class = "stringliteral" > " " < / span > < < mos-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#afc74cbe93df9c473a53db83a325f8f9d" > getModel< / a > ();< / div >
< div class = "line" > < span class = "keywordtype" > int< / span > j = 0;< / div >
< div class = "line" > < span class = "keywordflow" > for< / span > (map< string, string> ::const_iterator it =mos-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#aee7d59083b78d31ac5c19ab508da91e0" > getParameters< / a > ().begin() ; it != mos-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#aee7d59083b78d31ac5c19ab508da91e0" > getParameters< / a > ().end(); ++it, j++) {< / div >
< div class = "line" > < span class = "keywordflow" > if< / span > (j%6 == 0)< / div >
< div class = "line" > cerr < < endl < < < span class = "stringliteral" > " | | | | +" < / span > ;< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " " < / span > < < (*it).first < < < span class = "stringliteral" > " =" < / span > < < (*it).second;< / div >
< div class = "line" > }< / div >
< div class = "line" > } < span class = "keywordflow" > else< / span > < span class = "keywordflow" > if< / span > (dynamic_cast< SPICE::Resistor*> (inst)) {< / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_resistor.html" > SPICE::Resistor< / a > * res = < span class = "keyword" > static_cast< < / span > < a class = "code" href = "class_s_p_i_c_e_1_1_resistor.html" > SPICE::Resistor< / a > *< span class = "keyword" > > < / span > (inst);< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " " < / span > < < res-> < a class = "code" href = "class_s_p_i_c_e_1_1_resistor.html#ab57aa52f48a5a56c89dd49eae66c1a0f" > getFirst< / a > () < < < span class = "stringliteral" > " " < / span > < < res-> < a class = "code" href = "class_s_p_i_c_e_1_1_resistor.html#a9665313821b2fca41e14b9865133af7f" > getSecond< / a > () < < < span class = "stringliteral" > " " < / span > < < res-> < a class = "code" href = "class_s_p_i_c_e_1_1_resistor.html#a4c052cb2622c580a250b2c783a436882" > getValue< / a > ();< / div >
< div class = "line" > } < span class = "keywordflow" > else< / span > < span class = "keywordflow" > if< / span > (dynamic_cast< SPICE::Capacitor*> (inst)) {< / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_capacitor.html" > SPICE::Capacitor< / a > * capa = < span class = "keyword" > static_cast< < / span > < a class = "code" href = "class_s_p_i_c_e_1_1_capacitor.html" > SPICE::Capacitor< / a > *< span class = "keyword" > > < / span > (inst);< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " " < / span > < < capa-> < a class = "code" href = "class_s_p_i_c_e_1_1_capacitor.html#a1adb347b9a2c2da556e4417ab0eec0e1" > getPositive< / a > () < < < span class = "stringliteral" > " " < / span > < < capa-> < a class = "code" href = "class_s_p_i_c_e_1_1_capacitor.html#a8b4ab73ed1d99c533aa22af0a37ebb0d" > getNegative< / a > () < < < span class = "stringliteral" > " " < / span > < < capa-> < a class = "code" href = "class_s_p_i_c_e_1_1_capacitor.html#a4c052cb2622c580a250b2c783a436882" > getValue< / a > ();< / div >
< div class = "line" > } < span class = "keywordflow" > else< / span > {< / div >
< div class = "line" > < span class = "keywordflow" > for< / span > (< span class = "keywordtype" > size_t< / span > k = 0 ; k < inst-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#acce8940edeaa3d79c522006f987e0711" > getConnectors< / a > ().size() ; k++)< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " " < / span > < < inst-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#acce8940edeaa3d79c522006f987e0711" > getConnectors< / a > ()[k];< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " " < / span > < < inst-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#afc74cbe93df9c473a53db83a325f8f9d" > getModel< / a > ();< / div >
< div class = "line" > < span class = "keywordtype" > int< / span > l = 0;< / div >
< div class = "line" > < span class = "keywordflow" > for< / span > (map< string, string> ::const_iterator it = inst-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#aee7d59083b78d31ac5c19ab508da91e0" > getParameters< / a > ().begin() ; it != inst-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#aee7d59083b78d31ac5c19ab508da91e0" > getParameters< / a > ().end() ; ++it, l++) {< / div >
< div class = "line" > < span class = "keywordflow" > if< / span > (l%6 == 0)< / div >
< div class = "line" > cerr < < endl < < < span class = "stringliteral" > " | | | +" < / span > ;< / div >
< div class = "line" > cerr < < < span class = "stringliteral" > " " < / span > < < (*it).first < < < span class = "stringliteral" > " =" < / span > < < (*it).second;< / div >
< div class = "line" > }< / div >
< div class = "line" > }< / div >
< div class = "line" > cerr < < endl;< / div >
< div class = "line" > }< / div >
< div class = "line" > }< / div >
< div class = "line" > < span class = "keywordflow" > return< / span > 0;< / div >
< div class = "line" > }< / div >
< div class = "line" > < / div >
< / div > <!-- fragment --> < h3 > < a class = "anchor" id = "spiceDriveC" > < / a >
2018-06-06 11:42:26 -05:00
Driver< / h3 >
2018-08-19 06:27:09 -05:00
< p > This C++ code (< code > driveSpice.cpp< / code > ) generates an myOTA.spi file equivalent to the included one. < / p >
< div class = "fragment" > < div class = "line" > < span class = "preprocessor" > #include < string> < / span > < / div >
< div class = "line" > < span class = "keyword" > using namespace < / span > std;< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "preprocessor" > #include " vlsisapd/spice/Circuit.h" < / span > < / div >
< div class = "line" > < span class = "preprocessor" > #include " vlsisapd/spice/Subckt.h" < / span > < / div >
< div class = "line" > < span class = "preprocessor" > #include " vlsisapd/spice/Instances.h" < / span > < / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "keywordtype" > int< / span > main(< span class = "keywordtype" > int< / span > argc, < span class = "keywordtype" > char< / span > * argv[]) {< / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html" > SPICE::Circuit< / a > * circuit = < span class = "keyword" > new< / span > < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html" > SPICE::Circuit< / a > ();< / div >
< div class = "line" > circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#a798df9ebd558e22c85eeceb5202e3123" > setTitle< / a > (< span class = "stringliteral" > " * Single-ended two-stage amplifier" < / span > );< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "comment" > // PARAMS< / span > < / div >
< div class = "line" > circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#ab3ab147a16bc490ce96db905a4ca271c" > addParameter< / a > (< span class = "stringliteral" > " CC_VALUE" < / span > , < span class = "stringliteral" > " 2.8794pF" < / span > );< / div >
< div class = "line" > circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#ab3ab147a16bc490ce96db905a4ca271c" > addParameter< / a > (< span class = "stringliteral" > " L_VALUE" < / span > , < span class = "stringliteral" > " 0.340e-6" < / span > );< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "comment" > // SUBCKTS< / span > < / div >
< div class = "line" > < span class = "comment" > // CurrentMirror< / span > < / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html" > SPICE::Subckt< / a > * CM = circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#a0d1352e46d4537ce1e5f651de40e91a6" > addSubckt< / a > (< span class = "stringliteral" > " currentMirrorPMOS" < / span > );< / div >
< div class = "line" > CM-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ac162264683fa3d9b3384d3e8cc291fa2" > addInterface< / a > (< span class = "stringliteral" > " d1" < / span > );< / div >
< div class = "line" > CM-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ac162264683fa3d9b3384d3e8cc291fa2" > addInterface< / a > (< span class = "stringliteral" > " d2" < / span > );< / div >
< div class = "line" > CM-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ac162264683fa3d9b3384d3e8cc291fa2" > addInterface< / a > (< span class = "stringliteral" > " s1" < / span > );< / div >
< div class = "line" > CM-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ac162264683fa3d9b3384d3e8cc291fa2" > addInterface< / a > (< span class = "stringliteral" > " s2" < / span > );< / div >
< div class = "line" > CM-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ab3ab147a16bc490ce96db905a4ca271c" > addParameter< / a > (< span class = "stringliteral" > " l_val" < / span > , < span class = "stringliteral" > " 0.0" < / span > );< / div >
< div class = "line" > CM-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ab3ab147a16bc490ce96db905a4ca271c" > addParameter< / a > (< span class = "stringliteral" > " w_val" < / span > , < span class = "stringliteral" > " 0.0" < / span > );< / div >
< div class = "line" > CM-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ab3ab147a16bc490ce96db905a4ca271c" > addParameter< / a > (< span class = "stringliteral" > " nf_val" < / span > , < span class = "stringliteral" > " 1" < / span > );< / div >
< div class = "line" > CM-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ab3ab147a16bc490ce96db905a4ca271c" > addParameter< / a > (< span class = "stringliteral" > " aeq_val" < / span > , < span class = "stringliteral" > " 100e-6" < / span > );< / div >
< div class = "line" > CM-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ab3ab147a16bc490ce96db905a4ca271c" > addParameter< / a > (< span class = "stringliteral" > " temp_val" < / span > , < span class = "stringliteral" > " 27" < / span > );< / div >
< div class = "line" > < / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html" > SPICE::Instance< / a > * cmP3 = < span class = "keyword" > new< / span > < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html" > SPICE::Mosfet< / a > (< span class = "stringliteral" > " P3" < / span > , < span class = "stringliteral" > " d1" < / span > , < span class = "stringliteral" > " d1" < / span > , < span class = "stringliteral" > " s1" < / span > , < span class = "stringliteral" > " s1" < / span > , < span class = "stringliteral" > " psvt" < / span > );< / div >
< div class = "line" > cmP3-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " l" < / span > , < span class = "stringliteral" > " l_val" < / span > );< / div >
< div class = "line" > cmP3-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " wf" < / span > , < span class = "stringliteral" > " {w_val/nf_val}" < / span > );< / div >
< div class = "line" > cmP3-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " nf" < / span > , < span class = "stringliteral" > " nf_val" < / span > );< / div >
< div class = "line" > cmP3-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " aeq" < / span > , < span class = "stringliteral" > " aeq_val" < / span > );< / div >
< div class = "line" > cmP3-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " tempsimu" < / span > , < span class = "stringliteral" > " temp_val" < / span > );< / div >
< div class = "line" > CM-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#a7bb4a4532643568ab1ac2c229185a88e" > addInstance< / a > (cmP3);< / div >
< div class = "line" > < / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html" > SPICE::Instance< / a > * cmP4 = < span class = "keyword" > new< / span > < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html" > SPICE::Mosfet< / a > (< span class = "stringliteral" > " P4" < / span > , < span class = "stringliteral" > " d2" < / span > , < span class = "stringliteral" > " d1" < / span > , < span class = "stringliteral" > " s2" < / span > , < span class = "stringliteral" > " s2" < / span > , < span class = "stringliteral" > " psvt" < / span > );< / div >
< div class = "line" > cmP4-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " l" < / span > , < span class = "stringliteral" > " l_val" < / span > );< / div >
< div class = "line" > cmP4-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " wf" < / span > , < span class = "stringliteral" > " {w_val/nf_val}" < / span > );< / div >
< div class = "line" > cmP4-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " nf" < / span > , < span class = "stringliteral" > " nf_val" < / span > );< / div >
< div class = "line" > cmP4-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " aeq" < / span > , < span class = "stringliteral" > " aeq_val" < / span > );< / div >
< div class = "line" > cmP4-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " tempsimu" < / span > , < span class = "stringliteral" > " temp_val" < / span > );< / div >
< div class = "line" > CM-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#a7bb4a4532643568ab1ac2c229185a88e" > addInstance< / a > (cmP4);< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "comment" > // DifferentialPair< / span > < / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html" > SPICE::Subckt< / a > * DP = circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#a0d1352e46d4537ce1e5f651de40e91a6" > addSubckt< / a > (< span class = "stringliteral" > " diffPairNMOS" < / span > );< / div >
< div class = "line" > DP-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ac162264683fa3d9b3384d3e8cc291fa2" > addInterface< / a > (< span class = "stringliteral" > " d1" < / span > );< / div >
< div class = "line" > DP-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ac162264683fa3d9b3384d3e8cc291fa2" > addInterface< / a > (< span class = "stringliteral" > " d2" < / span > );< / div >
< div class = "line" > DP-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ac162264683fa3d9b3384d3e8cc291fa2" > addInterface< / a > (< span class = "stringliteral" > " g1" < / span > );< / div >
< div class = "line" > DP-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ac162264683fa3d9b3384d3e8cc291fa2" > addInterface< / a > (< span class = "stringliteral" > " g2" < / span > );< / div >
< div class = "line" > DP-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ac162264683fa3d9b3384d3e8cc291fa2" > addInterface< / a > (< span class = "stringliteral" > " s" < / span > );< / div >
< div class = "line" > DP-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ac162264683fa3d9b3384d3e8cc291fa2" > addInterface< / a > (< span class = "stringliteral" > " b" < / span > );< / div >
< div class = "line" > DP-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ab3ab147a16bc490ce96db905a4ca271c" > addParameter< / a > (< span class = "stringliteral" > " l_val" < / span > , < span class = "stringliteral" > " 0.0" < / span > );< / div >
< div class = "line" > DP-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ab3ab147a16bc490ce96db905a4ca271c" > addParameter< / a > (< span class = "stringliteral" > " w_val" < / span > , < span class = "stringliteral" > " 0.0" < / span > );< / div >
< div class = "line" > DP-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ab3ab147a16bc490ce96db905a4ca271c" > addParameter< / a > (< span class = "stringliteral" > " nf_val" < / span > , < span class = "stringliteral" > " 1" < / span > );< / div >
< div class = "line" > DP-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ab3ab147a16bc490ce96db905a4ca271c" > addParameter< / a > (< span class = "stringliteral" > " aeq_val" < / span > , < span class = "stringliteral" > " 100e-6" < / span > );< / div >
< div class = "line" > DP-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#ab3ab147a16bc490ce96db905a4ca271c" > addParameter< / a > (< span class = "stringliteral" > " temp_val" < / span > , < span class = "stringliteral" > " 27" < / span > );< / div >
< div class = "line" > < / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html" > SPICE::Instance< / a > * dpN1 = < span class = "keyword" > new< / span > < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html" > SPICE::Mosfet< / a > (< span class = "stringliteral" > " N1" < / span > , < span class = "stringliteral" > " d1" < / span > , < span class = "stringliteral" > " g1" < / span > , < span class = "stringliteral" > " s" < / span > , < span class = "stringliteral" > " b" < / span > , < span class = "stringliteral" > " nsvt" < / span > );< / div >
< div class = "line" > dpN1-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " l" < / span > , < span class = "stringliteral" > " l_val" < / span > );< / div >
< div class = "line" > dpN1-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " wf" < / span > , < span class = "stringliteral" > " {w_val/nf_val}" < / span > );< / div >
< div class = "line" > dpN1-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " nf" < / span > , < span class = "stringliteral" > " nf_val" < / span > );< / div >
< div class = "line" > dpN1-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " aeq" < / span > , < span class = "stringliteral" > " aeq_val" < / span > );< / div >
< div class = "line" > dpN1-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " tempsimu" < / span > , < span class = "stringliteral" > " temp_val" < / span > );< / div >
< div class = "line" > DP-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#a7bb4a4532643568ab1ac2c229185a88e" > addInstance< / a > (dpN1);< / div >
< div class = "line" > < / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html" > SPICE::Instance< / a > * dpN2 = < span class = "keyword" > new< / span > < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html" > SPICE::Mosfet< / a > (< span class = "stringliteral" > " N2" < / span > , < span class = "stringliteral" > " d2" < / span > , < span class = "stringliteral" > " g2" < / span > , < span class = "stringliteral" > " s" < / span > , < span class = "stringliteral" > " b" < / span > , < span class = "stringliteral" > " nsvt" < / span > );< / div >
< div class = "line" > dpN2-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " l" < / span > , < span class = "stringliteral" > " l_val" < / span > );< / div >
< div class = "line" > dpN2-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " wf" < / span > , < span class = "stringliteral" > " {w_val/nf_val}" < / span > );< / div >
< div class = "line" > dpN2-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " nf" < / span > , < span class = "stringliteral" > " nf_val" < / span > );< / div >
< div class = "line" > dpN2-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " aeq" < / span > , < span class = "stringliteral" > " aeq_val" < / span > );< / div >
< div class = "line" > dpN2-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " tempsimu" < / span > , < span class = "stringliteral" > " temp_val" < / span > );< / div >
< div class = "line" > DP-> < a class = "code" href = "class_s_p_i_c_e_1_1_subckt.html#a7bb4a4532643568ab1ac2c229185a88e" > addInstance< / a > (dpN2);< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "comment" > //INSTANCES< / span > < / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html" > SPICE::Instance< / a > * iCM = < span class = "keyword" > new< / span > < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html" > SPICE::Instance< / a > (< span class = "stringliteral" > " CM" < / span > , < span class = "stringliteral" > " currentMirrorPMOS" < / span > );< / div >
< div class = "line" > iCM-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#af9aeca34e780851a2b024df7c5ff5b54" > addConnector< / a > (< span class = "stringliteral" > " 1" < / span > );< / div >
< div class = "line" > iCM-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#af9aeca34e780851a2b024df7c5ff5b54" > addConnector< / a > (< span class = "stringliteral" > " 2" < / span > );< / div >
< div class = "line" > iCM-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#af9aeca34e780851a2b024df7c5ff5b54" > addConnector< / a > (< span class = "stringliteral" > " vdd" < / span > );< / div >
< div class = "line" > iCM-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#af9aeca34e780851a2b024df7c5ff5b54" > addConnector< / a > (< span class = "stringliteral" > " vdd" < / span > );< / div >
< div class = "line" > iCM-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " l_val" < / span > , < span class = "stringliteral" > " L_VALUE" < / span > );< / div >
< div class = "line" > iCM-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " w_val" < / span > , < span class = "stringliteral" > " 3.889618e-06" < / span > );< / div >
< div class = "line" > iCM-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " nf_val" < / span > , < span class = "stringliteral" > " 2" < / span > );< / div >
< div class = "line" > circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#a7bb4a4532643568ab1ac2c229185a88e" > addInstance< / a > (iCM);< / div >
< div class = "line" > < / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html" > SPICE::Instance< / a > * iDP = < span class = "keyword" > new< / span > < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html" > SPICE::Instance< / a > (< span class = "stringliteral" > " DP" < / span > , < span class = "stringliteral" > " diffPairNMOS" < / span > );< / div >
< div class = "line" > iDP-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#af9aeca34e780851a2b024df7c5ff5b54" > addConnector< / a > (< span class = "stringliteral" > " 1" < / span > );< / div >
< div class = "line" > iDP-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#af9aeca34e780851a2b024df7c5ff5b54" > addConnector< / a > (< span class = "stringliteral" > " 2" < / span > );< / div >
< div class = "line" > iDP-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#af9aeca34e780851a2b024df7c5ff5b54" > addConnector< / a > (< span class = "stringliteral" > " vim" < / span > );< / div >
< div class = "line" > iDP-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#af9aeca34e780851a2b024df7c5ff5b54" > addConnector< / a > (< span class = "stringliteral" > " vip" < / span > );< / div >
< div class = "line" > iDP-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#af9aeca34e780851a2b024df7c5ff5b54" > addConnector< / a > (< span class = "stringliteral" > " 3" < / span > );< / div >
< div class = "line" > iDP-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#af9aeca34e780851a2b024df7c5ff5b54" > addConnector< / a > (< span class = "stringliteral" > " vss" < / span > );< / div >
< div class = "line" > iDP-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " l_val" < / span > , < span class = "stringliteral" > " L_VALUE" < / span > );< / div >
< div class = "line" > iDP-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " w_val" < / span > , < span class = "stringliteral" > " 7.683346e-07" < / span > );< / div >
< div class = "line" > iDP-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " nf_val" < / span > , < span class = "stringliteral" > " 4" < / span > );< / div >
< div class = "line" > circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#a7bb4a4532643568ab1ac2c229185a88e" > addInstance< / a > (iDP);< / div >
< div class = "line" > < / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html" > SPICE::Instance< / a > * iP6 = < span class = "keyword" > new< / span > < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html" > SPICE::Mosfet< / a > (< span class = "stringliteral" > " P6" < / span > , < span class = "stringliteral" > " vout" < / span > , < span class = "stringliteral" > " 2" < / span > , < span class = "stringliteral" > " vdd" < / span > , < span class = "stringliteral" > " vdd" < / span > , < span class = "stringliteral" > " psvt" < / span > );< / div >
< div class = "line" > iP6-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " l_val" < / span > , < span class = "stringliteral" > " L_VALUE" < / span > );< / div >
< div class = "line" > iP6-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " w_val" < / span > , < span class = "stringliteral" > " 3.558995e-05" < / span > );< / div >
< div class = "line" > iP6-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " nf_val" < / span > , < span class = "stringliteral" > " 20" < / span > );< / div >
< div class = "line" > circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#a7bb4a4532643568ab1ac2c229185a88e" > addInstance< / a > (iP6);< / div >
< div class = "line" > < / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html" > SPICE::Instance< / a > * iN5 = < span class = "keyword" > new< / span > < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html" > SPICE::Mosfet< / a > (< span class = "stringliteral" > " N5" < / span > , < span class = "stringliteral" > " 3" < / span > , < span class = "stringliteral" > " 4" < / span > , < span class = "stringliteral" > " vss" < / span > , < span class = "stringliteral" > " vss" < / span > , < span class = "stringliteral" > " nsvt" < / span > );< / div >
< div class = "line" > iN5-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " l_val" < / span > , < span class = "stringliteral" > " L_VALUE" < / span > );< / div >
< div class = "line" > iN5-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " w_val" < / span > , < span class = "stringliteral" > " 2.536703e-06" < / span > );< / div >
< div class = "line" > iN5-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " nf_val" < / span > , < span class = "stringliteral" > " 4" < / span > );< / div >
< div class = "line" > circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#a7bb4a4532643568ab1ac2c229185a88e" > addInstance< / a > (iN5);< / div >
< div class = "line" > < / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html" > SPICE::Instance< / a > * iN7 = < span class = "keyword" > new< / span > < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html" > SPICE::Mosfet< / a > (< span class = "stringliteral" > " N7" < / span > , < span class = "stringliteral" > " vout" < / span > , < span class = "stringliteral" > " 4" < / span > , < span class = "stringliteral" > " vss" < / span > , < span class = "stringliteral" > " vss" < / span > , < span class = "stringliteral" > " nsvt" < / span > );< / div >
< div class = "line" > iN7-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " l_val" < / span > , < span class = "stringliteral" > " L_VALUE" < / span > );< / div >
< div class = "line" > iN7-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " w_val" < / span > , < span class = "stringliteral" > " 1.069083e-05" < / span > );< / div >
< div class = "line" > iN7-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " nf_val" < / span > , < span class = "stringliteral" > " 16" < / span > );< / div >
< div class = "line" > circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#a7bb4a4532643568ab1ac2c229185a88e" > addInstance< / a > (iN7);< / div >
< div class = "line" > < / div >
< div class = "line" > < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html" > SPICE::Instance< / a > * iN8 = < span class = "keyword" > new< / span > < a class = "code" href = "class_s_p_i_c_e_1_1_mosfet.html" > SPICE::Mosfet< / a > (< span class = "stringliteral" > " N8" < / span > , < span class = "stringliteral" > " 4" < / span > , < span class = "stringliteral" > " 4" < / span > , < span class = "stringliteral" > " vss" < / span > , < span class = "stringliteral" > " vss" < / span > , < span class = "stringliteral" > " nsvt" < / span > );< / div >
< div class = "line" > iN8-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " l_val" < / span > , < span class = "stringliteral" > " L_VALUE" < / span > );< / div >
< div class = "line" > iN8-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " w_val" < / span > , < span class = "stringliteral" > " 2.536703e-06" < / span > );< / div >
< div class = "line" > iN8-> < a class = "code" href = "class_s_p_i_c_e_1_1_instance.html#a8d69bbbea5ece0949e100c464e412f20" > addParameter< / a > (< span class = "stringliteral" > " nf_val" < / span > , < span class = "stringliteral" > " 4" < / span > );< / div >
< div class = "line" > circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#a7bb4a4532643568ab1ac2c229185a88e" > addInstance< / a > (iN8);< / div >
< div class = "line" > < / div >
< div class = "line" > circuit-> < a class = "code" href = "class_s_p_i_c_e_1_1_circuit.html#a7bb4a4532643568ab1ac2c229185a88e" > addInstance< / a > (< span class = "keyword" > new< / span > < a class = "code" href = "class_s_p_i_c_e_1_1_capacitor.html" > SPICE::Capacitor< / a > (< span class = "stringliteral" > " C1" < / span > , < span class = "stringliteral" > " vout" < / span > , < span class = "stringliteral" > " 2" < / span > , < span class = "stringliteral" > " CC_VALUE" < / span > ));< / div >
< div class = "line" > < / div >
< div class = "line" > circuit-> writeToFile(< span class = "stringliteral" > " ./myOTA.spi" < / span > );< / div >
< div class = "line" > < span class = "keywordflow" > return< / span > 0;< / div >
< div class = "line" > }< / div >
< div class = "line" > < / div >
< / div > <!-- fragment --> < dl class = "section note" > < dt > Note< / dt > < dd > In order to compile these codes, a CMakeLists.txt file is provided. User must set the $VLSISAPD_TOP variable before running these commands in the directory containing the CMakeLists.txt file: < div class = "fragment" > < div class = "line" > %> mkdir build; cd build< / div >
< div class = "line" > %> cmake ..< / div >
< div class = "line" > %> make< / div >
< / div > <!-- fragment --> < / dd > < / dl >
2018-06-06 11:42:26 -05:00
< h2 > < a class = "anchor" id = "spicePython" > < / a >
Python< / h2 >
< h3 > < a class = "anchor" id = "spiceParsePython" > < / a >
Parser< / h3 >
2018-08-19 06:27:09 -05:00
< p > The following python script (< code > parseSpice.py< / code > ) is an example of how to parse a SPICE file using python module. < / p >
< div class = "fragment" > < div class = "line" > < a name = "l00001" > < / a > < span class = "lineno" > 1< / span >   < span class = "keyword" > import< / span > sys< / div >
< div class = "line" > < a name = "l00002" > < / a > < span class = "lineno" > 2< / span >   < / div >
< div class = "line" > < a name = "l00003" > < / a > < span class = "lineno" > 3< / span >   < span class = "keyword" > from< / span > SPICE < span class = "keyword" > import< / span > *< / div >
< div class = "line" > < a name = "l00004" > < / a > < span class = "lineno" > 4< / span >   < / div >
< div class = "line" > < a name = "l00005" > < / a > < span class = "lineno" > 5< / span >   < span class = "keyword" > def < / span > printContents(circuit):< / div >
< div class = "line" > < a name = "l00006" > < / a > < span class = "lineno" > 6< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " +" < / span > , circuit.title< / div >
< div class = "line" > < a name = "l00007" > < / a > < span class = "lineno" > 7< / span >   < / div >
< div class = "line" > < a name = "l00008" > < / a > < span class = "lineno" > 8< / span >   < span class = "keywordflow" > if< / span > len(circuit.getIncludes()):< / div >
< div class = "line" > < a name = "l00009" > < / a > < span class = "lineno" > 9< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | + includes" < / span > < / div >
< div class = "line" > < a name = "l00010" > < / a > < span class = "lineno" > 10< / span >   < span class = "keywordflow" > for< / span > include < span class = "keywordflow" > in< / span > circuit.getIncludes():< / div >
< div class = "line" > < a name = "l00011" > < / a > < span class = "lineno" > 11< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | |" < / span > , include< / div >
< div class = "line" > < a name = "l00012" > < / a > < span class = "lineno" > 12< / span >   < / div >
< div class = "line" > < a name = "l00013" > < / a > < span class = "lineno" > 13< / span >   < span class = "keywordflow" > if< / span > len(circuit.getLibraries()):< / div >
< div class = "line" > < a name = "l00014" > < / a > < span class = "lineno" > 14< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | + libraries" < / span > < / div >
< div class = "line" > < a name = "l00015" > < / a > < span class = "lineno" > 15< / span >   < span class = "keywordflow" > for< / span > (lib, typ) < span class = "keywordflow" > in< / span > circuit.getLibraries():< / div >
< div class = "line" > < a name = "l00016" > < / a > < span class = "lineno" > 16< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | |" < / span > , lib, typ< / div >
< div class = "line" > < a name = "l00017" > < / a > < span class = "lineno" > 17< / span >   < / div >
< div class = "line" > < a name = "l00018" > < / a > < span class = "lineno" > 18< / span >   < span class = "keywordflow" > if< / span > len(circuit.getParameters()):< / div >
< div class = "line" > < a name = "l00019" > < / a > < span class = "lineno" > 19< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | + parameters" < / span > < / div >
< div class = "line" > < a name = "l00020" > < / a > < span class = "lineno" > 20< / span >   < span class = "keywordflow" > for< / span > (name, value) < span class = "keywordflow" > in< / span > circuit.getParameters().items():< / div >
< div class = "line" > < a name = "l00021" > < / a > < span class = "lineno" > 21< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | | %s=%s" < / span > %(name, value)< / div >
< div class = "line" > < a name = "l00022" > < / a > < span class = "lineno" > 22< / span >   < / div >
< div class = "line" > < a name = "l00023" > < / a > < span class = "lineno" > 23< / span >   < span class = "keywordflow" > if< / span > len(circuit.getOptions()):< / div >
< div class = "line" > < a name = "l00024" > < / a > < span class = "lineno" > 24< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | + options" < / span > < / div >
< div class = "line" > < a name = "l00025" > < / a > < span class = "lineno" > 25< / span >   < span class = "keywordflow" > for< / span > (name, value) < span class = "keywordflow" > in< / span > circuit.getOptions().items():< / div >
< div class = "line" > < a name = "l00026" > < / a > < span class = "lineno" > 26< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | | %s=%s" < / span > %(name, value)< / div >
< div class = "line" > < a name = "l00027" > < / a > < span class = "lineno" > 27< / span >   < / div >
< div class = "line" > < a name = "l00028" > < / a > < span class = "lineno" > 28< / span >   < span class = "keywordflow" > if< / span > len(circuit.getSources()):< / div >
< div class = "line" > < a name = "l00029" > < / a > < span class = "lineno" > 29< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | + sources" < / span > < / div >
< div class = "line" > < a name = "l00030" > < / a > < span class = "lineno" > 30< / span >   < span class = "keywordflow" > for< / span > source < span class = "keywordflow" > in< / span > circuit.getSources():< / div >
< div class = "line" > < a name = "l00031" > < / a > < span class = "lineno" > 31< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | |" < / span > , source.getName(), source.getPositive(), source.getNegative(), source.getValue()< / div >
< div class = "line" > < a name = "l00032" > < / a > < span class = "lineno" > 32< / span >   < / div >
< div class = "line" > < a name = "l00033" > < / a > < span class = "lineno" > 33< / span >   < span class = "keywordflow" > if< / span > len(circuit.getSubckts()):< / div >
< div class = "line" > < a name = "l00034" > < / a > < span class = "lineno" > 34< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | + subckts" < / span > < / div >
< div class = "line" > < a name = "l00035" > < / a > < span class = "lineno" > 35< / span >   < span class = "keywordflow" > for< / span > sub < span class = "keywordflow" > in< / span > circuit.getSubckts():< / div >
< div class = "line" > < a name = "l00036" > < / a > < span class = "lineno" > 36< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | | +" < / span > , sub.getName(),< / div >
< div class = "line" > < a name = "l00037" > < / a > < span class = "lineno" > 37< / span >   < span class = "keywordflow" > for< / span > interf < span class = "keywordflow" > in< / span > sub.getInterfaces():< / div >
< div class = "line" > < a name = "l00038" > < / a > < span class = "lineno" > 38< / span >   < span class = "keywordflow" > print< / span > interf,< / div >
< div class = "line" > < a name = "l00039" > < / a > < span class = "lineno" > 39< / span >   < span class = "keywordflow" > if< / span > len(sub.getParameters()):< / div >
< div class = "line" > < a name = "l00040" > < / a > < span class = "lineno" > 40< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " param:" < / span > ,< / div >
< div class = "line" > < a name = "l00041" > < / a > < span class = "lineno" > 41< / span >   < span class = "keywordflow" > for< / span > (name, value) < span class = "keywordflow" > in< / span > sub.getParameters().items():< / div >
< div class = "line" > < a name = "l00042" > < / a > < span class = "lineno" > 42< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " %s=%s" < / span > %(name,value),< / div >
< div class = "line" > < a name = "l00043" > < / a > < span class = "lineno" > 43< / span >   < span class = "keywordflow" > print< / span > < / div >
< div class = "line" > < a name = "l00044" > < / a > < span class = "lineno" > 44< / span >   < span class = "keywordflow" > for< / span > inst < span class = "keywordflow" > in< / span > sub.getInstances():< / div >
< div class = "line" > < a name = "l00045" > < / a > < span class = "lineno" > 45< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | | | +" < / span > , inst.getName(),< / div >
< div class = "line" > < a name = "l00046" > < / a > < span class = "lineno" > 46< / span >   < span class = "keywordflow" > if< / span > isinstance(inst, Mosfet):< / div >
< div class = "line" > < a name = "l00047" > < / a > < span class = "lineno" > 47< / span >   < span class = "keywordflow" > print< / span > inst.getDrain(), inst.getGrid(), inst.getSource(), inst.getBulk(), inst.getModel(),< / div >
< div class = "line" > < a name = "l00048" > < / a > < span class = "lineno" > 48< / span >   i = 0< / div >
< div class = "line" > < a name = "l00049" > < / a > < span class = "lineno" > 49< / span >   < span class = "keywordflow" > for< / span > (name, value) < span class = "keywordflow" > in< / span > inst.getParameters().items():< / div >
< div class = "line" > < a name = "l00050" > < / a > < span class = "lineno" > 50< / span >   < span class = "keywordflow" > if< / span > i%6 == 0:< / div >
< div class = "line" > < a name = "l00051" > < / a > < span class = "lineno" > 51< / span >   < span class = "keywordflow" > print< / span > < / div >
< div class = "line" > < a name = "l00052" > < / a > < span class = "lineno" > 52< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | | | | +" < / span > ,< / div >
< div class = "line" > < a name = "l00053" > < / a > < span class = "lineno" > 53< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " %s=%s" < / span > %(name, value),< / div >
< div class = "line" > < a name = "l00054" > < / a > < span class = "lineno" > 54< / span >   i += 1< / div >
< div class = "line" > < a name = "l00055" > < / a > < span class = "lineno" > 55< / span >   < span class = "keywordflow" > elif< / span > isinstance(inst, Resistor):< / div >
< div class = "line" > < a name = "l00056" > < / a > < span class = "lineno" > 56< / span >   < span class = "keywordflow" > print< / span > inst.getFirst(), inst.getSecond(), inst.getValue(),< / div >
< div class = "line" > < a name = "l00057" > < / a > < span class = "lineno" > 57< / span >   < span class = "keywordflow" > elif< / span > isinstance(inst, Capacitor):< / div >
< div class = "line" > < a name = "l00058" > < / a > < span class = "lineno" > 58< / span >   < span class = "keywordflow" > print< / span > inst.getPositive(), inst.getNegative(), inst.getValue(),< / div >
< div class = "line" > < a name = "l00059" > < / a > < span class = "lineno" > 59< / span >   < span class = "keywordflow" > else< / span > :< / div >
< div class = "line" > < a name = "l00060" > < / a > < span class = "lineno" > 60< / span >   < span class = "keywordflow" > for< / span > conn < span class = "keywordflow" > in< / span > inst.getConnectors():< / div >
< div class = "line" > < a name = "l00061" > < / a > < span class = "lineno" > 61< / span >   < span class = "keywordflow" > print< / span > conn,< / div >
< div class = "line" > < a name = "l00062" > < / a > < span class = "lineno" > 62< / span >   < span class = "keywordflow" > print< / span > inst.getModel(),< / div >
< div class = "line" > < a name = "l00063" > < / a > < span class = "lineno" > 63< / span >   i = 0< / div >
< div class = "line" > < a name = "l00064" > < / a > < span class = "lineno" > 64< / span >   < span class = "keywordflow" > for< / span > (name, value) < span class = "keywordflow" > in< / span > inst.getParameters().items():< / div >
< div class = "line" > < a name = "l00065" > < / a > < span class = "lineno" > 65< / span >   < span class = "keywordflow" > if< / span > i%6 == 0:< / div >
< div class = "line" > < a name = "l00066" > < / a > < span class = "lineno" > 66< / span >   < span class = "keywordflow" > print< / span > < / div >
< div class = "line" > < a name = "l00067" > < / a > < span class = "lineno" > 67< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | | | | +" < / span > ,< / div >
< div class = "line" > < a name = "l00068" > < / a > < span class = "lineno" > 68< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " %s=%s" < / span > %(name, value),< / div >
< div class = "line" > < a name = "l00069" > < / a > < span class = "lineno" > 69< / span >   i += 1< / div >
< div class = "line" > < a name = "l00070" > < / a > < span class = "lineno" > 70< / span >   < span class = "keywordflow" > print< / span > < / div >
< div class = "line" > < a name = "l00071" > < / a > < span class = "lineno" > 71< / span >   < / div >
< div class = "line" > < a name = "l00072" > < / a > < span class = "lineno" > 72< / span >   < span class = "keywordflow" > if< / span > len(circuit.getInstances()):< / div >
< div class = "line" > < a name = "l00073" > < / a > < span class = "lineno" > 73< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | + instances" < / span > < / div >
< div class = "line" > < a name = "l00074" > < / a > < span class = "lineno" > 74< / span >   < span class = "keywordflow" > for< / span > inst < span class = "keywordflow" > in< / span > circuit.getInstances():< / div >
< div class = "line" > < a name = "l00075" > < / a > < span class = "lineno" > 75< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | | | +" < / span > , inst.getName(),< / div >
< div class = "line" > < a name = "l00076" > < / a > < span class = "lineno" > 76< / span >   < span class = "keywordflow" > if< / span > isinstance(inst, Mosfet):< / div >
< div class = "line" > < a name = "l00077" > < / a > < span class = "lineno" > 77< / span >   < span class = "keywordflow" > print< / span > inst.getDrain(), inst.getGrid(), inst.getSource(), inst.getBulk(), inst.getModel(),< / div >
< div class = "line" > < a name = "l00078" > < / a > < span class = "lineno" > 78< / span >   i = 0< / div >
< div class = "line" > < a name = "l00079" > < / a > < span class = "lineno" > 79< / span >   < span class = "keywordflow" > for< / span > (name, value) < span class = "keywordflow" > in< / span > inst.getParameters().items():< / div >
< div class = "line" > < a name = "l00080" > < / a > < span class = "lineno" > 80< / span >   < span class = "keywordflow" > if< / span > i%6 == 0:< / div >
< div class = "line" > < a name = "l00081" > < / a > < span class = "lineno" > 81< / span >   < span class = "keywordflow" > print< / span > < / div >
< div class = "line" > < a name = "l00082" > < / a > < span class = "lineno" > 82< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | | | | +" < / span > ,< / div >
< div class = "line" > < a name = "l00083" > < / a > < span class = "lineno" > 83< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " %s=%s" < / span > %(name, value),< / div >
< div class = "line" > < a name = "l00084" > < / a > < span class = "lineno" > 84< / span >   i += 1< / div >
< div class = "line" > < a name = "l00085" > < / a > < span class = "lineno" > 85< / span >   < span class = "keywordflow" > elif< / span > isinstance(inst, Resistor):< / div >
< div class = "line" > < a name = "l00086" > < / a > < span class = "lineno" > 86< / span >   < span class = "keywordflow" > print< / span > inst.getFirst(), inst.getSecond(), inst.getValue(),< / div >
< div class = "line" > < a name = "l00087" > < / a > < span class = "lineno" > 87< / span >   < span class = "keywordflow" > elif< / span > isinstance(inst, Capacitor):< / div >
< div class = "line" > < a name = "l00088" > < / a > < span class = "lineno" > 88< / span >   < span class = "keywordflow" > print< / span > inst.getPositive(), inst.getNegative(), inst.getValue(),< / div >
< div class = "line" > < a name = "l00089" > < / a > < span class = "lineno" > 89< / span >   < span class = "keywordflow" > else< / span > :< / div >
< div class = "line" > < a name = "l00090" > < / a > < span class = "lineno" > 90< / span >   < span class = "keywordflow" > for< / span > conn < span class = "keywordflow" > in< / span > inst.getConnectors():< / div >
< div class = "line" > < a name = "l00091" > < / a > < span class = "lineno" > 91< / span >   < span class = "keywordflow" > print< / span > conn,< / div >
< div class = "line" > < a name = "l00092" > < / a > < span class = "lineno" > 92< / span >   < span class = "keywordflow" > print< / span > inst.getModel(),< / div >
< div class = "line" > < a name = "l00093" > < / a > < span class = "lineno" > 93< / span >   i = 0< / div >
< div class = "line" > < a name = "l00094" > < / a > < span class = "lineno" > 94< / span >   < span class = "keywordflow" > for< / span > (name, value) < span class = "keywordflow" > in< / span > inst.getParameters().items():< / div >
< div class = "line" > < a name = "l00095" > < / a > < span class = "lineno" > 95< / span >   < span class = "keywordflow" > if< / span > i%6 == 0:< / div >
< div class = "line" > < a name = "l00096" > < / a > < span class = "lineno" > 96< / span >   < span class = "keywordflow" > print< / span > < / div >
< div class = "line" > < a name = "l00097" > < / a > < span class = "lineno" > 97< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " | | | | +" < / span > ,< / div >
< div class = "line" > < a name = "l00098" > < / a > < span class = "lineno" > 98< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " %s=%s" < / span > %(name, value),< / div >
< div class = "line" > < a name = "l00099" > < / a > < span class = "lineno" > 99< / span >   i += 1< / div >
< div class = "line" > < a name = "l00100" > < / a > < span class = "lineno" > 100< / span >   < span class = "keywordflow" > print< / span > < / div >
< div class = "line" > < a name = "l00101" > < / a > < span class = "lineno" > 101< / span >   < / div >
< div class = "line" > < a name = "l00102" > < / a > < span class = "lineno" > 102< / span >   < span class = "keyword" > def < / span > usage():< / div >
< div class = "line" > < a name = "l00103" > < / a > < span class = "lineno" > 103< / span >   < span class = "keywordflow" > print< / span > < span class = "stringliteral" > " usage:" < / span > , sys.argv[0], < span class = "stringliteral" > " [filename]" < / span > < / div >
< div class = "line" > < a name = "l00104" > < / a > < span class = "lineno" > 104< / span >   sys.exit(48)< / div >
< div class = "line" > < a name = "l00105" > < / a > < span class = "lineno" > 105< / span >   < / div >
< div class = "line" > < a name = "l00106" > < / a > < span class = "lineno" > 106< / span >   < span class = "keyword" > def < / span > main():< / div >
< div class = "line" > < a name = "l00107" > < / a > < span class = "lineno" > 107< / span >   < span class = "keywordflow" > if< / span > len(sys.argv) == 1:< / div >
< div class = "line" > < a name = "l00108" > < / a > < span class = "lineno" > 108< / span >   filename = < span class = "stringliteral" > " ./OTA_miller.spi" < / span > < / div >
< div class = "line" > < a name = "l00109" > < / a > < span class = "lineno" > 109< / span >   < span class = "keywordflow" > elif< / span > len(sys.argv) == 2:< / div >
< div class = "line" > < a name = "l00110" > < / a > < span class = "lineno" > 110< / span >   filename = sys.argv[1]< / div >
< div class = "line" > < a name = "l00111" > < / a > < span class = "lineno" > 111< / span >   < span class = "keywordflow" > else< / span > :< / div >
< div class = "line" > < a name = "l00112" > < / a > < span class = "lineno" > 112< / span >   usage()< / div >
< div class = "line" > < a name = "l00113" > < / a > < span class = "lineno" > 113< / span >   < / div >
< div class = "line" > < a name = "l00114" > < / a > < span class = "lineno" > 114< / span >   circuit = Circuit.readFromFile(filename)< / div >
< div class = "line" > < a name = "l00115" > < / a > < span class = "lineno" > 115< / span >   printContents(circuit)< / div >
< div class = "line" > < a name = "l00116" > < / a > < span class = "lineno" > 116< / span >   < / div >
< div class = "line" > < a name = "l00117" > < / a > < span class = "lineno" > 117< / span >   < / div >
< div class = "line" > < a name = "l00118" > < / a > < span class = "lineno" > 118< / span >   < span class = "keywordflow" > if< / span > __name__ == < span class = "stringliteral" > " __main__" < / span > :< / div >
< div class = "line" > < a name = "l00119" > < / a > < span class = "lineno" > 119< / span >   main()< / div >
< div class = "line" > < a name = "l00120" > < / a > < span class = "lineno" > 120< / span >   < / div >
< / div > <!-- fragment --> < h3 > < a class = "anchor" id = "spiceDrivePython" > < / a >
2018-06-06 11:42:26 -05:00
Driver< / h3 >
2018-08-19 06:27:09 -05:00
< p > This python script (< code > driveSpice.py< / code > ) generates an myOTA.spi file equivalent to the included one. < / p >
< div class = "fragment" > < div class = "line" > < a name = "l00001" > < / a > < span class = "lineno" > 1< / span >   < span class = "keyword" > from< / span > SPICE < span class = "keyword" > import< / span > *< / div >
< div class = "line" > < a name = "l00002" > < / a > < span class = "lineno" > 2< / span >   < / div >
< div class = "line" > < a name = "l00003" > < / a > < span class = "lineno" > 3< / span >   circuit = Circuit()< / div >
< div class = "line" > < a name = "l00004" > < / a > < span class = "lineno" > 4< / span >   < / div >
< div class = "line" > < a name = "l00005" > < / a > < span class = "lineno" > 5< / span >   circuit.title = < span class = "stringliteral" > ' * Single-ended two-stage amplifier' < / span > < / div >
< div class = "line" > < a name = "l00006" > < / a > < span class = "lineno" > 6< / span >   < / div >
< div class = "line" > < a name = "l00007" > < / a > < span class = "lineno" > 7< / span >   < span class = "comment" > # PARAMS< / span > < / div >
< div class = "line" > < a name = "l00008" > < / a > < span class = "lineno" > 8< / span >   circuit.addParameter(< span class = "stringliteral" > " CC_VALUE" < / span > , < span class = "stringliteral" > " 2.8794pF" < / span > );< / div >
< div class = "line" > < a name = "l00009" > < / a > < span class = "lineno" > 9< / span >   circuit.addParameter(< span class = "stringliteral" > " L_VALUE" < / span > , < span class = "stringliteral" > " 0.340e-6" < / span > );< / div >
< div class = "line" > < a name = "l00010" > < / a > < span class = "lineno" > 10< / span >   < / div >
< div class = "line" > < a name = "l00011" > < / a > < span class = "lineno" > 11< / span >   < span class = "comment" > # SUBCKTS< / span > < / div >
< div class = "line" > < a name = "l00012" > < / a > < span class = "lineno" > 12< / span >   < span class = "comment" > # CurrentMirror< / span > < / div >
< div class = "line" > < a name = "l00013" > < / a > < span class = "lineno" > 13< / span >   CM = circuit.addSubckt(< span class = "stringliteral" > " currentMirrorPMOS" < / span > );< / div >
< div class = "line" > < a name = "l00014" > < / a > < span class = "lineno" > 14< / span >   CM.addInterface(< span class = "stringliteral" > " d1" < / span > );< / div >
< div class = "line" > < a name = "l00015" > < / a > < span class = "lineno" > 15< / span >   CM.addInterface(< span class = "stringliteral" > " d2" < / span > );< / div >
< div class = "line" > < a name = "l00016" > < / a > < span class = "lineno" > 16< / span >   CM.addInterface(< span class = "stringliteral" > " s1" < / span > );< / div >
< div class = "line" > < a name = "l00017" > < / a > < span class = "lineno" > 17< / span >   CM.addInterface(< span class = "stringliteral" > " s2" < / span > );< / div >
< div class = "line" > < a name = "l00018" > < / a > < span class = "lineno" > 18< / span >   CM.addParameter(< span class = "stringliteral" > " l_val" < / span > , < span class = "stringliteral" > " 0.0" < / span > );< / div >
< div class = "line" > < a name = "l00019" > < / a > < span class = "lineno" > 19< / span >   CM.addParameter(< span class = "stringliteral" > " w_val" < / span > , < span class = "stringliteral" > " 0.0" < / span > );< / div >
< div class = "line" > < a name = "l00020" > < / a > < span class = "lineno" > 20< / span >   CM.addParameter(< span class = "stringliteral" > " nf_val" < / span > , < span class = "stringliteral" > " 1" < / span > );< / div >
< div class = "line" > < a name = "l00021" > < / a > < span class = "lineno" > 21< / span >   CM.addParameter(< span class = "stringliteral" > " aeq_val" < / span > , < span class = "stringliteral" > " 100e-6" < / span > );< / div >
< div class = "line" > < a name = "l00022" > < / a > < span class = "lineno" > 22< / span >   CM.addParameter(< span class = "stringliteral" > " temp_val" < / span > , < span class = "stringliteral" > " 27" < / span > );< / div >
< div class = "line" > < a name = "l00023" > < / a > < span class = "lineno" > 23< / span >   < / div >
< div class = "line" > < a name = "l00024" > < / a > < span class = "lineno" > 24< / span >   cmP3 = Mosfet(< span class = "stringliteral" > " P3" < / span > , < span class = "stringliteral" > " d1" < / span > , < span class = "stringliteral" > " d1" < / span > , < span class = "stringliteral" > " s1" < / span > , < span class = "stringliteral" > " s1" < / span > , < span class = "stringliteral" > " psvt" < / span > );< / div >
< div class = "line" > < a name = "l00025" > < / a > < span class = "lineno" > 25< / span >   cmP3.addParameter(< span class = "stringliteral" > " l" < / span > , < span class = "stringliteral" > " l_val" < / span > );< / div >
< div class = "line" > < a name = "l00026" > < / a > < span class = "lineno" > 26< / span >   cmP3.addParameter(< span class = "stringliteral" > " wf" < / span > , < span class = "stringliteral" > " {w_val/nf_val}" < / span > );< / div >
< div class = "line" > < a name = "l00027" > < / a > < span class = "lineno" > 27< / span >   cmP3.addParameter(< span class = "stringliteral" > " nf" < / span > , < span class = "stringliteral" > " nf_val" < / span > );< / div >
< div class = "line" > < a name = "l00028" > < / a > < span class = "lineno" > 28< / span >   cmP3.addParameter(< span class = "stringliteral" > " aeq" < / span > , < span class = "stringliteral" > " aeq_val" < / span > );< / div >
< div class = "line" > < a name = "l00029" > < / a > < span class = "lineno" > 29< / span >   cmP3.addParameter(< span class = "stringliteral" > " tempsimu" < / span > , < span class = "stringliteral" > " temp_val" < / span > );< / div >
< div class = "line" > < a name = "l00030" > < / a > < span class = "lineno" > 30< / span >   CM.addInstance(cmP3);< / div >
< div class = "line" > < a name = "l00031" > < / a > < span class = "lineno" > 31< / span >   < / div >
< div class = "line" > < a name = "l00032" > < / a > < span class = "lineno" > 32< / span >   cmP4 = Mosfet(< span class = "stringliteral" > " P4" < / span > , < span class = "stringliteral" > " d2" < / span > , < span class = "stringliteral" > " d1" < / span > , < span class = "stringliteral" > " s2" < / span > , < span class = "stringliteral" > " s2" < / span > , < span class = "stringliteral" > " psvt" < / span > );< / div >
< div class = "line" > < a name = "l00033" > < / a > < span class = "lineno" > 33< / span >   cmP4.addParameter(< span class = "stringliteral" > " l" < / span > , < span class = "stringliteral" > " l_val" < / span > );< / div >
< div class = "line" > < a name = "l00034" > < / a > < span class = "lineno" > 34< / span >   cmP4.addParameter(< span class = "stringliteral" > " wf" < / span > , < span class = "stringliteral" > " {w_val/nf_val}" < / span > );< / div >
< div class = "line" > < a name = "l00035" > < / a > < span class = "lineno" > 35< / span >   cmP4.addParameter(< span class = "stringliteral" > " nf" < / span > , < span class = "stringliteral" > " nf_val" < / span > );< / div >
< div class = "line" > < a name = "l00036" > < / a > < span class = "lineno" > 36< / span >   cmP4.addParameter(< span class = "stringliteral" > " aeq" < / span > , < span class = "stringliteral" > " aeq_val" < / span > );< / div >
< div class = "line" > < a name = "l00037" > < / a > < span class = "lineno" > 37< / span >   cmP4.addParameter(< span class = "stringliteral" > " tempsimu" < / span > , < span class = "stringliteral" > " temp_val" < / span > );< / div >
< div class = "line" > < a name = "l00038" > < / a > < span class = "lineno" > 38< / span >   CM.addInstance(cmP4);< / div >
< div class = "line" > < a name = "l00039" > < / a > < span class = "lineno" > 39< / span >   < / div >
< div class = "line" > < a name = "l00040" > < / a > < span class = "lineno" > 40< / span >   < span class = "comment" > # DifferentialPair< / span > < / div >
< div class = "line" > < a name = "l00041" > < / a > < span class = "lineno" > 41< / span >   DP = circuit.addSubckt(< span class = "stringliteral" > " diffPairNMOS" < / span > );< / div >
< div class = "line" > < a name = "l00042" > < / a > < span class = "lineno" > 42< / span >   DP.addInterface(< span class = "stringliteral" > " d1" < / span > );< / div >
< div class = "line" > < a name = "l00043" > < / a > < span class = "lineno" > 43< / span >   DP.addInterface(< span class = "stringliteral" > " d2" < / span > );< / div >
< div class = "line" > < a name = "l00044" > < / a > < span class = "lineno" > 44< / span >   DP.addInterface(< span class = "stringliteral" > " g1" < / span > );< / div >
< div class = "line" > < a name = "l00045" > < / a > < span class = "lineno" > 45< / span >   DP.addInterface(< span class = "stringliteral" > " g2" < / span > );< / div >
< div class = "line" > < a name = "l00046" > < / a > < span class = "lineno" > 46< / span >   DP.addInterface(< span class = "stringliteral" > " s" < / span > );< / div >
< div class = "line" > < a name = "l00047" > < / a > < span class = "lineno" > 47< / span >   DP.addInterface(< span class = "stringliteral" > " b" < / span > );< / div >
< div class = "line" > < a name = "l00048" > < / a > < span class = "lineno" > 48< / span >   DP.addParameter(< span class = "stringliteral" > " l_val" < / span > , < span class = "stringliteral" > " 0.0" < / span > );< / div >
< div class = "line" > < a name = "l00049" > < / a > < span class = "lineno" > 49< / span >   DP.addParameter(< span class = "stringliteral" > " w_val" < / span > , < span class = "stringliteral" > " 0.0" < / span > );< / div >
< div class = "line" > < a name = "l00050" > < / a > < span class = "lineno" > 50< / span >   DP.addParameter(< span class = "stringliteral" > " nf_val" < / span > , < span class = "stringliteral" > " 1" < / span > );< / div >
< div class = "line" > < a name = "l00051" > < / a > < span class = "lineno" > 51< / span >   DP.addParameter(< span class = "stringliteral" > " aeq_val" < / span > , < span class = "stringliteral" > " 100e-6" < / span > );< / div >
< div class = "line" > < a name = "l00052" > < / a > < span class = "lineno" > 52< / span >   DP.addParameter(< span class = "stringliteral" > " temp_val" < / span > , < span class = "stringliteral" > " 27" < / span > );< / div >
< div class = "line" > < a name = "l00053" > < / a > < span class = "lineno" > 53< / span >   < / div >
< div class = "line" > < a name = "l00054" > < / a > < span class = "lineno" > 54< / span >   dpN1 = Mosfet(< span class = "stringliteral" > " N1" < / span > , < span class = "stringliteral" > " d1" < / span > , < span class = "stringliteral" > " g1" < / span > , < span class = "stringliteral" > " s" < / span > , < span class = "stringliteral" > " b" < / span > , < span class = "stringliteral" > " nsvt" < / span > );< / div >
< div class = "line" > < a name = "l00055" > < / a > < span class = "lineno" > 55< / span >   dpN1.addParameter(< span class = "stringliteral" > " l" < / span > , < span class = "stringliteral" > " l_val" < / span > );< / div >
< div class = "line" > < a name = "l00056" > < / a > < span class = "lineno" > 56< / span >   dpN1.addParameter(< span class = "stringliteral" > " wf" < / span > , < span class = "stringliteral" > " {w_val/nf_val}" < / span > );< / div >
< div class = "line" > < a name = "l00057" > < / a > < span class = "lineno" > 57< / span >   dpN1.addParameter(< span class = "stringliteral" > " nf" < / span > , < span class = "stringliteral" > " nf_val" < / span > );< / div >
< div class = "line" > < a name = "l00058" > < / a > < span class = "lineno" > 58< / span >   dpN1.addParameter(< span class = "stringliteral" > " aeq" < / span > , < span class = "stringliteral" > " aeq_val" < / span > );< / div >
< div class = "line" > < a name = "l00059" > < / a > < span class = "lineno" > 59< / span >   dpN1.addParameter(< span class = "stringliteral" > " tempsimu" < / span > , < span class = "stringliteral" > " temp_val" < / span > );< / div >
< div class = "line" > < a name = "l00060" > < / a > < span class = "lineno" > 60< / span >   DP.addInstance(dpN1);< / div >
< div class = "line" > < a name = "l00061" > < / a > < span class = "lineno" > 61< / span >   < / div >
< div class = "line" > < a name = "l00062" > < / a > < span class = "lineno" > 62< / span >   dpN2 = Mosfet(< span class = "stringliteral" > " N2" < / span > , < span class = "stringliteral" > " d2" < / span > , < span class = "stringliteral" > " g2" < / span > , < span class = "stringliteral" > " s" < / span > , < span class = "stringliteral" > " b" < / span > , < span class = "stringliteral" > " nsvt" < / span > );< / div >
< div class = "line" > < a name = "l00063" > < / a > < span class = "lineno" > 63< / span >   dpN2.addParameter(< span class = "stringliteral" > " l" < / span > , < span class = "stringliteral" > " l_val" < / span > );< / div >
< div class = "line" > < a name = "l00064" > < / a > < span class = "lineno" > 64< / span >   dpN2.addParameter(< span class = "stringliteral" > " wf" < / span > , < span class = "stringliteral" > " {w_val/nf_val}" < / span > );< / div >
< div class = "line" > < a name = "l00065" > < / a > < span class = "lineno" > 65< / span >   dpN2.addParameter(< span class = "stringliteral" > " nf" < / span > , < span class = "stringliteral" > " nf_val" < / span > );< / div >
< div class = "line" > < a name = "l00066" > < / a > < span class = "lineno" > 66< / span >   dpN2.addParameter(< span class = "stringliteral" > " aeq" < / span > , < span class = "stringliteral" > " aeq_val" < / span > );< / div >
< div class = "line" > < a name = "l00067" > < / a > < span class = "lineno" > 67< / span >   dpN2.addParameter(< span class = "stringliteral" > " tempsimu" < / span > , < span class = "stringliteral" > " temp_val" < / span > );< / div >
< div class = "line" > < a name = "l00068" > < / a > < span class = "lineno" > 68< / span >   DP.addInstance(dpN2);< / div >
< div class = "line" > < a name = "l00069" > < / a > < span class = "lineno" > 69< / span >   < / div >
< div class = "line" > < a name = "l00070" > < / a > < span class = "lineno" > 70< / span >   < span class = "comment" > # INSTANCES< / span > < / div >
< div class = "line" > < a name = "l00071" > < / a > < span class = "lineno" > 71< / span >   iCM = Instance(< span class = "stringliteral" > " CM" < / span > , < span class = "stringliteral" > " currentMirrorPMOS" < / span > );< / div >
< div class = "line" > < a name = "l00072" > < / a > < span class = "lineno" > 72< / span >   iCM.addConnector(< span class = "stringliteral" > " 1" < / span > );< / div >
< div class = "line" > < a name = "l00073" > < / a > < span class = "lineno" > 73< / span >   iCM.addConnector(< span class = "stringliteral" > " 2" < / span > );< / div >
< div class = "line" > < a name = "l00074" > < / a > < span class = "lineno" > 74< / span >   iCM.addConnector(< span class = "stringliteral" > " vdd" < / span > );< / div >
< div class = "line" > < a name = "l00075" > < / a > < span class = "lineno" > 75< / span >   iCM.addConnector(< span class = "stringliteral" > " vdd" < / span > );< / div >
< div class = "line" > < a name = "l00076" > < / a > < span class = "lineno" > 76< / span >   iCM.addParameter(< span class = "stringliteral" > " l_val" < / span > , < span class = "stringliteral" > " L_VALUE" < / span > );< / div >
< div class = "line" > < a name = "l00077" > < / a > < span class = "lineno" > 77< / span >   iCM.addParameter(< span class = "stringliteral" > " w_val" < / span > , < span class = "stringliteral" > " 3.889618e-06" < / span > );< / div >
< div class = "line" > < a name = "l00078" > < / a > < span class = "lineno" > 78< / span >   iCM.addParameter(< span class = "stringliteral" > " nf_val" < / span > , < span class = "stringliteral" > " 2" < / span > );< / div >
< div class = "line" > < a name = "l00079" > < / a > < span class = "lineno" > 79< / span >   circuit.addInstance(iCM);< / div >
< div class = "line" > < a name = "l00080" > < / a > < span class = "lineno" > 80< / span >   < / div >
< div class = "line" > < a name = "l00081" > < / a > < span class = "lineno" > 81< / span >   iDP = Instance(< span class = "stringliteral" > " DP" < / span > , < span class = "stringliteral" > " diffPairNMOS" < / span > );< / div >
< div class = "line" > < a name = "l00082" > < / a > < span class = "lineno" > 82< / span >   iDP.addConnector(< span class = "stringliteral" > " 1" < / span > );< / div >
< div class = "line" > < a name = "l00083" > < / a > < span class = "lineno" > 83< / span >   iDP.addConnector(< span class = "stringliteral" > " 2" < / span > );< / div >
< div class = "line" > < a name = "l00084" > < / a > < span class = "lineno" > 84< / span >   iDP.addConnector(< span class = "stringliteral" > " vim" < / span > );< / div >
< div class = "line" > < a name = "l00085" > < / a > < span class = "lineno" > 85< / span >   iDP.addConnector(< span class = "stringliteral" > " vip" < / span > );< / div >
< div class = "line" > < a name = "l00086" > < / a > < span class = "lineno" > 86< / span >   iDP.addConnector(< span class = "stringliteral" > " 3" < / span > );< / div >
< div class = "line" > < a name = "l00087" > < / a > < span class = "lineno" > 87< / span >   iDP.addConnector(< span class = "stringliteral" > " vss" < / span > );< / div >
< div class = "line" > < a name = "l00088" > < / a > < span class = "lineno" > 88< / span >   iDP.addParameter(< span class = "stringliteral" > " l_val" < / span > , < span class = "stringliteral" > " L_VALUE" < / span > );< / div >
< div class = "line" > < a name = "l00089" > < / a > < span class = "lineno" > 89< / span >   iDP.addParameter(< span class = "stringliteral" > " w_val" < / span > , < span class = "stringliteral" > " 7.683346e-07" < / span > );< / div >
< div class = "line" > < a name = "l00090" > < / a > < span class = "lineno" > 90< / span >   iDP.addParameter(< span class = "stringliteral" > " nf_val" < / span > , < span class = "stringliteral" > " 4" < / span > );< / div >
< div class = "line" > < a name = "l00091" > < / a > < span class = "lineno" > 91< / span >   circuit.addInstance(iDP);< / div >
< div class = "line" > < a name = "l00092" > < / a > < span class = "lineno" > 92< / span >   < / div >
< div class = "line" > < a name = "l00093" > < / a > < span class = "lineno" > 93< / span >   iP6 = Mosfet(< span class = "stringliteral" > " P6" < / span > , < span class = "stringliteral" > " vout" < / span > , < span class = "stringliteral" > " 2" < / span > , < span class = "stringliteral" > " vdd" < / span > , < span class = "stringliteral" > " vdd" < / span > , < span class = "stringliteral" > " psvt" < / span > );< / div >
< div class = "line" > < a name = "l00094" > < / a > < span class = "lineno" > 94< / span >   iP6.addParameter(< span class = "stringliteral" > " l_val" < / span > , < span class = "stringliteral" > " L_VALUE" < / span > );< / div >
< div class = "line" > < a name = "l00095" > < / a > < span class = "lineno" > 95< / span >   iP6.addParameter(< span class = "stringliteral" > " w_val" < / span > , < span class = "stringliteral" > " 3.558995e-05" < / span > );< / div >
< div class = "line" > < a name = "l00096" > < / a > < span class = "lineno" > 96< / span >   iP6.addParameter(< span class = "stringliteral" > " nf_val" < / span > , < span class = "stringliteral" > " 20" < / span > );< / div >
< div class = "line" > < a name = "l00097" > < / a > < span class = "lineno" > 97< / span >   circuit.addInstance(iP6);< / div >
< div class = "line" > < a name = "l00098" > < / a > < span class = "lineno" > 98< / span >   < / div >
< div class = "line" > < a name = "l00099" > < / a > < span class = "lineno" > 99< / span >   iN5 = Mosfet(< span class = "stringliteral" > " N5" < / span > , < span class = "stringliteral" > " 3" < / span > , < span class = "stringliteral" > " 4" < / span > , < span class = "stringliteral" > " vss" < / span > , < span class = "stringliteral" > " vss" < / span > , < span class = "stringliteral" > " nsvt" < / span > );< / div >
< div class = "line" > < a name = "l00100" > < / a > < span class = "lineno" > 100< / span >   iN5.addParameter(< span class = "stringliteral" > " l_val" < / span > , < span class = "stringliteral" > " L_VALUE" < / span > );< / div >
< div class = "line" > < a name = "l00101" > < / a > < span class = "lineno" > 101< / span >   iN5.addParameter(< span class = "stringliteral" > " w_val" < / span > , < span class = "stringliteral" > " 2.536703e-06" < / span > );< / div >
< div class = "line" > < a name = "l00102" > < / a > < span class = "lineno" > 102< / span >   iN5.addParameter(< span class = "stringliteral" > " nf_val" < / span > , < span class = "stringliteral" > " 4" < / span > );< / div >
< div class = "line" > < a name = "l00103" > < / a > < span class = "lineno" > 103< / span >   circuit.addInstance(iN5);< / div >
< div class = "line" > < a name = "l00104" > < / a > < span class = "lineno" > 104< / span >   < / div >
< div class = "line" > < a name = "l00105" > < / a > < span class = "lineno" > 105< / span >   iN7 = Mosfet(< span class = "stringliteral" > " N7" < / span > , < span class = "stringliteral" > " vout" < / span > , < span class = "stringliteral" > " 4" < / span > , < span class = "stringliteral" > " vss" < / span > , < span class = "stringliteral" > " vss" < / span > , < span class = "stringliteral" > " nsvt" < / span > );< / div >
< div class = "line" > < a name = "l00106" > < / a > < span class = "lineno" > 106< / span >   iN7.addParameter(< span class = "stringliteral" > " l_val" < / span > , < span class = "stringliteral" > " L_VALUE" < / span > );< / div >
< div class = "line" > < a name = "l00107" > < / a > < span class = "lineno" > 107< / span >   iN7.addParameter(< span class = "stringliteral" > " w_val" < / span > , < span class = "stringliteral" > " 1.069083e-05" < / span > );< / div >
< div class = "line" > < a name = "l00108" > < / a > < span class = "lineno" > 108< / span >   iN7.addParameter(< span class = "stringliteral" > " nf_val" < / span > , < span class = "stringliteral" > " 16" < / span > );< / div >
< div class = "line" > < a name = "l00109" > < / a > < span class = "lineno" > 109< / span >   circuit.addInstance(iN7);< / div >
< div class = "line" > < a name = "l00110" > < / a > < span class = "lineno" > 110< / span >   < / div >
< div class = "line" > < a name = "l00111" > < / a > < span class = "lineno" > 111< / span >   iN8 = Mosfet(< span class = "stringliteral" > " N8" < / span > , < span class = "stringliteral" > " 4" < / span > , < span class = "stringliteral" > " 4" < / span > , < span class = "stringliteral" > " vss" < / span > , < span class = "stringliteral" > " vss" < / span > , < span class = "stringliteral" > " nsvt" < / span > );< / div >
< div class = "line" > < a name = "l00112" > < / a > < span class = "lineno" > 112< / span >   iN8.addParameter(< span class = "stringliteral" > " l_val" < / span > , < span class = "stringliteral" > " L_VALUE" < / span > );< / div >
< div class = "line" > < a name = "l00113" > < / a > < span class = "lineno" > 113< / span >   iN8.addParameter(< span class = "stringliteral" > " w_val" < / span > , < span class = "stringliteral" > " 2.536703e-06" < / span > );< / div >
< div class = "line" > < a name = "l00114" > < / a > < span class = "lineno" > 114< / span >   iN8.addParameter(< span class = "stringliteral" > " nf_val" < / span > , < span class = "stringliteral" > " 4" < / span > );< / div >
< div class = "line" > < a name = "l00115" > < / a > < span class = "lineno" > 115< / span >   circuit.addInstance(iN8);< / div >
< div class = "line" > < a name = "l00116" > < / a > < span class = "lineno" > 116< / span >   < / div >
< div class = "line" > < a name = "l00117" > < / a > < span class = "lineno" > 117< / span >   capa = Capacitor(< span class = "stringliteral" > " C1" < / span > , < span class = "stringliteral" > " vout" < / span > , < span class = "stringliteral" > " 2" < / span > , < span class = "stringliteral" > " CC_VALUE" < / span > )< / div >
< div class = "line" > < a name = "l00118" > < / a > < span class = "lineno" > 118< / span >   circuit.addInstance(capa);< / div >
< div class = "line" > < a name = "l00119" > < / a > < span class = "lineno" > 119< / span >   < / div >
< div class = "line" > < a name = "l00120" > < / a > < span class = "lineno" > 120< / span >   circuit.writeToFile(< span class = "stringliteral" > " ./myOTA.spi" < / span > );< / div >
< / div > <!-- fragment --> < dl class = "section note" > < dt > Note< / dt > < dd > In order to run these two scripts (< code > parseSpice.py< / code > & driveSpice.py), user must ensure that $PYTHONPATH variable points to the directory containing SPICE.so module. < / dd > < / dl >
2018-06-06 11:42:26 -05:00
< / div > < / div > <!-- contents -->
< br >
< hr >
< table class = "footer1" >
< tr >
2018-10-01 09:52:17 -05:00
< td class = "LFooter" > < small > Generated by doxygen 1.8.5 on Mon Oct 1 2018< / small > < / td >
2018-06-06 11:42:26 -05:00
< td class = "RFooter" > < a href = '#pagetop' > < small > Return to top of page< / small > < / a > < / td >
< / tr >
< / table >
< table class = "footer2" >
< tr >
< td class = "LFooter" > VLSI SAPD Documentation< / td >
< td class = "RFooter" > < small > Copyright © 2010 - 2011 < a href = "http://www.upmc.fr" > UPMC< / a > All rights reserved< / small > < / td >
< / tr >
< / table >
< / body >
< / html >