1 /*============================================================================ 2 FILE EVTaccept.c 3 4 MEMBER OF process XSPICE 5 6 Public Domain 7 8 Georgia Tech Research Corporation 9 Atlanta, Georgia 30332 10 PROJECT A-8503 11 12 AUTHORS 13 14 9/12/91 Bill Kuhn 15 16 MODIFICATIONS 17 18 <date> <person name> <nature of modifications> 19 20 SUMMARY 21 22 This file contains a function called at the end of a 23 successful (accepted) analog timepoint. It saves pointers 24 to the states of the queues and data at this accepted time. 25 26 INTERFACES 27 28 void EVTaccept(CKTcircuit *ckt, double time) 29 30 REFERENCED FILES 31 32 None. 33 34 NON-STANDARD FEATURES 35 36 None. 37 38 ============================================================================*/ 39 40 /*=== INCLUDE FILES ===*/ 41 42 #include "ngspice/config.h" 43 #include <stdio.h> 44 #include "ngspice/cktdefs.h" 45 46 #include "ngspice/mif.h" 47 #include "ngspice/evt.h" 48 #include "ngspice/evtproto.h" 49 50 51 52 /* 53 EVTaccept() 54 55 This function is called at the end of a successful (accepted) 56 analog timepoint. It saves pointers to the states of the 57 queues and data at this accepted time. 58 */ 59 60 61 EVTaccept(CKTcircuit * ckt,double time)62void EVTaccept( 63 CKTcircuit *ckt, /* main circuit struct */ 64 double time) /* time at which analog soln was accepted */ 65 { 66 67 int i; 68 int index; 69 int num_modified; 70 71 Evt_Inst_Queue_t *inst_queue; 72 Evt_Output_Queue_t *output_queue; 73 74 Evt_Node_Data_t *node_data; 75 Evt_State_Data_t *state_data; 76 Evt_Msg_Data_t *msg_data; 77 78 79 /* Exit if no event instances */ 80 if(ckt->evt->counts.num_insts == 0) 81 return; 82 83 /* Get often used pointers */ 84 inst_queue = &(ckt->evt->queue.inst); 85 output_queue = &(ckt->evt->queue.output); 86 87 node_data = ckt->evt->data.node; 88 state_data = ckt->evt->data.state; 89 msg_data = ckt->evt->data.msg; 90 91 92 /* Process the inst queue */ 93 num_modified = inst_queue->num_modified; 94 /* Loop through list of items modified since last time */ 95 for(i = 0; i < num_modified; i++) { 96 /* Get the index of the inst modified */ 97 index = inst_queue->modified_index[i]; 98 /* Update last_step for this index */ 99 inst_queue->last_step[index] = inst_queue->current[index]; 100 /* Reset the modified flag */ 101 inst_queue->modified[index] = MIF_FALSE; 102 } 103 /* Record the new last_time and reset number modified to zero */ 104 inst_queue->last_time = time; 105 inst_queue->num_modified = 0; 106 107 108 /* Process the output queue */ 109 num_modified = output_queue->num_modified; 110 /* Loop through list of items modified since last time */ 111 for(i = 0; i < num_modified; i++) { 112 /* Get the index of the output modified */ 113 index = output_queue->modified_index[i]; 114 /* Update last_step for this index */ 115 output_queue->last_step[index] = output_queue->current[index]; 116 /* Reset the modified flag */ 117 output_queue->modified[index] = MIF_FALSE; 118 } 119 /* Record the new last_time and reset number modified to zero */ 120 output_queue->last_time = time; 121 output_queue->num_modified = 0; 122 123 124 /* Process the node data */ 125 num_modified = node_data->num_modified; 126 /* Loop through list of items modified since last time */ 127 for(i = 0; i < num_modified; i++) { 128 /* Get the index of the node modified */ 129 index = node_data->modified_index[i]; 130 /* Update last_step for this index */ 131 node_data->last_step[index] = node_data->tail[index]; 132 /* Reset the modified flag */ 133 node_data->modified[index] = MIF_FALSE; 134 } 135 /* Reset number modified to zero */ 136 node_data->num_modified = 0; 137 138 139 /* Process the state data */ 140 num_modified = state_data->num_modified; 141 /* Loop through list of items modified since last time */ 142 for(i = 0; i < num_modified; i++) { 143 /* Get the index of the state modified */ 144 index = state_data->modified_index[i]; 145 /* Update last_step for this index */ 146 state_data->last_step[index] = state_data->tail[index]; 147 /* Reset the modified flag */ 148 state_data->modified[index] = MIF_FALSE; 149 } 150 /* Reset number modified to zero */ 151 state_data->num_modified = 0; 152 153 154 /* Process the msg data */ 155 num_modified = msg_data->num_modified; 156 /* Loop through list of items modified since last time */ 157 for(i = 0; i < num_modified; i++) { 158 /* Get the index of the msg modified */ 159 index = msg_data->modified_index[i]; 160 /* Update last_step for this index */ 161 msg_data->last_step[index] = msg_data->tail[index]; 162 /* Reset the modified flag */ 163 msg_data->modified[index] = MIF_FALSE; 164 } 165 /* Reset number modified to zero */ 166 msg_data->num_modified = 0; 167 168 } /* EVTaccept */ 169 170 171