diff --git a/src/spicelib/devices/hicum2/model_class.cpp b/src/spicelib/devices/hicum2/model_class.cpp index 21b0be979..c7bb54c84 100644 --- a/src/spicelib/devices/hicum2/model_class.cpp +++ b/src/spicelib/devices/hicum2/model_class.cpp @@ -13,6 +13,7 @@ extern "C" { #include "ngspice/sperror.h" #include "ngspice/ifsim.h" #include "ngspice/suffix.h" +#include "ngspice/devdefs.h" } Parameter::Parameter(double value_default, double min_value, double max_value) { @@ -52,40 +53,8 @@ double Parameter::getValue(){ }; -Node::Node(CKTcircuit * ckt, NGSpiceModel * model , char * name){ - /* Node constructor. - Output - ----- - ckt : CKTcircuit * - The circuit in which the node shall be allocated. - model : NGSpiceModel * - The model that contains the node. - name : char * - The name of the node. - */ - int error = 0; - - CKTnode *tmp; - CKTnode *tmpNode; - IFuid tmpName; - - ckt = ckt; +Node::Node( char * name){ name = name; - - //todo node collapsing? - - //allocate the node - error = CKTmkVolt(ckt,&tmp, (char*)model->name, name); - //if(error) return(error); //why should there be an error? - id = tmp->number; - // if (ckt->CKTcopyNodesets) { - // if (CKTinst2Node(ckt,here,2,&tmpNode,&tmpName)==OK) { - // if (tmpNode->nsGiven) { - // tmp->nodeset=tmpNode->nodeset; - // tmp->nsGiven=tmpNode->nsGiven; - // } - // } - // } }; double Node::getPotential(){ @@ -96,13 +65,78 @@ double Node::getPotential(){ Branch::Branch(Node * node_from,Node * node_to,std::vector depends){ - node_from = node_from; - node_to = node_to; - branch_dependencies = depends; + node_from = node_from; + node_to = node_to; + branch_dependencies = depends; }; double inf = std::numeric_limits::infinity(); +SPICEdev * NGSpiceModel::get_model_info() +{ + SPICEdev model_info = { + .DEVpublic = { + .name = this.name, + .description = "High Current Model for BJT", + .terms = &this->n_external_nodes, + .numNames = &HICUMnSize, + .termNames = HICUMnames, + .numInstanceParms = &HICUMpTSize, + .instanceParms = HICUMpTable, + .numModelParms = &HICUMmPTSize, + .modelParms = HICUMmPTable, + .flags = DEV_DEFAULT, + + #ifdef XSPICE + .cm_func = NULL, + .num_conn = 0, + .conn = NULL, + .num_param = 0, + .param = NULL, + .num_inst_var = 0, + .inst_var = NULL, + #endif + }, + + .DEVparam = HICUMparam, + .DEVmodParam = HICUMmParam, + .DEVload = HICUMload, + .DEVsetup = HICUMsetup, + .DEVunsetup = HICUMunsetup, + .DEVpzSetup = HICUMsetup, + .DEVtemperature = HICUMtemp, + .DEVtrunc = HICUMtrunc, + .DEVfindBranch = NULL, + .DEVacLoad = HICUMacLoad, + .DEVaccept = NULL, + .DEVdestroy = NULL, + .DEVmodDelete = NULL, + .DEVdelete = NULL, + .DEVsetic = HICUMgetic, + .DEVask = HICUMask, + .DEVmodAsk = HICUMmAsk, + .DEVpzLoad = HICUMpzLoad, + .DEVconvTest = HICUMconvTest, + .DEVsenSetup = NULL, + .DEVsenLoad = NULL, + .DEVsenUpdate = NULL, + .DEVsenAcLoad = NULL, + .DEVsenPrint = NULL, + .DEVsenTrunc = NULL, + .DEVdisto = NULL, + .DEVnoise = HICUMnoise, + .DEVsoaCheck = HICUMsoaCheck, + .DEVinstSize = &HICUMiSize, + .DEVmodSize = &HICUMmSize, + + #ifdef CIDER + .DEVdump = NULL, + .DEVacct = NULL, + #endif + }; + return &modelinfo; +} + HICUML2::HICUML2(){ modelcard = { {"c10",Parameter(2.0E-30, 0,1)}, @@ -240,16 +274,36 @@ HICUML2::HICUML2(){ {"dt",Parameter(0.0,-inf,inf)}, {"type",Parameter(1,-1,1)}, }; + nodes = { + Node((char*)"B"), + Node((char*)"Bi"), + Node((char*)"Bp"), + Node((char*)"C"), + Node((char*)"Ci"), + Node((char*)"E"), + Node((char*)"Ei"), + Node((char*)"S"), + Node((char*)"T"), + }; + external_nodes = { + Node((char*)"B"), + Node((char*)"C"), + Node((char*)"E"), + Node((char*)"S"), + Node((char*)"T"), + }; + this->n_external_nodes = static_cast(this->external_nodes.size()); + this->description = "High Current Model for BJT"; }; -HICUML2 hicumL2_example = HICUML2(); +//HICUML2 hicumL2_example = HICUML2(); -void setModelcardPara(const char* para_name, double value){ - Parameter para(0,0,0); - try { - para = hicumL2_example.modelcard.at(para_name); - } catch (const std::out_of_range& oor) { - printf("Experimental HICUM: did not find parameter with name %s.\n", para_name); - } - para.setValue(value); -}; \ No newline at end of file +// void setModelcardPara(const char* para_name, double value){ +// Parameter para(0,0,0); +// try { +// para = hicumL2_example.modelcard.at(para_name); +// } catch (const std::out_of_range& oor) { +// printf("Experimental HICUM: did not find parameter with name %s.\n", para_name); +// } +// para.setValue(value); +// }; \ No newline at end of file diff --git a/src/spicelib/devices/hicum2/model_class.hpp b/src/spicelib/devices/hicum2/model_class.hpp index 5782a5e3e..6429dd450 100644 --- a/src/spicelib/devices/hicum2/model_class.hpp +++ b/src/spicelib/devices/hicum2/model_class.hpp @@ -9,6 +9,13 @@ #include extern "C" { #include "ngspice/cktdefs.h" +#include "ngspice/ngspice.h" +#include "ngspice/smpdefs.h" +#include "ngspice/const.h" +#include "ngspice/sperror.h" +#include "ngspice/ifsim.h" +#include "ngspice/devdefs.h" +#include "ngspice/suffix.h" } class NGSpiceModel; @@ -33,16 +40,17 @@ class Node char * name; CKTcircuit * ckt; //pointer to the circuit in which the node resides double getPotential(); - Node(CKTcircuit * ckt, NGSpiceModel * model, char * name); + //Node(CKTcircuit * ckt, NGSpiceModel * model, char * name); + Node(char * name); }; class Branch { //A branch specifies a current that flows from node_from to node_to public: - double value; //the current of the branch - std::unordered_map derivatives; //a map whose keys are node ids and the value is the derivative with that node - std::vector branch_dependencies; //all nodes for which a derivative is defined + double value; //the current of the branch + std::unordered_map derivatives; //a map whose keys are node ids and the value is the derivative with that node + std::vector branch_dependencies; //all nodes for which a derivative is defined Node * node_from; //the node where the current originates Node * node_to; //the node where the current is flowing to Branch(Node * node_from, Node * node_to, std::vector depends); @@ -52,9 +60,11 @@ class NGSpiceModel { public: std::unordered_map modelcard; //the modelcard of the model - std::vector nodes; //the nodes of the model - std::vector branches; //the branches of the model - const char * name = "None"; //the branches of the model + std::vector nodes; //all nodes of the model, including internal and externals + std::vector external_nodes; //the external nodes of the model + std::vector branches; //the branches of the model + int n_external_nodes; //the name of the model + const char * name = "None"; //the name of the model }; class HICUML2 : public NGSpiceModel @@ -62,6 +72,7 @@ class HICUML2 : public NGSpiceModel public: const char * name = "hl2"; HICUML2(); + SPICEdev * get_model_info(); // return the SPICEdev }; #endif