@ -61,20 +61,13 @@ static void EVTadd_msg(
int port_index ,
char * msg_text ) ;
static void EVTcreate _output_event(
static Evt_Output_Event_t * EVTget _output_event(
CKTcircuit * ckt ,
int node_index ,
int output_index ,
void * * value_ptr ) ;
Mif_Port_Data_t * port ) ;
static void EVTprocess_output (
CKTcircuit * ckt ,
Mif_Boolean_t changed ,
int output_index ,
Mif_Boolean_t invert ,
double delay ) ;
Mif_Port_Data_t * port ) ;
/*
EVTload
@ -101,14 +94,10 @@ int EVTload(
Mif_Conn_Data_t * conn ;
Mif_Port_Data_t * port ;
Mif_Private_t cm_data ;
MIFinstance * inst ;
Evt_Node_Data_t * node_data ;
MIFinstance * inst ;
void * value_ptr ;
Mif_Private_t cm_data ;
/* ***************************** */
@ -191,17 +180,16 @@ int EVTload(
port - > load = 0.0 ;
port - > total_load = node_data - > total_load [ port - > evt_data . node_index ] ;
/* If connection is an output, initialize changed to true */
/* and create a new output event object in the free list */
/* if transient analysis mode */
/* If connection is an output and transient analysis,
* initialize changed to true and ensure an output location .
*/
if ( conn - > is_output ) {
port - > changed = MIF_TRUE ;
if ( g_mif_info . circuit . anal_type = = MIF_TRAN ) {
EVTcreate_output_event ( ckt ,
port - > evt_data . node_index ,
port - > evt_data . output_index ,
& value_ptr ) ;
port - > output . pvalue = value_ptr ;
if ( port - > next_event = = NULL ) {
port - > next_event = EVTget_output_event ( ckt , port ) ;
}
port - > output . pvalue = port - > next_event - > value ;
}
}
}
@ -276,9 +264,9 @@ int EVTload(
continue ;
/* If output changed, process it */
EVTprocess_output ( ckt , port - > changed ,
port - > evt_data . output_index ,
port - > inver t , port - > delay ) ;
if ( port - > changed )
EVTprocess_output ( ck t, port ) ;
/* And prevent erroneous models from overwriting it during */
/* analog iterations */
@ -369,43 +357,40 @@ static void EVTcreate_state(
/*
EVTcreate _output_event
EVTget _output_event
This function creates a new output event .
*/
static void EVTcreate _output_event(
static Evt_Output_Event_t * EVTget _output_event(
CKTcircuit * ckt , /* The circuit structure */
int node_index , /* The node type port is on */
int output_index , /* The output index for this port */
void * * value_ptr ) /* The event created */
Mif_Port_Data_t * port ) /* The output port. */
{
int udn_index ;
Evt_Node_Info_t * * node_table ;
Evt_Output_Queue_t * output_queue ;
Evt_Output_Event_t * event ;
Evt_Output_Event_t * event , * * free_list ;
/* Check the output queue free list and use the structure */
/* at the head of the list if non-null. Otherwise, create a new one. */
output_queue = & ( ckt - > evt - > queue . output ) ;
if ( output_queue - > free [ output_index ] ) {
* value_ptr = output_queue - > free [ output_index ] - > value ;
}
else {
free_list = output_queue - > free_list [ port - > evt_data . output_index ] ;
if ( * free_list ) {
event = * free_list ;
* free_list = event - > next ;
} else {
/* Create a new event */
event = TMALLOC ( Evt_Output_Event_t , 1 ) ;
event - > next = NULL ;
/* Initialize the value */
node_table = ckt - > evt - > info . node_table ;
udn_index = node_table [ node_index ] - > udn_index ;
udn_index = node_table [ port - > evt_data . node_index ] - > udn_index ;
g_evt_udn_info [ udn_index ] - > create ( & ( event - > value ) ) ;
/* Put the event onto the free list and return the value pointer */
output_queue - > free [ output_index ] = event ;
* value_ptr = event - > value ;
}
return event ;
}
@ -483,15 +468,13 @@ the event is processed immediately.
static void EVTprocess_output (
CKTcircuit * ckt , /* The circuit structure */
Mif_Boolean_t changed , /* Has output changed? */
int output_index , /* The output of interest */
Mif_Boolean_t invert , /* Does output need to be inverted? */
double delay ) /* The output delay in transient analysis */
Mif_Port_Data_t * port )
{
int num_outputs ;
int node_index ;
int udn_index ;
int output_index ;
int output_subindex ;
Evt_Output_Info_t * * output_table ;
@ -503,33 +486,35 @@ static void EVTprocess_output(
Evt_Output_Queue_t * output_queue ;
Evt_Output_Event_t * output_event ;
Mif_Boolean_t equal ;
Mif_Boolean_t invert , equal ;
double delay ;
output_queue = & ( ckt - > evt - > queue . output ) ;
output_table = ckt - > evt - > info . output_table ;
node_table = ckt - > evt - > info . node_table ;
output_index = port - > evt_data . output_index ;
node_index = output_table [ output_index ] - > node_index ;
udn_index = node_table [ node_index ] - > udn_index ;
invert = port - > invert ;
/* if transient analysis, just put the output event on the queue */
/* to be processed at a later time */
if ( g_mif_info . circuit . anal_type = = MIF_TRAN ) {
/* If model signaled that output was not posted, */
/* leave the event struct on the free list and return */
if ( ! changed )
return ;
delay = port - > delay ;
if ( delay < = 0.0 ) {
printf ( " \n ERROR - Output delay <= 0 not allowed - output ignored! \n " ) ;
printf ( " Instance: %s \n Node: %s \n Time: %f \n " ,
g_mif_info . instance - > MIFname , node_table [ node_index ] - > name , g_mif_info . ckt - > CKTtime ) ;
g_mif_info . instance - > MIFname , node_table [ node_index ] - > name ,
g_mif_info . ckt - > CKTtime ) ;
return ;
}
/* Remove the (now used) struct from the head of the free list */
output_event = output_queue - > free [ output_index ] ;
output_queue - > free [ output_index ] = output_event - > next ;
/* Remove the (now used) struct from the port data struct. */
output_event = port - > next_event ;
port - > next_event = NULL ;
/* Invert the output value if necessary */
if ( invert )
g_evt_udn_info [ udn_index ] - > invert
@ -539,20 +524,11 @@ static void EVTprocess_output(
g_mif_info . circuit . evt_step ,
g_mif_info . circuit . evt_step + delay ) ;
return ;
}
} else {
/* If not transient analysis, process immediately. */
/* Determine if output has changed from rhsold value */
/* and put entry in output queue changed list if so */
else {
/* If model signaled that output was not posted, */
/* just return */
if ( ! changed )
return ;
/*
if ( delay > 0.0 )
printf ( " \n WARNING - Non-zero output delay not allowed in DCOP - delay ignored! \n " ) ;
*/
rhs = ckt - > evt - > data . node - > rhs ;
rhsold = ckt - > evt - > data . node - > rhsold ;