/*$Id: bm.h,v 26.11 2006/12/31 23:12:50 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. *------------------------------------------------------------------ * behavioral modeling base */ //testing=script 2006.07.13 #ifndef E_BM_H #define E_BM_H #include "e_compon.h" /*--------------------------------------------------------------------------*/ class SPLINE; class FPOLY1; /*--------------------------------------------------------------------------*/ class EVAL_BM_BASE : public COMMON_COMPONENT { protected: explicit EVAL_BM_BASE(int c=0) :COMMON_COMPONENT(c) {} explicit EVAL_BM_BASE(const EVAL_BM_BASE& p) :COMMON_COMPONENT(p) {} ~EVAL_BM_BASE() {} protected: // override virtual bool operator==(const COMMON_COMPONENT&)const{/*incomplete();*/return false;} bool has_tr_eval()const {return true;} bool has_ac_eval()const {return true;} }; /*--------------------------------------------------------------------------*/ class EVAL_BM_ACTION_BASE : public EVAL_BM_BASE { protected: PARAMETER _bandwidth; PARAMETER _delay; PARAMETER _phase; PARAMETER _ooffset; PARAMETER _ioffset; PARAMETER _scale; PARAMETER _tc1; PARAMETER _tc2; PARAMETER _ic; bool _has_ext_args; protected: explicit EVAL_BM_ACTION_BASE(int c=0); explicit EVAL_BM_ACTION_BASE(const EVAL_BM_ACTION_BASE& p); ~EVAL_BM_ACTION_BASE() {} double temp_adjust()const; void tr_final_adjust(FPOLY1* y, bool f_is_value)const; void tr_finish_tdv(ELEMENT* d, double val)const; void ac_final_adjust(COMPLEX* y)const; void ac_final_adjust_with_temp(COMPLEX* y)const; double uic(double x)const {return (SIM::uic_now()) ? _ic : x;} double ioffset(double x)const {return uic(x) + _ioffset;} public: // override virtual bool operator==(const COMMON_COMPONENT&)const; //COMPONENT_COMMON* clone()const; //COMPONENT_COMMON=0 //void parse(CS&); //COMPONENT_COMMON void print(OMSTREAM&, LANGUAGE)const; void elabo3(const COMPONENT*); //COMMON_COMPONENT* deflate(); //COMPONENT_COMMON/nothing //void tr_eval(ELEMENT*)const; //COMPONENT_COMMON void ac_eval(ELEMENT*)const; //bool has_tr_eval()const; //EVAL_BM_BASE/true //bool has_ac_eval()const; //EVAL_BM_BASE/true //const char* name()const //COMPONENT_COMMON=0 virtual bool ac_too()const = 0; protected: // override virtual //bool parse_numlist(CS&); //COMPONENT_COMMON/nothing bool parse_params(CS&); public: bool has_ext_args()const; static COMMON_COMPONENT* parse_func_type(CS&); }; /*--------------------------------------------------------------------------*/ class EVAL_BM_COND : public EVAL_BM_BASE { private: COMMON_COMPONENT* _func[sCOUNT]; bool _set[sCOUNT]; explicit EVAL_BM_COND(const EVAL_BM_COND& p); public: explicit EVAL_BM_COND(int c=0); ~EVAL_BM_COND(); private: // override virtual bool operator==(const COMMON_COMPONENT&)const; COMMON_COMPONENT* clone()const {return new EVAL_BM_COND(*this);} void parse(CS&); void print(OMSTREAM&, LANGUAGE)const; void elabo3(const COMPONENT*c); COMMON_COMPONENT* deflate(); void tr_eval(ELEMENT*d)const {assert(_func[SIM::_mode]); _func[SIM::_mode]->tr_eval(d);} void ac_eval(ELEMENT*d)const {assert(_func[s_AC]); _func[s_AC]->ac_eval(d);} //bool has_tr_eval()const; //EVAL_BM_BASE/true //bool has_ac_eval()const; //EVAL_BM_BASE/true const char* name()const {unreachable(); return "????";} //bool parse_numlist(CS&); //COMPONENT_COMMON/nothing/ignored //bool parse_params(CS&); //COMPONENT_COMMON/nothing/ignored }; /*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/ class EVAL_BM_MODEL : public EVAL_BM_ACTION_BASE { private: std::string _arglist; COMMON_COMPONENT* _func; explicit EVAL_BM_MODEL(const EVAL_BM_MODEL& p); public: explicit EVAL_BM_MODEL(int c=0); ~EVAL_BM_MODEL() {detach_common(&_func);} private: // override virtual bool operator==(const COMMON_COMPONENT&)const; COMMON_COMPONENT* clone()const {return new EVAL_BM_MODEL(*this);} void parse(CS&); void print(OMSTREAM&, LANGUAGE)const; void elabo3(const COMPONENT*); //COMMON_COMPONENT* deflate(); //COMPONENT_COMMON/nothing void tr_eval(ELEMENT*d)const {assert(_func); _func->tr_eval(d);} void ac_eval(ELEMENT*d)const {assert(_func); _func->ac_eval(d);} //bool has_tr_eval()const; //EVAL_BM_BASE/true //bool has_ac_eval()const; //EVAL_BM_BASE/true const char* name()const {untested();return modelname().c_str();} bool ac_too()const {return true;} //bool parse_numlist(CS&); //COMPONENT_COMMON/nothing/ignored //bool parse_params(CS&); //EVAL_BM_ACTION_BASE/ignored }; /*--------------------------------------------------------------------------*/ class EVAL_BM_VALUE : public EVAL_BM_ACTION_BASE { private: PARAMETER _value; explicit EVAL_BM_VALUE(const EVAL_BM_VALUE& p); public: explicit EVAL_BM_VALUE(int c=0); ~EVAL_BM_VALUE() {} const PARAMETER& value()const {return _value;} private: // override virtual bool operator==(const COMMON_COMPONENT&)const; COMMON_COMPONENT* clone()const {return new EVAL_BM_VALUE(*this);} //void parse(CS&); //COMPONENT_COMMON void print(OMSTREAM&, LANGUAGE)const; void elabo3(const COMPONENT*); //COMMON_COMPONENT* deflate(); //COMPONENT_COMMON/nothing void tr_eval(ELEMENT*)const; //void ac_eval(ELEMENT*)const; //EVAL_BM_ACTION_BASE //bool has_tr_eval()const; //EVAL_BM_BASE/true //bool has_ac_eval()const; //EVAL_BM_BASE/true const char* name()const {untested();return "VALUE";} bool ac_too()const {return false;} bool parse_numlist(CS&); bool parse_params(CS&); }; /*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/ #endif