/***************
Copyright © 1996 Norlinvest Ltd. All rights reserved.
Visual Code Model Generator, EDSpice, EDWin, EE Designer, CompCAD,
CAD 1000, CAD ABC and Visionics are trade marks of Norlinvest Ltd.
Copyright © 1983 - 1996.
*
*
Copyright 1991
Georgia Tech Research Corporation
Atlanta, Georgia 30332
All Rights Reserved
****************/

#ifndef EVT_HEADER
#define EVT_HEADER x

#include "MIFdefs.h"
#include "MIFcmdat.h"
#include "MIFtypes.h"

typedef struct Evt_Output_Info_s {
    struct Evt_Output_Info_s  *next;
    int  node_index; 
    int  output_subindex;
    int  inst_index; 
    int  port_index;
} Evt_Output_Info_t;

typedef struct Evt_Port_Info_s {
    struct Evt_Port_Info_s  *next;       
    int                     inst_index; 
    int                     node_index; 
    char                    *node_name; 
    char                    *inst_name;  
    char                    *conn_name; 
    int                     port_num;
} Evt_Port_Info_t;

typedef struct Evt_Inst_Index_s {
    struct Evt_Inst_Index_s  *next; 
    int                      index; 
} Evt_Inst_Index_t;

typedef struct Evt_Node_Info_s {
    struct Evt_Node_Info_s  *next;
    char              *name;
    int               udn_index;
    Mif_Boolean_t     invert; 
    int               num_ports; 
    int               num_outputs;
    int               num_insts;
    Evt_Inst_Index_t  *inst_list; 
} Evt_Node_Info_t;

typedef struct Evt_Inst_Info_s {
    struct Evt_Inst_Info_s  *next;
    MIFinstance             *inst_ptr;
} Evt_Inst_Info_t;

typedef struct {
    Evt_Inst_Info_t    *inst_list; 
    Evt_Node_Info_t    *node_list; 
    Evt_Port_Info_t    *port_list; 
    Evt_Output_Info_t  *output_list; 
    int                *hybrid_index; 
    Evt_Inst_Info_t    **inst_table;
    Evt_Node_Info_t    **node_table; 
    Evt_Port_Info_t    **port_table;  
    Evt_Output_Info_t  **output_table; 
} Evt_Info_t;

typedef struct Evt_Inst_Event_s {
    struct Evt_Inst_Event_s  *next;
    double            event_time; 
    double            posted_time;
} Evt_Inst_Event_t; 

typedef struct {
    Evt_Inst_Event_t  **head;    
    Evt_Inst_Event_t  ***current;  
    Evt_Inst_Event_t  ***last_step; 
    Evt_Inst_Event_t  **free;        
    double            last_time;     
    double            next_time;     
    int               num_modified;   
    int               *modified_index; 
    Mif_Boolean_t     *modified;       
    int               num_pending;     
    int               *pending_index; 
    Mif_Boolean_t     *pending;        
    int               num_to_call;     
    int               *to_call_index;
    Mif_Boolean_t     *to_call;     
} Evt_Inst_Queue_t;

typedef struct {
    int               num_to_eval;    
    int               *to_eval_index; 
    Mif_Boolean_t     *to_eval; 
    int               num_changed;
    int               *changed_index;
    Mif_Boolean_t     *changed;
} Evt_Node_Queue_t;

typedef struct Evt_Output_Event_s {
    struct Evt_Output_Event_s  *next; 
    double            event_time;
    double            posted_time;
    Mif_Boolean_t     removed; 
    double            removed_time; 
    void              *value;    
} Evt_Output_Event_t; 

typedef struct {
    Evt_Output_Event_t  **head;  
    Evt_Output_Event_t  ***current; 
    Evt_Output_Event_t  ***last_step;
    Evt_Output_Event_t  **free; 
    double              last_time; 
    double              next_time;  
    int                 num_modified; 
    int                 *modified_index;
    Mif_Boolean_t       *modified;  
    int                 num_pending;
    int                 *pending_index; 
    Mif_Boolean_t       *pending; 
    int                 num_changed;
    int                 *changed_index; 
    Mif_Boolean_t       *changed; 
} Evt_Output_Queue_t;


typedef struct {
    Evt_Inst_Queue_t   inst;   
    Evt_Node_Queue_t   node; 
    Evt_Output_Queue_t output; 
} Evt_Queue_t;


typedef struct Evt_Node_s {
    struct Evt_Node_s *next;         
    Mif_Boolean_t    op; 
    double           step;  
    void             **output_value;
    void             *node_value; 
    void             *inverted_value; 
} Evt_Node_t;

typedef struct {
    Evt_Node_t     **head;  
    Evt_Node_t     ***tail;  
    Evt_Node_t     ***last_step;
    Evt_Node_t     **free;  
    int            num_modified; 
    int            *modified_index;
    Mif_Boolean_t  *modified; 
    Evt_Node_t     *rhs;  
    Evt_Node_t     *rhsold; 
    double         *total_load;
} Evt_Node_Data_t;




typedef struct Evt_State_s {
    struct Evt_State_s   *next;  
    struct Evt_State_s   *prev;
    double               step; 
    void                 *block;
} Evt_State_t;


typedef struct Evt_State_Desc_s {
    struct Evt_State_Desc_s *next;
    int                     tag; 
    int                     size; 
    int                     offset; 
} Evt_State_Desc_t;


typedef struct {
    Evt_State_t    **head;  
    Evt_State_t    ***tail;  
    Evt_State_t    ***last_step;   
    Evt_State_t    **free;    
    int            num_modified;  
    int            *modified_index; 
    Mif_Boolean_t  *modified;  
    int            *total_size; 
    Evt_State_Desc_t **desc; 
} Evt_State_Data_t;




typedef struct Evt_Msg_s {
    struct Evt_Msg_s     *next;  
    Mif_Boolean_t        op; 
    double               step; 
    char                 *text;
    int                  port_index;
} Evt_Msg_t;


typedef struct {
    Evt_Msg_t      **head; 
    Evt_Msg_t      ***tail;  
    Evt_Msg_t      ***last_step;
    Evt_Msg_t      **free;  
    int            num_modified;
    int            *modified_index;
    Mif_Boolean_t  *modified; 
} Evt_Msg_Data_t;


typedef struct {
    int                op_alternations;
    int                op_load_calls; 
    int                op_event_passes; 
    int                tran_load_calls;
    int                tran_time_backups; 
} Evt_Statistic_t;




typedef struct {
    Evt_Node_Data_t    *node;    
    Evt_State_Data_t   *state;   
    Evt_Msg_Data_t     *msg; 
    Evt_Statistic_t    *statistics; 
} Evt_Data_t;


typedef struct {
    int          num_insts;  
    int          num_hybrids;   
    int          num_hybrid_outputs; 
    int          num_nodes; 
    int          num_ports;  
    int          num_outputs;
} Evt_Count_t;

typedef struct {
    int         max_event_passes;  
    int         max_op_alternations; 
} Evt_Limit_t;

typedef struct {
    int                num_jobs; 
    char               **job_name; 
    Evt_Node_Data_t    **node_data; 
    Evt_State_Data_t   **state_data; 
    Evt_Msg_Data_t     **msg_data; 
    Evt_Statistic_t    **statistics; 
} Evt_Job_t;

typedef struct {
    Mif_Boolean_t   op_alternate;
} Evt_Option_t;

typedef struct {
    Evt_Count_t     counts;  
    Evt_Info_t      info; 
    Evt_Queue_t     queue; 
    Evt_Data_t      data; 
    Evt_Limit_t     limits; 
    Evt_Job_t       jobs; 
    Evt_Option_t    options;    
} Evt_Ckt_Data_t;



#endif /* EVT_HEADER */
