FILE EVTplot.c
MEMBER OF process XSPICE
Copyright 1992
Georgia Tech Research Corporation
Atlanta, Georgia 30332
All Rights Reserved
PROJECT A-8503
AUTHORS
5/7/92 Bill Kuhn
MODIFICATIONS
<date> <person name> <nature of modifications>
SUMMARY
This file contains function EVTplot which is used to provide basic
plotting of event driven nodes through SPICE3's 'plot' command.
INTERFACES
void EVTplot()
REFERENCED FILES
None.
NON-STANDARD FEATURES
None.
============================================================================*/
#include "ngspice/ngspice.h"
#include "ngspice/evt.h"
#include "ngspice/evtudn.h"
#include "ngspice/evtproto.h"
#include "ngspice/mif.h"
#include "ngspice/mifproto.h"
#include "ngspice/sim.h"
#include "ngspice/dvec.h"
#include "ngspice/cpstd.h"
EVTfindvec()
This function is called from FTE/vectors.c:findvec() when a node specified
for plotting cannot be located in the analog plot data. It scans the
event driven data structures looking for the node, and if found, returns
a new 'dvec' structure holding the data to be plotted. The dvec struct
is created with it's own v_scale member holding the event time vector
for this node since the time vector is not aligned with the analog data
points or with other event vectors.
The node name supplied as argument can either be a simple node name, or a
name of the form <node name>(<member>), where <member> is the member of
the event-driven structure to be plotted. These member names are defined
by the individual "user-defined node" plot_val routines for the node
type in question. If the simple node name form is used, the special
keyword "all" is supplied to the plot_val routine for the member name.
*/
struct dvec *EVTfindvec(
char *node)
{
char *name;
char *member = "all";
char *ptr;
int i;
int num_nodes;
int udn_index;
int num_events;
Mif_Boolean_t found;
Evt_Ckt_Data_t *evt;
CKTcircuit *ckt;
Evt_Node_Info_t **node_table;
Evt_Node_t *head;
Evt_Node_t *event;
double *anal_point_vec;
double *value_vec;
double value = 0;
struct dvec *d;
struct dvec *scale;
ckt = g_mif_info.ckt;
if(! ckt)
return(NULL);
evt = ckt->evt;
if(! evt)
return(NULL);
if(! evt->info.node_table)
return(NULL);
if(evt->counts.num_nodes == 0)
return(NULL);
name = MIFcopy(node);
strtolower(name);
for(ptr = name; *ptr != '\0'; ptr++)
if(*ptr == '(')
break;
if(*ptr == '(') {
*ptr = '\0';
ptr++;
member = ptr;
for( ; *ptr != '\0'; ptr++)
if(*ptr == ')')
break;
*ptr = '\0';
}
num_nodes = evt->counts.num_nodes;
node_table = evt->info.node_table;
for(i = 0, found = MIF_FALSE; i < num_nodes; i++) {
if(cieq(name, node_table[i]->name)) {
found = MIF_TRUE;
break;
}
}
if(! found) {
tfree(name);
return(NULL);
}
udn_index = node_table[i]->udn_index;
if (!evt->data.node) {
tfree(name);
return(NULL);
}
head = evt->data.node->head[i];
for(event = head, num_events = 0; event; event = event->next)
num_events++;
anal_point_vec = TMALLOC(double, 2 * (num_events + 2));
value_vec = TMALLOC(double, 2 * (num_events + 2));
for(i = 0, event = head; event; event = event->next) {
if(i > 0) {
anal_point_vec[i] = event->step;
value_vec[i] = value;
i++;
}
value = 0.0;
g_evt_udn_info[udn_index]->plot_val (event->node_value,
member,
&value);
anal_point_vec[i] = event->step;
value_vec[i] = value;
i++;
}
anal_point_vec[i] = ckt->CKTtime;
value_vec[i++] = value;
ptr = tprintf("%s_steps", name);
scale = dvec_alloc(ptr,
SV_TIME,
(VF_REAL | VF_EVENT_NODE) & ~VF_PERMANENT,
i, anal_point_vec);
d = dvec_alloc(name,
SV_VOLTAGE,
(VF_REAL | VF_EVENT_NODE) & ~VF_PERMANENT,
i, value_vec);
d->v_scale = scale;
return(d);
}