Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / yagle / yagle / yag_lib.h
1 /****************************************************************************/
2 /* */
3 /* Chaine de CAO & VLSI Alliance */
4 /* */
5 /* Produit : YAGLE v3.50 */
6 /* Fichier : yag300.h */
7 /* */
8 /* (c) copyright 1994 Laboratoire MASI equipe CAO & VLSI */
9 /* Tous droits reserves */
10 /* Support : e-mail alliance-support@asim.lip6.fr */
11 /* */
12 /* */
13 /****************************************************************************/
14
15 #ifndef YAG
16 #define YAG
17
18 #include <sys/types.h>
19 #include <sys/time.h>
20 #include <sys/resource.h>
21 #include CNS_H
22
23 /* disassembly mode masks */
24
25 #define YAG_GENBEFIG ((long) 0x00000001 )
26 #define YAG_GENLOFIG ((long) 0x00000002 )
27
28 /* info constants */
29
30 #define YAG_INFODLATCH ((long) 0x00000001 )
31 #define YAG_INFONOTDLATCH ((long) 0x00000002 )
32 #define YAG_INFOPRECHARGE ((long) 0x00000004 )
33 #define YAG_INFONOTPRECHARGE ((long) 0x00000008 )
34 #define YAG_INFORSMARK ((long) 0x00000010 )
35 #define YAG_INFORSLEGAL ((long) 0x00000020 )
36 #define YAG_INFORSILLEGAL ((long) 0x00000040 )
37 #define YAG_INFOMODELLOOP ((long) 0x00000100 )
38 #define YAG_INFONOTMODELLOOP ((long) 0x00000200 )
39
40 /* transistor overtyping */
41
42 #define CAPACITE ((char) 0x10 )
43 #define BLEEDER ((char) 0x20 )
44 #define RESIST ((char) 0x40 )
45 #define DIODE ((char) 0x80 )
46 #define USED ((char) 0x01 )
47 #define ORIENTED ((char) 0x02 )
48
49 /* branch overtyping */
50
51 #define YAG_PULLUP ((long) 0x20000000 )
52 #define YAG_MARKFALSE ((long) 0x00200000 )
53 #define YAG_TREATED ((long) 0x00100000 )
54 #define YAG_FALSECONF ((long) 0x40000000 )
55 #define YAG_DUALBRANCH ((long) 0x01000000 )
56 #define YAG_TEMPBRANCH ((long) 0x02000000 )
57 #define YAG_IGNORE ((long) 0x04000000 )
58 #define YAG_ASYNC ((long) 0x08000000 )
59 #define YAG_SYNC ((long) 0x00400000 )
60 #define YAG_FALSE_UP ((long) 0x00800000 )
61 #define YAG_FALSE_DN ((long) 0x80000000 )
62 #define YAG_LATCH_NF ((long) 0x10000000 )
63
64 /* cone overtyping */
65
66 #define YAG_DELETED ((long) 0x80000000 )
67 #define YAG_PARTIAL ((long) 0x00800000 )
68 #define YAG_FORCED ((long) 0x20000000 )
69 #define YAG_MARK ((long) 0x10000000 )
70 #define YAG_TEMPCONE ((long) 0x08000000 )
71 #define YAG_CELLOUT ((long) 0x04000000 )
72 #define YAG_HASDUAL ((long) 0x02000000 )
73 #define YAG_CONESEEN ((long) 0x01000000 )
74 #define YAG_CONSTRAINT ((long) 0x00040000 )
75 #define YAG_STOP ((long) 0x00400000 )
76 #define YAG_GLUECONE ((long) 0x00200000 )
77 #define YAG_VISITED ((long) 0x00100000 )
78 #define YAG_LOOPCONF ((long) 0x00080000 )
79 #define YAG_FALSECONF ((long) 0x40000000 )
80 #define YAG_FORCEPRIM ((long) 0x00020000 )
81 #define YAG_AUTOLATCH ((long) 0x00010000 )
82
83 /* cone tectype overtyping */
84
85 #define YAG_SENSITIVE ((long) 0x01000000 )
86 #define YAG_SPLITTIMING ((long) 0x02000000 )
87 #define YAG_NOTLATCH ((long) 0x04000000 )
88 #define YAG_LEVELHOLD ((long) 0x08000000 )
89 #define YAG_RESCONF ((long) 0x10000000 )
90 #define YAG_BADCONE ((long) 0x20000000 )
91
92 /* edge overtyping */
93
94 #define YAG_MARK ((long) 0x10000000 )
95 #define YAG_PRECHCOM ((long) 0x20000000 )
96 #define YAG_FALSECONF ((long) 0x40000000 )
97 #define YAG_NOT_FUNCTIONAL ((long) 0x80000000 )
98 #define YAG_EDGE_MASK ((long) 0x00ffffff )
99
100 /* cell types */
101
102 #define YAG_CELL_MS_SC ((long) 0x00000001 )
103 #define YAG_CELL_MSS_SC ((long) 0x00000002 )
104 #define YAG_CELL_MSR_SC ((long) 0x00000003 )
105 #define YAG_CELL_MSNR_SC ((long) 0x00000023 )
106 #define YAG_CELL_MS_SC_RT ((long) 0x00000011 )
107 #define YAG_CELL_MSS_SC_RT ((long) 0x00000012 )
108 #define YAG_CELL_MSR_SC_RT ((long) 0x00000013 )
109 #define YAG_CELL_MSNR_SC_RT ((long) 0x00000033 )
110 #define YAG_CELL_MSDIFF ((long) 0x00000004 )
111 #define YAG_CELL_MS_SX ((long) 0x00000101 )
112 #define YAG_CELL_MS_SX_RT ((long) 0x00000111 )
113 #define YAG_CELL_FFT2 ((long) 0x00000005 )
114 #define YAG_CELL_FD2R ((long) 0x00000006 )
115 #define YAG_CELL_FD2S ((long) 0x00000007 )
116 #define YAG_CELL_LD1 ((long) 0x00000008 )
117 #define YAG_CELL_LD1R ((long) 0x00000009 )
118 #define YAG_CELL_BINAND ((long) 0x0000000a )
119 #define YAG_CELL_BINOR ((long) 0x0000000b )
120 #define YAG_CELL_LATCH ((long) 0x0000000c )
121 #define YAG_CELLMASK ((long) 0x0000ffff )
122
123 /* for the cnsfig USER field */
124
125 #define YAG_TEMPCONE_PTYPE ((long) 0x10000001 )
126 #define YAG_GLUECONE_PTYPE ((long) 0x10000002 )
127 #define YAG_CONE_NETLIST_PTYPE ((long) 0x10000004 )
128
129 /* for the cone USER field */
130
131 #define YAG_MEMORY_PTYPE ((long) 0x10000002 )
132 #define YAG_INPUTS_PTYPE ((long) 0x10000005 )
133 #define YAG_WEIGHT_PTYPE ((long) 0x10000006 )
134 #define YAG_MODEL_PTYPE ((long) 0x10000007 )
135 #define YAG_OLDNAME_PTYPE ((long) 0x10000008 )
136 #define YAG_OLDINDEX_PTYPE ((long) 0x10000009 )
137 #define YAG_LATCHINFO_PTYPE ((long) 0x1000000b )
138 #define YAG_BISTABLE_PTYPE ((long) 0x1000000c )
139 #define YAG_INCONE_PTYPE ((long) 0x10000012 )
140 #define YAG_BACK_PTYPE ((long) 0x10000013 )
141 #define YAG_DUALEXPR_PTYPE ((long) 0x10000014 )
142 #define YAG_DUALINPUTS_PTYPE ((long) 0x10000015 )
143 #define YAG_LATCHBEFIG_PTYPE ((long) 0x10000016 )
144 #define YAG_BUSBEFIG_PTYPE ((long) 0x10000017 )
145 #define YAG_INFO_PTYPE ((long) 0x10000018 )
146 #define YAG_STOP_PTYPE ((long) 0x10000019 )
147 #define YAG_SAVEINPUTS_PTYPE ((long) 0x10000020 )
148 #define YAG_MARK_PTYPE ((long) 0x10000111 )
149
150 /* for the edge USER field */
151
152 #define YAG_WEIGHT_PTYPE ((long) 0x10000006 )
153 #define YAG_MODEL_PTYPE ((long) 0x10000007 )
154
155 /* for the branch USER field */
156
157 #define YAG_WEIGHT_PTYPE ((long) 0x10000006 )
158 #define YAG_SIGLIST_PTYPE ((long) 0x1000000d )
159 #define YAG_LOCONLIST_PTYPE ((long) 0x1000000e )
160 #define YAG_BRANCHEXPR_PTYPE ((long) 0x1000000f )
161 #define YAG_BRANCHBDD_PTYPE ((long) 0x10000010 )
162
163 /* for the cell USER field */
164
165 #define YAG_SIGLIST_PTYPE ((long) 0x1000000d )
166
167 /* for the connector USER field */
168
169 #define YAG_CONSTRAINT_PTYPE ((long) 0x1000000f )
170 #define YAG_OLDNAME_PTYPE ((long) 0x10000008 )
171 #define YAG_INOUT_PTYPE ((long) 0x1000000b )
172 #define YAG_LOCON_PTYPE ((long) 0x1000000c )
173 #define YAG_INPUT_PTYPE ((long) 0x1000000d )
174
175 /* for the signal USER field */
176
177 #define YAG_CONE_PTYPE ((long) 0x10000010 )
178 #define YAG_VAL_S_PTYPE ((long) 0x10000011 )
179 #define YAG_TOPSIG_PTYPE ((long) 0x10000012 )
180 #define YAG_MARKSIG_PTYPE ((long) 0x10000013 )
181 #define YAG_CHECK_PTYPE ((long) 0x10000014 )
182 #define YAG_DONE_PTYPE ((long) 0x10000015 )
183
184 /* for the instance USER field */
185
186 #define YAG_MARKINS_PTYPE ((long) 0x10000013 )
187
188 /* for the transistor USER field */
189
190 #define YAG_GRIDCON_PTYPE ((long) 0x10000014 )
191 #define YAG_BIDIR_PTYPE ((long) 0x10000015 )
192 #define YAG_TRANS_SIGN ((long) 0x10000016 )
193 #define YAG_WIDTH_PTYPE ((long) 0x10000017 )
194
195 /* for bequad USER field */
196
197 #define YAG_CONE_PTYPE ((long) 0x10000010 )
198 #define YAG_CONELIST_PTYPE ((long) 0x10000011 )
199 #define YAG_LOCK_PTYPE ((long) 0x10000012 )
200
201 #ifndef TRUE
202 #define TRUE 1
203 #endif
204 #ifndef FALSE
205 #define FALSE 0
206 #endif
207
208 #define YAG_YES 1
209 #define YAG_NO 0
210
211 #define VDD_BRANCH 0
212 #define VSS_BRANCH 1
213 #define EXT_BRANCH 2
214 #define GND_BRANCH 3
215
216 #define A_LOT_OF_BRANCHES 200
217
218 #define YAGBUFSIZE 1024
219
220 #define YAG_NO_TIMING 0
221 #define YAG_MAX_TIMING 1
222 #define YAG_MIN_TIMING 2
223 #define YAG_MED_TIMING 3
224
225 /* RS detection mode masks */
226 #define YAG_RS_MODEL ((short) 0x08 )
227 #define YAG_RS_LATCH ((short) 0x10 )
228 #define YAG_RS_TOLERANT ((short) 0x20 )
229 #define YAG_RS_LEGAL ((short) 0x40 )
230 #define YAG_RS_ILLEGAL ((short) 0x80 )
231
232 /* speed up flags */
233 #define YAG_HAS_INF_INPUTS 1
234
235 /* branch group */
236
237 typedef struct {
238 branch_list *BREXT, /* list of external branches */
239 *BRVDD, /* list of branches to VDD */
240 *BRVSS, /* list of branches to VSS */
241 *BRGND; /* list of branches to GND */
242 } branch_group;
243
244 /* functional dependancy graph structure */
245
246 typedef union {
247 cone_list *CONE;
248 locon_list *LOCON;
249 void *PTR;
250 } yag_gnodedata;
251
252 typedef struct gnode {
253 struct gnode *NEXT;
254 long TYPE;
255 yag_gnodedata OBJECT;
256 short VISITED;
257 short DEPTH;
258 short TREEBIT;
259 short NUMSONS;
260 chain_list *SONS;
261 chain_list *FATHERS;
262 } gnode_list;
263
264 typedef struct graph {
265 struct graph *NEXT;
266 gnode_list *HEADNODE;
267 ptype_list *ROOTNODES;
268 chain_list *PRIMVARS;
269 ptype_list *CONSTRAINTS;
270 ptype_list *EXTRA_CONSTRAINTS;
271 ht *HASHTAB;
272 ht *NAMEHASHTAB;
273 short WIDTH;
274 int COMPLETE;
275 } graph;
276
277 /* Global variables to be positionned for yagDisassemble */
278
279 typedef struct yag_context {
280 struct yag_context *NEXT;
281 short YAG_DEPTH; /* functional analysis depth */
282 short YAG_MAX_LINKS; /* max length of one branch */
283 int YAG_BDDCEILING; /* max nodes in BDD system */
284 short YAG_USE_FCF; /* !=0 if FCF analysis used */
285 short YAG_ORIENT; /* transistor orientation */
286 short YAG_PROP_HZ; /* FCF through HZ nodes */
287 short YAG_MAKE_CELLS; /* cell detection */
288 short YAG_GENIUS; /* GENIUS hierarchical recognition */
289 short YAG_ONLY_GENIUS; /* only use GENIUS */
290 short YAG_CELL_SHARE; /* cones in multiple cells */
291 short YAG_DETECT_LATCHES; /* latch detection */
292 short YAG_DETECT_PRECHARGE; /* precharge detection */
293 short YAG_BLEEDER_STRICTNESS; /* level 0-2 of bleeder strictness */
294 short YAG_LOOP_ANALYSIS; /* functional analysis of loops */
295 short YAG_AUTO_RS; /* automatic RS detection */
296 short YAG_BUS_ANALYSIS; /* full bus analysis */
297 short YAG_BUS_DEPTH; /* depth for bus analysis */
298 short YAG_AUTOLOOP_CEILING; /* max inputs for auto latch */
299 short YAG_AUTOLOOP_DEPTH; /* analysis depth for auto latch */
300 short YAG_FCL_DETECT; /* cell detection using FCL */
301 short YAG_ONLY_FCL; /* only use FCL */
302 short YAG_ONE_SUPPLY; /* single vdd and vss in vbe */
303 short YAG_NO_SUPPLY; /* no vdd or vss in vbe */
304 short YAG_NOTSTRICT; /* undriven gate not error */
305 short YAG_REMOVE_PARA; /* remove parallel transistors */
306 short YAG_RELAX_ALGO; /* give-up algo during making gates*/
307 short YAG_RELAX_LINKS; /* max links during give-up algo */
308 short YAG_MINIMISE_CONES; /* remove parallel branches */
309 short YAG_MINIMISE_INV; /* remove simple inversions */
310 short YAG_GEN_SIGNATURE; /* generate signature for cones */
311 short YAG_ASSUME_PRECEDE; /* assume no conflicts for bux/bus */
312 short YAG_BLEEDER_PRECHARGE; /* assume bleeder maintains one */
313 short YAG_TRISTATE_MEMORY; /* internal tristates memorise */
314 short YAG_MARK_TRISTATE_MEMORY; /* internal tristates marked latch */
315 short YAG_INTERFACE_VECTORS; /* vectorise interface */
316 short YAG_SIMPLIFY_EXPR; /* simplify elementary expressions */
317 short YAG_SIMPLIFY_PROCESSES; /* simplify processes */
318 short YAG_COMPACT_BEHAVIOUR; /* compact the data flow */
319 short YAG_ELP; /* update capas from elp file */
320 short YAG_BLOCK_BIDIR; /* block and report bidir trans. */
321 double YAG_THRESHOLD; /* latch resolution threshold */
322 short YAG_TAS_TIMING; /* calculate delays with Tas */
323 double YAG_SPLITTIMING_RATIO; /* factor for up/down separation */
324 double YAG_SENSITIVE_RATIO; /* factor for sensitive timing */
325 short YAG_SENSITIVE_MAX; /* max driver for sensitive timing */
326 short YAG_HELP_S; /* use _s orientation info */
327 short YAG_STAT_MODE; /* save a .stat file */
328 char *YAG_DEBUG_CONE; /* name of cone to debug */
329 short YAG_SILENT_MODE; /* no messages displayed on stdout */
330 short YAG_LOOP_MODE; /* generate a .loop file */
331 short YAG_KEEP_REDUNDANT; /* keep redundant branches */
332 short YAG_KEEP_GLITCHERS; /* keep glitched branches */
333 short YAG_STRICT_CKLATCH; /* unmark all non CKLATCH commands */
334 short YAG_USESTMSOLVER; /* STM conflict resolution */
335 short YAG_UNMARK_BISTABLES; /* Bistables not latches */
336 short YAG_LATCH_REQUIRE_CLOCK; /* Use INF clockdefs latche recog. */
337 short YAG_AUTO_FLIPFLOP; /* automatic flip-flop recog. */
338 short YAG_AUTO_ASYNC; /* automatic set-reset recog. */
339 short YAG_AUTO_MEMSYM; /* automatic memsym recog. */
340 short YAG_DETECT_REDUNDANT; /* detect redundant branches */
341 short YAG_DETECT_LEVELHOLD; /* detect level-hold loops */
342 short YAG_SIMPLE_LATCH; /* simple latch detection */
343 short YAG_USE_CONNECTOR_DIRECTION; /* connector direction orients transistors */
344 short YAG_CLOCK_GATE; /* detect clock gating */
345 short YAG_DETECT_SIMPLE_MEMSYM; /* simple memsym */
346 short YAG_MEMSYM_HEURISTIC; /* memsym branch suppression */
347 short YAG_STUCK_LATCH; /* stuck latch allowed */
348 short YAG_DELAYED_RS; /* non-overlapping clockgen */
349
350 /* Names passed on command line */
351
352 char *YAG_FILENAME; /* filename & default figure name */
353 char *YAG_FIGNAME; /* cone netlist figure name */
354 char *YAG_OUTNAME; /* behavioural figure name */
355
356 /* Additional global variables to be positionned for yagle_main */
357
358 short YAG_FILE; /* generate a .cns file with simplified lofig */
359 short YAG_CNSLO; /* generate a .cns file with full lofig */
360 short YAG_CONE_NETLIST; /* generate a hierarchical cone netlist */
361 short YAG_BEFIG; /* generate a behavioural model */
362 short YAG_BLACKBOX_SUPPRESS; /* suppress instances in blackbox list */
363 short YAG_BLACKBOX_IGNORE; /* ignore instances in blackbox list */
364 short YAG_NORC; /* delete RC interconnects */
365 short YAG_HIERARCHICAL_MODE; /* hierarchical disassembly */
366
367 /* Don't need to be positioned */
368
369 char *YAGLE_TOOLNAME;
370 char YAGLE_LANG;
371
372 long YAGLE_NB_ERR;
373 chain_list *YAGLE_INSTANCE_BEFIGS;
374 befig_list *YAG_BEFIG_LIST;
375
376 /* Statistic and error files */
377
378 FILE *YAGLE_ERR_FILE;
379 FILE *YAGLE_STAT_FILE;
380 FILE *YAGLE_LOOP_FILE;
381
382 /* Internal variables */
383 lofig_list *YAG_CURLOFIG; /* logical figure list head */
384 cnsfig_list *YAG_CURCNSFIG; /* disassembled figure list head */
385 chain_list *YAG_CONSTRAINT_LIST; /* List of user specified constraints */
386 int YAG_MAXNODES; /* max number of BDD nodes */
387 int YAG_LASTNODECOUNT; /* previous BDD node count */
388 int YAG_REQUIRE_COMPLETE_GRAPH;/* Functional analysis modes */
389 int YAG_BIABL_INDEX; /* index for guarded expression label */
390 pCircuit YAG_CURCIRCUIT; /* circuit of cone under analysis */
391 graph *YAG_CONE_GRAPH; /* dependency graph of current cone */
392 graph *YAG_SUPPORT_GRAPH; /* support graph of current cone */
393 int YAG_ITERATIONS; /* cone building iteration count */
394 int YAG_FLAGS; /* speed up flags / added zinaps */
395 } yag_context_list;
396
397 extern yag_context_list *YAG_CONTEXT;
398
399 /* Function declarations */
400
401 /* Primary interface functions */
402
403 cnsfig_list *yagle_main(void);
404 cnsfig_list *yagDisassemble(char *figname, lofig_list *ptmbkfig, long mode);
405 void yagenv(void (*initfunc)());
406 void yagrestore(void);
407
408 /* general CNS utility functions */
409
410 void yagFindSupplies __P((inffig_list *ifl, lofig_list *ptlofig, int silent));
411 void yagFindInternalSupplies __P((inffig_list *ifl, lofig_list *ptlofig, int silent));
412 void yagTestTransistors __P((lofig_list *ptmbkfig, int silent));
413 void yagExit __P((int code));
414 void yagPrintTime __P((struct rusage *start, struct rusage *end, time_t rstart, time_t rend));
415 void yagChrono __P((struct rusage *t, time_t *rt));
416 int yagDepthFirstProcess __P((cone_list *headcone, int (*processCone)()));
417 void yagDestroyBranch __P((cone_list *ptcone, branch_list *ptdel));
418 branch_list *yagAppendBranch __P((branch_list *pt1, branch_list *pt2));
419 void yagDelBranchList __P((branch_list *ptlist));
420 branch_list *yagCopyBranch __P((branch_list *pthead, branch_list *ptbranch));
421 int yagCountBranches __P((cone_list *ptcone));
422 link_list *yagCopyLinkList __P((link_list *ptheadlink));
423 int yagCountLinks __P((link_list *ptheadlink));
424 int yagCountActiveLinks __P((link_list *ptheadlink));
425 link_list *yagAddTransLink __P((link_list *ptheadlink, lotrs_list *pttrans, losig_list *ptsig));
426 void yagFreeEdgeList __P((edge_list *ptlist));
427 int yagCountEdges __P((edge_list *ptlist));
428 int yagCountActiveEdges __P((edge_list *ptlist));
429 int yagCountConeEdges __P((edge_list *ptlist));
430 cone_list * yagGetNextConeEdge (edge_list *ptlist);
431 edge_list *yagGetEdge __P((edge_list *ptedgelist, void *ptinput));
432 edge_list *yagGetEdge_QUICK __P((edge_list *ptedgelist, void *ptinput, ht **FAST));
433 chain_list *yagGetChain __P((chain_list *pthead, void *ptdata));
434 chain_list *yagGetChain_QUICK __P((chain_list *pthead, void *ptdata, ht **FAST));
435 void *yagGetChainInd __P((chain_list *ptchain, int index));
436 chain_list *yagRmvChain __P((chain_list *pthead, void *ptdata));
437 int yagCountChains __P((chain_list *headchain));
438 chain_list *yagCopyChainList __P((chain_list *headchain));
439 chain_list *yagUnionChainList __P((chain_list *ptchain1, chain_list *ptchain2));
440 ptype_list *yagGetPtype __P((ptype_list *pthead, void *ptdata));
441
442 /* signal name processing functions */
443
444 int yagTestJoker __P((char *testname, char *oldname));
445 char *yagVectorizeName __P((char *name));
446 char *yagGetName __P((inffig_list *ifl, losig_list *pt_sig));
447 char *yagTreatName __P((char *str));
448 char *yagDownName __P((char *name));
449
450 /* BDD utility functions */
451
452 void yagControlBdd __P((int mode));
453
454 /* lofig utility functions */
455
456 locon_list *yagGetExtLocon __P((losig_list *ptsig));
457 chain_list *yagGetExtLoconList __P((losig_list *ptsig));
458 char yagMergeDirection __P((char dir1, char dir2));
459
460 /* branch resistance calculation */
461
462 float yagCalcBranchResistance __P((branch_list *ptbranch));
463 float yagCalcParallelResistance __P((chain_list *ptbranchlist));
464 float yagCalcMaxDownRes __P((cone_list *ptcone));
465 float yagCalcMaxUpRes __P((cone_list *ptcone));
466
467 #endif
468