/*$Id: e_model.cc,v 26.21 2007/03/27 08:33:15 al Exp $ -*- C++ -*- * Copyright (C) 2001 Albert Davis * Author: Albert Davis * * This file is part of "Gnucap", the Gnu Circuit Analysis Package * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. *------------------------------------------------------------------ * base class for all models */ //testing=script 2006.07.12 #include "e_model.h" /*--------------------------------------------------------------------------*/ MODEL_CARD::MODEL_CARD() :CARD(), _tnom_c(NOT_INPUT) { } /*--------------------------------------------------------------------------*/ MODEL_CARD::MODEL_CARD(const MODEL_CARD& p) :CARD(p), _tnom_c(p._tnom_c) { } /*--------------------------------------------------------------------------*/ MODEL_CARD::~MODEL_CARD() { } /*--------------------------------------------------------------------------*/ void MODEL_CARD::parse_spice(CS& cmd) { cmd.reset(); cmd.skiparg(); /* skip known ".model" */ parse_label(cmd); parse_front(cmd); int paren = cmd.skip1b('('); bool in_error = false; for (;;) { int here = cmd.cursor(); parse_params(cmd); if (!cmd.more()) { break; }else if (paren && cmd.skip1b(')')) { break; }else if (cmd.stuck(&here)) { if (in_error) {itested(); // so you don't get two errors on name = value. cmd.skiparg(); in_error = false; }else{itested(); cmd.warn(bDANGER, "bad paramerter -- ignored"); cmd.skiparg().skip1b("="); in_error = true; } }else{ in_error = false; } } cmd.check(bWARNING, "what's this?"); } /*--------------------------------------------------------------------------*/ void MODEL_CARD::print(OMSTREAM& o, LANGUAGE lang)const { switch(lang) { case lACS:untested(); case lSPICE: o << ".model " << short_label() << " "; print_front(o, lang); o << " ("; print_params(o, lang); o << ")\n*+("; print_calculated(o, lang); o << ")\n"; break; case lVERILOG:itested(); o << "paramset " << short_label() << " "; print_front(o, lang); o << ";\n"; print_params(o, lang); o << ";\n //"; print_calculated(o, lang); o << ";\nendparmset\n"; break; case lAUTO: unreachable(); break; } } /*--------------------------------------------------------------------------*/ bool MODEL_CARD::parse_params(CS& cmd) { itested(); return ONE_OF || get(cmd, "TNOM", &_tnom_c); ; } /*--------------------------------------------------------------------------*/ void MODEL_CARD::print_params(OMSTREAM& o, LANGUAGE lang)const { print_pair(o, lang, "tnom", _tnom_c); } /*--------------------------------------------------------------------------*/ void MODEL_CARD::elabo1() { if (1 || !evaluated()) { CARD::elabo1(); _tnom_c.e_val(OPT::tnom_c, scope()); }else{ unreachable(); } } /*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/