1 /* -*- tab-width: 4 -*-
2  *
3  * Electric(tm) VLSI Design System
4  *
5  * File: simals.h
6  * Header file for asynchronous logic simulator
7  * From algorithms by: Brent Serbin and Peter J. Gallant
8  * Last maintained by: Steven M. Rubin
9  *
10  * Copyright (c) 2000 Static Free Software.
11  *
12  * Electric(tm) is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * Electric(tm) is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with Electric(tm); see the file COPYING.  If not, write to
24  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
25  * Boston, Mass 02111-1307, USA.
26  *
27  * Static Free Software
28  * 4119 Alpine Road
29  * Portola Valley, California 94028
30  * info@staticfreesoft.com
31  */
32 
33 #if defined(__cplusplus) && !defined(ALLCPLUSPLUS)
34 extern "C"
35 {
36 #endif
37 
38 typedef enum {DELAY_MIN=0, DELAY_TYP, DELAY_MAX} DELAY_TYPES;
39 
40 /* The trace buffer in ALS can currently hold 10000 events.
41  * More events can be accommodated in the trace buffer by
42  * increasing its size.
43  */
44 #define DEFAULT_TRACE_SIZE	10000
45 
46 typedef struct model_ds
47 {
48 	INTBIG              num;
49 	CHAR               *name;
50 	CHAR                type;
51 	CHAR               *ptr;	/* may be CONPTR or ROWPTR or FUNCPTR */
52 	struct export_ds   *exptr;
53 	struct io_ds       *setptr;
54 	struct load_ds     *loadptr;
55 	CHAR                fanout;
56 	INTSML              priority;
57 	struct model_ds    *next;
58 	CHAR               *level;  /* hierarchical level */
59 } MODEL;
60 typedef MODEL *MODPTR;
61 
62 typedef struct row_ds
63 {
64 	struct io_ds   *inptr;
65 	struct io_ds   *outptr;
66 	float           delta;
67 	float           linear;
68 	float           exp;
69 	float           random;
70 	float           abs;    /* BA delay - SDF absolute port delay */
71 	struct row_ds  *next;
72 	CHAR           *delay;  /* delay transition name (01, 10, etc) */
73 } ROW;
74 typedef ROW *ROWPTR;
75 
76 typedef struct io_ds
77 {
78 	struct node_ds *nodeptr;
79 	UCHAR           operatr;
80 	CHAR           *operand;
81 	INTSML          strength;
82 	struct io_ds   *next;
83 } IO;
84 typedef IO *IOPTR;
85 
86 typedef struct connect_ds
87 {
88 	CHAR               *inst_name;
89 	CHAR               *model_name;
90 	struct export_ds   *exptr;
91 	struct connect_ds  *parent;
92 	struct connect_ds  *child;
93 	struct connect_ds  *next;
94 	struct channel_ds  *display_page;  /* pointer to the display page */
95 	INTBIG              num_chn;       /* number of exported channels in this level */
96 } CONNECT;
97 typedef CONNECT *CONPTR;
98 
99 typedef struct export_ds
100 {
101 	CHAR              *node_name;
102 	struct node_ds    *nodeptr;
103 	struct export_ds  *next;
104 	INTBIG            td[12];  /* transition delays */
105 } EXPORT;
106 typedef EXPORT *EXPTR;
107 
108 typedef struct load_ds
109 {
110 	CHAR            *ptr;
111 	float            load;
112 	struct load_ds  *next;
113 } LOAD;
114 typedef LOAD *LOADPTR;
115 
116 typedef struct func_ds
117 {
118 	void             (*procptr)(MODPTR);
119 	struct export_ds  *inptr;
120 	float              delta;
121 	float              linear;
122 	float              exp;
123 	float              abs;    /* absolute delay for back annotation */
124 	float              random;
125 	CHAR              *userptr;
126 	INTBIG             userint;
127 	float              userfloat;
128 } FUNC;
129 typedef FUNC *FUNCPTR;
130 
131 typedef struct node_ds
132 {
133 	struct connect_ds  *cellptr;
134 	INTBIG              num;
135 	INTBIG              sum_state;
136 	INTSML              sum_strength;
137 	INTBIG              new_state;
138 	INTSML              new_strength;
139 	BOOLEAN             tracenode;
140 	INTBIG              plot_node;
141 	struct stat_ds     *statptr;
142 	struct load_ds     *pinptr;
143 	float               load;
144 	INTBIG              visit;
145 	INTBIG              maxsize;
146 	INTBIG              arrive;
147 	INTBIG              depart;
148 	float               tk_sec;
149 	double              t_last;
150 	struct node_ds     *next;
151 } NODE;
152 typedef NODE *NODEPTR;
153 
154 typedef struct stat_ds
155 {
156 	struct model_ds  *primptr;
157 	struct node_ds   *nodeptr;
158 	INTBIG            new_state;
159 	INTSML            new_strength;
160 	UCHAR             sched_op;
161 	INTBIG            sched_state;
162 	INTSML            sched_strength;
163 	struct stat_ds   *next;
164 } STAT;
165 typedef STAT *STATPTR;
166 
167 typedef struct link_ds
168 {
169 	struct link_ds  *left;
170 	struct link_ds  *right;
171 	struct link_ds  *up;
172 	struct link_ds  *down;
173 	CHAR            *ptr;
174 	CHAR             type;
175 	UCHAR            operatr;
176 	INTBIG           state;
177 	INTSML           strength;
178 	INTSML           priority;
179 	double           time;
180 	MODPTR           primhead;
181 } LINK;
182 typedef LINK *LINKPTR;
183 
184 typedef struct trak_ds
185 {
186 	struct node_ds  *ptr;
187 	INTBIG           state;
188 	INTSML           strength;
189 	double           time;
190 } TRAK;
191 typedef TRAK *TRAKPTR;
192 
193 typedef struct channel_ds
194 {
195 	CHAR            *name;
196 	struct node_ds  *nodeptr;
197 	INTBIG           displayptr;
198 } CHANNEL;
199 typedef CHANNEL *CHNPTR;
200 
201 /*
202  * Now come all the global variables declared extern for reference by other files
203  */
204 extern MODPTR      simals_modroot, simals_primroot;
205 extern ROWPTR      simals_rowptr2;
206 extern IOPTR       simals_ioptr2;
207 extern CONPTR      simals_levelptr, simals_cellroot;
208 extern EXPTR       simals_exptr2;
209 extern NODEPTR     simals_noderoot, simals_drive_node;
210 extern LINKPTR     simals_linkfront, simals_linkback, simals_setroot;
211 extern TRAKPTR     simals_trakroot;
212 extern LOADPTR     simals_chekroot;
213 extern CHAR      **simals_rowptr1, **simals_ioptr1;
214 extern CHAR       *simals_instbuf;
215 extern INTBIG      simals_pseq, simals_nseq, *simals_instptr,
216 				   simals_trakfull, simals_trakptr;
217 extern INTBIG      simals_no_update_key;		/* variable key for "SIM_als_no_update" */
218 extern BOOLEAN     simals_seed_flag, simals_trace_all_nodes;
219 extern double      simals_time_abs;
220 extern NODEPROTO  *simals_mainproto;
221 extern INTBIG      simals_trace_size;
222 extern CHAR       *simals_title;
223 
224 /* prototypes for intratool interface */
225 LINKPTR   simals_alloc_link_mem(void);
226 #ifdef DEBUGMEMORY
227   CHAR   *_simals_alloc_mem(INTBIG, CHAR*, INTBIG);
228 # define  simals_alloc_mem(a) _simals_alloc_mem((a), (CHAR *)__FILE__, (INTBIG)__LINE__)
229 #else
230   CHAR   *simals_alloc_mem(INTBIG);
231 #endif
232 void      simals_annotate_command(INTBIG, CHAR*[]);
233 INTBIG    simals_atoi(CHAR*);
234 void      simals_build_actel_command(INTBIG, CHAR*[]);
235 void      simals_clearallvectors(BOOLEAN);
236 void      simals_clock_command(INTBIG, CHAR*[]);
237 void      simals_com_comp(INTBIG, CHAR*[10]);
238 void      simals_compute_node_name(NODEPTR, CHAR*);
239 CHAR     *simals_compute_path_name(CONPTR);
240 void      simals_convert_to_upper(CHAR*);
241 void      simals_erase_model(void);
242 void      simals_fill_display_arrays(void);
243 CONPTR    simals_find_level(CHAR*);
244 NODEPTR   simals_find_node(CHAR*);
245 BOOLEAN   simals_flatten_network(void);
246 BOOLEAN   simals_fragment_command(CHAR*);
247 void      simals_free_link_mem(LINKPTR);
248 void      simals_freeflatmemory(void);
249 void      simals_freesimmemory(void);
250 INTBIG   *simals_get_function_address(CHAR*);
251 void      simals_go_command(INTBIG, CHAR*[]);
252 void      simals_help_command(void);
253 void      simals_init(void);
254 void      simals_init_display(void);
255 double    simals_initialize_simulator(BOOLEAN);
256 void      simals_insert_link_list(LINKPTR);
257 CHAR    **simals_insert_set_list(LINKPTR);
258 void      simals_level_up_command(void);
259 void      simals_level_set_command(CHAR *instname);
260 CHAR     *simals_nextinstance(void);
261 void      simals_order_command(INTBIG, CHAR*[]);
262 void      simals_print_command(INTBIG, CHAR*[]);
263 BOOLEAN   simals_read_net_desc(NODEPROTO*);
264 void      simals_seed_command(INTBIG, CHAR*[]);
265 void      simals_set_command(INTBIG, CHAR*[]);
266 BOOLEAN   simals_set_current_level(void);
267 void      simals_term(void);
268 BOOLEAN   simals_topofinstances(CHAR**);
269 void      simals_trace_command(INTBIG, CHAR*[]);
270 CHAR     *simals_trans_number_to_state(INTBIG);
271 INTBIG    simals_trans_state_to_number(CHAR*);
272 void      simals_vector_command(INTBIG, CHAR*[]);
273 
274 BOOLEAN   simals_startsimulation(NODEPROTO *np);
275 BOOLEAN   simals_charhandlerschem(WINDOWPART*, INTSML, INTBIG);
276 BOOLEAN   simals_charhandlerwave(WINDOWPART*, INTSML, INTBIG);
277 void      simals_reportsignals(WINDOWPART *simwin, void *(*addbranch)(CHAR*, void*),
278 			void *(*findbranch)(CHAR*, void*), void *(*addleaf)(CHAR*, void*), CHAR *(*nodename)(void*));
279 
280 #if defined(__cplusplus) && !defined(ALLCPLUSPLUS)
281 }
282 #endif
283