understanding spice interface

This commit is contained in:
Markus Mueller 2020-08-09 18:37:50 +02:00
parent 18829c6779
commit 7a023e466b
2 changed files with 85 additions and 33 deletions

View File

@ -74,13 +74,13 @@ double inf = std::numeric_limits<double>::infinity();
SPICEdev * NGSpiceModel::get_model_info()
{
SPICEdev model_info = {
this->model_info = {
.DEVpublic = {
.name = this.name,
.description = "High Current Model for BJT",
.terms = &this->n_external_nodes,
.numNames = &HICUMnSize,
.termNames = HICUMnames,
.name = this->name,
.description = "High Current Model for BJT",
.terms = &this->n_external_nodes,
.numNames = &this->n_external_nodes,
.termNames = this->MODELnames,
.numInstanceParms = &HICUMpTSize,
.instanceParms = HICUMpTable,
.numModelParms = &HICUMmPTSize,
@ -99,7 +99,7 @@ SPICEdev * NGSpiceModel::get_model_info()
},
.DEVparam = HICUMparam,
.DEVmodParam = HICUMmParam,
.DEVmodParam = this->MODELmParam,
.DEVload = HICUMload,
.DEVsetup = HICUMsetup,
.DEVunsetup = HICUMunsetup,
@ -121,24 +121,24 @@ SPICEdev * NGSpiceModel::get_model_info()
.DEVsenLoad = NULL,
.DEVsenUpdate = NULL,
.DEVsenAcLoad = NULL,
.DEVsenPrint = NULL,
.DEVsenTrunc = NULL,
.DEVdisto = NULL,
.DEVnoise = HICUMnoise,
.DEVsoaCheck = HICUMsoaCheck,
.DEVinstSize = &HICUMiSize,
.DEVmodSize = &HICUMmSize,
.DEVsenPrint = NULL,
.DEVsenTrunc = NULL,
.DEVdisto = NULL,
.DEVnoise = HICUMnoise,
.DEVsoaCheck = HICUMsoaCheck,
.DEVinstSize = &this->instance_size,
.DEVmodSize = &this->model_size,
#ifdef CIDER
.DEVdump = NULL,
.DEVacct = NULL,
#endif
};
return &modelinfo;
return &(this->model_info);
}
HICUML2::HICUML2(){
modelcard = {
this->spice_model_struct.modelcard = {
{"c10",Parameter(2.0E-30, 0,1)},
{"qp0",Parameter(2.0E-14,0,1)},
{"ich",Parameter(0.0,0,inf)},
@ -285,15 +285,10 @@ HICUML2::HICUML2(){
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<int>(this->external_nodes.size());
this->description = "High Current Model for BJT";
// set model specific constants
this->n_external_nodes = sizeof(this->MODELnames);
this->model_size = sizeof(this->spice_model_struct);
this->instance_size = sizeof(this->spice_instance_struct);
};
//HICUML2 hicumL2_example = HICUML2();

View File

@ -56,23 +56,80 @@ class Branch
Branch(Node * node_from, Node * node_to, std::vector<Node*> depends);
};
//SPICE model structure
typedef struct sGENmodel {
struct GENmodel gen;
#define GENmodType gen.GENmodType
#define GENnextModel(inst) ((struct sGENmodel *)((inst)->gen.GENnextModel))
#define GENinstances(inst) ((GENinstance *)((inst)->gen.GENinstances))
#define GENmodName gen.GENmodName
std::unordered_map<const char *, Parameter> modelcard; //the modelcard of the model
};
// SPICE instance structure
typedef struct sGENinstance {
struct GENinstance gen;
#define MODELmodPtr(inst) ((struct sGENmodel *)((inst)->gen.GENmodPtr))
#define MODELnextInstance(inst) ((struct sGENinstance *)((inst)->gen.GENnextInstance))
#define MODELname gen.GENname
#define MODELstate gen.GENstate
//the external nodes in exactly the same order as they appear in the call to the model
//TODO -> how to generalize this
const int HICUMcollNode; /* number of collector node of hicum */
const int HICUMbaseNode; /* number of base node of hicum */
const int HICUMemitNode; /* number of emitter node of hicum */
const int HICUMsubsNode; /* number of substrate node of hicum */
const int HICUMtempNode; /* number of the temperature node of the hicum */
};
class NGSpiceModel
{
public:
std::unordered_map<const char *, Parameter> modelcard; //the modelcard of the model
std::vector<Node> nodes; //all nodes of the model, including internal and externals
std::vector<Node> external_nodes; //the external nodes of the model
std::vector<Branch> branches; //the branches of the model
int n_external_nodes; //the name of the model
const char * name = "None"; //the name of the model
std::vector<Node> nodes; //all nodes of the model, including internal and externals
std::vector<Node> external_nodes; //the external nodes of the model
std::vector<Branch> branches; //the branches of the model
int n_external_nodes; //the name of the model
int model_size; //the size of the model structure
int instance_size; //the size of the instance structure
char * name ; //the name of the model
const char * description ; //the description of the model
char *MODELnames[]; // array of the names of the external nodes
//spice data structures
sGENmodel spice_model_struct;
sGENinstance spice_instance_struct;
SPICEdev model_info;
//spice methods
SPICEdev * get_model_info();
int MODELacLoad(GENmodel *,CKTcircuit*);
int MODELask(CKTcircuit *,GENinstance*,int,IFvalue*,IFvalue*);
int MODELconvTest(GENmodel*,CKTcircuit*);
int MODELdelete(GENinstance*);
int MODELgetic(GENmodel*,CKTcircuit*);
//extern int HICUMload(GENmodel*,CKTcircuit*);//moved to hicumL2.hpp
int MODELmAsk(CKTcircuit*,GENmodel*,int,IFvalue*);
int MODELmParam(int,IFvalue*,GENmodel*);
int MODELparam(int,IFvalue*,GENinstance*,IFvalue*);
int MODELpzLoad(GENmodel*, CKTcircuit*, SPcomplex*);
int MODELsetup(SMPmatrix*,GENmodel*,CKTcircuit*,int*);
int MODELunsetup(GENmodel*,CKTcircuit*);
// extern int HICUMtemp(GENmodel*,CKTcircuit*); // moved to hicum2temp.hpp
int MODELtrunc(GENmodel*,CKTcircuit*,double*);
int MODELnoise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*);
int MODELsoaCheck(CKTcircuit *, GENmodel *);
};
class HICUML2 : public NGSpiceModel
{
public:
const char * name = "hl2";
const char * name = "hl2";
const char * description = "high-speed HBT model"; //the description of the model
char *MODELnames[5] = {
"collector",
"base",
"emitter",
"substrate",
"temp"
};
HICUML2();
SPICEdev * get_model_info(); // return the SPICEdev
};
#endif