Moved the KLU binding structures to be property of the XSPICE connections, instead of XSPICE instances

This commit is contained in:
Francesco Lannutti 2020-03-17 20:58:19 +01:00 committed by Holger Vogt
parent 534394c0bb
commit 4c351f51bd
4 changed files with 143 additions and 84 deletions

View File

@ -1,54 +1,102 @@
#ifndef _KLU_BINDING_H
#define _KLU_BINDING_H
#define CREATE_KLU_BINDING_TABLE(ptr, binding, a, b) \
if ((here->a != 0) && (here->b != 0)) { \
i = here->ptr ; \
#define CREATE_KLU_BINDING_TABLE(ptr, binding, a, b) \
if ((here->a != 0) && (here->b != 0)) { \
i = here->ptr ; \
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; \
here->binding = matched ; \
here->ptr = matched->CSC ; \
here->binding = matched ; \
here->ptr = matched->CSC ; \
}
#define CONVERT_KLU_BINDING_TABLE_TO_COMPLEX(ptr, binding, a, b) \
if ((here->a != 0) && (here->b != 0)) \
#define CONVERT_KLU_BINDING_TABLE_TO_COMPLEX(ptr, binding, a, b) \
if ((here->a != 0) && (here->b != 0)) \
here->ptr = here->binding->CSC_Complex ;
#define CONVERT_KLU_BINDING_TABLE_TO_REAL(ptr, binding, a, b) \
if ((here->a != 0) && (here->b != 0)) \
#define CONVERT_KLU_BINDING_TABLE_TO_REAL(ptr, binding, a, b) \
if ((here->a != 0) && (here->b != 0)) \
here->ptr = here->binding->CSC ;
#ifdef XSPICE
#define CREATE_KLU_BINDING_TABLE_XSPICE_OUTPUTS(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_out->b != 0)) { \
i = smp_data_out->ptr ; \
#define CREATE_KLU_BINDING_TABLE_XSPICE_OUTPUTS(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_out->b != 0)) { \
i = smp_data_out->ptr ; \
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; \
here->binding = matched ; \
smp_data_out->ptr = matched->CSC ; \
smp_data_out->binding = matched ; \
smp_data_out->ptr = matched->CSC ; \
}
#define CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_OUTPUTS(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_out->b != 0)) \
smp_data_out->ptr = here->binding->CSC_Complex ;
#define CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_OUTPUTS(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_out->b != 0)) \
smp_data_out->ptr = smp_data_out->binding->CSC_Complex ;
#define CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_OUTPUTS(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_out->b != 0)) \
smp_data_out->ptr = here->binding->CSC ;
#define CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_OUTPUTS(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_out->b != 0)) \
smp_data_out->ptr = smp_data_out->binding->CSC ;
#define CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_cntl->b != 0)) { \
i = smp_data_out->input[k].port[l].ptr ; \
#define CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS_E(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_cntl->b != 0)) { \
i = smp_data_out->input[k].port[l].ptr ; \
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; \
here->binding = matched ; \
smp_data_out->input[k].port[l].ptr = matched->CSC ; \
smp_data_out->input[k].port[l].e.binding = matched ; \
smp_data_out->input[k].port[l].ptr = matched->CSC ; \
}
#define CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_cntl->b != 0)) \
smp_data_out->input[k].port[l].ptr = here->binding->CSC_Complex ;
#define CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS_E(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_cntl->b != 0)) \
smp_data_out->input[k].port[l].ptr = smp_data_out->input[k].port[l].e.binding->CSC_Complex ;
#define CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_cntl->b != 0)) \
smp_data_out->input[k].port[l].ptr = here->binding->CSC ;
#define CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS_E(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_cntl->b != 0)) \
smp_data_out->input[k].port[l].ptr = smp_data_out->input[k].port[l].e.binding->CSC ;
#define CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS_F(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_cntl->b != 0)) { \
i = smp_data_out->input[k].port[l].ptr ; \
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; \
smp_data_out->input[k].port[l].f.binding = matched ; \
smp_data_out->input[k].port[l].ptr = matched->CSC ; \
}
#define CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS_F(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_cntl->b != 0)) \
smp_data_out->input[k].port[l].ptr = smp_data_out->input[k].port[l].f.binding->CSC_Complex ;
#define CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS_F(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_cntl->b != 0)) \
smp_data_out->input[k].port[l].ptr = smp_data_out->input[k].port[l].f.binding->CSC ;
#define CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS_G(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_cntl->b != 0)) { \
i = smp_data_out->input[k].port[l].ptr ; \
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; \
smp_data_out->input[k].port[l].g.binding = matched ; \
smp_data_out->input[k].port[l].ptr = matched->CSC ; \
}
#define CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS_G(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_cntl->b != 0)) \
smp_data_out->input[k].port[l].ptr = smp_data_out->input[k].port[l].g.binding->CSC_Complex ;
#define CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS_G(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_cntl->b != 0)) \
smp_data_out->input[k].port[l].ptr = smp_data_out->input[k].port[l].g.binding->CSC ;
#define CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS_H(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_cntl->b != 0)) { \
i = smp_data_out->input[k].port[l].ptr ; \
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ; \
smp_data_out->input[k].port[l].h.binding = matched ; \
smp_data_out->input[k].port[l].ptr = matched->CSC ; \
}
#define CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS_H(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_cntl->b != 0)) \
smp_data_out->input[k].port[l].ptr = smp_data_out->input[k].port[l].h.binding->CSC_Complex ;
#define CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS_H(ptr, binding, a, b) \
if ((smp_data_out->a != 0) && (smp_data_cntl->b != 0)) \
smp_data_out->input[k].port[l].ptr = smp_data_out->input[k].port[l].h.binding->CSC ;
#endif
#endif

View File

@ -46,7 +46,11 @@ NON-STANDARD FEATURES
#include "ngspice/typedefs.h"
#include "ngspice/miftypes.h"
#include "ngspice/miftypes.h"
#ifdef KLU
#include "ngspice/smpdefs.h"
#endif
/* ************************************************************************** */
@ -61,6 +65,11 @@ typedef struct Mif_E_Ptr_s {
double *branch_poscntl; /* Branch row, positive controlling column */
double *branch_negcntl; /* Branch row, negative controlling column */
#ifdef KLU
BindElement *branch_poscntlBinding ;
BindElement *branch_negcntlBinding ;
#endif
} Mif_E_Ptr_t;
@ -74,6 +83,11 @@ typedef struct Mif_F_Ptr_s {
double *pos_ibranchcntl; /* Positive row, controlling branch column */
double *neg_ibranchcntl; /* Negative row, controlling branch column */
#ifdef KLU
BindElement *pos_ibranchcntlBinding ;
BindElement *neg_ibranchcntlBinding ;
#endif
} Mif_F_Ptr_t;
@ -89,6 +103,13 @@ typedef struct Mif_G_Ptr_s {
double *neg_poscntl; /* Negative row, positive controlling column */
double *neg_negcntl; /* Negative row, negative controlling column */
#ifdef KLU
BindElement *pos_poscntlBinding ;
BindElement *pos_negcntlBinding ;
BindElement *neg_poscntlBinding ;
BindElement *neg_negcntlBinding ;
#endif
} Mif_G_Ptr_t;
@ -100,6 +121,10 @@ typedef struct Mif_H_Ptr_s {
double *branch_ibranchcntl; /* Branch row, controlling branch column */
#ifdef KLU
BindElement *branch_ibranchcntlBinding ;
#endif
} Mif_H_Ptr_t;
@ -168,6 +193,17 @@ typedef struct Mif_Smp_Ptr_s {
/* array of pointer info required for putting partials into the matrix */
Mif_Conn_Ptr_t *input; /* Matrix pointers associated with inputs */
#ifdef KLU
BindElement *pos_branchBinding ;
BindElement *neg_branchBinding ;
BindElement *branch_posBinding ;
BindElement *branch_negBinding ;
BindElement *pos_ibranchBinding ;
BindElement *neg_ibranchBinding ;
BindElement *ibranch_posBinding ;
BindElement *ibranch_negBinding ;
#endif
} Mif_Smp_Ptr_t;

View File

@ -47,10 +47,6 @@ NON-STANDARD FEATURES
#include "ngspice/gendefs.h"
#include "ngspice/ifsim.h"
#ifdef KLU
#include "ngspice/smpdefs.h"
#endif
/* The per-instance data structure */
struct MIFinstance {
@ -87,27 +83,6 @@ struct MIFinstance {
int inst_index; /* Index into inst_table in evt struct in ckt */
Mif_Callback_t callback; /* instance callback function */
#ifdef KLU
BindElement *pos_branchBinding ;
BindElement *neg_branchBinding ;
BindElement *branch_posBinding ;
BindElement *branch_negBinding ;
BindElement *pos_ibranchBinding ;
BindElement *neg_ibranchBinding ;
BindElement *ibranch_posBinding ;
BindElement *ibranch_negBinding ;
BindElement *branch_poscntlBinding ;
BindElement *branch_negcntlBinding ;
BindElement *pos_ibranchcntlBinding ;
BindElement *neg_ibranchcntlBinding ;
BindElement *pos_poscntlBinding ;
BindElement *pos_negcntlBinding ;
BindElement *neg_poscntlBinding ;
BindElement *neg_negcntlBinding ;
BindElement *branch_ibranchcntlBinding ;
#endif
};

View File

@ -159,21 +159,21 @@ MIFbindCSC (GENmodel *inModel, CKTcircuit *ckt)
switch(cntl_src_type) {
case MIF_VCVS:
CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS(e.branch_poscntl, branch_poscntlBinding, branch, pos_node);
CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS(e.branch_negcntl, branch_negcntlBinding, branch, neg_node);
CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS_E(e.branch_poscntl, branch_poscntlBinding, branch, pos_node);
CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS_E(e.branch_negcntl, branch_negcntlBinding, branch, neg_node);
break;
case MIF_ICIS:
CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS(f.pos_ibranchcntl, pos_ibranchcntlBinding, pos_node, ibranch);
CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS(f.neg_ibranchcntl, neg_ibranchcntlBinding, neg_node, ibranch);
CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS_F(f.pos_ibranchcntl, pos_ibranchcntlBinding, pos_node, ibranch);
CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS_F(f.neg_ibranchcntl, neg_ibranchcntlBinding, neg_node, ibranch);
break;
case MIF_VCIS:
CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS(g.pos_poscntl, pos_poscntlBinding, pos_node, pos_node);
CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS(g.pos_negcntl, pos_negcntlBinding, pos_node, neg_node);
CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS(g.neg_poscntl, neg_poscntlBinding, neg_node, pos_node);
CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS(g.neg_negcntl, neg_negcntlBinding, neg_node, neg_node);
CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS_G(g.pos_poscntl, pos_poscntlBinding, pos_node, pos_node);
CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS_G(g.pos_negcntl, pos_negcntlBinding, pos_node, neg_node);
CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS_G(g.neg_poscntl, neg_poscntlBinding, neg_node, pos_node);
CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS_G(g.neg_negcntl, neg_negcntlBinding, neg_node, neg_node);
break;
case MIF_ICVS:
CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS(h.branch_ibranchcntl, branch_ibranchcntlBinding, branch, ibranch);
CREATE_KLU_BINDING_TABLE_XSPICE_INPUTS_H(h.branch_ibranchcntl, branch_ibranchcntlBinding, branch, ibranch);
break;
case MIF_minus_one:
break;
@ -318,21 +318,21 @@ MIFbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt)
switch(cntl_src_type) {
case MIF_VCVS:
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS(e.branch_poscntl, branch_poscntlBinding, branch, pos_node);
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS(e.branch_negcntl, branch_negcntlBinding, branch, neg_node);
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS_E(e.branch_poscntl, branch_poscntlBinding, branch, pos_node);
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS_E(e.branch_negcntl, branch_negcntlBinding, branch, neg_node);
break;
case MIF_ICIS:
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS(f.pos_ibranchcntl, pos_ibranchcntlBinding, pos_node, ibranch);
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS(f.neg_ibranchcntl, neg_ibranchcntlBinding, neg_node, ibranch);
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS_F(f.pos_ibranchcntl, pos_ibranchcntlBinding, pos_node, ibranch);
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS_F(f.neg_ibranchcntl, neg_ibranchcntlBinding, neg_node, ibranch);
break;
case MIF_VCIS:
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS(g.pos_poscntl, pos_poscntlBinding, pos_node, pos_node);
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS(g.pos_negcntl, pos_negcntlBinding, pos_node, neg_node);
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS(g.neg_poscntl, neg_poscntlBinding, neg_node, pos_node);
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS(g.neg_negcntl, neg_negcntlBinding, neg_node, neg_node);
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS_G(g.pos_poscntl, pos_poscntlBinding, pos_node, pos_node);
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS_G(g.pos_negcntl, pos_negcntlBinding, pos_node, neg_node);
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS_G(g.neg_poscntl, neg_poscntlBinding, neg_node, pos_node);
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS_G(g.neg_negcntl, neg_negcntlBinding, neg_node, neg_node);
break;
case MIF_ICVS:
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS(h.branch_ibranchcntl, branch_ibranchcntlBinding, branch, ibranch);
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX_XSPICE_INPUTS_H(h.branch_ibranchcntl, branch_ibranchcntlBinding, branch, ibranch);
break;
case MIF_minus_one:
break;
@ -477,21 +477,21 @@ MIFbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt)
switch(cntl_src_type) {
case MIF_VCVS:
CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS(e.branch_poscntl, branch_poscntlBinding, branch, pos_node);
CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS(e.branch_negcntl, branch_negcntlBinding, branch, neg_node);
CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS_E(e.branch_poscntl, branch_poscntlBinding, branch, pos_node);
CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS_E(e.branch_negcntl, branch_negcntlBinding, branch, neg_node);
break;
case MIF_ICIS:
CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS(f.pos_ibranchcntl, pos_ibranchcntlBinding, pos_node, ibranch);
CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS(f.neg_ibranchcntl, neg_ibranchcntlBinding, neg_node, ibranch);
CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS_F(f.pos_ibranchcntl, pos_ibranchcntlBinding, pos_node, ibranch);
CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS_F(f.neg_ibranchcntl, neg_ibranchcntlBinding, neg_node, ibranch);
break;
case MIF_VCIS:
CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS(g.pos_poscntl, pos_poscntlBinding, pos_node, pos_node);
CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS(g.pos_negcntl, pos_negcntlBinding, pos_node, neg_node);
CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS(g.neg_poscntl, neg_poscntlBinding, neg_node, pos_node);
CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS(g.neg_negcntl, neg_negcntlBinding, neg_node, neg_node);
CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS_G(g.pos_poscntl, pos_poscntlBinding, pos_node, pos_node);
CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS_G(g.pos_negcntl, pos_negcntlBinding, pos_node, neg_node);
CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS_G(g.neg_poscntl, neg_poscntlBinding, neg_node, pos_node);
CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS_G(g.neg_negcntl, neg_negcntlBinding, neg_node, neg_node);
break;
case MIF_ICVS:
CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS(h.branch_ibranchcntl, branch_ibranchcntlBinding, branch, ibranch);
CONVERT_KLU_BINDING_TABLE_TO_REAL_XSPICE_INPUTS_H(h.branch_ibranchcntl, branch_ibranchcntlBinding, branch, ibranch);
break;
case MIF_minus_one:
break;