diff --git a/alliance/src/btr/Makefile.am b/alliance/src/btr/Makefile.am new file mode 100644 index 00000000..af437a64 --- /dev/null +++ b/alliance/src/btr/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/alliance/src/btr/configure.in b/alliance/src/btr/configure.in new file mode 100644 index 00000000..f6b9f2ff --- /dev/null +++ b/alliance/src/btr/configure.in @@ -0,0 +1,45 @@ +dnl +/* +dnl This file is part of the Alliance CAD System +dnl Copyright (C) Laboratoire LIP6 - Département ASIM +dnl Universite Pierre et Marie Curie +dnl +dnl Home page : http://www-asim.lip6.fr/alliance/ +dnl E-mail support : mailto:alliance-support@asim.lip6.fr +dnl +dnl This library is free software; you can redistribute it and/or modify it +dnl under the terms of the GNU Library General Public License as published +dnl by the Free Software Foundation; either version 2 of the License, or (at +dnl your option) any later version. +dnl +dnl Alliance VLSI CAD System is distributed in the hope that it will be +dnl useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +dnl Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License along +dnl with the GNU C Library; see the file COPYING. If not, write to the Free +dnl Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +dnl +dnl Purpose : Auto stuffing Alliance +dnl Almost ten years since I wrote this stuff, I just can't +dnl believe it +dnl Date : 01/02/2002 +dnl Author : Frederic Petrot +dnl $Id: configure.in,v 1.1 2002/03/20 10:24:57 ludo Exp $ +dnl +dnl +AC_INIT(src/btr.h) +AM_INIT_AUTOMAKE(btr, 1.3) +AC_PROG_INSTALL +AC_PROG_CC +AC_HEADER_STDC +AC_C_CONST +AC_PROG_RANLIB + +AM_ALLIANCE + +AC_OUTPUT([ +Makefile +src/Makefile +]) diff --git a/alliance/src/btr/src/btr.h b/alliance/src/btr/src/btr.h new file mode 100644 index 00000000..4bc63f0c --- /dev/null +++ b/alliance/src/btr/src/btr.h @@ -0,0 +1,211 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------\ +| | +| Title : Structures and fonctions for BTR | +| | +| Date : 14.02.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------*/ + +# ifndef BTR_102_H +# define BTR_102_H + +/*------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------*/ +/*------------------------------------------------------\ +| | +| Macros | +| | +\------------------------------------------------------*/ +/*------------------------------------------------------\ +| | +| Type | +| | +\------------------------------------------------------*/ +/*------------------------------------------------------\ +| | +| Bdd Transition Function | +| | +\------------------------------------------------------*/ + + typedef long btrvarorder; + + typedef struct btrvarfunc + { + bddnode *VAR; + bddnode *FUNC; + + } btrvarfunc; + + typedef struct btrtransfunc + { + btrvarfunc *VAR_FUNC; + btrvarorder *VAR_ORDER; + bddvar MAX_VAR; + bddvar NUMBER_VAR; + bddsystem *BDD_SYSTEM; + + } btrtransfunc; + +/*------------------------------------------------------\ +| | +| Bdd Transition Relation | +| | +\------------------------------------------------------*/ + + typedef struct btrvarrel + { + bddnode *VAR; + bddnode *PRIME; + bddnode *REL; + + } btrvarrel; + + typedef struct btrtransrel + { + btrvarrel *VAR_REL; + bddassoc *PRIME_ASSOC; + bddassoc *VAR_ASSOC; + bddvar MAX_VAR; + bddvar NUMBER_VAR; + bddsystem *BDD_SYSTEM; + + } btrtransrel; + +/*------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------*/ +/*------------------------------------------------------\ +| | +| Env Functions | +| | +\------------------------------------------------------*/ + + extern void btrenv __P(()); + +/*------------------------------------------------------\ +| | +| Allocation Functions | +| | +\------------------------------------------------------*/ + + extern btrtransfunc * allocbtrtransfunc __P(()); + extern btrvarfunc * allocbtrvarfunc __P((long Number)); + extern btrvarorder * allocbtrvarorder __P((long Number)); + + extern btrtransrel * allocbtrtransrel __P(()); + extern btrvarrel * allocbtrvarrel __P((long Number)); + +/*------------------------------------------------------\ +| | +| Free Functions | +| | +\------------------------------------------------------*/ + + extern void freebtrtransfunc __P((btrtransfunc *TransFunc)); + extern void freebtrvarfunc __P((btrvarfunc *VarFunc)); + extern void freebtrvarorder __P((btrvarorder *VarOrder)); + + extern void freebtrtransrel __P((btrtransrel *TransRel)); + extern void freebtrvarrel __P((btrvarrel *VarRel)); + +/*------------------------------------------------------\ +| | +| Resize Functions | +| | +\------------------------------------------------------*/ + + extern btrvarfunc * resizebtrvarfunc __P((btrvarfunc *VarFunc, long OldNum, long NewNum)); + extern btrvarorder * resizebtrvarorder __P((btrvarorder *VarOrder, long OldNum, long NewNum)); + + extern btrvarrel * resizebtrvarrel __P((btrvarrel *VarRel, long OldNum, long NewNum)); + +/*------------------------------------------------------\ +| | +| Transition Function Functions | +| | +\------------------------------------------------------*/ + + extern btrtransfunc * createbtrtransfunc __P((bddsystem *BddSystem, bddvar MaxVar)); + extern void resetbtrtransfunc __P((btrtransfunc *TransFunc)); + extern void destroybtrtransfunc __P((btrtransfunc *TransFunc)); + extern void viewbtrtransfunc __P((btrtransfunc *TransFunc, void (*FuncView)())); + extern void addbtrtransfunc __P((btrtransfunc *TransFunc, bddnode *VarNode, bddnode *FuncNode)); + +/*------------------------------------------------------\ +| | +| Image and PreImage Transition Function | +| | +\------------------------------------------------------*/ + + extern bddnode * imagebtrtransfunc __P((btrtransfunc *TransFunc, bddnode *StateSet)); + extern bddnode * preimagebtrtransfunc __P((btrtransfunc *TransFunc, bddnode *StateSet)); + +/*------------------------------------------------------\ +| | +| Reorder Transition Function | +| | +\------------------------------------------------------*/ + + extern void reorderbtrtransfunc __P((btrtransfunc *TransFunc)); + +/*------------------------------------------------------\ +| | +| Transition Relation Functions | +| | +\------------------------------------------------------*/ + + extern btrtransrel * createbtrtransrel __P((bddsystem *BddSystem, bddvar MaxVar)); + extern void resetbtrtransrel __P((btrtransrel *TransRel)); + extern void destroybtrtransrel __P((btrtransrel *TransRel)); + extern void viewbtrtransrel __P((btrtransrel *TransRel, void (*FuncView)())); + +/*------------------------------------------------------\ +| | +| Image and PreImage Transition Relation | +| | +\------------------------------------------------------*/ + + extern bddnode * imagebtrtransrel __P((btrtransrel *TransRel, bddnode *StateSet)); + bddnode *preimagebtrtransrel(); + +# endif diff --git a/alliance/src/btr/src/btralloc.c b/alliance/src/btr/src/btralloc.c new file mode 100644 index 00000000..e79a06cb --- /dev/null +++ b/alliance/src/btr/src/btralloc.c @@ -0,0 +1,133 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Btr | +| | +| File : btralloc.c | +| | +| Date : 03.12.96 | +| | +| Btrhor : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "btr.h" + +# include +# include "btralloc.h" +# include "btrerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Btr Alloc Function Transition | +| | +\------------------------------------------------------------*/ + +btrtransfunc *allocbtrtransfunc() +{ + return( (btrtransfunc *)autallocblock( sizeof( btrtransfunc ) ) ); +} + +/*------------------------------------------------------------\ +| | +| Bdd Alloc Variable Function | +| | +\------------------------------------------------------------*/ + +btrvarfunc *allocbtrvarfunc( Number ) + + long Number; +{ + return( (btrvarfunc *)autallocblock( sizeof( btrvarfunc ) * Number ) ); +} + +/*------------------------------------------------------------\ +| | +| Btr Alloc Function Transition | +| | +\------------------------------------------------------------*/ + +btrvarorder *allocbtrvarorder( Number ) + + long Number; +{ + return( (btrvarorder *)autallocblock( sizeof( btrvarorder ) * Number ) ); +} + +/*------------------------------------------------------------\ +| | +| Btr Alloc Relation Transition | +| | +\------------------------------------------------------------*/ + +btrtransrel *allocbtrtransrel() +{ + return( (btrtransrel *)autallocblock( sizeof( btrtransrel ) ) ); +} + +/*------------------------------------------------------------\ +| | +| Bdd Alloc Variable Relation | +| | +\------------------------------------------------------------*/ + +btrvarrel *allocbtrvarrel( Number ) + + long Number; +{ + return( (btrvarrel *)autallocblock( sizeof( btrvarrel ) * Number ) ); +} diff --git a/alliance/src/btr/src/btralloc.h b/alliance/src/btr/src/btralloc.h new file mode 100644 index 00000000..e071952b --- /dev/null +++ b/alliance/src/btr/src/btralloc.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Btr | +| | +| File : btralloc.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef BTR_ALLOC_H +# define BTR_ALLOC_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/btr/src/btrenv.c b/alliance/src/btr/src/btrenv.c new file mode 100644 index 00000000..8a38708c --- /dev/null +++ b/alliance/src/btr/src/btrenv.c @@ -0,0 +1,82 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Btr | +| | +| File : btrenv.c | +| | +| Date : 03.12.96 | +| | +| Btrhor : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "btr.h" + +# include +# include "btrenv.h" +# include "btrerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Btr Env | +| | +\------------------------------------------------------------*/ + +void btrenv() +{ +} diff --git a/alliance/src/btr/src/btrenv.h b/alliance/src/btr/src/btrenv.h new file mode 100644 index 00000000..c2da63c6 --- /dev/null +++ b/alliance/src/btr/src/btrenv.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Btr | +| | +| File : btrenv.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef BTR_ENV_H +# define BTR_ENV_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/btr/src/btrerror.c b/alliance/src/btr/src/btrerror.c new file mode 100644 index 00000000..ed913976 --- /dev/null +++ b/alliance/src/btr/src/btrerror.c @@ -0,0 +1,129 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Btr | +| | +| File : Btr Errors | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 03.12.96 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "btr.h" +# include "btrerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +void btr_error( Error, Value, File, Line ) + + char Error; + long Value; + char *File; + long Line; +{ + char *Name; + + Name = mbkstrdup( File ); + Name[ strlen( File ) - 1 ] = '\0'; + + fprintf( stderr, "%s%ld ", Name, Line ); + + switch( Error ) + { + default : + + fprintf( stderr, "unknown internal %d", Error ); + } + + fprintf( stderr, " error !\n" ); + + autexit( 1 ); +} + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +void btr_warning( Warning, Value1, Value2, File, Line ) + + char Warning; + long Value1; + long Value2; + char *File; + long Line; +{ + char *Name; + + Name = mbkstrdup( File ); + Name[ strlen( File ) - 1 ] = '\0'; + + fprintf( stderr, "%s%ld ", Name, Line ); + + switch( Warning ) + { + default : + + fprintf( stderr, "unknown internal %d", Warning ); + } + + fprintf( stderr, " warning !\n" ); +} diff --git a/alliance/src/btr/src/btrerror.h b/alliance/src/btr/src/btrerror.h new file mode 100644 index 00000000..55f854ff --- /dev/null +++ b/alliance/src/btr/src/btrerror.h @@ -0,0 +1,96 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Btr | +| | +| File : Btr Errors | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 03.12.96 | +| | +\------------------------------------------------------------*/ + +# ifndef BTR_ERROR_H +# define BTR_ERROR_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define BTR_BAD_VAR_ERROR 0 +# define BTR_NO_MORE_VAR_ERROR 1 + +/*------------------------------------------------------------\ +| | +| Error | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Warning | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macros | +| | +\------------------------------------------------------------*/ + +# define btrerror( E, V ) (btr_error( (E), (V), __FILE__, __LINE__ )) +# define btrwarning( W, V1, V2 ) (btr_warning( (W), (V1), (V2), __FILE__, __LINE__ )) + +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void btr_error __P((char Error, long Value, char *File, long Line)); + extern void btr_warning __P((char Warning, long Value1, long Value2, char *File, long Line)); + +# endif diff --git a/alliance/src/btr/src/btrfree.c b/alliance/src/btr/src/btrfree.c new file mode 100644 index 00000000..4e6875b5 --- /dev/null +++ b/alliance/src/btr/src/btrfree.c @@ -0,0 +1,138 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Btr | +| | +| File : btrfree.c | +| | +| Date : 03.12.96 | +| | +| Btrhor : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "btr.h" + +# include +# include "btrfree.h" +# include "btrerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Btr Free Function Transition | +| | +\------------------------------------------------------------*/ + +void freebtrtransfunc( TransFunc ) + + btrtransfunc *TransFunc; +{ + autfreeblock( (char *)TransFunc ); +} + +/*------------------------------------------------------------\ +| | +| Bdd Free Variable Function | +| | +\------------------------------------------------------------*/ + +void freebtrvarfunc( VarFunc ) + + btrvarfunc *VarFunc; +{ + autfreeblock( (char *)VarFunc ); +} + +/*------------------------------------------------------------\ +| | +| Bdd Free Variable Order | +| | +\------------------------------------------------------------*/ + +void freebtrvarorder( VarOrder ) + + btrvarorder *VarOrder; +{ + autfreeblock( (char *)VarOrder ); +} + +/*------------------------------------------------------------\ +| | +| Btr Free Relation Transition | +| | +\------------------------------------------------------------*/ + +void freebtrtransrel( TransRel ) + + btrtransrel *TransRel; +{ + autfreeblock( (char *)TransRel ); +} + +/*------------------------------------------------------------\ +| | +| Bdd Free Variable Relation | +| | +\------------------------------------------------------------*/ + +void freebtrvarrel( VarRel ) + + btrvarrel *VarRel; +{ + autfreeblock( (char *)VarRel ); +} + diff --git a/alliance/src/btr/src/btrfree.h b/alliance/src/btr/src/btrfree.h new file mode 100644 index 00000000..a2cc8d0f --- /dev/null +++ b/alliance/src/btr/src/btrfree.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Btr | +| | +| File : btrfree.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef BTR_FREE_H +# define BTR_FREE_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/btr/src/btrfunc.c b/alliance/src/btr/src/btrfunc.c new file mode 100644 index 00000000..47195feb --- /dev/null +++ b/alliance/src/btr/src/btrfunc.c @@ -0,0 +1,606 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Btr | +| | +| File : Btr Transition Function | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 03.12.96 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "btr.h" +# include "btrfunc.h" +# include "btrerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static btrvarfunc *BtrLocalVarFunc = (btrvarfunc *)0; + static btrvarorder *BtrLocalVarOrder = (btrvarorder *)0; + static long BtrLocalNumberVar = 0; + static long BtrLocalIndexVar = 0; + + static long *BtrLocalCostArray = (long *)0; + static long BtrLocalCostLength = 0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Local Btr PreImage Transition Function | +| | +\------------------------------------------------------------*/ + +bddnode *loc_preimagebtrtransfunc( StateSet ) + + bddnode *StateSet; +{ + btrvarfunc *VarFunc; + bddnode *BddSetIn; + bddnode *BddSetOut; + bddnode *BddResult; + bddnode *BddHigh; + bddnode *BddLow; + + if ( StateSet->INDEX < BDD_INDEX_MIN ) + { + return( StateSet ); + } + + VarFunc = &BtrLocalVarFunc[ BtrLocalVarOrder[ BtrLocalIndexVar ] ]; + + BddSetIn = decbddrefext( applybddnodenot( (bddsystem *)0, StateSet ) ); + BddSetIn = applybddnode( (bddsystem *)0, ABL_OR , VarFunc->VAR , BddSetIn ); + BddSetOut = applybddnode( (bddsystem *)0, ABL_NAND, VarFunc->VAR , StateSet ); + + BtrLocalIndexVar++; + + if ( BtrLocalIndexVar >= BtrLocalNumberVar ) + { +/* +** StateSet => Rn, Fn +*/ + if ( BddSetIn->INDEX == BDD_INDEX_ONE ) + { + BddResult = incbddrefext( VarFunc->FUNC ); + } + else +/* +** StateSet => ! Rn, ! Fn +*/ + if ( BddSetOut->INDEX == BDD_INDEX_ONE ) + { + BddResult = applybddnodenot( (bddsystem *)0, VarFunc->FUNC ); + } + else + { + BddResult = BddLocalSystem->ONE; + } + } + else + { +/* +** StateSet => Ri, Fi . Img( StateSet ) +*/ + if ( BddSetIn->INDEX == BDD_INDEX_ONE ) + { + BddResult = decbddrefext( loc_preimagebtrtransfunc( StateSet ) ); + BddResult = applybddnode( (bddsystem *)0, ABL_AND, VarFunc->FUNC, BddResult ); + } + else +/* +** StateSet => ! Ri, ! Fi . Img( StateSet ) +*/ + if ( BddSetOut->INDEX == BDD_INDEX_ONE ) + { + BddLow = loc_preimagebtrtransfunc( StateSet ); + BddHigh = applybddnodenot( (bddsystem *)0, VarFunc->FUNC ); + + BddResult = applybddnode( (bddsystem *)0, ABL_AND, + decbddrefext( BddHigh ), + decbddrefext( BddLow ) ); + } + else + { +/* +** Fi . Img( StateSet . Ri ) + ! Fi . Img( StateSet . ! Ri ) +*/ + BddSetOut = applybddnodenot( (bddsystem *)0, decbddrefext( BddSetOut ) ); + BddSetIn = applybddnodenot( (bddsystem *)0, decbddrefext( BddSetIn ) ); + + BddHigh = applybddnodenot( (bddsystem *)0, VarFunc->FUNC ); + BddLow = loc_preimagebtrtransfunc( BddSetIn ); + BddLow = applybddnode( (bddsystem *)0, ABL_AND, + decbddrefext( BddHigh ), + decbddrefext( BddLow ) ); + + BddHigh = decbddrefext( loc_preimagebtrtransfunc( BddSetOut ) ); + BddHigh = applybddnode( (bddsystem *)0, ABL_AND, VarFunc->FUNC, BddHigh ); + + BddResult = applybddnode( (bddsystem *)0, ABL_OR, + decbddrefext( BddHigh ), + decbddrefext( BddLow ) ); + } + } + + BtrLocalIndexVar--; + + decbddrefext( BddSetIn ); + decbddrefext( BddSetOut ); + + return( BddResult ); +} + +/*------------------------------------------------------------\ +| | +| Btr PreImage Transition Function | +| | +\------------------------------------------------------------*/ + +bddnode *preimagebtrtransfunc( TransFunc, StateSet ) + + btrtransfunc *TransFunc; + bddnode *StateSet; +{ + bddnode *BddResult; + + setbddlocalsystem( TransFunc->BDD_SYSTEM ); + + BtrLocalVarFunc = TransFunc->VAR_FUNC; + BtrLocalVarOrder = TransFunc->VAR_ORDER; + BtrLocalNumberVar = TransFunc->NUMBER_VAR; + BtrLocalIndexVar = 0; + + if ( BtrLocalNumberVar == 0 ) + { + btrerror( BTR_BAD_VAR_ERROR, BtrLocalNumberVar ); + } + + BddResult = loc_preimagebtrtransfunc( StateSet ); + + return( BddResult ); +} + +/*------------------------------------------------------------\ +| | +| Local Btr Image Transition Function | +| | +\------------------------------------------------------------*/ + +bddnode *loc_imagebtrtransfunc( StateSet ) + + bddnode *StateSet; +{ + btrvarfunc *VarFunc; + bddnode *BddSetIn; + bddnode *BddSetOut; + bddnode *BddResult; + bddnode *BddHigh; + bddnode *BddLow; + + if ( StateSet->INDEX == BDD_INDEX_ZERO ) + { + return( StateSet ); + } + + VarFunc = &BtrLocalVarFunc[ BtrLocalVarOrder[ BtrLocalIndexVar ] ]; + + BddSetIn = decbddrefext( applybddnodenot( (bddsystem *)0, StateSet ) ); + BddSetIn = applybddnode( (bddsystem *)0, ABL_OR , VarFunc->FUNC, BddSetIn ); + BddSetOut = applybddnode( (bddsystem *)0, ABL_NAND, VarFunc->FUNC, StateSet ); + + BtrLocalIndexVar++; + + if ( BtrLocalIndexVar >= BtrLocalNumberVar ) + { +/* +** StateSet => Fn, Rn +*/ + if ( BddSetIn->INDEX == BDD_INDEX_ONE ) + { + BddResult = incbddrefext( VarFunc->VAR ); + } + else +/* +** StateSet => ! Fn, ! Rn +*/ + if ( BddSetOut->INDEX == BDD_INDEX_ONE ) + { + BddResult = applybddnodenot( (bddsystem *)0, VarFunc->VAR ); + } + else + { + BddResult = BddLocalSystem->ONE; + } + } + else + { +/* +** StateSet => Fi, Ri . Img( StateSet ) +*/ + if ( BddSetIn->INDEX == BDD_INDEX_ONE ) + { + BddResult = decbddrefext( loc_imagebtrtransfunc( StateSet ) ); + BddResult = applybddnode( (bddsystem *)0, ABL_AND, VarFunc->VAR, BddResult ); + } + else +/* +** StateSet => ! Fi, ! Ri . Img( StateSet ) +*/ + if ( BddSetOut->INDEX == BDD_INDEX_ONE ) + { + BddLow = loc_imagebtrtransfunc( StateSet ); + BddHigh = applybddnodenot( (bddsystem *)0, VarFunc->VAR ); + + BddResult = applybddnode( (bddsystem *)0, ABL_AND, + decbddrefext( BddHigh ), + decbddrefext( BddLow ) ); + } + else + { +/* +** Ri . Img( StateSet . Fi ) + ! Ri . Img( StateSet . ! Fi ) +*/ + BddSetOut = applybddnodenot( (bddsystem *)0, decbddrefext( BddSetOut ) ); + BddSetIn = applybddnodenot( (bddsystem *)0, decbddrefext( BddSetIn ) ); + + BddHigh = applybddnodenot( (bddsystem *)0, VarFunc->VAR ); + BddLow = loc_imagebtrtransfunc( BddSetIn ); + BddLow = applybddnode( (bddsystem *)0, ABL_AND, + decbddrefext( BddHigh ), + decbddrefext( BddLow ) ); + + BddHigh = decbddrefext( loc_imagebtrtransfunc( BddSetOut ) ); + BddHigh = applybddnode( (bddsystem *)0, ABL_AND, VarFunc->VAR, BddHigh ); + + BddResult = applybddnode( (bddsystem *)0, ABL_OR, + decbddrefext( BddHigh ), + decbddrefext( BddLow ) ); + } + } + + BtrLocalIndexVar--; + + decbddrefext( BddSetIn ); + decbddrefext( BddSetOut ); + + return( BddResult ); +} + +/*------------------------------------------------------------\ +| | +| Btr Image Transition Function | +| | +\------------------------------------------------------------*/ + +bddnode *imagebtrtransfunc( TransFunc, StateSet ) + + btrtransfunc *TransFunc; + bddnode *StateSet; +{ + bddnode *BddResult; + + setbddlocalsystem( TransFunc->BDD_SYSTEM ); + + BtrLocalVarFunc = TransFunc->VAR_FUNC; + BtrLocalVarOrder = TransFunc->VAR_ORDER; + BtrLocalNumberVar = TransFunc->NUMBER_VAR; + BtrLocalIndexVar = 0; + + if ( BtrLocalNumberVar == 0 ) + { + btrerror( BTR_BAD_VAR_ERROR, BtrLocalNumberVar ); + } + + BddResult = loc_imagebtrtransfunc( StateSet ); + + return( BddResult ); +} + +/*------------------------------------------------------------\ +| | +| Btr Creates Transition Function | +| | +\------------------------------------------------------------*/ + +btrtransfunc *createbtrtransfunc( BddSystem, MaxVar ) + + bddsystem *BddSystem; + bddvar MaxVar; +{ + btrtransfunc *TransFunc; + + setbddlocalsystem( BddSystem ); + + if ( MaxVar >= BDD_MAX_VAR ) + { + btrerror( BTR_BAD_VAR_ERROR, MaxVar ); + } + + TransFunc = allocbtrtransfunc(); + + TransFunc->BDD_SYSTEM = BddLocalSystem; + + TransFunc->MAX_VAR = MaxVar; + TransFunc->VAR_FUNC = allocbtrvarfunc( MaxVar ); + TransFunc->VAR_ORDER = allocbtrvarorder( MaxVar ); + + return( TransFunc ); +} + +/*------------------------------------------------------------\ +| | +| Btr Add Transition Function | +| | +\------------------------------------------------------------*/ + +void addbtrtransfunc( TransFunc, VarNode, FuncNode ) + + btrtransfunc *TransFunc; + bddnode *VarNode; + bddnode *FuncNode; +{ + btrvarfunc *VarFunc; + btrvarorder *VarOrder; + long MaxVar; + long NumberVar; + + NumberVar = TransFunc->NUMBER_VAR; + MaxVar = TransFunc->MAX_VAR; + + if ( NumberVar >= BDD_MAX_VAR ) + { + btrerror( BTR_NO_MORE_VAR_ERROR, 0 ); + } + + if ( NumberVar == MaxVar ) + { + MaxVar = MaxVar * BTR_VAR_STRETCH_FACTOR; + + if ( MaxVar >= BDD_MAX_VAR ) + { + MaxVar = BDD_MAX_VAR - 1; + } + + VarFunc = resizebtrvarfunc( TransFunc->VAR_FUNC, + TransFunc->MAX_VAR, MaxVar ); + + VarOrder = resizebtrvarorder( TransFunc->VAR_ORDER, + TransFunc->MAX_VAR, MaxVar ); + + TransFunc->VAR_FUNC = VarFunc; + TransFunc->VAR_ORDER = VarOrder; + TransFunc->MAX_VAR = MaxVar; + } + else + { + VarFunc = TransFunc->VAR_FUNC; + VarOrder = TransFunc->VAR_ORDER; + } + + VarFunc [ NumberVar ].FUNC = incbddrefext( FuncNode ); + VarFunc [ NumberVar ].VAR = VarNode; + VarOrder[ NumberVar ] = NumberVar; + + TransFunc->NUMBER_VAR++; +} + +/*------------------------------------------------------------\ +| | +| Btr Reset Transition Function | +| | +\------------------------------------------------------------*/ + +void resetbtrtransfunc( TransFunc ) + + btrtransfunc *TransFunc; +{ + btrvarfunc *VarFunc; + btrvarorder *VarOrder; + long Variable; + long NumberVar; + + NumberVar = TransFunc->NUMBER_VAR; + VarFunc = TransFunc->VAR_FUNC; + VarOrder = TransFunc->VAR_ORDER; + + for ( Variable = 0; Variable < NumberVar; Variable++ ) + { + decbddrefext( VarFunc[ Variable ].FUNC ); + } + + memset( (void *)VarFunc, 0, + (size_t)NumberVar * sizeof( btrvarfunc ) ); + + memset( (void *)VarOrder, 0, + (size_t)NumberVar * sizeof( btrvarorder ) ); + + TransFunc->NUMBER_VAR = 0; +} + +/*------------------------------------------------------------\ +| | +| Btr Destroys Transition Function | +| | +\------------------------------------------------------------*/ + +void destroybtrtransfunc( TransFunc ) + + btrtransfunc *TransFunc; +{ + btrvarfunc *VarFunc; + long Variable; + long NumberVar; + + NumberVar = TransFunc->NUMBER_VAR; + VarFunc = TransFunc->VAR_FUNC; + + for ( Variable = 0; Variable < NumberVar; Variable++ ) + { + decbddrefext( VarFunc[ Variable ].FUNC ); + } + + freebtrvarfunc( TransFunc->VAR_FUNC ); + freebtrvarorder( TransFunc->VAR_ORDER ); + freebtrtransfunc( TransFunc ); +} + +/*------------------------------------------------------------\ +| | +| Btr View Transition Function | +| | +\------------------------------------------------------------*/ + +void viewbtrtransfunc( TransFunc, FuncView ) + + btrtransfunc *TransFunc; + void (*FuncView)(); +{ + btrvarfunc *VarFunc; + long Variable; + long NumberVar; + + fprintf( stdout, "--> BtrTransFunc\n" ); + + fprintf( stdout, " MAX_VAR : %ld\n", (long)TransFunc->MAX_VAR ); + fprintf( stdout, " NUMBER_VAR : %ld\n", (long)TransFunc->NUMBER_VAR ); + + NumberVar = TransFunc->NUMBER_VAR; + VarFunc = TransFunc->VAR_FUNC; + + for ( Variable = 0; Variable < NumberVar; Variable++ ) + { + fprintf( stdout, " VAR_FUNC[ %ld ] : ", Variable ); + + if ( FuncView ) + { + (*FuncView)( &VarFunc[ Variable ] ); + } + else + { + fprintf( stdout, "\n" ); + } + } + + fprintf( stdout, "<-- BtrTransFunc\n" ); +} + +/*------------------------------------------------------------\ +| | +| Btr Local Reorder Compare | +| | +\------------------------------------------------------------*/ + +static long loc_ordercompare( ValueArray, Index1, Index2 ) + + long *ValueArray; + long Index1; + long Index2; +{ + return( ValueArray[ Index1 ] - ValueArray[ Index2 ] ); +} + +/*------------------------------------------------------------\ +| | +| Btr Reorder Transition Function | +| | +\------------------------------------------------------------*/ + +void reorderbtrtransfunc( TransFunc ) + + btrtransfunc *TransFunc; +{ + btrvarfunc *VarFunc; + btrvarorder *VarOrder; + long NumberVar; + long Variable; + bddnode *BddNode; + + NumberVar = TransFunc->NUMBER_VAR; + VarFunc = TransFunc->VAR_FUNC; + VarOrder = TransFunc->VAR_ORDER; + + setbddlocalsystem( TransFunc->BDD_SYSTEM ); + + if ( BtrLocalCostArray == (long *)0 ) + { + BtrLocalCostArray = (long *)autallocblock( sizeof(long) * NumberVar ); + BtrLocalCostLength = NumberVar; + } + else + if ( BtrLocalCostLength < NumberVar ) + { + BtrLocalCostArray = + + (long *)autresizeblock( (char *)BtrLocalCostArray, + sizeof( long ) * BtrLocalCostLength, + sizeof( long ) * NumberVar ); + + BtrLocalCostLength = NumberVar; + } + + for ( Variable = 0; Variable < NumberVar; Variable++ ) + { + BddNode = VarFunc[ Variable ].FUNC; + BtrLocalCostArray[ Variable ] = getbddnodesize( (bddsystem *)0, BddNode ); + + } + + sortautarray( BtrLocalCostArray, VarOrder, NumberVar, loc_ordercompare ); +} diff --git a/alliance/src/btr/src/btrfunc.h b/alliance/src/btr/src/btrfunc.h new file mode 100644 index 00000000..7d26e768 --- /dev/null +++ b/alliance/src/btr/src/btrfunc.h @@ -0,0 +1,88 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Btr | +| | +| File : Btr Transition Function | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 03.12.96 | +| | +\------------------------------------------------------------*/ + +# ifndef BTR_FUNC_H +# define BTR_FUNC_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define BTR_VAR_STRETCH_FACTOR 2 + +/*------------------------------------------------------------\ +| | +| Error | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Warning | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macros | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/btr/src/btrresize.c b/alliance/src/btr/src/btrresize.c new file mode 100644 index 00000000..0baf9058 --- /dev/null +++ b/alliance/src/btr/src/btrresize.c @@ -0,0 +1,123 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Btr | +| | +| File : btrresize.c | +| | +| Date : 03.12.96 | +| | +| Btrhor : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "btr.h" + +# include +# include "btrresize.h" +# include "btrerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Btr Resize Variable Function | +| | +\------------------------------------------------------------*/ + +btrvarfunc *resizebtrvarfunc( VarFunc, OldNum, NewNum ) + + btrvarfunc *VarFunc; + long OldNum; + long NewNum; +{ + return( (btrvarfunc *)autresizeblock( (char *)VarFunc, + sizeof( btrvarfunc ) * OldNum, + sizeof( btrvarfunc ) * NewNum ) ); +} + +/*------------------------------------------------------------\ +| | +| Btr Resize Variable Order | +| | +\------------------------------------------------------------*/ + +btrvarorder *resizebtrvarorder( VarOrder, OldNum, NewNum ) + + btrvarorder *VarOrder; + long OldNum; + long NewNum; +{ + return( (btrvarorder *)autresizeblock( (char *)VarOrder, + sizeof( btrvarorder ) * OldNum, + sizeof( btrvarorder ) * NewNum ) ); +} + +/*------------------------------------------------------------\ +| | +| Btr Resize Variable Relation | +| | +\------------------------------------------------------------*/ + +btrvarrel *resizebtrvarrel( VarRel, OldNum, NewNum ) + + btrvarrel *VarRel; + long OldNum; + long NewNum; +{ + return( (btrvarrel *)autresizeblock( (char *)VarRel, + sizeof( btrvarrel ) * OldNum, + sizeof( btrvarrel ) * NewNum ) ); +} diff --git a/alliance/src/btr/src/btrresize.h b/alliance/src/btr/src/btrresize.h new file mode 100644 index 00000000..021fce4f --- /dev/null +++ b/alliance/src/btr/src/btrresize.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Btr | +| | +| File : btrresize.h | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef BTR_RESIZE_H +# define BTR_RESIZE_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/btr/src/btrtrans.c b/alliance/src/btr/src/btrtrans.c new file mode 100644 index 00000000..ffe4aa99 --- /dev/null +++ b/alliance/src/btr/src/btrtrans.c @@ -0,0 +1,319 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Btr | +| | +| File : Btr Transition Relation | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 03.12.96 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "btr.h" +# include "btrtrans.h" +# include "btrerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Btr Image Transition Function | +| | +\------------------------------------------------------------*/ + +bddnode *imagebtrtransrel( TransRel, StateSet ) + + btrtransrel *TransRel; + bddnode *StateSet; +{ + bddnode *BddImage; + btrvarrel *VarRel; + long NumberVar; + long Variable; + + setbddlocalsystem( TransRel->BDD_SYSTEM ); + + NumberVar = TransRel->NUMBER_VAR; + + if ( NumberVar == 0 ) + { + btrerror( BTR_BAD_VAR_ERROR, NumberVar ); + } + + BddImage = BddLocalSystem->ONE; + + for ( Variable = 0; Variable < NumberVar; Variable++ ) + { + VarRel = &TransRel->VAR_REL[ Variable ]; + BddImage = applybddnode( (bddsystem *)0, ABL_AND, + decbddrefext( BddImage ), VarRel->REL ); + } + + BddImage = relprodbddnodeassoc( (bddsystem *)0, + decbddrefext( BddImage ), StateSet, + TransRel->VAR_ASSOC ); + + BddImage = substbddnodeassoc( (bddsystem *)0, + decbddrefext( BddImage ), + TransRel->PRIME_ASSOC ); + return( BddImage ); +} + +/*------------------------------------------------------------\ +| | +| Btr Create Transition Relation | +| | +\------------------------------------------------------------*/ + +btrtransrel *createbtrtransrel( BddSystem, MaxVar ) + + bddsystem *BddSystem; + bddvar MaxVar; +{ + btrtransrel *TransRel; + + setbddlocalsystem( BddSystem ); + + if ( MaxVar >= BDD_MAX_VAR ) + { + btrerror( BTR_BAD_VAR_ERROR, MaxVar ); + } + + TransRel = allocbtrtransrel(); + + TransRel->BDD_SYSTEM = BddLocalSystem; + + TransRel->MAX_VAR = MaxVar; + TransRel->VAR_REL = allocbtrvarrel( MaxVar ); + + TransRel->PRIME_ASSOC = addbddassoc( (bddsystem *)0 ); + TransRel->VAR_ASSOC = addbddassoc( (bddsystem *)0 ); + + return( TransRel ); +} + +/*------------------------------------------------------------\ +| | +| Btr Add Transition Relation | +| | +\------------------------------------------------------------*/ + +void addbtrtransrel( TransRel, VarNode, PrimeNode, FuncNode ) + + btrtransrel *TransRel; + bddnode *VarNode; + bddnode *PrimeNode; + bddnode *FuncNode; +{ + btrvarrel *VarRel; + bddnode *RelNode; + bddvar VarPrime; + bddvar Variable; + long MaxVar; + long NumberVar; + + setbddlocalsystem( TransRel->BDD_SYSTEM ); + + NumberVar = TransRel->NUMBER_VAR; + MaxVar = TransRel->MAX_VAR; + + if ( NumberVar >= BDD_MAX_VAR ) + { + btrerror( BTR_NO_MORE_VAR_ERROR, 0 ); + } + + if ( NumberVar == MaxVar ) + { + MaxVar = MaxVar * BTR_VAR_STRETCH_FACTOR; + + if ( MaxVar >= BDD_MAX_VAR ) + { + MaxVar = BDD_MAX_VAR - 1; + } + + VarRel = resizebtrvarrel( TransRel->VAR_REL, + TransRel->MAX_VAR, MaxVar ); + + TransRel->VAR_REL = VarRel; + TransRel->MAX_VAR = MaxVar; + } + else + { + VarRel = TransRel->VAR_REL; + } + + VarPrime = BddLocalSystem->INDEX_TO_VAR[ PrimeNode->INDEX ]; + Variable = BddLocalSystem->INDEX_TO_VAR[ VarNode->INDEX ]; + + addbddnodeassoc( (bddsystem *)0, TransRel->PRIME_ASSOC, VarPrime, VarNode ); + addbddnodeassoc( (bddsystem *)0, TransRel->VAR_ASSOC , Variable, PrimeNode ); + + RelNode = applybddnode( (bddsystem *)0, ABL_NXOR, FuncNode, PrimeNode ); + + VarRel[ NumberVar ].REL = RelNode; + VarRel[ NumberVar ].VAR = VarNode; + VarRel[ NumberVar ].PRIME = PrimeNode; + + TransRel->NUMBER_VAR++; +} + +/*------------------------------------------------------------\ +| | +| Btr Reset Transition Relation | +| | +\------------------------------------------------------------*/ + +void resetbtrtransrel( TransRel ) + + btrtransrel *TransRel; +{ + btrvarrel *VarRel; + long Variable; + long NumberVar; + + setbddlocalsystem( TransRel->BDD_SYSTEM ); + + NumberVar = TransRel->NUMBER_VAR; + VarRel = TransRel->VAR_REL; + + for ( Variable = 0; Variable < NumberVar; Variable++ ) + { + decbddrefext( VarRel[ Variable ].REL ); + } + + memset( (void *)VarRel, 0, + (size_t)NumberVar * sizeof( btrvarrel ) ); + + TransRel->NUMBER_VAR = 0; + + resetbddassoc( (bddsystem *)0, TransRel->PRIME_ASSOC ); + resetbddassoc( (bddsystem *)0, TransRel->VAR_ASSOC ); +} + +/*------------------------------------------------------------\ +| | +| Btr Destroy Transition Relation | +| | +\------------------------------------------------------------*/ + +void destroybtrtransrel( TransRel ) + + btrtransrel *TransRel; +{ + btrvarrel *VarRel; + long Variable; + long NumberVar; + + setbddlocalsystem( TransRel->BDD_SYSTEM ); + + NumberVar = TransRel->NUMBER_VAR; + VarRel = TransRel->VAR_REL; + + for ( Variable = 0; Variable < NumberVar; Variable++ ) + { + decbddrefext( VarRel[ Variable ].REL ); + } + + freebtrvarrel( TransRel->VAR_REL ); + freebtrtransrel( TransRel ); + + delbddassoc( (bddsystem *)0, TransRel->PRIME_ASSOC ); + delbddassoc( (bddsystem *)0, TransRel->VAR_ASSOC ); +} + +/*------------------------------------------------------------\ +| | +| Btr View Transition Relation | +| | +\------------------------------------------------------------*/ + +void viewbtrtransrel( TransRel, FuncView ) + + btrtransrel *TransRel; + void (*FuncView)(); +{ + btrvarrel *VarRel; + long Variable; + long NumberVar; + + fprintf( stdout, "--> BtrTransRel\n" ); + + fprintf( stdout, " MAX_VAR : %ld\n", (long)TransRel->MAX_VAR ); + fprintf( stdout, " NUMBER_VAR : %ld\n", (long)TransRel->NUMBER_VAR ); + + NumberVar = TransRel->NUMBER_VAR; + VarRel = TransRel->VAR_REL; + + for ( Variable = 0; Variable < NumberVar; Variable++ ) + { + fprintf( stdout, " VAR_REL[ %ld ] : ", Variable ); + + if ( FuncView ) + { + (*FuncView)( &VarRel[ Variable ] ); + } + else + { + fprintf( stdout, "\n" ); + } + } + + fprintf( stdout, "<-- BtrTransRel\n" ); +} diff --git a/alliance/src/btr/src/btrtrans.h b/alliance/src/btr/src/btrtrans.h new file mode 100644 index 00000000..abc38ce7 --- /dev/null +++ b/alliance/src/btr/src/btrtrans.h @@ -0,0 +1,88 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/*------------------------------------------------------------\ +| | +| Tool : Btr | +| | +| File : Btr Transition Function | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 03.12.96 | +| | +\------------------------------------------------------------*/ + +# ifndef BTR_TRANS_H +# define BTR_TRANS_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define BTR_VAR_STRETCH_FACTOR 2 + +/*------------------------------------------------------------\ +| | +| Error | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Warning | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macros | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/btr/src/go b/alliance/src/btr/src/go new file mode 100644 index 00000000..018f7087 --- /dev/null +++ b/alliance/src/btr/src/go @@ -0,0 +1,10 @@ +for I in *[ch] +do + sed -e 's/\/\"aut.h\"/g' \ + -e 's/\/\"mut.h\"/g' \ + -e 's/\/\"abl.h\"/g' \ + -e 's/\/\"btr.h\"/g' \ + -e 's/\/\"bdd.h\"/g' $I > 1 + mv 1 $I +done + diff --git a/alliance/src/btr/src/main.c b/alliance/src/btr/src/main.c new file mode 100644 index 00000000..a75f8c93 --- /dev/null +++ b/alliance/src/btr/src/main.c @@ -0,0 +1,508 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : Btr | +| | +| File : main.c | +| | +| Date : 03.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "log.h" +# include "beh.h" +# include "bvl.h" +# include "bhl.h" +# include "btr.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static char *BtrStateArray = (char *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Btr Usage | +| | +\------------------------------------------------------------*/ + +void BtrUsage() +{ + fprintf( stderr, "Usage: btrtest [-tfip] filename\n" ); + + exit( 1 ); +} + +/*------------------------------------------------------------\ +| | +| BtrViewBddState | +| | +\------------------------------------------------------------*/ + +void BtrViewBddState( BddNode ) + + bddnode *BddNode; +{ + bddindex BddIndex; + + if ( BddNode->INDEX < BDD_INDEX_MIN ) + { + if ( BddNode->INDEX == BDD_INDEX_ONE ) + { + fprintf( stdout, "%s\n", BtrStateArray ); + } + } + else + { + BddIndex = BddNode->INDEX - BDD_INDEX_MIN; + + BtrStateArray[ BddIndex ] = '1'; + BtrViewBddState( BddNode->HIGH ); + + BtrStateArray[ BddIndex ] = '0'; + BtrViewBddState( BddNode->LOW ); + + BtrStateArray[ BddIndex ] = '*'; + } +} + +/*------------------------------------------------------------\ +| | +| BtrViewBddNode | +| | +\------------------------------------------------------------*/ + +void BtrViewBddNode( BddNode ) + + bddnode *BddNode; +{ + chain_list *Expr; + + Expr = convertbddcircuitabl( (bddcircuit *)0, BddNode ); + viewablexpr( Expr, ABL_VIEW_VHDL ); + delablexpr( Expr ); + + fprintf( stdout, "\n" ); +} + +/*------------------------------------------------------------\ +| | +| BtrViewFunc | +| | +\------------------------------------------------------------*/ + +void BtrViewFunc( VarFunc ) + + btrvarfunc *VarFunc; +{ + fprintf( stdout, "\nVAR : " ); + BtrViewBddNode( VarFunc->VAR ); + fprintf( stdout, "FUNC: " ); + BtrViewBddNode( VarFunc->FUNC ); +} + +/*------------------------------------------------------------\ +| | +| BtrViewRel | +| | +\------------------------------------------------------------*/ + +void BtrViewRel( VarRel ) + + btrvarrel *VarRel; +{ + fprintf( stdout, "\nVAR : " ); + BtrViewBddNode( VarRel->VAR ); + fprintf( stdout, "PRIME: " ); + BtrViewBddNode( VarRel->PRIME ); + fprintf( stdout, "REL: " ); + BtrViewBddNode( VarRel->REL ); +} + +/*------------------------------------------------------------\ +| | +| PreImage | +| | +\------------------------------------------------------------*/ + +void BtrPreImageFunc( BtrTransFunc, BddInitial, BddAssoc ) + + btrtransfunc *BtrTransFunc; + bddnode *BddInitial; + bddassoc *BddAssoc; +{ + bddnode *BddCurrent; + bddnode *BddReached; + bddnode *BddNew; + bddnode *BddPreImage; + + BddCurrent = BddInitial; + + fprintf( stdout, "Initial:\n" ); +/*\ + BtrViewBddState( BddCurrent ); +\*/ + + BddReached = incbddrefext( BddCurrent ); + + do + { + BddPreImage = (bddnode *)preimagebtrtransfunc( BtrTransFunc, BddCurrent ); + decbddrefext( BddCurrent ); + + BddCurrent = missbddnodeassocon( (bddsystem *)0, BddPreImage, BddAssoc ); + decbddrefext( BddPreImage ); + + fprintf( stdout, "PreImage:\n" ); +/*\ + BtrViewBddState( BddCurrent ); +\*/ + BddNew = applybddnodenot( (bddsystem *)0, BddReached ); + BddNew = applybddnode( (bddsystem *)0, ABL_AND, BddCurrent, decbddrefext( BddNew ) ); + + BddReached = applybddnode( (bddsystem *)0, ABL_OR, + decbddrefext( BddReached ), + decbddrefext( BddCurrent ) ); + + BddCurrent = BddNew; + } + while ( BddNew != BddLocalSystem->ZERO ); + + decbddrefext( BddReached ); +} + +/*------------------------------------------------------------\ +| | +| Image | +| | +\------------------------------------------------------------*/ + +void BtrImageFunc( BtrTransFunc, BddInitial ) + + btrtransfunc *BtrTransFunc; + bddnode *BddInitial; +{ + bddnode *BddCurrent; + bddnode *BddReached; + bddnode *BddNew; + bddnode *BddImage; + + BddCurrent = BddInitial; + + fprintf( stdout, "Initial:\n" ); + BtrViewBddState( BddCurrent ); + + BddReached = incbddrefext( BddCurrent ); + + do + { + BddImage = (bddnode *)imagebtrtransfunc( BtrTransFunc, BddCurrent ); + + decbddrefext( BddCurrent ); + BddCurrent = BddImage; + + fprintf( stdout, "Image:\n" ); + BtrViewBddState( BddImage ); + + BddNew = applybddnodenot( (bddsystem *)0, BddReached ); + BddNew = applybddnode( (bddsystem *)0, ABL_AND, BddCurrent, decbddrefext( BddNew ) ); + + BddReached = applybddnode( (bddsystem *)0, ABL_OR, + decbddrefext( BddReached ), + decbddrefext( BddCurrent ) ); + + BddCurrent = BddNew; + } + while ( BddNew != BddLocalSystem->ZERO ); + + decbddrefext( BddReached ); +} + +/*------------------------------------------------------------\ +| | +| Image | +| | +\------------------------------------------------------------*/ + +void BtrImageRel( BtrTransRel, BddInitial, BddAssoc ) + + btrtransrel *BtrTransRel; + bddnode *BddInitial; + bddassoc *BddAssoc; +{ + bddnode *BddCurrent; + bddnode *BddReached; + bddnode *BddNew; + bddnode *BddImage; + + BddCurrent = BddInitial; + + fprintf( stdout, "Initial:\n" ); + BtrViewBddState( BddCurrent ); + + BddReached = incbddrefext( BddCurrent ); + + do + { + BddImage = (bddnode *)imagebtrtransrel( BtrTransRel, BddCurrent ); + BddImage = missbddnodeassocon( (bddsystem *)0, + decbddrefext( BddImage ), BddAssoc ); + + decbddrefext( BddCurrent ); + BddCurrent = BddImage; + + fprintf( stdout, "Image:\n" ); + BtrViewBddState( BddImage ); + + BddNew = applybddnodenot( (bddsystem *)0, BddReached ); + BddNew = applybddnode( (bddsystem *)0, ABL_AND, BddCurrent, decbddrefext( BddNew ) ); + + BddReached = applybddnode( (bddsystem *)0, ABL_OR, + decbddrefext( BddReached ), + decbddrefext( BddCurrent ) ); + + BddCurrent = BddNew; + } + while ( BddNew != BddLocalSystem->ZERO ); + + decbddrefext( BddReached ); +} + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +int main( argc, argv ) + + int argc; + char *argv[]; +{ + befig_list *BehFigure; + bereg_list *BehReg; + binode_list *BiNode; + bddnode *BddNode; + bddnode *BddPrime; + + bddassoc *BddAssoc; + + bddnode *BddInitial; + bddsystem *BddSystem; + bddcircuit *BddCircuit; + + long BtrNumReg; + + btrtransfunc *BtrTransFunc; + btrtransrel *BtrTransRel; + char Buffer[ 512 ]; + + char *InputFileName; + int FlagImage; + int FlagFunc; + int FlagDebug; + + int Number; + int Index; + char Option; + + mbkenv(); + + InputFileName = (char *)0; + FlagImage = 1; + FlagFunc = 1; + FlagDebug = 0; + + for ( Number = 1; Number < argc; Number++ ) + { + if ( argv[ Number ][ 0 ] == '-' ) + { + for ( Index = 1; argv[ Number ][ Index ] != '\0'; Index++ ) + { + Option = argv[ Number ][ Index ]; + + switch ( Option ) + { + case 'f' : FlagFunc = 1; + break; + case 't' : FlagFunc = 0; + break; + case 'i' : FlagImage = 1; + break; + case 'p' : FlagImage = 0; + break; + case 'd' : FlagDebug = 1; + break; + default : BtrUsage(); + } + } + } + else + { + InputFileName = argv[ Number ]; + } + } + + if ( ( argc < 2 ) || + ( InputFileName == (char *)0 ) ) + { + BtrUsage(); + } + + fprintf( stdout, "vhdlloadbefig %s\n", InputFileName ); + BehFigure = vhdlloadbefig( (befig_list *)0, InputFileName, 3 ); + fprintf( stdout, "file %s loaded\n", InputFileName ); + + BddSystem = createbddsystem( 100, 1000, 100, 500000 ); + reorderbddsystemdynamic( BddSystem, reorderbddsystemsimple, 30000, 100 ); + + BehFigure->BEDLY = (beaux_list *)0; + + fprintf( stdout, "beh_makbdd\n" ); + beh_makbdd( BehFigure, 0, 0 ); + + if ( FlagFunc ) + { + BtrTransFunc = createbtrtransfunc( (bddsystem *)0, 100 ); + } + else + { + BtrTransRel = createbtrtransrel( (bddsystem *)0, 100 ); + } + + BddAssoc = addbddassoc( (bddsystem *)0 ); + + BehReg = BehFigure->BEREG; + + while ( BehReg != (bereg_list *)0 ) + { + BiNode = BehReg->BINODE; + + BddNode = searchbddcircuitin( (bddcircuit *)0, BehReg->NAME ); + + if ( FlagFunc ) + { + addbtrtransfunc( BtrTransFunc, BddNode, BiNode->VALNODE ); + } + else + { + sprintf( Buffer, "'%s", BehReg->NAME ); + BddPrime = addbddcircuitin( (bddcircuit *)0, Buffer, + BddNode->INDEX, BDD_IN_MODE_AFTER ); + + addbtrtransrel( BtrTransRel, BddNode, BddPrime, BiNode->VALNODE ); + } + + addbddnodeassoc( (bddsystem *)0, BddAssoc, + getbddvarbyindex( (bddsystem *)0, BddNode->INDEX ), + BddLocalSystem->ONE ); + + BehReg = BehReg->NEXT; + } + + BtrStateArray = autallocblock( BddLocalCircuit->NUMBER_NAME_IN + 1 ); + memset( BtrStateArray, '*', BddLocalCircuit->NUMBER_NAME_IN ); + + fprintf( stdout, "Node: %ld\n", BddSystem->NUMBER_NODE ); + + testbddcircuit( (bddcircuit *)0 ); + + BddInitial = searchbddcircuitout( (bddcircuit *)0, "initial" ); + + if ( BddInitial == (bddnode *)0 ) + { + fprintf( stdout, "Missing output 'initial'\n" ); + EXIT( 1 ); + } + + if ( FlagFunc ) + { + if ( FlagDebug ) + { + viewbtrtransfunc( BtrTransFunc, BtrViewFunc ); + } + + if ( FlagImage ) BtrImageFunc ( BtrTransFunc, BddInitial ); + else BtrPreImageFunc( BtrTransFunc, BddInitial, BddAssoc ); + + destroybtrtransfunc( BtrTransFunc ); + } + else + { + if ( FlagDebug ) + { + viewbtrtransrel( BtrTransRel, BtrViewRel ); + } + + if ( FlagImage ) BtrImageRel( BtrTransRel, BddInitial, BddAssoc ); + + destroybtrtransrel( BtrTransRel ); + } + + delbddassoc( (bddsystem *)0, BddAssoc ); + + testbddcircuit( (bddcircuit *)0 ); + + destroybddcircuit( BehFigure->CIRCUI ); + destroybddsystem( BddSystem ); + + beh_frebefig( BehFigure ); + + return( 0 ); +}