diff --git a/src/include/ngspice/cmproto.h b/src/include/ngspice/cmproto.h index 17518160c..d137264c5 100644 --- a/src/include/ngspice/cmproto.h +++ b/src/include/ngspice/cmproto.h @@ -99,6 +99,7 @@ double cm_netlist_get_l(void); void cm_irreversible(unsigned int); const char *cm_get_node_name(const char *, unsigned int); +const char *cm_get_neg_node_name(const char *, unsigned int); bool cm_probe_node(unsigned int, unsigned int, void *); bool cm_schedule_output(unsigned int, unsigned int, double, void *); diff --git a/src/include/ngspice/dllitf.h b/src/include/ngspice/dllitf.h index eaeef3d77..dd79ee4fc 100644 --- a/src/include/ngspice/dllitf.h +++ b/src/include/ngspice/dllitf.h @@ -61,6 +61,7 @@ struct coreInfo_t { double ((*dllitf_cm_netlist_get_l)(void)); void ((*dllitf_cm_irreversible)(unsigned int)); const char * ((*dllitf_cm_get_node_name)(const char *, unsigned int)); + const char* ((*dllitf_cm_get_neg_node_name)(const char*, unsigned int)); bool ((*dllitf_cm_probe_node)(unsigned int, unsigned int, void *)); bool ((*dllitf_cm_schedule_output)(unsigned int, unsigned int, diff --git a/src/xspice/cm/cm.c b/src/xspice/cm/cm.c index bf3c56180..ce4fdcdc7 100644 --- a/src/xspice/cm/cm.c +++ b/src/xspice/cm/cm.c @@ -40,6 +40,7 @@ INTERFACES cm_irreversible() cm_get_node_name() + cm_get_neg_node_name() cm_probe_node() REFERENCED FILES @@ -852,6 +853,33 @@ const char *cm_get_node_name(const char *port_name, unsigned int index) return NULL; } +/* Get the neg name of a circuit node connected to a port. */ + +const char* cm_get_neg_node_name(const char* port_name, unsigned int index) +{ + MIFinstance* instance; + Mif_Conn_Data_t* conn; + Mif_Port_Data_t* port; + int i; + + instance = g_mif_info.instance; + for (i = 0; i < instance->num_conn; ++i) { + conn = instance->conn[i]; + if (!strcmp(port_name, conn->name)) { + if (index >= (unsigned int)conn->size) + return NULL; + port = conn->port[index]; + if (port->type == MIF_DIGITAL || port->type == MIF_USER_DEFINED) { + /* Event node, no name in port data. */ + return NULL; + } + return port->neg_node_str; + } + } + return NULL; +} + + /* Test the resolved value of a connected Digital/UDN node, given * an assumed value for a particular port. */ diff --git a/src/xspice/cm/cmexport.c b/src/xspice/cm/cmexport.c index eb7846363..56cb974eb 100644 --- a/src/xspice/cm/cmexport.c +++ b/src/xspice/cm/cmexport.c @@ -60,6 +60,7 @@ struct coreInfo_t coreInfo = cm_netlist_get_l, cm_irreversible, cm_get_node_name, + cm_get_neg_node_name, cm_probe_node, cm_schedule_output, cp_getvar, diff --git a/src/xspice/icm/dlmain.c b/src/xspice/icm/dlmain.c index 8c005cf56..dae5c7993 100644 --- a/src/xspice/icm/dlmain.c +++ b/src/xspice/icm/dlmain.c @@ -350,6 +350,10 @@ const char *cm_get_node_name(const char *port, unsigned int index) { return coreitf->dllitf_cm_get_node_name(port, index); } +const char *cm_get_neg_node_name(const char *port, unsigned int index) { + return coreitf->dllitf_cm_get_neg_node_name(port, index); +} + bool cm_probe_node(unsigned int conn_index, unsigned int port_index, void *value) {