2 * This file is part of the Alliance CAD System
3 * Copyright (C) Laboratoire LIP6 - Département ASIM
4 * Universite Pierre et Marie Curie
6 * Home page : http://www-asim.lip6.fr/alliance/
7 * E-mail support : mailto:alliance-support@asim.lip6.fr
9 * This progam is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
14 * Alliance VLSI CAD System is distributed in the hope that it will be
15 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17 * Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with the GNU C Library; see the file COPYING. If not, write to the Free
21 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * Tool : ABL, BDD, HT Librarie
28 * Modified by Czo <Olivier.Sirol@lip6.fr> 1996,97
33 /* $Id: log_lib.h,v 1.39 2009/07/07 14:28:25 anthony Exp $ */
68 /* ==================================================================
69 Gestion de table de hachage Version du 16.07.91
70 Les structures de donnees
72 ================================================================== */
79 /*------ les structures pour la table de hachage des entiers -----*/
89 length est la longueur de la table,
90 pElemTH le pointeur sur le debut de table,
91 count le nombre d'elements deja rentres. */
93 typedef struct tableTH
103 typedef htitem
*pElemTH
;
105 #define createTH addht
106 #define destroyTH delht
107 #define searchTH gethtitem
108 #define addTH addhtitem
109 #define addExistTH sethtitem
110 #define deleteTH delhtitem
112 /* ==============================================================
113 La bibliotheque des Arbres binaires Lisp-like version 23/08/91
115 Structures de donnees
116 ============================================================== */
120 /*----------- Fonctions Lisp-Like de bas-niveau -------------*/
122 #define CDR(expr) (expr->NEXT)
123 #define CAR(expr) (*(chain_list **) &expr->DATA)
124 #define CADR(expr) CAR(CDR(expr))
125 #define CDAR(expr) CDR(CAR(expr))
126 #define ATOM(expr) (!expr->NEXT)
127 #define VALUE_ATOM(expr) (*(char **) &expr->DATA)
128 #define OPER(expr) (*(long *)&(CAR(expr))->DATA)
129 #define VECT_S(expr) (*(long *)&CADR(CAR(expr)))
130 #define REP_NB(expr) (*(long *)&CADR(CDAR(expr)))
131 #define ATTRIB(expr) CDAR(expr)
132 #define VALUE_ATTRIB(expr) REP_NB(expr)
134 /* ==============================================================
135 La bibliotheque des graphes de decision binaires version 06/09/91
137 Structures de donnees
138 ============================================================== */
154 #undef BDDTABLE_PLEINE
177 #define TABLE_PLEINE -3l
178 #define BDDDELETE (pNode) DELETE
179 #define BDDTABLE_PLEINE (pNode) TABLE_PLEINE
180 #define MAX_SIZE_BDD 50000000 /* 50 Mega de noeuds Bdd */
188 /*---------------- structure d'un noeud de BDD -------------------*/
192 struct node
*high
, *low
; /* les noeuds fils */
193 short index
; /* index de la variable */
194 short mark
; /* nombre de peres pointant le noeud */
199 /*--------------- La table de hachage pour des BDD ------------ */
201 /* table de hachage qui retourne des pointeurs de BDD
202 lenTableBdd est la longueur de la table,
203 pBddT le pointeur sur le debut de table,
204 compteur le nombre d'elements deja rentres. */
206 typedef struct tableBdd
216 /*------ les structures pour la table de hachage local -----*/
218 typedef struct vertexLoc
220 pNode high
, low
, father
;
225 /* table de hachage pour la recuperation d'operation locale.
226 lenTable est la longueur de la table,
227 pElemT le pointeur sur le debut de table,
228 compteur le nombre d'elements deja rentres. */
230 typedef struct tableLoc
237 /*------------- structure pour les circuits -------------*/
239 typedef struct circuit
249 #define MAX_PACK 1000
251 /* structure systeme pour la generation de GDB . */
262 extern struct systemBdd sysBdd
;
264 //extern pNode one, zero;
265 extern pNode BDD_one
, BDD_zero
;
267 /**************** DECLARATION DES FONCTIONS *******/
270 # if defined(__STDC__) || defined(__GNUC__)
277 /* Prototypes from log_bdd0.c */
279 extern int bddSystemAbandoned
__P((void));
280 extern void setBddCeiling
__P((int limit
));
281 extern int getBddCeiling
__P((void));
282 extern void unsetBddCeiling
__P((void));
283 extern pNode initVertexBdd
__P((int index
, pNode high
, pNode low
));
284 extern pNode createNodeTermBdd
__P((short index
));
285 extern void initializeBdd
__P((int size
));
286 extern void destroyBdd
__P((int level
));
287 extern void resetBdd
__P(());
288 extern int numberNodeAllBdd
__P(());
289 extern int numberNodeBdd
__P((pNode pBdd
));
290 extern int countNode
__P((pNode pt
));
291 extern int countNodeTdg
__P((pNode pt
));
292 extern chain_list
* muxAbl
__P((pNode high
, pNode low
, chain_list
*a
, char **tabName
));
293 extern chain_list
* bddToAbl
__P((pNode pt
, char **tabName
));
294 extern void displayBddLoc
__P((short level
, pNode pt
));
295 extern void displayBdd
__P((pNode pBdd
, int level
));
296 extern void assignNumNodeBdd
__P((pNode bdd
, pTH vTable
, int *pNodeNumber
));
297 extern void displayGraphicBdd
__P((pNode pBdd
));
298 extern void displayBddName
__P((short level
, pNode pt
, char **TabName
));
299 extern void displayBddNameLog
__P((int lib
, int loglevel
, short level
, pNode pt
, char **TabName
));
300 extern pNode notBdd
__P((pNode pBdd
));
301 extern pNode applyTerm
__P((int oper
, short index
, pNode pBdd
));
302 extern pNode applyBinBdd
__P((short oper
, pNode pBdd1
, pNode pBdd2
));
303 extern pNode applyBdd
__P((short oper
, chain_list
*pt
));
304 extern pNode cnstBdd
__P((pNode pBdd1
, pNode pBddGc
));
305 extern pNode restrictBdd
__P((pNode pBdd1
, pNode pBddGc
));
306 extern pNode constraintBdd
__P((pNode pBdd1
, pNode pBddGc
));
307 extern pNode simplifDcZeroBdd
__P((pNode pGon
, pNode pGdc
));
308 extern pNode simplifPlusDcZeroBdd
__P((pNode pGon
, pNode pGdc
));
309 extern pNode simplifDcOneBdd
__P((pNode pGon
, pNode pGdc
));
310 extern pNode simplifDcOneFPGABdd
__P((pNode pGon
, pNode pGdc
));
311 extern pNode composeBdd
__P((pNode pBdd1
, pNode pBdd2
, int index
));
312 extern chain_list
* addListBdd
__P((chain_list
*pt
, pNode pBdd
));
313 extern int oneBdd
__P((pNode pBdd
));
314 extern int zeroBdd
__P((pNode pBdd
));
315 extern int equalBdd
__P((pNode pBdd1
, pNode pBdd2
));
316 extern void markBdd
__P((pNode pBdd
, short value
));
317 extern pNode upVarBdd
__P((pNode pF
, pNode pFoldIndex
, short newIndex
));
318 extern void markAllBdd
__P((short value
));
319 extern void supportBddInt
__P((pNode pt
, chain_list
**ppCL
));
320 extern chain_list
* supportChain_listBdd
__P((pNode pBdd
));
321 extern pNode initVertexBddAux
__P((short index
, pNode high
, pNode low
, struct systemBdd
*sysCible
));
322 extern pNode regenereBdd
__P((pNode pBdd
, struct systemBdd
*sysCible
, pTH pTHNode
));
323 extern void gcNodeBdd
__P((chain_list
*pt
));
324 extern void rempTabIndex
__P((pNode pt
, char *tabIndex
));
325 extern chain_list
* supportIndexBdd
__P((pNode pt
, int sens
));
328 /* Prototypes from log_bdd1.c */
330 extern pCircuit initializeCct
__P((char *name
, int nbI
, int nbO
));
331 extern void resetCct
__P((pCircuit pC
));
332 extern void destroyCct
__P((pCircuit pC
));
333 extern pNode searchOutputCct
__P((pCircuit pC
, char *name
));
334 extern pNode searchOutputCct_no_NA
__P((pCircuit pC
, char *name
));
335 extern void addOutputCct
__P((pCircuit pC
, char *name
, pNode pt
));
336 extern void addOutputCct_no_NA
__P((pCircuit pC
, char *name
, pNode pt
));
337 extern char * searchIndexCct
__P((pCircuit pC
, short index
));
338 extern short searchInputCct
__P((pCircuit pC
, char *name
));
339 extern short searchInputCct_no_NA
__P((pCircuit pC
, char *name
));
340 extern short addInputCct
__P((pCircuit pC
, char *name
));
341 extern short addInputCct_no_NA
__P((pCircuit pC
, char *name
));
342 extern void delInputCct
__P((pCircuit pC
, char *name
));
343 extern void displayCctLog
__P((int lib
, int loglevel
, pCircuit pC
, int mode
));
344 extern void displayCct
__P((pCircuit pC
, int mode
));
346 extern void composeCct
__P((pCircuit pC
, char *name
, pNode pt
));
347 extern void constraintCct
__P((pCircuit pC
, pNode pt
));
348 extern void proofCct
__P((pCircuit pC1
, pCircuit pC2
));
349 extern pNode ablToBddCct
__P((pCircuit pC
, chain_list
*expr
));
350 extern void cpOrderCct
__P((pCircuit CC1
, pCircuit CC2
));
351 extern void upVarCct
__P((pCircuit pC
, pNode ptOldIndex
, short newIndex
));
352 extern int numberNodeCct
__P((pCircuit pC
));
353 extern int numberNodeTdgCct
__P((pCircuit pC
));
354 extern chain_list
* bddToAblCct
__P((pCircuit pC
, pNode pBdd
));
355 extern void gcNodeCct
__P((pCircuit pC
));
358 /* Prototypes from log_prefbib.c */
360 extern char * gensym_abl
__P((char *name
, int num
));
361 extern void ablError
__P((chain_list
*expr
, char *func
));
362 extern chain_list
* createAtom
__P((char *name
));
363 extern chain_list
* createAtom_no_NA
__P((char *name
));
364 extern chain_list
* createExpr
__P((short oper
));
365 extern chain_list
* notExpr
__P((chain_list
*expr
));
366 extern chain_list
* createBinExpr
__P((short oper
, chain_list
*expr1
, chain_list
*expr2
));
367 extern void addQExpr
__P((chain_list
*expr1
, chain_list
*expr2
));
368 extern void addHExpr
__P((chain_list
*expr1
, chain_list
*expr2
));
369 extern void freeExpr
__P((chain_list
*expr
));
370 extern char * operToChar
__P((short oper
));
371 extern short charToOper
__P((char *name
));
372 extern void displayExpr
__P((chain_list
*expr
));
373 extern void displayExprLog
__P((int lib
, int loglevel
, chain_list
*expr
));
374 extern void displayInfExprLog
__P((int lib
, int loglevel
, chain_list
*expr
));
375 extern void displayInfExpr
__P((chain_list
*expr
));
376 extern char * exprToCharInt
__P((chain_list
*expr
, int mode
, char *chaine
, int *taille
));
377 extern char * exprToChar
__P((chain_list
*expr
, int mode
));
378 extern char * identExprInt
__P((chain_list
*expr
, char *chaine
, int *taille
));
379 extern char * identExpr
__P((chain_list
*expr
));
380 extern int profExpr
__P((chain_list
*expr
));
381 extern int profAOExpr
__P((chain_list
*expr
));
382 extern chain_list
* mapCarExpr
__P((chain_list
*(*func
)(), short oper
, chain_list
*expr
));
383 extern void mapExpr
__P((void (*func
)(), chain_list
*expr
));
384 extern int anyExpr
__P((int (*func
)(), chain_list
*expr
));
385 extern int everyExpr
__P((int (*func
)(), chain_list
*expr
));
386 extern int searchOperExpr
__P((chain_list
*expr
, short oper
));
387 extern short searchExprLow
__P((chain_list
*expr
, char *name
));
388 extern int searchExpr
__P((chain_list
*expr
, char *name
));
389 extern int equalExpr
__P((chain_list
*expr1
, chain_list
*expr2
));
390 extern int equalVarExpr
__P((chain_list
*expr1
, chain_list
*expr2
));
391 extern int lengthExpr
__P((chain_list
*expr
));
392 extern int numberOperBinExpr
__P((chain_list
*expr
));
393 extern int numberAtomExpr
__P((chain_list
*expr
));
394 extern chain_list
* copyExpr
__P((chain_list
*expr
));
395 extern void substPhyExpr
__P((chain_list
*expr1
, char *name
, chain_list
*expr2
));
396 extern chain_list
* substExpr
__P((chain_list
*expr1
, char *name
, chain_list
*expr2
));
397 extern chain_list
* devXorExpr
__P((chain_list
*expr
));
398 extern chain_list
* devXor2Expr
__P((chain_list
*expr
));
399 extern chain_list
* flatPolarityExpr
__P((chain_list
*expr
, int signe
));
400 extern void flatArityExpr
__P((chain_list
*expr
));
401 extern void supportChain_listExprInt
__P((chain_list
*expr
, chain_list
**ppCL
));
402 extern chain_list
* supportChain_listExpr
__P((chain_list
*expr
));
403 extern void fullSupportChain_listExprInt
__P((chain_list
*expr
, chain_list
**ppCL
));
404 extern chain_list
* fullSupportChain_listExpr
__P((chain_list
*expr
));
405 extern void supportPtype_listExprInt
__P((chain_list
*expr
, ptype_list
**ppCL
));
406 extern ptype_list
* supportPtype_listExpr
__P((chain_list
*expr
));
407 extern chain_list
* maxExpr
__P((chain_list
*expr
, int (*func
)()));
408 extern chain_list
* minExpr
__P((chain_list
*expr
, int (*func
)()));
409 extern void sortExpr
__P((chain_list
*expr
, long (*func
)(), int direction
));
410 extern long funcNormExpr
__P((chain_list
*expr
));
411 extern void normExpr
__P((chain_list
*expr
));
412 extern void deleteNumExpr
__P((chain_list
*expr
, int i
));
413 extern chain_list
* searchNumExpr
__P((chain_list
*expr
, int i
));
414 extern int numberOccExpr
__P((chain_list
*exp
, char *name
));
415 extern void changeOperExpr
__P((chain_list
*expr
, short oper
));
416 extern chain_list
* simplif10Expr
__P((chain_list
*expr
));
417 extern chain_list
* simplifNotExpr
__P((chain_list
*exp
));
418 extern chain_list
* charToExprInt
__P((char *stringExpr
, int *cptCar
));
419 extern chain_list
* charToExpr
__P((char *stringExpr
));
420 extern char * tokenExpr
__P((char *stringExpr
, int *cptCar
));
421 extern int PMExprInt
__P((chain_list
*expr
, chain_list
*pattern
, ptype_list
**bind
));
422 extern int PMExpr
__P((chain_list
*expr
, chain_list
*pattern
));
424 extern void replaceAtomByExpr
__P((chain_list
*expr
, char *name
, chain_list
*newexpr
));
426 /* Prototypes from log_thash.c */
428 extern int hashTH
__P((char *pn
));
429 extern pTH createTH
__P((int len
));
430 extern void destroyTH
__P((pTH pTable
));
431 extern long searchTH
__P((pTH pTable
, char *key
));
432 extern long addTH
__P((pTH pTable
, char *key
, long value
));
433 extern long addExistTH
__P((pTH pTable
, char *key
, long value
));
434 extern long deleteTH
__P((pTH pTable
, char *key
));
435 extern void displayTH
__P((pTH pTable
));
436 extern void reAllocTH
__P((pTH pTable
));
440 /* Prototypes from log_thashbdd.c */
442 extern long hashBdd
__P((int index
, pNode high
, pNode low
));
443 extern long newKeyBdd
__P((int index
, pNode high
, pNode low
));
444 extern pTableBdd createTableBdd
__P((int len
));
445 extern void destroyTableBdd
__P((pTableBdd pTab
));
446 extern pTableBdd reAllocTableBdd
__P((pTableBdd pTab
));
447 extern pNode searchTableBdd
__P((pTableBdd pTab
, int index
, pNode high
, pNode low
));
448 extern long addTableBdd
__P((pTableBdd pTab
, pNode pBdd
));
449 extern long deleteTableBdd
__P((pTableBdd pTab
, pNode pBdd
));
450 extern void displayHashBdd
__P((pTableBdd pTab
));
453 /* Prototypes from log_thashloc.c */
455 extern long hashLoc
__P((pNode high
, pNode low
));
456 extern pTableLoc createTabLoc
__P((int len
));
457 extern void destroyTabLoc
__P((pTableLoc pTab
));
458 extern pNode searchTabLoc
__P((pTableLoc pTab
, pNode high
, pNode low
, short oper
));
459 extern long addTabLoc
__P((pTableLoc pTab
, pNode high
, pNode low
, pNode father
, short oper
));
460 extern void displayLoc
__P((pTableLoc pTab
));
461 extern void videTabLoc
__P((pTableLoc pTab
));
464 /* Prototypes from log_vectabl.c */
465 extern chain_list
* concatAbl
__P((chain_list
*expr1
,chain_list
*expr2
));
466 extern chain_list
* replicateAbl
__P((chain_list
*expr
,int n
));
467 extern chain_list
* getAblAtPos
__P((chain_list
*expr
,int pos
));
468 extern int getVectAblRange
__P((chain_list
*expr
,int *left
,int *right
));
469 extern char * getVectAblVarName
__P((chain_list
*expr
));
470 extern int verifyVectAbl
__P((chain_list
*expr
));
471 extern int getAtomSize
__P((chain_list
*expr
));
472 extern chain_list
* getAblAtIndex
__P((chain_list
*expr
,int left
,int right
,int index
));
473 extern void invertVectAbl
__P((chain_list
*expr
));
474 extern void invertAtom
__P((chain_list
*expr
));
475 extern void initBitStrTable
__P((void));
476 extern int isBitStr
__P((char *bitstr
));
477 extern char * genOneBitStr
__P((int n
));
478 extern char * genZeroBitStr
__P((int n
));
479 extern char * genHZBitStr
__P((int n
));
480 extern void fprintHZBitStr
__P((FILE *file
,char *bitstr
));
481 extern char * notBitStr
__P((char *bitstr
));
482 extern chain_list
* createBitStr
__P((char *bitstr
));
483 extern char * genUBitStr
__P((int n
));
484 extern char * getBitStr
__P((char *str
));
485 extern int changeAblAtRange
__P((chain_list
*expr
,int left
,int right
, chain_list
*added
,int mode
));
486 extern char * renameVectAtom
__P((char *oldname
,char *newname
,int shift
));
487 extern chain_list
* createVectAtom
__P((char *name
,int left
,int right
));
488 extern char * createVectAtomName
__P((char *name
,int left
,int right
));
489 extern void getVectAtomRange
__P((chain_list
*expr
,char **name
,int *left
, int*right
));
490 extern void repToCatVectAbl
__P((chain_list
*expr
));
491 extern char * makeBitStr
__P((char *bistr
));
492 extern FILE *LOG_DEBUG_FILE
;
493 extern chain_list
* supportChain_listBddExpr(pCircuit circuit
, pNode bdd
);
495 chain_list
*ablCreateMintermList(chain_list
*expr
);