New code-model library functions cm_schedule_output() and cm_getvar().
To be used in the inertial delay code for digital code models.
This commit is contained in:
parent
4d8e17487b
commit
a9270aa312
|
|
@ -98,6 +98,10 @@ double cm_netlist_get_l(void);
|
|||
|
||||
const char *cm_get_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 *);
|
||||
|
||||
enum cp_types;
|
||||
bool cm_getvar(char *, enum cp_types, void *, size_t);
|
||||
|
||||
Complex_t cm_complex_set(double real, double imag);
|
||||
Complex_t cm_complex_add(Complex_t x, Complex_t y);
|
||||
|
|
|
|||
|
|
@ -61,6 +61,9 @@ struct coreInfo_t {
|
|||
const char * ((*dllitf_cm_get_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,
|
||||
double, void *));
|
||||
bool ((*dllitf_cm_getvar)(char *, enum cp_types, void *, size_t));
|
||||
Complex_t ((*dllitf_cm_complex_set)(double, double));
|
||||
Complex_t ((*dllitf_cm_complex_add)(Complex_t, Complex_t));
|
||||
Complex_t ((*dllitf_cm_complex_subtract)(Complex_t, Complex_t));
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
#include "ngspice/cm.h"
|
||||
#include "ngspice/dllitf.h"
|
||||
|
||||
extern bool cp_getvar(char *, enum cp_types, void *, size_t);
|
||||
|
||||
/*how annoying!, needed for structure below*/
|
||||
static void *tcalloc(size_t a, size_t b) {
|
||||
return tmalloc(a*b); /* FIXME, tcalloc must zero !?!? */
|
||||
|
|
@ -60,6 +62,8 @@ struct coreInfo_t coreInfo =
|
|||
cm_netlist_get_l,
|
||||
cm_get_node_name,
|
||||
cm_probe_node,
|
||||
cm_schedule_output,
|
||||
cp_getvar,
|
||||
cm_complex_set,
|
||||
cm_complex_add,
|
||||
cm_complex_subtract,
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ NON-STANDARD FEATURES
|
|||
|
||||
#include "ngspice/mifproto.h"
|
||||
#include "ngspice/evtproto.h"
|
||||
#include "ngspice/cmproto.h"
|
||||
|
||||
|
||||
static void EVTcreate_state(
|
||||
|
|
@ -127,7 +128,6 @@ int EVTload(
|
|||
cm_data.circuit.call_type = MIF_EVENT_DRIVEN;
|
||||
cm_data.circuit.temperature = ckt->CKTtemp - 273.15;
|
||||
|
||||
|
||||
/* Setup data needed by cm_... functions */
|
||||
|
||||
g_mif_info.ckt = ckt;
|
||||
|
|
@ -456,6 +456,51 @@ static void EVTadd_msg(
|
|||
}
|
||||
|
||||
|
||||
/* This is a code-model library function. Placed here to use local
|
||||
* static functions.
|
||||
*/
|
||||
|
||||
bool cm_schedule_output(unsigned int conn_index, unsigned int port_index,
|
||||
double delay, void *vp)
|
||||
{
|
||||
MIFinstance *instance;
|
||||
Mif_Conn_Data_t *conn;
|
||||
Mif_Port_Data_t *port;
|
||||
Evt_Node_Info_t *node_info;
|
||||
Evt_Output_Event_t *output_event;
|
||||
int udn_index;
|
||||
|
||||
if (delay < 0 || g_mif_info.circuit.anal_type != MIF_TRAN)
|
||||
return FALSE;
|
||||
instance = g_mif_info.instance;
|
||||
if (conn_index >= (unsigned int)instance->num_conn)
|
||||
return FALSE;
|
||||
conn = instance->conn[conn_index];
|
||||
if (port_index >= (unsigned int)conn->size)
|
||||
return FALSE;
|
||||
port = conn->port[port_index];
|
||||
if (port->type != MIF_DIGITAL && port->type != MIF_USER_DEFINED)
|
||||
return FALSE;
|
||||
|
||||
/* Get an output structure and copy the new value. */
|
||||
|
||||
output_event = EVTget_output_event(g_mif_info.ckt, port);
|
||||
node_info =
|
||||
g_mif_info.ckt->evt->info.node_table[port->evt_data.node_index];
|
||||
udn_index = node_info->udn_index;
|
||||
g_evt_udn_info[node_info->udn_index]->copy(vp, output_event->value);
|
||||
|
||||
/* Queue the output. */
|
||||
|
||||
if (port->invert)
|
||||
g_evt_udn_info[udn_index]->invert(output_event->value);
|
||||
EVTqueue_output(g_mif_info.ckt, port->evt_data.output_index,
|
||||
udn_index, output_event,
|
||||
g_mif_info.circuit.evt_step,
|
||||
g_mif_info.circuit.evt_step + delay);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
EVTprocess_output
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ngspice/cpextern.h"
|
||||
#include "ngspice/devdefs.h"
|
||||
#include "ngspice/dstring.h"
|
||||
#include "ngspice/dllitf.h"
|
||||
|
|
@ -348,6 +349,18 @@ bool cm_probe_node(unsigned int conn_index,
|
|||
return coreitf->dllitf_cm_probe_node(conn_index, port_index, value);
|
||||
}
|
||||
|
||||
bool cm_schedule_output(unsigned int conn_index, unsigned int port_index,
|
||||
double delay, void *vp)
|
||||
{
|
||||
return (coreitf->dllitf_cm_schedule_output)(conn_index, port_index,
|
||||
delay, vp);
|
||||
}
|
||||
|
||||
bool cm_getvar(char *name, enum cp_types type, void *retval, size_t rsize)
|
||||
{
|
||||
return (coreitf->dllitf_cm_getvar)(name, type, retval, rsize);
|
||||
}
|
||||
|
||||
Complex_t cm_complex_set(double real, double imag) {
|
||||
return (coreitf->dllitf_cm_complex_set)(real,imag);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue