⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 evtqueue.c

📁 ngspice又一个电子CAD仿真软件代码.功能更全
💻 C
字号:
/*============================================================================FILE    EVTqueue.cMEMBER OF process XSPICECopyright 1991Georgia Tech Research CorporationAtlanta, Georgia 30332All Rights ReservedPROJECT A-8503AUTHORS    9/12/91  Bill KuhnMODIFICATIONS    <date> <person name> <nature of modifications>SUMMARY    This file contains functions that place new events into the output and    instance queues.INTERFACES    void EVTqueue_output(        CKTcircuit *ckt,        int        output_index,        int        udn_index,        Evt_Output_Event_t  *new_event,        double     posted_time,        double     event_time)    void EVTqueue_inst(        CKTcircuit *ckt,        int        inst_index,        double     posted_time,        double     event_time)REFERENCED FILES    None.NON-STANDARD FEATURES    None.============================================================================*/#include <stdio.h>#include "ngspice.h"#include "cktdefs.h"//#include "util.h"#include "mif.h"#include "evt.h"#include "evtudn.h"#include "evtproto.h"/*EVTqueue_outputThis function places the specified output event onto the outputqueue.  It is called by EVTload during a transient analysis.The linked list in the queue for the specified output issearched beginning at the current head of the pending eventsto find the location at which to insert the new event.  Theevents are ordered in the list by event_time.  If the eventis placed before the end of the list, subsequent events areremoved from the list by marking them as 'removed' andrecording the time of removal.  This allows efficient backupof the state of the queue if a subsequent analog timestepfails.*/void EVTqueue_output(    CKTcircuit *ckt,                 /* The circuit structure */    int        output_index,         /* The output in question */    int        udn_index,            /* The associated user-defined node type */    Evt_Output_Event_t  *new_event,  /* The event to queue */    double     posted_time,          /* The current time */    double     event_time)           /* The time the event should happen */{    Evt_Output_Queue_t  *output_queue;    Evt_Output_Event_t  **here;    Evt_Output_Event_t  *next;    Mif_Boolean_t       splice;    /* Get pointers for fast access */    output_queue = &(ckt->evt->queue.output);    /* Put the times into the event struct */    new_event->event_time = event_time;    new_event->posted_time = posted_time;    new_event->removed = MIF_FALSE;    /* Update next_time in output queue */    if((output_queue->num_pending <= 0) ||            (event_time < output_queue->next_time))        output_queue->next_time = event_time;    /* Find location at which to insert event */    splice = MIF_FALSE;    here = output_queue->current[output_index];    while(*here) {        if(event_time <= (*here)->event_time) {            splice = MIF_TRUE;            break;        }        here = &((*here)->next);    }    /* If needs to be spliced into middle of existing list */    if(splice) {        /* splice it in */        next = *here;        *here = new_event;        new_event->next = next;        /* mark later events as removed */        while(next) {            if(! next->removed) {                next->removed = MIF_TRUE;                next->removed_time = posted_time;            }            next = next->next;        }    }    /* else, just put it at the end */    else {        *here = new_event;        new_event->next = NULL;    }    /* Add to the list of outputs modified since last accepted timestep */    if(! output_queue->modified[output_index]) {        output_queue->modified[output_index] = MIF_TRUE;        output_queue->modified_index[(output_queue->num_modified)++] =                output_index;    }    /* Add to the list of outputs with events pending */    if(! output_queue->pending[output_index]) {        output_queue->pending[output_index] = MIF_TRUE;        output_queue->pending_index[(output_queue->num_pending)++] =                output_index;    }}/*EVTqueue_instThis function places the specified inst event onto the instqueue.The linked list in the queue for the specified inst issearched beginning at the current head of the pending eventsto find the location at which to insert the new event.  Theevents are ordered in the list by event_time.*/void EVTqueue_inst(    CKTcircuit *ckt,          /* The circuit structure */    int        inst_index,    /* The instance in question */    double     posted_time,   /* The current time */    double     event_time)    /* The time the event should happen */{    Evt_Inst_Queue_t  *inst_queue;    Evt_Inst_Event_t  **here;    Evt_Inst_Event_t  *new_event;    Evt_Inst_Event_t  *next;    Mif_Boolean_t       splice;    /* Get pointers for fast access */    inst_queue = &(ckt->evt->queue.inst);    /* Update next_time in inst queue */    if((inst_queue->num_pending <= 0) ||            (event_time < inst_queue->next_time))        inst_queue->next_time = event_time;    /* Create a new event or get one from the free list and copy in data */    if(inst_queue->free[inst_index]) {        new_event = inst_queue->free[inst_index];        inst_queue->free[inst_index] = new_event->next;    }    else {        new_event = (void *) MALLOC(sizeof(Evt_Inst_Event_t));    }    new_event->event_time = event_time;    new_event->posted_time = posted_time;    /* Find location at which to insert event */    splice = MIF_FALSE;    here = inst_queue->current[inst_index];    while(*here) {        /* If there's an event with the same time, don't duplicate it */        if(event_time == (*here)->event_time)            return;        else if(event_time < (*here)->event_time) {            splice = MIF_TRUE;            break;        }        here = &((*here)->next);    }    /* If needs to be spliced into middle of existing list */    if(splice) {        /* splice it in */        next = *here;        *here = new_event;        new_event->next = next;    }    /* else, just put it at the end */    else {        *here = new_event;        new_event->next = NULL;    }    /* Add to the list of insts modified since last accepted timestep */    if(! inst_queue->modified[inst_index]) {        inst_queue->modified[inst_index] = MIF_TRUE;        inst_queue->modified_index[(inst_queue->num_modified)++] =                inst_index;    }    /* Add to the list of insts with events pending */    if(! inst_queue->pending[inst_index]) {        inst_queue->pending[inst_index] = MIF_TRUE;        inst_queue->pending_index[(inst_queue->num_pending)++] =                inst_index;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -