Updated MIFunsetup()

This commit is contained in:
pnenzi 2005-08-06 08:41:27 +00:00
parent 363ffb85e0
commit 3c0898d7ac
2 changed files with 63 additions and 48 deletions

View File

@ -1,3 +1,9 @@
2005-08-06 Paolo Nenzi <p.nenzi@ieee.org>
* src/xspice/mif/mifsetup.c: Updated MIFunsetup to the latest version
provided by Hitoshi Tanaka.
2005-08-04 Paolo Nenzi <p.nenzi@ieee.org> 2005-08-04 Paolo Nenzi <p.nenzi@ieee.org>
* Fixed a bug in memory management of xspice/ngspice that caused * Fixed a bug in memory management of xspice/ngspice that caused

View File

@ -462,67 +462,76 @@ MIFunsetup(GENmodel *inModel,CKTcircuit *ckt)
Mif_Smp_Ptr_t *smp_data_out; Mif_Smp_Ptr_t *smp_data_out;
Mif_Smp_Ptr_t *smp_data_cntl; Mif_Smp_Ptr_t *smp_data_cntl;
Mif_Port_Type_t type,in_type,out_type; Mif_Port_Type_t type,in_type,out_type;
Mif_Cntl_Src_Type_t cntl_src_type; Mif_Cntl_Src_Type_t cntl_src_type;
int num_conn,num_port,i,j; int num_conn,num_port,i,j,k,l,num_port_k;
for (model = (MIFmodel *)inModel; model != NULL; for (model = (MIFmodel *)inModel; model != NULL;
model = model->MIFnextModel) model = model->MIFnextModel)
{ {
for(here = model->MIFinstances; here != NULL; for(here = model->MIFinstances; here != NULL;
here = here->MIFnextInstance) here = here->MIFnextInstance)
{ {
num_conn=here->num_conn; num_conn=here->num_conn;
for(i = 0; i < num_conn; i++) { for(i = 0; i < num_conn; i++) {
// if the connection is null, skip to next connection // if the connection is null, skip to next connection
if(here->conn[i]->is_null) continue; if(here->conn[i]->is_null) continue;
// prepare things for convenient access later // prepare things for convenient access later
num_port = here->conn[i]->size; num_port = here->conn[i]->size;
// loop through all ports on this connection // loop through all ports on this connection
for(j = 0; j < num_port; j++) { for(j = 0; j < num_port; j++) {
// Skip if port is digital or user-defined type // determine the type of this output port
type = here->conn[i]->port[j]->type; out_type = here->conn[i]->port[j]->type;
// determine the type of this output port // create a pointer to the smp data for quick access
out_type = here->conn[i]->port[j]->type; smp_data_out = &(here->conn[i]->port[j]->smp_data);
// create a pointer to the smp data for quick access for(k = 0; k < num_conn; k++) {
smp_data_out = &(here->conn[i]->port[j]->smp_data); // if the connection is null or is not an input
// skip to next connection
if((here->conn[k]->is_null) || (! here->conn[k]->is_input))
continue;
num_port_k = here->conn[k]->size;
// determine the type of this input port
for(l = 0; l < num_port_k; l++) {
// determine the type of this input port // if port is null, skip to next
in_type = here->conn[i]->port[j]->type; if(here->conn[k]->port[l]->is_null)
cntl_src_type = MIFget_cntl_src_type(in_type, out_type); continue;
in_type = here->conn[i]->port[j]->type;
cntl_src_type = MIFget_cntl_src_type(in_type, out_type);
switch(cntl_src_type) switch(cntl_src_type)
{ {
case MIF_VCVS: case MIF_VCVS:
case MIF_ICVS: case MIF_ICVS:
case -1: case MIF_VCIS:
if(smp_data_out->branch) case MIF_ICIS:
{ case -1:
CKTdltNNum(ckt, smp_data_out->branch); if(smp_data_out->branch)
smp_data_out->branch = 0; {
} CKTdltNNum(ckt, smp_data_out->branch);
smp_data_out->branch = 0;
if(smp_data_out->ibranch) }
{
CKTdltNNum(ckt, smp_data_out->ibranch);
smp_data_out->ibranch = 0;
}
here->initialized=MIF_FALSE;
break;
}
} if(smp_data_out->ibranch)
} {
CKTdltNNum(ckt, smp_data_out->ibranch);
} smp_data_out->ibranch = 0;
}
here->initialized=MIF_FALSE;
break;
}
}
}
}
}
}
} }
//printf("MIFunsetup completed.\n"); //printf("MIFunsetup completed.\n");
return OK; return OK;
} }