source: vis_dev/vis-2.3/src/truesim/truesimInt.h @ 99

Last change on this file since 99 was 14, checked in by cecile, 13 years ago

vis2.3

File size: 10.4 KB
Line 
1/**CHeaderFile*****************************************************************
2
3  FileName    [truesimInt.h]
4
5  PackageName [truesim]
6
7  Synopsis    [Internal data structures for the truesim package.]
8
9  Description [Internal data structures for the truesim package.]
10
11  SeeAlso     [truesim.h]
12
13  Author      [Balakrishna Kumthekar]
14
15  Copyright   [This file was created at the University of Colorado at Boulder.
16  The University of Colorado at Boulder makes no warranty about the suitability
17  of this software for any purpose.  It is presented on an AS IS basis.]
18
19******************************************************************************/
20
21#ifndef _TRUESIMINT
22#define _TRUESIMINT
23
24#include "truesim.h"
25#include <string.h>
26
27/*---------------------------------------------------------------------------*/
28/* Constant declarations                                                     */
29/*---------------------------------------------------------------------------*/
30
31#define TRUESIM_NETWORK_APPL_KEY "Truesim_NetworkApplKey"
32#define TRUESIM_ERROR_VALUE -1
33
34/* Different types of event. */
35#define SIM_EVENT_0   0
36#define SIM_EVENT_1   1
37/* Threshold events are book-keeping events. They are not
38 * simulation events */
39#define THRESHOLD_1   2
40#define THRESHOLD_2   3   
41#define THRESHOLD_3   4
42#define THRESHOLD_I   5
43#define SIM_EVENT_C   6 /* Even to describe cancellation of a previously
44                         * scheduled event */
45
46/* Constant used during random number generation */
47#define MODULUS1 2147483563 /* Borrowed from util package */
48
49
50/* Basic wheel parameters for the event queue. */
51#define LOG_HOR_LEN         3
52#define LOG_WHEEL_SIZE      10
53#define MAX_TIME            2147483647 /* 2^32 -1  */
54
55/* Derived wheel parameters */
56#define HOR_LEN   (1 << LOG_HOR_LEN) /* # of time 'ticks' in
57                                      * each slot of the time wheel. */
58#define WHEEL_SIZE  (1 << LOG_WHEEL_SIZE) /* # slots in the wheel */
59#define PERIOD  (HOR_LEN * WHEEL_SIZE) /* # time ticks in the wheel */
60#define HALF_PERIOD  (PERIOD / 2)
61
62/* # events to allocate at a time. */
63#define MEM_CHUNK 1023
64
65
66/*---------------------------------------------------------------------------*/
67/* Type declarations                                                         */
68/*---------------------------------------------------------------------------*/
69
70
71/*---------------------------------------------------------------------------*/
72/* Structure declarations                                                    */
73/*---------------------------------------------------------------------------*/
74
75/**Struct**********************************************************************
76
77  Synopsis    [Structure to store simulation events.]
78
79  Description [Structure to store simulation events. The Event structure is
80  used only for real-delay simulation.]
81
82  SeeAlso     [EventQueue]
83
84******************************************************************************/
85typedef struct Event {
86  long type; /* One of the events defined above */
87  long time; /* time to simulate the event */
88  Ntk_Node_t *gate; /* node that needs to be simulated */
89  struct Event *horizontal; /* Pointer to other events in queue */
90  struct Event *vertical;
91  struct Event *bottom;
92} Event;
93
94
95/**Struct**********************************************************************
96
97  Synopsis    [Event queue.]
98
99  Description [Event queue. The event queue is a converging list data structure
100  used to access simulation events as the time progresses. It is based on the
101  concept of circular buffer (time wheel). Each slot in the wheel
102  represents a range of time values, i.e., a time interval.
103  Since there are events for different times in the same list, the list
104  is kept sorted. Each element in the list is itself a vertical list of
105  events. Events in the vertical list are all scheduled to be simulated at
106  a given time within the time interval mapped by the slot. The following
107  shows the converging list data structure.
108
109  wheel      Vertial lists
110    |             |
111    v             v
112   -------      _____   _____ 
113   |slot 0| --> |   |-->|   |-->         <---- Horizontal list
114   -------      -----   -----
115                  |       |
116                  v       v
117                ----- 
118                |   |
119                -----
120                  | 
121                  v
122                  .
123                  .
124                  .
125   -------      _____   _____ 
126   |slot 1| --> |   |-->|   |-->         <---- Horizontal list
127   -------      -----   -----
128                  |       |
129                  v       v
130                -----   -----
131                |   |-->|   |-->
132                -----   -----
133                  |       |
134                  v       v
135                  .       .
136                  .       .
137                  .       .
138
139  All the horizontal lists point to an event, 'Threshold1', th1.
140  Event 'th1' points to a list of events that do not fit in the current time
141  interval represented by the wheel. Event 'thi' is the last event,
142  i.e., event at time infinity.
143
144  The events th1, th2, th3 and thi are 'control events' and not simulation
145  events. They help in managing event queue. For more info. please refer
146  to InitQueue in truesimMain.c.
147
148  freeList and nextFre aid in memory management.]
149
150  SeeAlso     [Event]
151
152******************************************************************************/
153typedef struct EventQueue {
154  Event *th1,*th2,*th3,*thi;
155  Event **wheel;
156  Event *current;
157  long time; /* Current time */
158  Event **freeList;
159  Event *nextFree;
160} EventQueue;
161
162
163/**Struct**********************************************************************
164
165  Synopsis [Structure to handle simulation needs of the network. This
166  data structure needs to be initialized for each node in the network.]
167
168  Description [Structure to handle simulation needs of the network. This
169  data structure needs to be initialized for each node in the network.]
170
171  SeeAlso     [Event]
172
173******************************************************************************/
174typedef struct TrueSim_t {
175  int depth; /* Node's topological depth */
176  float delay; /* Node delay */
177  char value; /* Node output value */
178  float prob; /* Prob. of being 1 */
179  float switching; /* Number of switchings */
180  float load; /* Load at the output of the node */
181  Event *event; /* Pointer back to the event. In the ideal case this should be
182                 * a member of the Ntk_Node_t data structure. */
183} TrueSim_t;
184
185
186/**Struct**********************************************************************
187
188  Synopsis [Data structure for the truesim package.]
189
190  Description [Data structure for the truesim package. It holds information
191  that remains unchanged during a given simulation run.]
192
193  SeeAlso     [TrueSim_t]
194
195******************************************************************************/
196typedef struct TruesimInfoStruct {
197  boolean trueDelay; /* TRUE for true delay simulation, FALSE for zero delay */
198  int repeatHeader; /* Print PI/PO names along with their values during
199                     * simulation */
200  int truesimVerbose; /* Verbosity level */
201  array_t *depthArray; /* Sorted array (according to top. depth) of array of
202                        * network nodes */
203  st_table *nodeToSimTable; /* node --> TrueSim_t table */
204}Truesim_Info_t;
205
206/*---------------------------------------------------------------------------*/
207/* Variable declarations                                                     */
208/*---------------------------------------------------------------------------*/
209
210
211/*---------------------------------------------------------------------------*/
212/* Macro declarations                                                        */
213/*---------------------------------------------------------------------------*/
214
215/**Macro***********************************************************************
216
217   Synopsis     [Given a time, the macro returns the slot in the time wheel.]
218
219   SideEffects  [None]
220
221   SeeAlso      [TYPE, TIME, NEXT_HOR, NEXT_VER]
222
223******************************************************************************/
224
225#define WHEEL_POS(t)    (((t) >> LOG_HOR_LEN) & ((1 << LOG_WHEEL_SIZE) - 1))
226
227
228/**Macro***********************************************************************
229
230  Synopsis     [Allocate a new event or reuse a free event form the freelist.]
231
232  SideEffects  [nextFree is changed.]
233
234  SeeAlso      []
235
236******************************************************************************/
237
238#define EVENT_ALLOC(queue,new) \
239  if ((queue)->nextFree == NIL(Event)) { \
240       NewPage(queue); \
241  } \
242  new = (queue)->nextFree; \
243  (queue)->nextFree = (queue)->nextFree->horizontal
244
245/**Macro***********************************************************************
246
247  Synopsis     [Return memory associated with an event to the freeList.]
248
249  SideEffects  [nextFree is updated.]
250
251  SeeAlso      []
252
253******************************************************************************/
254
255#define EVENT_FREE(queue,old) \
256(old)->horizontal = (queue)->nextFree; \
257(queue)->nextFree = (old);
258
259/* Various macros to get details of an event */
260#define TYPE(_event) (_event)->type
261#define TIME(_event) (_event)->time
262#define NEXT_HOR(_event) (_event)->horizontal
263#define NEXT_VER(_event) (_event)->vertical
264#define NEXT_BOT(_event) (_event)->bottom
265#define GATE(_event) (_event)->gate
266
267
268/**AutomaticStart*************************************************************/
269
270/*---------------------------------------------------------------------------*/
271/* Function prototypes                                                       */
272/*---------------------------------------------------------------------------*/
273
274EXTERN void TruesimEndSimulation(void *data);
275EXTERN int TruesimSimulateNetwork(Ntk_Network_t *network, char *simFile, char *probFile, char *delayFile, char *dumpFile, boolean trueDelay, int genVectors, int N);
276EXTERN char TruesimEvaluateNode(Ntk_Node_t *node, graph_t *partition, bdd_manager *ddManager, st_table *nodeToSimTable);
277EXTERN st_table * TruesimNetworkReadSimTable(Ntk_Network_t *network);
278EXTERN array_t * TruesimNetworkReadDepthArray(Ntk_Network_t *network);
279EXTERN void TruesimInitializeActivityFields(Ntk_Network_t *network, st_table *nodeToSimTable);
280EXTERN bdd_t * TruesimComputeFaninMinterm(bdd_manager *ddManager, Ntk_Node_t *node, st_table *nodeToSimTable);
281EXTERN void TruesimPrintNameHeader(Ntk_Network_t *network);
282EXTERN void TruesimPrintNetworkNodeLogicState(Ntk_Network_t *network);
283EXTERN void TruesimReadDelayFile(Ntk_Network_t *network, char *delayFile, st_table *nodeToSimTable);
284EXTERN void TruesimWarmUpPatternSimulate(Ntk_Network_t *network, array_t *inputArray, char *vector);
285
286/**AutomaticEnd***************************************************************/
287
288#endif /* _TRUESIMINT */
Note: See TracBrowser for help on using the repository browser.