diff --git a/alliance/src/ftl/Makefile.am b/alliance/src/ftl/Makefile.am new file mode 100644 index 00000000..af437a64 --- /dev/null +++ b/alliance/src/ftl/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/alliance/src/ftl/configure.in b/alliance/src/ftl/configure.in new file mode 100644 index 00000000..f1480068 --- /dev/null +++ b/alliance/src/ftl/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 14:37:03 ludo Exp $ +dnl +dnl +AC_INIT(src/fsm.h) +AM_INIT_AUTOMAKE(fsm, 1.4) +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/ftl/src/Makefile.am b/alliance/src/ftl/src/Makefile.am new file mode 100644 index 00000000..ff1ffc9c --- /dev/null +++ b/alliance/src/ftl/src/Makefile.am @@ -0,0 +1,6 @@ +CFLAGS = @CFLAGS@ \ + -DALLIANCE_TOP=\"${ALLIANCE_TOP}\" +lib_LIBRARIES = libFtl.a +include_HEADERS = ftl.h +libFtl_a_SOURCES = \ +ftl.h ftlacces.c ftlacces.h ftlerror.c ftlerror.h diff --git a/alliance/src/ftl/src/ftl.h b/alliance/src/ftl/src/ftl.h new file mode 100644 index 00000000..1eb2be3c --- /dev/null +++ b/alliance/src/ftl/src/ftl.h @@ -0,0 +1,81 @@ +/*------------------------------------------------------------\ +| | +| 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 FTL | +| | +| Date : 28.01.95 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------*/ + +# ifndef FTL_104_H +# define FTL_104_H + +/*------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------*/ +/*------------------------------------------------------\ +| | +| Structures | +| | +\------------------------------------------------------*/ +/*------------------------------------------------------\ +| | +| Global Variables | +| | +\------------------------------------------------------*/ + + extern char *FSM_IN; + extern char *FSM_OUT; + + extern char *FSM_KISS_FORMAT; + extern char *FSM_VHDL_FORMAT; + +/*------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------*/ + + + extern void fsmenv __P(()); + extern fsmfig_list * getfsmfig __P((char *Name)); + extern void loadfsmfig __P((fsmfig_list *Figure, char *Name)); + extern void savefsmfig __P((fsmfig_list *Figure)); + +# endif diff --git a/alliance/src/ftl/src/ftlacces.c b/alliance/src/ftl/src/ftlacces.c new file mode 100644 index 00000000..e6e673e5 --- /dev/null +++ b/alliance/src/ftl/src/ftlacces.c @@ -0,0 +1,195 @@ +/*------------------------------------------------------------\ +| | +| 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 : Ftl | +| | +| File : ftlacces.c | +| | +| Date : 04.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "fsm.h" +# include "ftl.h" + +# include "ftlacces.h" +# include "ftlerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + char *FSM_IN; + char *FSM_OUT; + + char *FSM_KISS_FORMAT = (char *)0; + char *FSM_VHDL_FORMAT = (char *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| fsmenv | +| | +\------------------------------------------------------------*/ + +void fsmenv() +{ + FSM_IN = namealloc( mbkgetenv( "FSM_IN") ); + + if ( FSM_IN == (char *)0 ) + { + FSM_IN = namealloc( FTL_DEFAULT_IN ); + } + + FSM_OUT = namealloc( mbkgetenv( "FSM_OUT") ); + + if ( FSM_OUT == (char *)0 ) + { + FSM_OUT = namealloc( FTL_DEFAULT_OUT ); + } + + FSM_KISS_FORMAT = namealloc( "kiss2" ); + FSM_VHDL_FORMAT = namealloc( "fsm" ); +} + +/*------------------------------------------------------------\ +| | +| loadfsmfig | +| | +\------------------------------------------------------------*/ + +void loadfsmfig( Figure, Name ) + + fsmfig_list *Figure; + char *Name; +{ + if ( FSM_IN == FSM_KISS_FORMAT ) + { + kissloadfsmfig( Figure, Name ); + } + else + if ( FSM_IN == FSM_VHDL_FORMAT ) + { + vhdlloadfsmfig( Figure, Name ); + } + else + { + ftlerror( FTL_UNKNOWN_FSM_IN, FSM_IN ); + } +} + +/*------------------------------------------------------------\ +| | +| savefsmfig | +| | +\------------------------------------------------------------*/ + +void savefsmfig( Figure ) + + fsmfig_list *Figure; +{ + if ( FSM_OUT == FSM_KISS_FORMAT ) + { + kisssavefsmfig( Figure ); + } + else + if ( FSM_OUT == FSM_VHDL_FORMAT ) + { + vhdlsavefsmfig( Figure ); + } + else + { + ftlerror( FTL_UNKNOWN_FSM_OUT, FSM_OUT ); + } +} + +/*------------------------------------------------------------\ +| | +| getfsmfig | +| | +\------------------------------------------------------------*/ + +fsmfig_list *getfsmfig( Name ) + + char *Name; +{ + fsmfig_list *Figure; + + Name = namealloc( Name ); + + for ( Figure = HEAD_FSMFIG; + Figure != (fsmfig_list *)0; + Figure = Figure->NEXT ) + { + if ( Figure->NAME == Name ) break; + } + + if ( Figure == (fsmfig_list *)0 ) + { + Figure = addfsmfig( Name ); + + loadfsmfig( Figure, Name ); + } + + return( Figure ); +} diff --git a/alliance/src/ftl/src/ftlacces.h b/alliance/src/ftl/src/ftlacces.h new file mode 100644 index 00000000..f0c9c4af --- /dev/null +++ b/alliance/src/ftl/src/ftlacces.h @@ -0,0 +1,83 @@ +/*------------------------------------------------------------\ +| | +| 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 : Ftl | +| | +| File : ftlacces.h | +| | +| Date : 04.12.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef FTL_ACCES_H +# define FTL_ACCES_H + +# define FTL_DEFAULT_IN "fsm" +# define FTL_DEFAULT_OUT "fsm" + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void kissloadfsmfig(); + extern void kisssavefsmfig(); + extern void vhdlloadfsmfig(); + extern void vhdlsavefsmfig(); + +# endif diff --git a/alliance/src/ftl/src/ftlerror.c b/alliance/src/ftl/src/ftlerror.c new file mode 100644 index 00000000..a971d02e --- /dev/null +++ b/alliance/src/ftl/src/ftlerror.c @@ -0,0 +1,112 @@ +/*------------------------------------------------------------\ +| | +| 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 : Ftl | +| | +| File : Ftl Errors | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 04.12.96 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "fsm.h" +# include "ftl.h" + +# include "ftlerror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +void ftl_error( Error, Text, File, Line ) + + char Error; + char *Text; + char *File; + long Line; +{ + char *Name; + + Name = mbkstrdup( File ); + Name[ strlen( File ) - 1 ] = '\0'; + + fprintf( stderr, "%s%ld ", Name, Line ); + + switch( Error ) + { + case FTL_UNKNOWN_FSM_OUT : + + fprintf( stderr, "Unknown fsm output format %s\n", Text ); + + break; + + case FTL_UNKNOWN_FSM_IN : + + fprintf( stderr, "Unknown fsm input format %s\n", Text ); + + break; + + default : + + fprintf( stderr, "unknown internal error %d !\n", Error ); + } + + autexit( 1 ); +} diff --git a/alliance/src/ftl/src/ftlerror.h b/alliance/src/ftl/src/ftlerror.h new file mode 100644 index 00000000..9291c053 --- /dev/null +++ b/alliance/src/ftl/src/ftlerror.h @@ -0,0 +1,84 @@ +/*------------------------------------------------------------\ +| | +| 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 : Ftl | +| | +| File : Ftl Errors | +| | +| Authors : Jacomme Ludovic | +| | +| Date : 04.12.96 | +| | +\------------------------------------------------------------*/ + +# ifndef FTL_ERROR_H +# define FTL_ERROR_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define FTL_UNKNOWN_FSM_IN 0 +# define FTL_UNKNOWN_FSM_OUT 1 + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macros | +| | +\------------------------------------------------------------*/ + +# define ftlerror( E, V ) (ftl_error( (E), (V), __FILE__, __LINE__ )) + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void ftl_error __P((char Error, char *Text, char *File, long Line)); + +# endif diff --git a/alliance/src/fvh/Makefile.am b/alliance/src/fvh/Makefile.am new file mode 100644 index 00000000..af437a64 --- /dev/null +++ b/alliance/src/fvh/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/alliance/src/fvh/configure.in b/alliance/src/fvh/configure.in new file mode 100644 index 00000000..a5b125d2 --- /dev/null +++ b/alliance/src/fvh/configure.in @@ -0,0 +1,47 @@ +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 14:33:38 ludo Exp $ +dnl +dnl +AC_INIT(src/fvh.h) +AM_INIT_AUTOMAKE(fvh, 1.4) +AC_PROG_INSTALL +AC_PROG_CC +AC_PROG_YACC +AM_PROG_LEX +AC_HEADER_STDC +AC_C_CONST +AC_PROG_RANLIB + +AM_ALLIANCE + +AC_OUTPUT([ +Makefile +src/Makefile +]) diff --git a/alliance/src/fvh/src/Makefile.am b/alliance/src/fvh/src/Makefile.am new file mode 100644 index 00000000..0165e78b --- /dev/null +++ b/alliance/src/fvh/src/Makefile.am @@ -0,0 +1,14 @@ +lib_LIBRARIES = libFvh.a +libFvh_a_SOURCES = fbl_bcomp.y fbl_bcomp.l \ +fbh_add.c fbh_rmv.c fbl_blex.h fbl_drive.h fvh.h fvhfbh2fsm.c \ +fbh_del.c fbh_typ.c fbl_bspec.c fbl_utdef.h fvhdrive.c fvhfbh2fsm.h \ +fbh_env.c fbh_uti.c fbl_bspec.h fbl_util.c fvhdrive.h fvhparse.c \ +fbh_fre.c fbh_view.c fbl_byacc.h fbl_util.h fvherror.c fvhparse.h \ +fbh_rin.c fbl_bedef.h fbl_drive.c fbl_utype.h fvherror.h + +CLEANFILES = fbl_bcompyac.c fbl_bcompyac.h fbl_bcomplex.c + +fbl_bcompyac.c fbl_bcompyac.h : $(srcdir)/fbl_bcomp.y + $(YACC) -d $(YFLAGS) $(srcdir)/fbl_bcomp.y && sed -e "s/yy/fbl_y_/g" -e "s/YY/FBL_Y_/g" y.tab.c > fbl_bcompyac.c && sed -e "s/yy/fbl_y_/g" -e "s/YY/FBL_Y_/g" y.tab.h > fbl_bcompyac.h +fbl_bcomplex.c : $(srcdir)/fbl_bcomp.l fbl_bcompyac.h + $(LEX) -t $(srcdir)/fbl_bcomp.l | sed -e "s/yy/fbl_y_/g" -e "s/YY/FBL_Y_/g" > fbl_bcomplex.c diff --git a/alliance/src/fvh/src/fbh_add.c b/alliance/src/fvh/src/fbh_add.c new file mode 100644 index 00000000..b9ae55c8 --- /dev/null +++ b/alliance/src/fvh/src/fbh_add.c @@ -0,0 +1,629 @@ +/*------------------------------------------------------------\ +| | +| 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. | +| | +\------------------------------------------------------------*/ +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbh_addfbasg.c */ +/* date : Aug 28 1992 */ +/* version : v102 */ +/* authors : Pirouz BAZARGAN SABET */ +/* content : contains a specific function used to create a */ +/* fbhaviour data structure */ +/* */ +/* ###--------------------------------------------------------------### */ + +#include "mut.h" +#include "aut.h" +#include "abl.h" +#include "bdd.h" +#include "fvh.h" + +/* ###--------------------------------------------------------------### */ +/* function : fbh_addfbasg */ +/* description : create a BEASG structure at the top the list */ +/* called func. : addptype, mbkalloc, namealloc */ +/* ###--------------------------------------------------------------### */ + +struct ptype *fbh_addfbasg (lastptype, name, abl, type) + +struct ptype *lastptype; /* pointer on the last ptype structure */ +char *name; /* signal's name */ +struct chain *abl; /* condition's expression */ +unsigned char type; /* signal's type (cannot be 0) */ + + { + struct ptype *ptptype; + struct fbasg *ptfbasg; + + name = namealloc (name); + + ptfbasg = (struct fbasg *) mbkalloc (sizeof(struct fbasg)); + ptfbasg->NAME = name; + ptfbasg->ABL = abl; + ptfbasg->TYPE = type; + + ptptype = addptype (lastptype, FBH_BEASG, (void *)ptfbasg); + + return (ptptype); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_addfbaux */ +/* description : create a BEAUX structure at the top the list */ +/* called func. : namealloc, mbkalloc */ +/* ###--------------------------------------------------------------### */ + +struct fbaux *fbh_addfbaux (lastfbaux, name, abl_expr, bdd_expr, type) + +struct fbaux *lastfbaux; /* pointer on the last fbaux structure */ +char *name; /* signal's name */ +struct chain *abl_expr; /* signal's expression (ABL) */ +bddnode *bdd_expr; /* signal's expression (BDD) */ +unsigned char type; /* signal's type */ + + { + struct fbaux *ptaux; + + name = namealloc (name); + + ptaux = (struct fbaux *) mbkalloc (sizeof(struct fbaux)); + ptaux->NAME = name; + ptaux->ABL = abl_expr; + ptaux->NODE = bdd_expr; + ptaux->TYPE = type; + ptaux->NEXT = lastfbaux; + + return (ptaux); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_addfbbus */ +/* description : create a BEBUS structure at the top the list */ +/* called func. : namealloc, mbkalloc */ +/* ###--------------------------------------------------------------### */ + +struct fbbus *fbh_addfbbus (lastfbbus, name, biabl, binode, type) + +struct fbbus *lastfbbus; /* pointer on the last fbbus structure */ +char *name; /* port's name */ +struct biabl *biabl; /* port's drivers (ABL) */ +struct binode *binode; /* port's drivers (BDD) */ +char type; /* port type mark (M or W) */ + + { + struct fbbus *ptbus; + + name = namealloc (name); + + ptbus = (struct fbbus *) mbkalloc (sizeof(struct fbbus)); + ptbus->NAME = name; + ptbus->BIABL = biabl; + ptbus->BINODE = binode; + ptbus->TYPE = type; + ptbus->NEXT = lastfbbus; + + return (ptbus); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_addfbbux */ +/* description : create a BEBUX structure at the top the list */ +/* called func. : namealloc, mbkalloc */ +/* ###--------------------------------------------------------------### */ + +struct fbbux *fbh_addfbbux (lastfbbux, name, biabl, binode, type) + +struct fbbux *lastfbbux; /* pointer on the last fbbux structure */ +char *name; /* signal's name */ +struct biabl *biabl; /* signal's expression (ABL) */ +struct binode *binode; /* signal's expression (BDD) */ +char type; /* signal's type mark (M or W) */ + + { + struct fbbux *ptbux; + + name = namealloc (name); + + ptbux = (struct fbbux *) mbkalloc (sizeof(struct fbbux)); + ptbux->NAME = name; + ptbux->BIABL = biabl; + ptbux->BINODE = binode; + ptbux->TYPE = type; + ptbux->NEXT = lastfbbux; + + return (ptbux); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_addfbcas */ +/* description : create a BECAS structure at the top the list */ +/* called func. : addptype, mbkalloc */ +/* ###--------------------------------------------------------------### */ + +struct ptype *fbh_addfbcas (lastptype, abl,type) + +struct ptype *lastptype; /* pointer on the last ptype structure */ +struct chain *abl; /* condition's expression */ +unsigned char type; /* expression's type i */ + + { + struct ptype *ptptype; + struct fbcas *ptfbcas; + + ptfbcas = (struct fbcas *) mbkalloc (sizeof(struct fbcas)); + ptfbcas->ABL = abl; + ptfbcas->CHOICE = 0; + ptfbcas->USER = 0; + ptfbcas->SIZE = 0; + ptfbcas->TYPE = type; + + ptptype = addptype (lastptype, FBH_BECAS, (void *)ptfbcas); + + return (ptptype); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_addfbfig */ +/* description : create an empty BEFIG structure at the top of the list*/ +/* The FBH_HEDFIG list is not modified. */ +/* called func. : namealloc, mbkalloc */ +/* ###--------------------------------------------------------------### */ + +struct fbfig *fbh_addfbfig (lastfbfig, name) + +struct fbfig *lastfbfig; /* pointer on the last fbfig structure */ +char *name; /* figure's name */ + + { + struct fbfig *ptfig; + + name = namealloc (name); + + ptfig = (struct fbfig *) mbkalloc (sizeof(struct fbfig)); + ptfig->NAME = name; + ptfig->BEREG = 0; + ptfig->BEMSG = 0; + ptfig->BERIN = 0; + ptfig->BEOUT = 0; + ptfig->BEBUS = 0; + ptfig->BEAUX = 0; + ptfig->BEDLY = 0; + ptfig->BEBUX = 0; + ptfig->BEPOR = 0; + ptfig->BEPCS = 0; + ptfig->BETYP = 0; + ptfig->BEPGM = 0; + ptfig->CIRCUI = 0; + ptfig->USER = 0; + ptfig->FLAG = 0; + ptfig->NEXT = lastfbfig; + + return (ptfig); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_addfbgen */ +/* description : create a BEGEN structure at the top the list */ +/* called func. : namealloc, mbkalloc */ +/* ###--------------------------------------------------------------### */ + +struct fbgen *fbh_addfbgen (lastfbgen, name, type, value) + +struct fbgen *lastfbgen; /* pointer on the last fbgen structure */ +char *name; /* generic's name */ +char *type; /* generic's type */ +void *value; /* generic's value */ + + { + + struct fbgen *ptgen; + + name = namealloc (name); + + ptgen = (struct fbgen *) mbkalloc (sizeof(struct fbgen)); + ptgen->NAME = name; + ptgen->TYPE = type; + ptgen->VALUE = value; + ptgen->NEXT = lastfbgen; + + return (ptgen); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_addfbifs */ +/* description : create a BEIFS structure at the top the list */ +/* called func. : addptype, mbkalloc */ +/* ###--------------------------------------------------------------### */ + +struct ptype *fbh_addfbifs (lastptype, abl) + +struct ptype *lastptype; /* pointer on the last ptype structure */ +struct chain *abl; /* condition's expression */ + + { + struct ptype *ptptype; + struct fbifs *ptfbifs; + + ptfbifs = (struct fbifs *) mbkalloc (sizeof(struct fbifs)); + ptfbifs->CND = abl; + ptfbifs->CNDTRUE = 0; + ptfbifs->CNDFALSE = 0; + ptptype = addptype (lastptype, FBH_BEIFS, (void *)ptfbifs); + + return (ptptype); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_addfbmsg */ +/* description : create BEMSG structure at the top the list */ +/* called func. : mbkalloc, namealloc */ +/* ###--------------------------------------------------------------### */ + +struct fbmsg *fbh_addfbmsg (lastfbmsg,label,level,message,abl_expr,bdd_expr) + +struct fbmsg *lastfbmsg; /* pointer on the last fbmsg structure */ +char *label; /* assert's label */ +char level; /* severity level (E or W) */ +char *message; /* reported message */ +struct chain *abl_expr; /* assert's condition (ABL) */ +bddnode *bdd_expr; /* assert's condition (BDD) */ + + { + + struct fbmsg *ptmsg; + + label = namealloc (label); + + ptmsg = (struct fbmsg *) mbkalloc (sizeof(struct fbmsg)); + ptmsg->LABEL = label; + ptmsg->LEVEL = level; + ptmsg->MESSAGE = message; + ptmsg->ABL = abl_expr; + ptmsg->NODE = bdd_expr; + ptmsg->NEXT = lastfbmsg; + + return (ptmsg); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_addfbout */ +/* description : create a BEOUT structure at the top the list */ +/* called func. : namealloc, mbkalloc */ +/* ###--------------------------------------------------------------### */ + +struct fbout *fbh_addfbout (lastfbout, name, abl_expr, bdd_expr,type) + +struct fbout *lastfbout; /* pointer on the last fbout structure */ +char *name; /* port's name */ +struct chain *abl_expr; /* port's expression (ABL) */ +bddnode *bdd_expr; /* port's expression (BDD) */ +unsigned char type; /* port's type */ + + { + struct fbout *ptout; + + name = namealloc (name); + + ptout = (struct fbout *) mbkalloc (sizeof(struct fbout)); + ptout->NAME = name; + ptout->ABL = abl_expr; + ptout->NODE = bdd_expr; + ptout->TYPE = type; + ptout->NEXT = lastfbout; + + return (ptout); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_addfbpcs */ +/* description : create a BEPCS structure at the top the list */ +/* called func. : namealloc, mbkalloc */ +/* ###--------------------------------------------------------------### */ + +struct fbpcs *fbh_addfbpcs (lastfbpcs, label, sens, inst, outs, flag) + +struct fbpcs *lastfbpcs; /* pointer on the last fbpcs structure */ +char *label; /* process's label */ +struct chain *sens; /* sensitivity list */ +struct ptype *inst; /* list of instructions */ +struct chain *outs; /* list of outputs */ +char flag; /* flag */ + + { + struct fbpcs *ptfbpcs; + + label = namealloc (label); + + ptfbpcs = (struct fbpcs *) mbkalloc (sizeof(struct fbpcs)); + ptfbpcs->LABEL = label; + ptfbpcs->SENSITIVITY = sens; + ptfbpcs->OUTPUTS = outs; + ptfbpcs->INSTRUCTION = inst; + ptfbpcs->FLAG = flag; + + ptfbpcs->NEXT = lastfbpcs; + + return (ptfbpcs); + } +/* ###--------------------------------------------------------------### */ +/* function : fbh_addfbpgm */ +/* description : add an BEPGM structure at the top of a list */ +/* called func. : namealloc, mbkalloc */ +/* ###--------------------------------------------------------------### */ + +struct fbpgm *fbh_addfbpgm (lastfbpgm, type , name , value) +struct fbpgm *lastfbpgm; /* pointer on the last fbpgm */ +char *type; /* pragma's type */ +char *name; /* pragma's name */ +void *value; /* pragma's content */ + { + struct fbpgm *ptfbpgm; + + if(type) + type = namealloc (type); + if(name) + name = namealloc (name); + + ptfbpgm = (struct fbpgm *) mbkalloc (sizeof(struct fbpgm)); + + ptfbpgm->TYPE = type; + ptfbpgm->NAME = name; + ptfbpgm->VALUE = value; + + ptfbpgm->NEXT = lastfbpgm; + + return (ptfbpgm); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_addfbpor */ +/* description : create a BEPOR structure at the top the list */ +/* called func. : namealloc, mbkalloc */ +/* ###--------------------------------------------------------------### */ + +struct fbpor *fbh_addfbpor (lastfbpor, name, dir, type) + +struct fbpor *lastfbpor; /* pointer on the last fbpor structure */ +char *name; /* signal's name */ +char dir; /* signal's mode (I, O, B, Z, or T) */ +unsigned char type; /* signal's type (M or W) */ + + { + struct fbpor *ptfbpor; + + name = namealloc (name); + + ptfbpor = (struct fbpor *) mbkalloc (sizeof(struct fbpor)); + ptfbpor->NAME = name; + ptfbpor->DIRECTION = dir; + ptfbpor->TYPE = type; + ptfbpor->NEXT = lastfbpor; + + return (ptfbpor); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_addfbreg */ +/* description : create a BEREG structure at the top the list */ +/* called func. : namealloc, mbkalloc */ +/* ###--------------------------------------------------------------### */ + +struct fbreg *fbh_addfbreg (lastfbreg, name, biabl, binode) + +struct fbreg *lastfbreg; /* pointer on the last fbreg structure */ +char *name; /* register's name */ +struct biabl *biabl; /* register's drivers (ABL) */ +struct binode *binode; /* register's drivers (BDD) */ +/*unsigned char type; register's type */ + + { + struct fbreg *ptreg; + + name = namealloc (name); + + ptreg = (struct fbreg *) mbkalloc (sizeof(struct fbreg)); + ptreg->NAME = name; + ptreg->BIABL = biabl; + ptreg->BINODE = binode; + ptreg->NEXT = lastfbreg; + + return (ptreg); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_addfbrin */ +/* description : create a BERIN structure at the top the list */ +/* called func. : namealloc, mbkalloc */ +/* ###--------------------------------------------------------------### */ + +struct fbrin *fbh_addfbrin (lastfbrin, name) + +struct fbrin *lastfbrin; /* pointer on the last fbrin structure */ +char *name; /* signal's name */ + + { + struct fbrin *ptrin; + + name = namealloc (name); + + ptrin = (struct fbrin *) mbkalloc (sizeof(struct fbrin)); + ptrin->NAME = name; + ptrin->NEXT = lastfbrin; + + return (ptrin); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_addfbtyp */ +/* description : add an BETYP structure at the top of a list */ +/* called func. : namealloc, mbkalloc */ +/* ###--------------------------------------------------------------### */ + +struct fbtyp *fbh_addfbtyp (lastfbtyp, name , left , right , value , + size , byte , base , index, resolv, class) + +struct fbtyp *lastfbtyp; /* pointer on the last fbtyp */ +char *name; /* type's name */ +int left; /* left bound */ +int right; /* right bound */ +char **value; /* list of values */ +unsigned int size; /* number of values */ +unsigned int byte; /* number of bytes needed to code values*/ +unsigned char base; /* the base type or element's type */ +unsigned char index; /* the type of the index for an array */ +unsigned char resolv; /* index of resolution function */ +char class; /* type's class (E, I, A, S) */ + + { + struct fbtyp *ptfbtyp; + + name = namealloc (name); + + ptfbtyp = (struct fbtyp *) mbkalloc (sizeof(struct fbtyp)); + + ptfbtyp->CLASS = class; + ptfbtyp->NAME = name; + ptfbtyp->LEFT = left; + ptfbtyp->RIGHT = right; + ptfbtyp->VALUE = value; + ptfbtyp->SIZE = size; + ptfbtyp->BYTE = byte; + ptfbtyp->BASE = base; + ptfbtyp->INDEX = index; + ptfbtyp->RESOLV = resolv; + + ptfbtyp->NEXT = lastfbtyp; + + return (ptfbtyp); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_addbiabl */ +/* description : create a BIABL structure at the top the list */ +/* called func. : namealloc, mbkalloc */ +/* ###--------------------------------------------------------------### */ + +struct biabl *fbh_addbiabl (lastbiabl, label, condition, value) + +struct biabl *lastbiabl; /* pointer on the last biabl structure */ +char *label; /* block's label */ +struct chain *condition; /* guard expression (ABL) */ +struct chain *value; /* value expression (ABL) */ + + { + struct biabl *ptbiabl; + + ptbiabl = (struct biabl *) mbkalloc (sizeof(struct biabl)); + label = namealloc (label); + + ptbiabl->LABEL = label; + ptbiabl->CNDABL = condition; + ptbiabl->VALABL = value; + ptbiabl->NEXT = lastbiabl; + + return (ptbiabl); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_addbinode */ +/* description : create a BINODE structure at the top the list */ +/* called func. : namealloc, mbkalloc */ +/* ###--------------------------------------------------------------### */ + +struct binode *fbh_addbinode (lastbinode, condition, value) + +struct binode *lastbinode; /* pointer on the last binode structure */ +bddnode *condition; /* guard expression (BDD) */ +bddnode *value; /* value expression (BDD) */ + + { + struct binode *ptbinode; + + ptbinode = (struct binode *) mbkalloc (sizeof(struct binode)); + ptbinode->CNDNODE = condition; + ptbinode->VALNODE = value; + ptbinode->NEXT = lastbinode; + + return (ptbinode); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_prdeftyp */ +/* description : create BETYPs for predefined types */ +/* called func. : fbh_addfbtyp, namealloc */ +/* ###--------------------------------------------------------------### */ + +struct fbtyp *fbh_prdeftyp () + +{ + static char *bit_vl[2]; + static char *boolean_vl[2]; + static char *severity_vl[2]; + struct fbtyp *t = 0; + + boolean_vl[0] = namealloc ("false"); + boolean_vl[1] = namealloc ("true"); + + bit_vl[0] = namealloc ("'0'"); + bit_vl[1] = namealloc ("'1'"); + + severity_vl[0] = namealloc ("warning"); + severity_vl[1] = namealloc ("error"); + + /* ###------------------------------------------------------### */ + /* Enumeration types */ + /* ###------------------------------------------------------### */ + + t = fbh_addfbtyp (t,"severity_level",0,1,severity_vl,2,1,0,0,0,'E'); + t = fbh_addfbtyp (t,"boolean" ,0,1,boolean_vl ,2,1,0,0,0,'E'); + t = fbh_addfbtyp (t,"bit" ,0,1,bit_vl ,2,1,0,0,0,'E'); + + /* ###------------------------------------------------------### */ + /* Integer types */ + /* ###------------------------------------------------------### */ + + t = fbh_addfbtyp (t,"integer",0x80000000,0x7fffffff,0, 0,0,0,0,0,'I'); + + /* ###------------------------------------------------------### */ + /* Subtypes */ + /* ###------------------------------------------------------### */ + + t = fbh_addfbtyp (t,"mux_bit",0,1 ,0,0,1,2,0,1,'S'); + t = fbh_addfbtyp (t,"wor_bit",0,1 ,0,0,1,2,0,2,'S'); + t = fbh_addfbtyp (t,"reg_bit",0,1 ,0,0,1,2,0,3,'S'); + t = fbh_addfbtyp (t,"natural",0,0x7fffffff,0,0,1,3,0,0,'S'); + + /* ###------------------------------------------------------### */ + /* Unconstraint array types */ + /* ###------------------------------------------------------### */ + + t = fbh_addfbtyp (t,"bit_vector",0,0x7fffffff,0,0,1,2,7,0,'U'); + t = fbh_addfbtyp (t,"mux_vector",0,0x7fffffff,0,0,1,4,7,0,'U'); + t = fbh_addfbtyp (t,"wor_vector",0,0x7fffffff,0,0,1,5,7,0,'U'); + t = fbh_addfbtyp (t,"reg_vector",0,0x7fffffff,0,0,1,6,7,0,'U'); + + return (t); +} diff --git a/alliance/src/fvh/src/fbh_del.c b/alliance/src/fvh/src/fbh_del.c new file mode 100644 index 00000000..cda8ed78 --- /dev/null +++ b/alliance/src/fvh/src/fbh_del.c @@ -0,0 +1,750 @@ +/*------------------------------------------------------------\ +| | +| 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. | +| | +\------------------------------------------------------------*/ +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbh_delfbaux.c */ +/* date : Aug 24 1992 */ +/* version : v102 */ +/* authors : Pirouz BAZARGAN SABET */ +/* content : contains a specific function used to delete a */ +/* fbhaviour data structure */ +/* */ +/* ###--------------------------------------------------------------### */ + +#include "mut.h" +#include "aut.h" +#include "abl.h" +#include "bdd.h" +#include "fvh.h" + +/* ###--------------------------------------------------------------### */ +/* function : fbh_delfbaux */ +/* description : delete a BEAUX structure and return the pointer of */ +/* the next object. A warning is printed out if the */ +/* object to be deleted is not empty when the mode is N */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbaux *fbh_delfbaux (listfbaux, ptfbaux, mode) + +struct fbaux *listfbaux; /* list of fbaux containing the object */ +struct fbaux *ptfbaux; /* pointer of the BEAUX to be deleted */ +char mode; /* recursive delete or not (Y or N) */ + +{ +struct fbaux headaux; +struct fbaux *ptlastaux; + +if ((listfbaux != 0) && (ptfbaux != 0)) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headaux.NEXT = listfbaux; + ptlastaux = &headaux; + while ((ptlastaux != 0) && (ptlastaux->NEXT != ptfbaux)) + ptlastaux = ptlastaux->NEXT; + + if (ptlastaux != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* If the object has been found check the mode and, if asked */ + /* delete pointed objects recursively. */ + /* ###------------------------------------------------------### */ + + if (mode == 'N') + { + if (ptfbaux->ABL != 0) + (void) fprintf (stderr,"FBH_warning : fbaux `%s` not empty\n", + ptfbaux->NAME); + } + else + delablexpr (ptfbaux->ABL); + + ptlastaux->NEXT = ptfbaux->NEXT; + mbkfree (ptfbaux); + } + + listfbaux = headaux.NEXT; + } + +return(listfbaux); +} + +/* ###--------------------------------------------------------------### */ +/* function : fbh_delfbbus */ +/* description : delete a BEBUS structure and return the pointer of */ +/* the next object. A warning is printed out if the */ +/* object to be deleted is not empty when the mode is N */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbbus *fbh_delfbbus (listfbbus, ptfbbus, mode) + +struct fbbus *listfbbus; /* list of fbbus containing the object */ +struct fbbus *ptfbbus; /* pointer of the BEBUS to be deleted */ +char mode; /* recursive delete or not (Y or N) */ + +{ +struct fbbus headbus; +struct fbbus *ptlastbus; + +if ((listfbbus != 0) && (ptfbbus != 0)) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headbus.NEXT = listfbbus; + ptlastbus = &headbus; + while ((ptlastbus != 0) && (ptlastbus->NEXT != ptfbbus)) + ptlastbus = ptlastbus->NEXT; + + if (ptlastbus != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* If the object has been found check the mode and, if asked */ + /* delete pointed objects recursively. */ + /* ###------------------------------------------------------### */ + + if (mode == 'N') + { + if ((ptfbbus->BIABL != 0) || (ptfbbus->BINODE != 0)) + (void) fprintf (stderr,"FBH_warning : fbbus `%s` not empty\n", + ptfbbus->NAME); + } + else + { + fbh_frebiabl (ptfbbus->BIABL); + fbh_frebinode (ptfbbus->BINODE); + } + + ptlastbus->NEXT = ptfbbus->NEXT; + mbkfree (ptfbbus); + } + + listfbbus = headbus.NEXT; + } + +return(listfbbus); +} + +/* ###--------------------------------------------------------------### */ +/* function : fbh_delfbbux */ +/* description : delete a BEBUX structure and return the pointer of */ +/* the next object. A warning is printed out if the */ +/* object to be deleted is not empty when the mode is N */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbbux *fbh_delfbbux (listfbbux, ptfbbux, mode) + +struct fbbux *listfbbux; /* list of fbbux containing the object */ +struct fbbux *ptfbbux; /* pointer of the BEBUX to be deleted */ +char mode; /* recursive delete or not (Y or N) */ + +{ +struct fbbux headbux; +struct fbbux *ptlastbux; + +if ((listfbbux != 0) && (ptfbbux != 0)) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headbux.NEXT = listfbbux; + ptlastbux = &headbux; + while ((ptlastbux != 0) && (ptlastbux->NEXT != ptfbbux)) + ptlastbux = ptlastbux->NEXT; + + if (ptlastbux != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* If the object has been found check the mode and, if asked */ + /* delete pointed objects recursively. */ + /* ###------------------------------------------------------### */ + + if (mode == 'N') + { + if ((ptfbbux->BIABL != 0) || (ptfbbux->BINODE != 0)) + (void) fprintf (stderr,"FBH_warning : fbbux `%s` not empty\n", + ptfbbux->NAME); + } + else + { + fbh_frebiabl (ptfbbux->BIABL); + fbh_frebinode (ptfbbux->BINODE); + } + + ptlastbux->NEXT = ptfbbux->NEXT; + mbkfree (ptfbbux); + } + + listfbbux = headbux.NEXT; + } + +return(listfbbux); +} + +/* ###--------------------------------------------------------------### */ +/* function : fbh_delfbfig */ +/* description : delete a BEFIG structure and return the pointer of */ +/* the next object. A warning is printed out if the */ +/* object to be deleted is not empty when the mode is N. */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbfig *fbh_delfbfig (listfbfig, ptfbfig, mode) + +struct fbfig *listfbfig; /* list of fbfig containing the object */ +struct fbfig *ptfbfig; /* pointer of the BEFIG to be deleted */ +char mode; /* recursive delete or not (Y or N) */ + +{ +struct fbfig headfig; +struct fbfig *ptlastfig; +struct ptype *ptptype; + +if ((listfbfig != 0) && (ptfbfig != 0)) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headfig.NEXT = listfbfig; + ptlastfig = &headfig; + while ((ptlastfig != 0) && (ptlastfig->NEXT != ptfbfig)) + ptlastfig = ptlastfig->NEXT; + + if (ptlastfig != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* If the object has been found check the mode and, if asked */ + /* delete pointed objects recursively. */ + /* ###------------------------------------------------------### */ + + if (mode == 'N') + { + if ((ptfbfig->BEREG != 0) || (ptfbfig->BEMSG != 0) || + (ptfbfig->BERIN != 0) || (ptfbfig->BEOUT != 0) || + (ptfbfig->BEBUS != 0) || (ptfbfig->BEAUX != 0) || + (ptfbfig->BEDLY != 0) || (ptfbfig->BEBUX != 0) || + (ptfbfig->BEPOR != 0) || (ptfbfig->USER != 0)) + + (void) fprintf (stderr,"FBH_warning : fbfig `%s` not empty\n", + ptfbfig->NAME); + } + else + { + fbh_frefbreg (ptfbfig->BEREG); + fbh_frefbmsg (ptfbfig->BEMSG); + fbh_frefbrin (ptfbfig->BERIN); + fbh_frefbout (ptfbfig->BEOUT); + fbh_frefbbus (ptfbfig->BEBUS); + fbh_frefbaux (ptfbfig->BEAUX); + fbh_frefbaux (ptfbfig->BEDLY); + fbh_frefbbux (ptfbfig->BEBUX); + fbh_frefbpor (ptfbfig->BEPOR); + if ((ptptype = getptype (ptfbfig->USER,FBH_GENERIC)) != 0) + fbh_frefbgen (ptptype->DATA); + } + + ptlastfig->NEXT = ptfbfig->NEXT; + mbkfree (ptfbfig); + } + + listfbfig = headfig.NEXT; + } + +return(listfbfig); +} + +/* ###--------------------------------------------------------------### */ +/* function : fbh_delfbgen */ +/* description : delete a BEGEN structure and return the pointer of */ +/* the next object. A warning is printed out if the */ +/* object to be deleted is not empty when the mode is N */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbgen *fbh_delfbgen (listfbgen, ptfbgen, mode) + +struct fbgen *listfbgen; /* list of fbgen containing the object */ +struct fbgen *ptfbgen; /* pointer of the BEGEN to be deleted */ +char mode; /* recursive delete or not (Y or N) */ + +{ +struct fbgen headgen; +struct fbgen *ptlastgen; + +if ((listfbgen != 0) && (ptfbgen != 0)) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headgen.NEXT = listfbgen; + ptlastgen = &headgen; + while ((ptlastgen != 0) && (ptlastgen->NEXT != ptfbgen)) + ptlastgen = ptlastgen->NEXT; + + if (ptlastgen != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* If the object has been found check the mode and, if asked */ + /* delete pointed objects recursively. */ + /* ###------------------------------------------------------### */ + + if (mode == 'N') + { + if (ptfbgen->VALUE != 0) + (void) fprintf (stderr,"FBH_warning : fbgen `%s` not empty\n", + ptfbgen->NAME); + } + else + mbkfree (ptfbgen->VALUE); + + ptlastgen->NEXT = ptfbgen->NEXT; + mbkfree (ptfbgen); + } + + listfbgen = headgen.NEXT; + } + +return(listfbgen); +} + +/* ###--------------------------------------------------------------### */ +/* function : fbh_delfbmsg */ +/* description : delete a BEMSG structure and return the pointer of */ +/* the next object. A warning is printed out if the */ +/* object to be deleted is not empty when the mode is N */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbmsg *fbh_delfbmsg (listfbmsg, ptfbmsg, mode) + +struct fbmsg *listfbmsg; /* list of fbmsg containing the object */ +struct fbmsg *ptfbmsg; /* pointer of the BEMSG to be deleted */ +char mode; /* recursive delete or not (Y or N) */ + +{ +struct fbmsg headmsg; +struct fbmsg *ptlastmsg; + +if ((listfbmsg != 0) && (ptfbmsg != 0)) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headmsg.NEXT = listfbmsg; + ptlastmsg = &headmsg; + while ((ptlastmsg != 0) && (ptlastmsg->NEXT != ptfbmsg)) + ptlastmsg = ptlastmsg->NEXT; + + if (ptlastmsg != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* If the object has been found check the mode and, if asked */ + /* delete pointed objects recursively. */ + /* ###------------------------------------------------------### */ + + if (mode == 'N') + { + if (ptfbmsg->ABL != 0) + (void) fprintf (stderr,"FBH_warning : fbmsg `%s` not empty\n", + ptfbmsg->LABEL); + } + else + delablexpr (ptfbmsg->ABL); + + ptlastmsg->NEXT = ptfbmsg->NEXT; + mbkfree (ptfbmsg); + } + + listfbmsg = headmsg.NEXT; + } + +return(listfbmsg); +} + +/* ###--------------------------------------------------------------### */ +/* function : fbh_delfbout */ +/* description : delete a BEOUT structure and return the pointer of */ +/* the next object. A warning is printed out if the */ +/* object to be deleted is not empty when the mode is N */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbout *fbh_delfbout (listfbout, ptfbout, mode) + +struct fbout *listfbout; /* list of fbout containing the object */ +struct fbout *ptfbout; /* pointer of the BEOUT to be deleted */ +char mode; /* recursive delete or not (Y or N) */ + +{ +struct fbout headout; +struct fbout *ptlastout; + +if ((listfbout != 0) && (ptfbout != 0)) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headout.NEXT = listfbout; + ptlastout = &headout; + while ((ptlastout != 0) && (ptlastout->NEXT != ptfbout)) + ptlastout = ptlastout->NEXT; + + if (ptlastout != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* If the object has been found check the mode and, if asked */ + /* delete pointed objects recursively. */ + /* ###------------------------------------------------------### */ + + if (mode == 'N') + { + if (ptfbout->ABL != 0) + (void) fprintf (stderr,"FBH_warning : fbout `%s` not empty\n", + ptfbout->NAME); + } + else + delablexpr (ptfbout->ABL); + + ptlastout->NEXT = ptfbout->NEXT; + mbkfree (ptfbout); + } + + listfbout = headout.NEXT; + } + +return(listfbout); +} + +/* ###--------------------------------------------------------------### */ +/* function : fbh_delfbpor */ +/* description : delete a BEPOR structure and return the pointer of */ +/* the next object. */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbpor *fbh_delfbpor (listfbpor, ptfbpor) + +struct fbpor *listfbpor; /* list of fbpor containing the object */ +struct fbpor *ptfbpor; /* pointer of the BEPOR to be deleted */ + +{ +struct fbpor headpor; +struct fbpor *ptlastpor; + +if ((listfbpor != 0) && (ptfbpor != 0)) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headpor.NEXT = listfbpor; + ptlastpor = &headpor; + while ((ptlastpor != 0) && (ptlastpor->NEXT != ptfbpor)) + ptlastpor = ptlastpor->NEXT; + + if (ptlastpor != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* ###------------------------------------------------------### */ + + ptlastpor->NEXT = ptfbpor->NEXT; + mbkfree (ptfbpor); + } + + listfbpor = headpor.NEXT; + } + +return(listfbpor); +} + +/* ###--------------------------------------------------------------### */ +/* function : fbh_delfbreg */ +/* description : delete a BEREG structure and return the pointer of */ +/* the next object. A warning is printed out if the */ +/* object to be deleted is not empty when the mode is N */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbreg *fbh_delfbreg (listfbreg, ptfbreg, mode) + +struct fbreg *listfbreg; /* list of fbreg containing the object */ +struct fbreg *ptfbreg; /* pointer of the BEREG to be deleted */ +char mode; /* recursive delete or not (Y or N) */ + +{ +struct fbreg headreg; +struct fbreg *ptlastreg; + +if ((listfbreg != 0) && (ptfbreg != 0)) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headreg.NEXT = listfbreg; + ptlastreg = &headreg; + while ((ptlastreg != 0) && (ptlastreg->NEXT != ptfbreg)) + ptlastreg = ptlastreg->NEXT; + + if (ptlastreg != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* If the object has been found check the mode and, if asked */ + /* delete pointed objects recursively. */ + /* ###------------------------------------------------------### */ + + if (mode == 'N') + { + if ((ptfbreg->BIABL != 0) || (ptfbreg->BINODE != 0)) + (void) fprintf (stderr,"FBH_warning : fbreg `%s` not empty\n", + ptfbreg->NAME); + } + else + { + fbh_frebiabl (ptfbreg->BIABL); + fbh_frebinode (ptfbreg->BINODE); + } + + ptlastreg->NEXT = ptfbreg->NEXT; + mbkfree (ptfbreg); + } + + listfbreg = headreg.NEXT; + } + +return(listfbreg); +} + +/* ###--------------------------------------------------------------### */ +/* function : fbh_delfbrin */ +/* description : delete a BERIN structure and return the pointer of */ +/* the next object. */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbrin *fbh_delfbrin (listfbrin, ptfbrin) + +struct fbrin *listfbrin; /* list of fbrin containing the object */ +struct fbrin *ptfbrin; /* pointer of the BERIN to be deleted */ + +{ +struct fbrin headrin; +struct fbrin *ptlastrin; + +if ((listfbrin != 0) && (ptfbrin != 0)) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headrin.NEXT = listfbrin; + ptlastrin = &headrin; + while ((ptlastrin != 0) && (ptlastrin->NEXT != ptfbrin)) + ptlastrin = ptlastrin->NEXT; + + if (ptlastrin != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* ###------------------------------------------------------### */ + + ptlastrin->NEXT = ptfbrin->NEXT; + mbkfree (ptfbrin); + } + + listfbrin = headrin.NEXT; + } + +return(listfbrin); +} + +/* ###--------------------------------------------------------------### */ +/* function : fbh_delbiabl */ +/* description : delete a BIABL structure and return the pointer of */ +/* the next object. A warning is printed out if the */ +/* object to be deleted is not empty when the mode is N */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct biabl *fbh_delbiabl (listbiabl, ptbiabl, mode) + +struct biabl *listbiabl; /* list of biabl containing the object */ +struct biabl *ptbiabl; /* pointer of the BIABL to be deleted */ +char mode; /* recursive delete or not (Y or N) */ + +{ +struct biabl headabl; +struct biabl *ptlastabl; + +if ((listbiabl != 0) && (ptbiabl != 0)) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headabl.NEXT = listbiabl; + ptlastabl = &headabl; + while ((ptlastabl != 0) && (ptlastabl->NEXT != ptbiabl)) + ptlastabl = ptlastabl->NEXT; + + if (ptlastabl != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* If the object has been found check the mode and, if asked */ + /* delete pointed objects recursively. */ + /* ###------------------------------------------------------### */ + + if (mode == 'N') + { + if ((ptbiabl->VALABL != 0) || (ptbiabl->CNDABL != 0)) + (void) fprintf (stderr,"FBH_warning : biabl not empty\n"); + } + else + { + delablexpr (ptbiabl->VALABL); + delablexpr (ptbiabl->CNDABL); + } + + ptlastabl->NEXT = ptbiabl->NEXT; + mbkfree (ptbiabl); + } + + listbiabl = headabl.NEXT; + } + +return(listbiabl); +} + +/* ###--------------------------------------------------------------### */ +/* function : fbh_delbinode */ +/* description : delete a BINODE structure and return the pointer of */ +/* the next object. A warning is printed out if the */ +/* object to be deleted is not empty when the mode is N */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct binode *fbh_delbinode (listbinode, ptbinode, mode) + +struct binode *listbinode; /* list of binode containing the object */ +struct binode *ptbinode; /* pointer of the BINODE to be deleted */ +char mode; /* recursive delete or not (Y or N) */ + +{ +struct binode headnode; +struct binode *ptlastnode; + +if ((listbinode != 0) && (ptbinode != 0)) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headnode.NEXT = listbinode; + ptlastnode = &headnode; + while ((ptlastnode != 0) && (ptlastnode->NEXT != ptbinode)) + ptlastnode = ptlastnode->NEXT; + + if (ptlastnode != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* If the object has been found check the mode and, if asked */ + /* delete pointed objects recursively. */ + /* ###------------------------------------------------------### */ + + if (mode == 'N') + { + if ((ptbinode->VALNODE != 0) || (ptbinode->CNDNODE != 0)) + (void) fprintf (stderr,"FBH_warning : binode not empty\n"); + } + + ptlastnode->NEXT = ptbinode->NEXT; + mbkfree (ptbinode); + } + + listbinode = headnode.NEXT; + } + +return(listbinode); +} diff --git a/alliance/src/fvh/src/fbh_env.c b/alliance/src/fvh/src/fbh_env.c new file mode 100644 index 00000000..b4a15c42 --- /dev/null +++ b/alliance/src/fvh/src/fbh_env.c @@ -0,0 +1,78 @@ +/*------------------------------------------------------------\ +| | +| 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. | +| | +\------------------------------------------------------------*/ + +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbh_getgenva.c */ +/* date : Aug 24 1992 */ +/* version : v102 */ +/* authors : Pirouz BAZARGAN SABET */ +/* content : contains a specific function used to acces to the */ +/* value of a fbhaviour data structure */ +/* */ +/* ###--------------------------------------------------------------### */ + +#include "mut.h" +#include "aut.h" +#include "abl.h" +#include "bdd.h" +#include "fvh.h" + +/* ###--------------------------------------------------------------### */ +/* function : fbh_getgenval */ +/* description : Search an find a BEGEN structure (known from its name)*/ +/* then return its value field. If the BEGEN is not found*/ +/* a 0 pointer is returned */ +/* called func. : */ +/* ###--------------------------------------------------------------### */ + +void *fbh_getgenval (listfbgen, fbgenname) + +struct fbgen *listfbgen; /* head of BEGEN list */ +char *fbgenname; /* name of the structure */ + + { + struct fbgen *ptfbgen; + void *value = 0; + + /* ###------------------------------------------------------### */ + /* searching the object */ + /* ###------------------------------------------------------### */ + + ptfbgen = listfbgen; + while ((ptfbgen != 0) && (ptfbgen->NAME != fbgenname)) + ptfbgen = ptfbgen->NEXT; + + /* ###------------------------------------------------------### */ + /* if found return its value field */ + /* ###------------------------------------------------------### */ + + if (ptfbgen != 0) + value = ptfbgen->VALUE; + + return (value); + } diff --git a/alliance/src/fvh/src/fbh_fre.c b/alliance/src/fvh/src/fbh_fre.c new file mode 100644 index 00000000..9f0944ae --- /dev/null +++ b/alliance/src/fvh/src/fbh_fre.c @@ -0,0 +1,465 @@ +/*------------------------------------------------------------\ +| | +| 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. | +| | +\------------------------------------------------------------*/ +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbh_frefbaux.c */ +/* date : Aug 24 1992 */ +/* version : v102 */ +/* authors : Pirouz BAZARGAN SABET */ +/* content : contains a specific function used to delete a list */ +/* of fbhaviour data structures */ +/* */ +/* ###--------------------------------------------------------------### */ + +#include "mut.h" +#include "aut.h" +#include "abl.h" +#include "bdd.h" +#include "fvh.h" + +/* ###--------------------------------------------------------------### */ +/* function : fbh_frefbaux */ +/* description : delete a list of BEAUX structures and all objects */ +/* pointed by any os BEAUXs in the list */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +void fbh_frefbaux (listfbaux) + +struct fbaux *listfbaux; /* list of fbaux to be deleted */ + + { + struct fbaux *ptfbaux; + + /* ###------------------------------------------------------### */ + /* for each object of the list, first delete pointed objects */ + /* then, delete the object itself */ + /* ###------------------------------------------------------### */ + + while (listfbaux != 0) + { + freeablexpr (listfbaux->ABL); + + ptfbaux = listfbaux; + listfbaux = listfbaux->NEXT; + mbkfree (ptfbaux); + } + + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_frefbbus */ +/* description : delete a list of BEBUS structures and all objects */ +/* pointed by any os BEBUSs in the list */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +void fbh_frefbbus (listfbbus) + +struct fbbus *listfbbus; /* list of fbbus to be deleted */ + + { + struct fbbus *ptfbbus; + + /* ###------------------------------------------------------### */ + /* for each object of the list, first delete pointed objects */ + /* then, delete the object itself */ + /* ###------------------------------------------------------### */ + + while (listfbbus != 0) + { + fbh_frebiabl (listfbbus->BIABL); + fbh_frebinode (listfbbus->BINODE); + + ptfbbus = listfbbus; + listfbbus = listfbbus->NEXT; + mbkfree (ptfbbus); + } + + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_frefbbux */ +/* description : delete a list of BEBUX structures and all objects */ +/* pointed by any os BEBUXs in the list */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +void fbh_frefbbux (listfbbux) + +struct fbbux *listfbbux; /* list of fbbux to be deleted */ + + { + struct fbbux *ptfbbux; + + /* ###------------------------------------------------------### */ + /* for each object of the list, first delete pointed objects */ + /* then, delete the object itself */ + /* ###------------------------------------------------------### */ + + while (listfbbux != 0) + { + fbh_frebiabl (listfbbux->BIABL); + fbh_frebinode (listfbbux->BINODE); + + ptfbbux = listfbbux; + listfbbux = listfbbux->NEXT; + mbkfree (ptfbbux); + } + + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_frefbfig */ +/* description : delete a list of BEFIG structures and all objects */ +/* pointed by any os BEFIGs in the list */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +void fbh_frefbfig (listfbfig) + +struct fbfig *listfbfig; /* list of fbfig to be deleted */ + + { + struct fbfig *ptfbfig; + struct ptype *ptptype; + + /* ###------------------------------------------------------### */ + /* for each object of the list, first delete pointed objects */ + /* then, delete the object itself */ + /* ###------------------------------------------------------### */ + + while (listfbfig != 0) + { + fbh_frefbreg (ptfbfig->BEREG); + fbh_frefbmsg (ptfbfig->BEMSG); + fbh_frefbrin (ptfbfig->BERIN); + fbh_frefbout (ptfbfig->BEOUT); + fbh_frefbbus (ptfbfig->BEBUS); + fbh_frefbaux (ptfbfig->BEAUX); + fbh_frefbaux (ptfbfig->BEDLY); + fbh_frefbbux (ptfbfig->BEBUX); + fbh_frefbpor (ptfbfig->BEPOR); + fbh_frefbpgm (ptfbfig->BEPGM); + if ((ptptype = getptype (ptfbfig->USER,FBH_GENERIC)) != 0) + fbh_frefbgen (ptptype->DATA); + + ptfbfig = listfbfig; + listfbfig = listfbfig->NEXT; + mbkfree (ptfbfig); + } + + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_frefbgen */ +/* description : delete a list of BEGEN structures and all objects */ +/* pointed by any os BEGENs in the list */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +void fbh_frefbgen (listfbgen) + +struct fbgen *listfbgen; /* list of fbgen to be deleted */ + + { + struct fbgen *ptfbgen; + + /* ###------------------------------------------------------### */ + /* for each object of the list, first delete pointed objects */ + /* then, delete the object itself */ + /* ###------------------------------------------------------### */ + + while (listfbgen != 0) + { + mbkfree (listfbgen->VALUE); + + ptfbgen = listfbgen; + listfbgen = listfbgen->NEXT; + mbkfree (ptfbgen); + } + + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_frefbmsg */ +/* description : delete a list of BEMSG structures and all objects */ +/* pointed by any os BEMSGs in the list */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +void fbh_frefbmsg (listfbmsg) + +struct fbmsg *listfbmsg; /* list of fbmsg to be deleted */ + + { + struct fbmsg *ptfbmsg; + + /* ###------------------------------------------------------### */ + /* for each object of the list, first delete pointed objects */ + /* then, delete the object itself */ + /* ###------------------------------------------------------### */ + + while (listfbmsg != 0) + { + freeablexpr (listfbmsg->ABL); + + ptfbmsg = listfbmsg; + listfbmsg = listfbmsg->NEXT; + mbkfree (ptfbmsg); + } + + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_frefbmsg */ +/* description : delete a list of BEMSG structures and all objects */ +/* pointed by any os BEMSGs in the list */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +void fbh_frefbpgm (listfbpgm) + +struct fbpgm *listfbpgm; /* list of fbpgm to be deleted */ + + { + struct fbpgm *ptfbpgm; + + /* ###------------------------------------------------------### */ + /* for each object of the list, first delete pointed objects */ + /* then, delete the object itself */ + /* ###------------------------------------------------------### */ + + while (listfbpgm != 0) + { + ptfbpgm = listfbpgm; + listfbpgm = listfbpgm->NEXT; + mbkfree (ptfbpgm); + } + + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_frefbout */ +/* description : delete a list of BEOUT structures and all objects */ +/* pointed by any os BEOUTs in the list */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +void fbh_frefbout (listfbout) + +struct fbout *listfbout; /* list of fbout to be deleted */ + + { + struct fbout *ptfbout; + + /* ###------------------------------------------------------### */ + /* for each object of the list, first delete pointed objects */ + /* then, delete the object itself */ + /* ###------------------------------------------------------### */ + + while (listfbout != 0) + { + freeablexpr (listfbout->ABL); + + ptfbout = listfbout; + listfbout = listfbout->NEXT; + mbkfree (ptfbout); + } + + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_frefbpor */ +/* description : delete a list of BEAUX structures and all objects */ +/* pointed by any os BEAUXs in the list */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +void fbh_frefbpor (listfbpor) + +struct fbpor *listfbpor; /* list of fbpor to be deleted */ + + { + struct fbpor *ptfbpor; + + /* ###------------------------------------------------------### */ + /* for each object of the list, delete the object itself */ + /* ###------------------------------------------------------### */ + + while (listfbpor != 0) + { + ptfbpor = listfbpor; + listfbpor = listfbpor->NEXT; + mbkfree (ptfbpor); + } + + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_frefbreg */ +/* description : delete a list of BEAUX structures and all objects */ +/* pointed by any os BEAUXs in the list */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +void fbh_frefbreg (listfbreg) + +struct fbreg *listfbreg; /* list of fbreg to be deleted */ + + { + struct fbreg *ptfbreg; + + /* ###------------------------------------------------------### */ + /* for each object of the list, first delete pointed objects */ + /* then, delete the object itself */ + /* ###------------------------------------------------------### */ + + while (listfbreg != 0) + { + fbh_frebiabl (listfbreg->BIABL); + fbh_frebinode (listfbreg->BINODE); + + ptfbreg = listfbreg; + listfbreg = listfbreg->NEXT; + mbkfree (ptfbreg); + } + + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_frefbrin */ +/* description : delete a list of BEAUX structures and all objects */ +/* pointed by any os BEAUXs in the list */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +void fbh_frefbrin (listfbrin) + +struct fbrin *listfbrin; /* list of fbrin to be deleted */ + + { + struct fbrin *ptfbrin; + + /* ###------------------------------------------------------### */ + /* for each object of the list delete the object itself */ + /* ###------------------------------------------------------### */ + + while (listfbrin != 0) + { + ptfbrin = listfbrin; + listfbrin = listfbrin->NEXT; + mbkfree (ptfbrin); + } + + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_frefbtyp */ +/* description : delete a list of BETYP structures and all objects */ +/* pointed by any os BETYPs in the list */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +void fbh_frefbtyp (listfbtyp) + +struct fbtyp *listfbtyp; /* list of fbtyp to be deleted */ + + { + struct fbtyp *ptfbtyp; + + /* ###------------------------------------------------------### */ + /* for each object of the list delete the object itself */ + /* ###------------------------------------------------------### */ + + while (listfbtyp != 0) + { + ptfbtyp = listfbtyp; + listfbtyp = listfbtyp->NEXT; + mbkfree (ptfbtyp); + } + + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_frebiabl */ +/* description : delete a list of BIABL structures and all objects */ +/* pointed by any os BIABLs in the list */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +void fbh_frebiabl (listbiabl) + +struct biabl *listbiabl; /* list of biabl to be deleted */ + + { + struct biabl *ptbiabl; + + /* ###------------------------------------------------------### */ + /* for each object of the list, first delete pointed objects */ + /* then, delete the object itself */ + /* ###------------------------------------------------------### */ + + while (listbiabl != 0) + { + freeablexpr (listbiabl->VALABL); + freeablexpr (listbiabl->CNDABL); + + ptbiabl = listbiabl; + listbiabl = listbiabl->NEXT; + mbkfree (ptbiabl); + } + + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_frebinode */ +/* description : delete a list of BINODE structures and all objects */ +/* pointed by any os BINODEs in the list */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +void fbh_frebinode (listbinode) + +struct binode *listbinode; /* list of binode to be deleted */ + + { + struct binode *ptbinode; + + /* ###------------------------------------------------------### */ + /* for each object of the list, first delete pointed objects */ + /* then, delete the object itself */ + /* ###------------------------------------------------------### */ + + while (listbinode != 0) + { + ptbinode = listbinode; + listbinode = listbinode->NEXT; + mbkfree (ptbinode); + } + + } diff --git a/alliance/src/fvh/src/fbh_rin.c b/alliance/src/fvh/src/fbh_rin.c new file mode 100644 index 00000000..d7eedb27 --- /dev/null +++ b/alliance/src/fvh/src/fbh_rin.c @@ -0,0 +1,84 @@ +/*------------------------------------------------------------\ +| | +| 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. | +| | +\------------------------------------------------------------*/ + +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbh_crtfbrin.c */ +/* date : Aug 24 1992 */ +/* version : v102 */ +/* authors : Pirouz BAZARGAN SABET */ +/* content : contains a specific function used to create a */ +/* fbhaviour data structure */ +/* */ +/* ###--------------------------------------------------------------### */ + +#include "mut.h" +#include "aut.h" +#include "abl.h" +#include "bdd.h" +#include "fvh.h" + +/* ###--------------------------------------------------------------### */ +/* function : fbh_crtfbrin */ +/* description : create an array of BETYPs from a list of BETYPs */ +/* called func. : namealloc, mbkalloc */ +/* ###--------------------------------------------------------------### */ + +struct fbrin *fbh_crtfbrin (listfbrin) + +struct fbrin *listfbrin; /* pointer on the list of fbrins */ + + { + struct fbrin *lclfbrin = listfbrin; + struct fbrin *ptfbrin = 0; + int size = 0; + + while (lclfbrin != 0) + { + lclfbrin = lclfbrin->NEXT; + size++; + } + + if (size != 0) + { + ptfbrin = (struct fbrin *) mbkalloc (size * sizeof(struct fbrin)); + lclfbrin = ptfbrin; + + while (listfbrin != 0) + { + lclfbrin->NAME = listfbrin->NAME; + lclfbrin->NEXT = lclfbrin + 1; + + listfbrin = listfbrin->NEXT; + lclfbrin++; + } + + (lclfbrin - 1)->NEXT = 0; + } + + return (ptfbrin); + } diff --git a/alliance/src/fvh/src/fbh_rmv.c b/alliance/src/fvh/src/fbh_rmv.c new file mode 100644 index 00000000..63833d2f --- /dev/null +++ b/alliance/src/fvh/src/fbh_rmv.c @@ -0,0 +1,673 @@ +/*------------------------------------------------------------\ +| | +| 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. | +| | +\------------------------------------------------------------*/ +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbh_rmvfbaux.c */ +/* date : Aug 24 1992 */ +/* version : v102 */ +/* authors : Pirouz BAZARGAN SABET */ +/* content : contains a specific function used to delete a */ +/* fbhaviour data structure */ +/* */ +/* ###--------------------------------------------------------------### */ + +#include "mut.h" +#include "aut.h" +#include "abl.h" +#include "bdd.h" +#include "fvh.h" + +/* ###--------------------------------------------------------------### */ +/* function : fbh_rmvfbaux */ +/* description : delete a BEAUX structure and return the pointer of */ +/* the next object. A warning is printed out if the */ +/* object to be deleted is not empty when the mode is N */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbaux *fbh_rmvfbaux (listfbaux, fbauxname, mode) + +struct fbaux *listfbaux; /* list of fbaux containing the object */ +char *fbauxname; /* name of the BEAUX to be deleted */ +char mode; /* recursive delete or not (Y or N) */ + + { + struct fbaux headaux; + struct fbaux *ptlastaux; + struct fbaux *ptfbaux; + + if (listfbaux != 0) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headaux.NEXT = listfbaux; + ptfbaux = &headaux; + while ((ptfbaux != 0) && (ptfbaux->NAME != fbauxname)) + { + ptlastaux = ptfbaux; + ptfbaux = ptfbaux->NEXT; + } + + if (ptfbaux != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* If the object has been found check the mode and, if asked */ + /* delete pointed objects recursively. */ + /* ###------------------------------------------------------### */ + + if (mode == 'N') + { + if (ptfbaux->ABL != 0) + (void) fprintf (stderr,"FBH_warning : fbaux `%s` not empty\n", + fbauxname); + } + else + delablexpr (ptfbaux->ABL); + + ptlastaux->NEXT = ptfbaux->NEXT; + mbkfree (ptfbaux); + } + + listfbaux = headaux.NEXT; + } + + return(listfbaux); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_rmvfbbus */ +/* description : delete a BEBUS structure and return the pointer of */ +/* the next object. A warning is printed out if the */ +/* object to be deleted is not empty when the mode is N */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbbus *fbh_rmvfbbus (listfbbus, fbbusname, mode) + +struct fbbus *listfbbus; /* list of fbbus containing the object */ +char *fbbusname; /* name of the BEBUS to be deleted */ +char mode; /* recursive delete or not (Y or N) */ + + { + struct fbbus headbus; + struct fbbus *ptlastbus; + struct fbbus *ptfbbus; + + if (listfbbus != 0) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headbus.NEXT = listfbbus; + ptfbbus = &headbus; + while ((ptfbbus != 0) && (ptfbbus->NAME != fbbusname)) + { + ptlastbus = ptfbbus; + ptfbbus = ptfbbus->NEXT; + } + + if (ptfbbus != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* If the object has been found check the mode and, if asked */ + /* delete pointed objects recursively. */ + /* ###------------------------------------------------------### */ + + if (mode == 'N') + { + if ((ptfbbus->BIABL != 0) || (ptfbbus->BINODE != 0)) + (void) fprintf (stderr,"FBH_warning : fbbus `%s` not empty\n", + fbbusname); + } + else + { + fbh_frebiabl (ptfbbus->BIABL); + fbh_frebinode (ptfbbus->BINODE); + } + + ptlastbus->NEXT = ptfbbus->NEXT; + mbkfree (ptfbbus); + } + + listfbbus = headbus.NEXT; + } + + return(listfbbus); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_rmvfbbux */ +/* description : delete a BEBUX structure and return the pointer of */ +/* the next object. A warning is printed out if the */ +/* object to be deleted is not empty when the mode is N */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbbux *fbh_rmvfbbux (listfbbux, fbbuxname, mode) + +struct fbbux *listfbbux; /* list of fbbux containing the object */ +char *fbbuxname; /* name of the BEBUX to be deleted */ +char mode; /* recursive delete or not (Y or N) */ + + { + struct fbbux headbux; + struct fbbux *ptlastbux; + struct fbbux *ptfbbux; + + if (listfbbux != 0) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headbux.NEXT = listfbbux; + ptfbbux = &headbux; + while ((ptfbbux != 0) && (ptfbbux->NAME != fbbuxname)) + { + ptlastbux = ptfbbux; + ptfbbux = ptfbbux->NEXT; + } + + if (ptfbbux != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* If the object has been found check the mode and, if asked */ + /* delete pointed objects recursively. */ + /* ###------------------------------------------------------### */ + + if (mode == 'N') + { + if ((ptfbbux->BIABL != 0) || (ptfbbux->BINODE != 0)) + (void) fprintf (stderr,"FBH_warning : fbbux `%s` not empty\n", + fbbuxname); + } + else + { + fbh_frebiabl (ptfbbux->BIABL); + fbh_frebinode (ptfbbux->BINODE); + } + + ptlastbux->NEXT = ptfbbux->NEXT; + mbkfree (ptfbbux); + } + + listfbbux = headbux.NEXT; + } + + return(listfbbux); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_rmvfbfig */ +/* description : delete a BEFIG structure and return the pointer of */ +/* the next object. A warning is printed out if the */ +/* object to be deleted is not empty when the mode is N. */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbfig *fbh_rmvfbfig (listfbfig, fbfigname, mode) + +struct fbfig *listfbfig; /* list of fbfig containing the object */ +char *fbfigname; /* name of the BEFIG to be deleted */ +char mode; /* recursive delete or not (Y or N) */ + + { + struct fbfig headfig; + struct fbfig *ptlastfig; + struct fbfig *ptfbfig; + struct ptype *ptptype; + + if (listfbfig != 0) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headfig.NEXT = listfbfig; + ptfbfig = &headfig; + while ((ptfbfig != 0) && (ptfbfig->NAME != fbfigname)) + { + ptlastfig = ptfbfig; + ptfbfig = ptfbfig->NEXT; + } + + if (ptfbfig != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* If the object has been found check the mode and, if asked */ + /* delete pointed objects recursively. */ + /* ###------------------------------------------------------### */ + + if (mode == 'N') + { + if ((ptfbfig->BEREG != 0) || (ptfbfig->BEMSG != 0) || + (ptfbfig->BERIN != 0) || (ptfbfig->BEOUT != 0) || + (ptfbfig->BEBUS != 0) || (ptfbfig->BEAUX != 0) || + (ptfbfig->BEDLY !=0) || (ptfbfig->BEBUX != 0) || + (ptfbfig->BEPOR != 0) || (ptfbfig->USER != 0)) + + (void) fprintf (stderr,"FBH_warning : fbfig `%s` not empty\n", + fbfigname); + } + else + { + fbh_frefbreg (ptfbfig->BEREG); + fbh_frefbmsg (ptfbfig->BEMSG); + fbh_frefbrin (ptfbfig->BERIN); + fbh_frefbout (ptfbfig->BEOUT); + fbh_frefbbus (ptfbfig->BEBUS); + fbh_frefbaux (ptfbfig->BEAUX); + fbh_frefbaux (ptfbfig->BEDLY); + fbh_frefbbux (ptfbfig->BEBUX); + fbh_frefbpor (ptfbfig->BEPOR); + if ((ptptype = getptype (ptfbfig->USER,FBH_GENERIC)) != 0) + fbh_frefbgen (ptptype->DATA); + } + + ptlastfig->NEXT = ptfbfig->NEXT; + mbkfree (ptfbfig); + } + + listfbfig = headfig.NEXT; + } + + return(listfbfig); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_rmvfbgen */ +/* description : delete a BEGEN structure and return the pointer of */ +/* the next object. A warning is printed out if the */ +/* object to be deleted is not empty when the mode is N */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbgen *fbh_rmvfbgen (listfbgen, fbgenname, mode) + +struct fbgen *listfbgen; /* list of fbgen containing the object */ +char *fbgenname; /* name of the BEGEN to be deleted */ +char mode; /* recursive delete or not (Y or N) */ + + { + struct fbgen headgen; + struct fbgen *ptlastgen; + struct fbgen *ptfbgen; + + if (listfbgen != 0) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headgen.NEXT = listfbgen; + ptfbgen = &headgen; + while ((ptfbgen != 0) && (ptfbgen->NAME != fbgenname)) + { + ptlastgen = ptfbgen; + ptfbgen = ptfbgen->NEXT; + } + + if (ptfbgen != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* If the object has been found check the mode and, if asked */ + /* delete pointed objects recursively. */ + /* ###------------------------------------------------------### */ + + if (mode == 'N') + { + if (ptfbgen->VALUE != 0) + (void) fprintf (stderr,"FBH_warning : fbgen `%s` not empty\n", + fbgenname); + } + else + mbkfree (ptfbgen->VALUE); + + ptlastgen->NEXT = ptfbgen->NEXT; + mbkfree (ptfbgen); + } + + listfbgen = headgen.NEXT; + } + + return(listfbgen); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_rmvfbmsg */ +/* description : delete a BEMSG structure and return the pointer of */ +/* the next object. A warning is printed out if the */ +/* object to be deleted is not empty when the mode is N */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbmsg *fbh_rmvfbmsg (listfbmsg, fbmsglabl, mode) + +struct fbmsg *listfbmsg; /* list of fbmsg containing the object */ +char *fbmsglabl; /* label of the BEMSG to be deleted */ +char mode; /* recursive delete or not (Y or N) */ + + { + struct fbmsg headmsg; + struct fbmsg *ptlastmsg; + struct fbmsg *ptfbmsg; + + if (listfbmsg != 0) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headmsg.NEXT = listfbmsg; + ptfbmsg = &headmsg; + while ((ptfbmsg != 0) && (ptfbmsg->LABEL != fbmsglabl)) + { + ptlastmsg = ptfbmsg; + ptfbmsg = ptfbmsg->NEXT; + } + + if (ptfbmsg != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* If the object has been found check the mode and, if asked */ + /* delete pointed objects recursively. */ + /* ###------------------------------------------------------### */ + + if (mode == 'N') + { + if (ptfbmsg->ABL != 0) + (void) fprintf (stderr,"FBH_warning : fbmsg `%s` not empty\n", + fbmsglabl); + } + else + delablexpr (ptfbmsg->ABL); + + ptlastmsg->NEXT = ptfbmsg->NEXT; + mbkfree (ptfbmsg); + } + + listfbmsg = headmsg.NEXT; + } + + return(listfbmsg); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_rmvfbout */ +/* description : delete a BEOUT structure and return the pointer of */ +/* the next object. A warning is printed out if the */ +/* object to be deleted is not empty when the mode is N */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbout *fbh_rmvfbout (listfbout, fboutname, mode) + +struct fbout *listfbout; /* list of fbout containing the object */ +char *fboutname; /* name of the BEOUT to be deleted */ +char mode; /* recursive delete or not (Y or N) */ + + { + struct fbout headout; + struct fbout *ptlastout; + struct fbout *ptfbout; + + if (listfbout != 0) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headout.NEXT = listfbout; + ptfbout = &headout; + while ((ptfbout != 0) && (ptfbout->NAME != fboutname)) + { + ptlastout = ptfbout; + ptfbout = ptfbout->NEXT; + } + + if (ptfbout != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* If the object has been found check the mode and, if asked */ + /* delete pointed objects recursively. */ + /* ###------------------------------------------------------### */ + + if (mode == 'N') + { + if (ptfbout->ABL != 0) + (void) fprintf (stderr,"FBH_warning : fbout `%s` not empty\n", + fboutname); + } + else + delablexpr (ptfbout->ABL); + + ptlastout->NEXT = ptfbout->NEXT; + mbkfree (ptfbout); + } + + listfbout = headout.NEXT; + } + + return(listfbout); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_rmvfbpor */ +/* description : delete a BEPOR structure and return the pointer of */ +/* the next object. */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbpor *fbh_rmvfbpor (listfbpor, fbporname) + +struct fbpor *listfbpor; /* list of fbpor containing the object */ +char *fbporname; /* name of the BEPOR to be deleted */ + + { + struct fbpor headpor; + struct fbpor *ptlastpor; + struct fbpor *ptfbpor; + + if (listfbpor != 0) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headpor.NEXT = listfbpor; + ptfbpor = &headpor; + while ((ptfbpor != 0) && (ptfbpor->NAME != fbporname)) + { + ptlastpor = ptfbpor; + ptfbpor = ptfbpor->NEXT; + } + + if (ptfbpor != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* ###------------------------------------------------------### */ + + ptlastpor->NEXT = ptfbpor->NEXT; + mbkfree (ptfbpor); + } + + listfbpor = headpor.NEXT; + } + + return(listfbpor); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_rmvfbreg */ +/* description : delete a BEREG structure and return the pointer of */ +/* the next object. A warning is printed out if the */ +/* object to be deleted is not empty when the mode is N */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbreg *fbh_rmvfbreg (listfbreg, fbregname, mode) + +struct fbreg *listfbreg; /* list of fbreg containing the object */ +char *fbregname; /* name of the BEREG to be deleted */ +char mode; /* recursive delete or not (Y or N) */ + + { + struct fbreg headreg; + struct fbreg *ptlastreg; + struct fbreg *ptfbreg; + + if (listfbreg != 0) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headreg.NEXT = listfbreg; + ptfbreg = &headreg; + while ((ptfbreg != 0) && (ptfbreg->NAME != fbregname)) + { + ptlastreg = ptfbreg; + ptfbreg = ptfbreg->NEXT; + } + + if (ptfbreg != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* If the object has been found check the mode and, if asked */ + /* delete pointed objects recursively. */ + /* ###------------------------------------------------------### */ + + if (mode == 'N') + { + if ((ptfbreg->BIABL != 0) || (ptfbreg->BINODE != 0)) + (void) fprintf (stderr,"FBH_warning : fbreg `%s` not empty\n", + fbregname); + } + else + { + fbh_frebiabl (ptfbreg->BIABL); + fbh_frebinode (ptfbreg->BINODE); + } + + ptlastreg->NEXT = ptfbreg->NEXT; + mbkfree (ptfbreg); + } + + listfbreg = headreg.NEXT; + } + + return(listfbreg); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbh_rmvfbrin */ +/* description : delete a BERIN structure and return the pointer of */ +/* the next object. */ +/* called func. : mbkfree */ +/* ###--------------------------------------------------------------### */ + +struct fbrin *fbh_rmvfbrin (listfbrin, fbrinname) + +struct fbrin *listfbrin; /* list of fbrin containing the object */ +char *fbrinname; /* name of the BERIN to be deleted */ + + { + struct fbrin headrin; + struct fbrin *ptlastrin; + struct fbrin *ptfbrin; + + if (listfbrin != 0) + { + + /* ###------------------------------------------------------### */ + /* Search the object to be deleted */ + /* ###------------------------------------------------------### */ + + headrin.NEXT = listfbrin; + ptfbrin = &headrin; + while ((ptfbrin != 0) && (ptfbrin->NAME != fbrinname)) + { + ptlastrin = ptfbrin; + ptfbrin = ptfbrin->NEXT; + } + + if (ptfbrin != 0) + { + + /* ###------------------------------------------------------### */ + /* If the object doesn't exist return the list without */ + /* modification. */ + /* ###------------------------------------------------------### */ + + ptlastrin->NEXT = ptfbrin->NEXT; + mbkfree (ptfbrin); + } + + listfbrin = headrin.NEXT; + } + + return(listfbrin); + } diff --git a/alliance/src/fvh/src/fbh_typ.c b/alliance/src/fvh/src/fbh_typ.c new file mode 100644 index 00000000..8f4f427f --- /dev/null +++ b/alliance/src/fvh/src/fbh_typ.c @@ -0,0 +1,94 @@ +/*------------------------------------------------------------\ +| | +| 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. | +| | +\------------------------------------------------------------*/ + +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbh_crtfbtyp.c */ +/* date : Aug 24 1992 */ +/* version : v102 */ +/* authors : Pirouz BAZARGAN SABET */ +/* content : contains a specific function used to create a */ +/* fbhaviour data structure */ +/* */ +/* ###--------------------------------------------------------------### */ + +#include "mut.h" +#include "aut.h" +#include "abl.h" +#include "bdd.h" +#include "fvh.h" + +/* ###--------------------------------------------------------------### */ +/* function : fbh_crtfbtyp */ +/* description : create an array of BETYPs from a list of BETYPs */ +/* called func. : namealloc, mbkalloc */ +/* ###--------------------------------------------------------------### */ + +struct fbtyp *fbh_crtfbtyp (listfbtyp) + +struct fbtyp *listfbtyp; /* pointer on the list of fbtyps */ + + { + struct fbtyp *lclfbtyp = listfbtyp; + struct fbtyp *ptfbtyp = 0; + int size = 0; + + while (lclfbtyp != 0) + { + lclfbtyp = lclfbtyp->NEXT; + size++; + } + + if (size != 0) + { + ptfbtyp = (struct fbtyp *) mbkalloc (size * sizeof(struct fbtyp)); + lclfbtyp = ptfbtyp; + + while (listfbtyp != 0) + { + lclfbtyp->NAME = listfbtyp->NAME; + lclfbtyp->LEFT = listfbtyp->LEFT; + lclfbtyp->RIGHT = listfbtyp->RIGHT; + lclfbtyp->VALUE = listfbtyp->VALUE; + lclfbtyp->SIZE = listfbtyp->SIZE; + lclfbtyp->BYTE = listfbtyp->BYTE; + lclfbtyp->BASE = listfbtyp->BASE; + lclfbtyp->INDEX = listfbtyp->INDEX; + lclfbtyp->RESOLV = listfbtyp->RESOLV; + lclfbtyp->CLASS = listfbtyp->CLASS; + + lclfbtyp->NEXT = lclfbtyp + 1; + + listfbtyp = listfbtyp->NEXT; + lclfbtyp++; + } + + (lclfbtyp - 1)->NEXT = 0; + } + + return (ptfbtyp); + } diff --git a/alliance/src/fvh/src/fbh_uti.c b/alliance/src/fvh/src/fbh_uti.c new file mode 100644 index 00000000..a259bf39 --- /dev/null +++ b/alliance/src/fvh/src/fbh_uti.c @@ -0,0 +1,173 @@ +/*------------------------------------------------------------\ +| | +| 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. | +| | +\------------------------------------------------------------*/ +/*************************************************************************** +* Fonctions utiles pour fbfig : optimisation des abl d'un fbfig, evaluation * +* du cout . . . * +* Le 01/09/92. +****************************************************************************/ +#include +#include "mut.h" +#include "aut.h" +#include "abl.h" +#include "bdd.h" +#include "fvh.h" + +/*------------------------------------------------------------------------i +fsp_mapCarExprFbh : applique une fonction de conversion sur chaque expression + d'une fbfig +--------------------------------------------------------------------------- +retour : un void. +---------------------------------------------------------------------------*/ +void fsp_mapCarExprFbh(fbh,func) + +fbfig_list *fbh; +chain_list *(*func)(); +{ +fbout_list *out; +fbreg_list *reg; +fbbus_list *bus; +fbbux_list *bux; +biabl_list *biabl; +fbaux_list *aux; + + +aux = fbh->BEAUX; +while (aux) + { + if (aux->ABL) + { + aux->ABL = (*func)(aux->ABL); + } + aux = aux->NEXT; + } + +out = fbh->BEOUT; +while (out) + { + if (out->ABL) + { + out->ABL = (*func)(out->ABL); + } + out = out->NEXT; + } + +reg = fbh->BEREG; +while (reg) + { + biabl = reg->BIABL; + while (biabl) + { + if (biabl->CNDABL && biabl->VALABL) + { + biabl->CNDABL = (*func)(biabl->CNDABL); + biabl->VALABL = (*func)(biabl->VALABL); + } + biabl = biabl->NEXT; + } + reg = reg->NEXT; + } + +bus = fbh->BEBUS; +while (bus) + { + biabl = bus->BIABL; + while (biabl) + { + if (biabl->CNDABL && biabl->VALABL) + { + biabl->CNDABL = (*func)(biabl->CNDABL); + biabl->VALABL = (*func)(biabl->VALABL); + } + biabl = biabl->NEXT; + } + bus = bus->NEXT; + } + +bux = fbh->BEBUX; +while (bux) + { + biabl = bux->BIABL; + while (biabl) + { + if (biabl->CNDABL && biabl->VALABL) + { + biabl->CNDABL = (*func)(biabl->CNDABL); + biabl->VALABL = (*func)(biabl->VALABL); + } + biabl = biabl->NEXT; + } + bux = bux->NEXT; + } +} + +/*----------------------------------------------------------------------- +fbrinToChain_list : forme une chaine liste des entrees. + prend l'odre d'apparition. +----------------------------------------------------------------------- +parametres : fbh. +--------------------------------------------------------------------------- +retour : un pointeur de chain_list. +---------------------------------------------------------------------------*/ +chain_list *fbrinToChain_list(fbh) +fbfig_list *fbh; +{ +fbrin_list *in; +chain_list *lst; + +in = fbh->BERIN; /* entrees primaires */ +lst = 0; + +while (in) + { + lst = addchain(lst,(void *)in->NAME); + in = in->NEXT; + }; + + return(lst); +} + +/*------------------------------------------------------------------------- +fsp_countInputFbh : compte les entrees d'un circuit (fbrin) +--------------------------------------------------------------------------- +retour : un int. +---------------------------------------------------------------------------*/ + +int fsp_countInputFbh(fbh) +fbfig_list *fbh; +{ +fbrin_list *in; +int count = 0; + +in = fbh->BERIN; /* entrees primaires */ +while (in) + { + in = in->NEXT; + count++; + }; + +return(count); +} diff --git a/alliance/src/fvh/src/fbh_view.c b/alliance/src/fvh/src/fbh_view.c new file mode 100644 index 00000000..f99cafb4 --- /dev/null +++ b/alliance/src/fvh/src/fbh_view.c @@ -0,0 +1,249 @@ +/*------------------------------------------------------------\ +| | +| 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 : FBH | +| | +| File : fbh_view.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 09.11.99 | +| | +\------------------------------------------------------------*/ + +#include "mut.h" +#include "aut.h" +#include "abl.h" +#include "bdd.h" +#include "fvh.h" + +static void loc_fbh_viewablexprln( Expr ) + + ablexpr *Expr; +{ + if ( Expr == (ablexpr *)0 ) + { + fprintf( stdout, "NULL\n" ); + } + else + { + viewablexprln( Expr, ABL_VIEW_VHDL ); + } +} + +void fbh_viewbiabl( BiAbl ) + + biabl_list *BiAbl; +{ + if ( BiAbl == (biabl_list *)0 ) + { + fprintf( stdout, "NULL\n" ); + } + else + { + while ( BiAbl != (biabl_list *)0 ) + { + fprintf( stdout, "--> biabl_list\n" ); + fprintf( stdout, " LABEL : %s\n", BiAbl->LABEL ); + fprintf( stdout, " CNDABL : " ); + loc_fbh_viewablexprln( BiAbl->CNDABL ); + fprintf( stdout, " VALABL : " ); + loc_fbh_viewablexprln( BiAbl->VALABL ); + fprintf( stdout, "<-- biabl_list\n" ); + + BiAbl = BiAbl->NEXT; + } + } +} + +void fbh_viewfbreg( ScanReg ) + + fbreg_list *ScanReg; +{ + if ( ScanReg != (fbreg_list *)0 ) + { + fprintf( stdout, "--> fbreg_list\n" ); + fprintf( stdout, " NAME : %s\n", ScanReg->NAME ); + fprintf( stdout, " FLAG : %d\n", (int)ScanReg->FLAG ); + fprintf( stdout, " BIABL :\n" ); + fbh_viewbiabl( ScanReg->BIABL ); + fprintf( stdout, "<-- fbreg_list\n" ); + } +} + +void fbh_viewfbbux( ScanBux ) + + fbbux_list *ScanBux; +{ + if ( ScanBux != (fbbux_list *)0 ) + { + fprintf( stdout, "--> fbbux_list\n" ); + fprintf( stdout, " NAME : %s\n", ScanBux->NAME ); + fprintf( stdout, " TYPE : %d\n", (int)ScanBux->TYPE ); + fprintf( stdout, " FLAG : %d\n", (int)ScanBux->FLAG ); + fprintf( stdout, " BIABL :\n" ); + fbh_viewbiabl( ScanBux->BIABL ); + fprintf( stdout, "<-- fbbux_list\n" ); + } +} + +void fbh_viewfbbus( ScanBus ) + + fbbus_list *ScanBus; +{ + if ( ScanBus != (fbbus_list *)0 ) + { + fprintf( stdout, "--> fbbus_list\n" ); + fprintf( stdout, " NAME : %s\n", ScanBus->NAME ); + fprintf( stdout, " TYPE : %d\n", (int)ScanBus->TYPE ); + fprintf( stdout, " FLAG : %d\n", (int)ScanBus->FLAG ); + fprintf( stdout, " BIABL :\n" ); + fbh_viewbiabl( ScanBus->BIABL ); + fprintf( stdout, "<-- fbbus_list\n" ); + } +} + +void fbh_viewfbaux( ScanAux ) + + fbaux_list *ScanAux; +{ + if ( ScanAux != (fbaux_list *)0 ) + { + fprintf( stdout, "--> fbaux_list\n" ); + fprintf( stdout, " NAME : %s\n", ScanAux->NAME ); + fprintf( stdout, " TYPE : %d\n", (int)ScanAux->TYPE ); + fprintf( stdout, " FLAG : %d\n", (int)ScanAux->FLAG ); + fprintf( stdout, " ABL :" ); + loc_fbh_viewablexprln( ScanAux->ABL, ABL_VIEW_VHDL ); + fprintf( stdout, "<-- fbaux_list\n" ); + } +} + +void fbh_viewfbout( ScanOut ) + + fbout_list *ScanOut; +{ + if ( ScanOut != (fbout_list *)0 ) + { + fprintf( stdout, "--> fbout_list\n" ); + fprintf( stdout, " NAME : %s\n", ScanOut->NAME ); + fprintf( stdout, " TYPE : %d\n", (int)ScanOut->TYPE ); + fprintf( stdout, " FLAG : %d\n", (int)ScanOut->FLAG ); + fprintf( stdout, " ABL :" ); + loc_fbh_viewablexprln( ScanOut->ABL ); + fprintf( stdout, "<-- fbout_list\n" ); + } +} + +void fbh_viewfbpor( ScanPort ) + + fbpor_list *ScanPort; +{ + if ( ScanPort != (fbpor_list *)0 ) + { + fprintf( stdout, "--> fbpor_list\n" ); + fprintf( stdout, " NAME : %s\n", ScanPort->NAME ); + fprintf( stdout, " DIR : %c\n", ScanPort->DIRECTION ); + fprintf( stdout, " TYPE : %d\n", (int)ScanPort->TYPE ); + fprintf( stdout, "<-- fbpor_list\n" ); + } +} + +void fbh_viewfbfig( ScanFigure ) + + fbfig_list *ScanFigure; +{ + fbpor_list *ScanPort; + fbaux_list *ScanAux; + fbbus_list *ScanBus; + fbbux_list *ScanBux; + fbreg_list *ScanReg; + fbout_list *ScanOut; + + if ( ScanFigure != (fbfig_list *)0 ) + { + fprintf( stdout, "--> fbfig_list\n" ); + fprintf( stdout, " NAME : %s\n", ScanFigure->NAME ); + + fprintf( stdout, " BEPOR:\n" ); + + for ( ScanPort = ScanFigure->BEPOR; + ScanPort != (fbpor_list *)0; + ScanPort = ScanPort->NEXT ) + { + fbh_viewfbpor( ScanPort ); + } + + fprintf( stdout, " BEAUX:\n" ); + + for ( ScanAux = ScanFigure->BEAUX; + ScanAux != (fbaux_list *)0; + ScanAux = ScanAux->NEXT ) + { + fbh_viewfbaux( ScanAux ); + } + + fprintf( stdout, " BEBUS:\n" ); + + for ( ScanBus = ScanFigure->BEBUS; + ScanBus != (fbbus_list *)0; + ScanBus = ScanBus->NEXT ) + { + fbh_viewfbbus( ScanBus ); + } + + fprintf( stdout, " BEBUX:\n" ); + + for ( ScanBux = ScanFigure->BEBUX; + ScanBux != (fbbux_list *)0; + ScanBux = ScanBux->NEXT ) + { + fbh_viewfbbux( ScanBux ); + } + + fprintf( stdout, " BEREG:\n" ); + + for ( ScanReg = ScanFigure->BEREG; + ScanReg != (fbreg_list *)0; + ScanReg = ScanReg->NEXT ) + { + fbh_viewfbreg( ScanReg ); + } + + fprintf( stdout, " BEOUT:\n" ); + + for ( ScanOut = ScanFigure->BEOUT; + ScanOut != (fbout_list *)0; + ScanOut = ScanOut->NEXT ) + { + fbh_viewfbout( ScanOut ); + } + + fprintf( stdout, "<-- fbfig_list\n" ); + } +} diff --git a/alliance/src/fvh/src/fbl_bcomp.l b/alliance/src/fvh/src/fbl_bcomp.l new file mode 100644 index 00000000..82805090 --- /dev/null +++ b/alliance/src/fvh/src/fbl_bcomp.l @@ -0,0 +1,269 @@ +/*------------------------------------------------------------\ +| | +| 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. | +| | +\------------------------------------------------------------*/ +%{ +#include +#include +#include +#include +#include "mut.h" +#include "aut.h" +#include "abl.h" +#include "bdd.h" +#include "fvh.h" + +typedef struct fbl_expr + { + char *IDENT; /* identifier or constant name */ + struct chain *LIST_ABL; /* pointer on fbl_abllst list */ + short WIDTH; /* width of bit vector */ + } +fbl_ablstr; + +typedef struct + { + char *NAME; /* identifier name */ + short LEFT; /* vector's left index */ + short RIGHT; /* vector's right index */ + char FLAG; + } +fbl_name; + +struct g_type + { + int VALU; + char FLAG; + }; + + + +#include "fbl_y.tab.h" +#include "fbl_bedef.h" +#include "fbl_blex.h" + +static el_mc tab_mc []= + { + {"abs" ,ABS}, + {"access" ,ACCESS}, + {"after" ,AFTER}, + {"alias" ,ALIAS}, + {"all" ,ALL}, + {"and" ,_AND}, + {"architecture" ,ARCHITECTURE}, + {"array" ,ARRAY}, + {"assert" ,ASSERT}, + {"attribute" ,ATTRIBUTE}, + {"begin" ,_BEGIN}, + {"block" ,_BLOCK}, + {"body" ,BODY}, + {"buffer" ,BUFFER}, + {"bus" ,BUS}, + {"case" ,CASE}, + {"component" ,COMPONENT}, + {"configuration" ,CONFIGURATION}, + {"constant" ,CONSTANT}, + {"disconnect" ,DISCONNECT}, + {"downto" ,DOWNTO}, + {"else" ,ELSE}, + {"elsif" ,ELSIF}, + {"end" ,_END}, + {"entity" ,ENTITY}, + {"error" ,ERROR}, + {"event" ,_EVENT}, + {"exit" ,_EXIT}, + {"file" ,_FILE}, + {"for" ,FOR}, + {"function" ,FUNCTION}, + {"generate" ,GENERATE}, + {"generic" ,GENERIC}, + {"guarded" ,GUARDED}, + {"if" ,IF}, + {"in" ,_IN}, + {"inout" ,_INOUT}, + {"is" ,IS}, + {"label" ,_LABEL}, + {"library" ,LIBRARY}, + {"linkage" ,_LINKAGE}, + {"loop" ,LOOP}, + {"map" ,MAP}, + {"mod" ,MOD}, + {"nand" ,_NAND}, + {"new" ,NEW}, + {"next" ,_NEXT}, + {"nor" ,_NOR}, + {"not" ,_NOT}, + {"null" ,_NULL}, + {"of" ,OF}, + {"on" ,ON}, + {"open" ,OPEN}, + {"or" ,_OR}, + {"others" ,OTHERS}, + {"out" ,_OUT}, + {"package" ,PACKAGE}, + {"port" ,PORT}, + {"procedure" ,PROCEDURE}, + {"process" ,PROCESS}, + {"range" ,RANGE}, + {"record" ,RECORD}, + {"register" ,REGISTER}, + {"rem" ,REM}, + {"report" ,REPORT}, + {"return" ,RETURN}, + {"select" ,SELECT}, + {"severity" ,SEVERITY}, + {"signal" ,SIGNAL}, + {"stable" ,_STABLE}, + {"subtype" ,SUBTYPE}, + {"then" ,THEN}, + {"to" ,TO}, + {"transport" ,TRANSPORT}, + {"type" ,FBHTYPE}, + {"units" ,UNITS}, + {"until" ,UNTIL}, + {"use" ,USE}, + {"variable" ,VARIABLE}, + {"wait" ,WAIT}, + {"warning" ,WARNING}, + {"when" ,WHEN}, + {"while" ,WHILE}, + {"with" ,WITH}, + {"xor" ,_XOR} + }; + +static int find_mc(s) + + char *s; + { + char *loc; + el_mc *pt; + + loc = namealloc(s); + pt= (el_mc *) bsearch(loc, (char *)tab_mc,FBL_NB_MC,sizeof(el_mc),strcmp); + if (pt==NULL) return(-1); + return(pt->kval); + } + + +%} + +upper_case_letter [A-Z] +digit [0-9] +special_character [\#\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\_\|] +space_character [ \t] +format_effector [\t\v\r\l\f] +end_of_line \n +lower_case_letter [a-z] +other_special_character [\!\$\@\?\[\\\]\^\`\{\}\~] + +graphic_character ({basic_graphic_character}|{lower_case_letter}|{other_special_character}) +basic_graphic_character ({upper_case_letter}|{digit}|{special_character}|{space_character}) +letter ({upper_case_letter}|{lower_case_letter}) +letter_or_digit ({letter}|{digit}) +decimal_literal {integer}(\.{integer})?({exponent})? +integer {digit}(_?{digit})* +exponent ([eE][-+]?{integer}) +base {integer} +based_integer {extended_digit}(_?{extended_digit})* +extended_digit ({digit}|[a-fA-F]) +base_specifier (B|b|O|o|X|x) + +%% +[ \t] ; +\& { return(Ampersand); } +\' { return(Apostrophe); } +\( { return(LeftParen); } +\) { return(RightParen); } +"**" { return(DoubleStar); } +\* { return(Star); } +\+ { return(Plus); } +\, { return(Comma); } +\- { return(Minus); } +":=" { return(VarAsgn); } +\: { return(Colon); } +\; { return(Semicolon); } +"<=" { return(_LESym); } +">=" { return(_GESym); } +\< { return(_LTSym); } +\> { return(_GTSym); } += { return(_EQSym); } +\/= { return(_NESym); } +"=>" { return(Arrow); } +"<>" { return(Box); } +\| { return(Bar); } +! { return(Bar); } +\. { return(Dot); } + +{letter}(_?{letter_or_digit})* { + int itoken; + itoken=find_mc(yytext); + if (itoken== -1) + { + yylval.text = namealloc(yytext); + return ( Identifier ); + } + else + { + return ( itoken ); + } + } +({decimal_literal})|({base}#{based_integer}(\.{based_integer})?#({exponent})?)|({base}:{based_integer}(\.{based_integer})?:({exponent})?) { + yylval.text = mbkalloc((unsigned int)strlen(yytext)+1); + strcpy(yylval.text,yytext); + return ( AbstractLit ); + } +'({graphic_character}|\"|\%)' { + yylval.text = namealloc (yytext); + return ( CharacterLit ); + } +(\"({graphic_character}|(\"\")|\%)*\")|(\%({graphic_character}|(\%\%)|\")*\%) { + yylval.text = namealloc (yytext); + return ( StringLit ); + } +{base_specifier}((\"{extended_digit}(_?{extended_digit})*\")|(\%{extended_digit}(_?{extended_digit})*\%)) { + yylval.text = namealloc (yytext); + return ( BitStringLit ); + } +\n { + /* end of line */ + FBL_LINNUM++; + } +\-\-{space_character}*[pP][rR][aA][gG][mM][aA].*$ { + /* pragma */ + yylval.text = namealloc (yytext); + return(Pragma); + } +\-\-.*$ { + /* comment */ + /* nothing */ + } +. { + return (*yytext); + } +%% +int yywrap() +{ + return(1); +} diff --git a/alliance/src/fvh/src/fbl_bcomp.y b/alliance/src/fvh/src/fbl_bcomp.y new file mode 100644 index 00000000..00d00fcb --- /dev/null +++ b/alliance/src/fvh/src/fbl_bcomp.y @@ -0,0 +1,3801 @@ +/*------------------------------------------------------------\ +| | +| 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. | +| | +\------------------------------------------------------------*/ +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbl_bcomp.yac */ +/* date : NOV 5 1992 */ +/* version : v100 */ +/* author : P. BAZARGAN, M. HANAFI */ +/* Modified by Ludovic Jacome */ +/* content : yacc rules for fbhavioural VHDL */ +/* */ +/* ###--------------------------------------------------------------### */ + +%{ +#include +#include +#include +#include + +#include "mut.h" +#include "aut.h" +#include "abl.h" +#include "bdd.h" +#include "fvh.h" + +#include "fbl_utype.h" +#include "fbl_bedef.h" +#include "fbl_bspec.h" +#include "fbl_byacc.h" + +static struct dct_entry *addent (); +static struct dct_recrd *addrcd (); +static struct dct_entry **initab (); +static void addtab (); +static long chktab (); +static void fretab (); +void *fbl_addstr (); +int fbl_chkdcl (); +struct ptype *reversetype(); +struct choice_chain *order_choice(); +%} + +%union { + int valu; + char *text; + struct ptype *ptyp; + struct fbpcs proc; + struct g_type dble; + fbl_name name; + fbl_ablstr list; + struct fbtyp type; + }; + +%token _AND +%token Pragma +%token _BEGIN +%token _END +%token _EQSym +%token _EXIT +%token _FILE +%token _GESym +%token _GTSym +%token _IN +%token _INOUT +%token _LABEL +%token _LESym +%token _LINKAGE +%token _LTSym +%token _NAND +%token _NESym +%token _NEXT +%token _NOR +%token _NOT +%token _NULL +%token _OR +%token _OUT +%token _XOR +%token ABS +%token ACCESS +%token AFTER +%token ALIAS +%token ALL +%token ARCHITECTURE +%token ARRAY +%token ASSERT +%token ATTRIBUTE +%token AbstractLit +%token Ampersand +%token Apostrophe +%token Arrow +%token _BLOCK +%token BODY +%token BUFFER +%token BUS +%token Bar +%token BasedInt +%token BasedReal +%token BitStringLit +%token Box +%token CASE +%token COMPONENT +%token CONFIGURATION +%token CONSTANT +%token CharacterLit +%token Colon +%token Comma +%token DISCONNECT +%token DOWNTO +%token DecimalInt +%token DecimalReal +%token Dot +%token DoubleStar +%token ELSE +%token ELSIF +%token ENTITY +%token ERROR +%token FOR +%token FUNCTION +%token GENERATE +%token GENERIC +%token GUARDED +%token IF +%token IS +%token Identifier +%token LIBRARY +%token LOOP +%token LeftParen +%token MAP +%token MOD +%token Minus +%token NEW +%token OF +%token ON +%token OPEN +%token OTHERS +%token PACKAGE +%token PORT +%token PROCEDURE +%token PROCESS +%token Plus +%token RANGE +%token RECORD +%token REGISTER +%token REM +%token REPORT +%token RETURN +%token RightParen +%token SELECT +%token SEVERITY +%token SIGNAL +%token _STABLE +%token _EVENT +%token SUBTYPE +%token Semicolon +%token Star +%token StringLit +%token THEN +%token TO +%token TRANSPORT +%token FBHTYPE +%token UNITS +%token UNTIL +%token USE +%token VARIABLE +%token VarAsgn +%token WAIT +%token WARNING +%token WHEN +%token WHILE +%token WITH + +%left _AND _OR _NAND _NOR _XOR +%left _EQSym _NESym +%left _NOT + + +%type .SEVERITY__expression. +%type severity__message +%type .REPORT__expression. +%type report__message +%type .guard_expression. +%type guard_expression + + +%type waveform +%type waveform_element +%type ...waveform__WHEN__choices.. +%type waveform__WHEN__choices +%type condition +%type expression +%type relation..AND__relation.. +%type relation..OR__relation.. +%type relation.NAND_NOR__relation. +%type relation..XOR__relation.. +%type relation +%type simple_expression +%type .sign.term..add_op__term.. +%type term +%type factor +%type primary +%type relational_operator +%type literal +%type choice +%type aggregate + +%type .GUARDED. + +%type type_definition +%type scalar_type_definition +%type composite_type_definition +%type enumeration_type_definition +%type subtype_indication +%type unconstrained_array_definition +%type constrained_array_definition +%type array_type_definition + +%type index_subtype_definition +%type index_constraint +%type discrete_range + +%type .label. +%type label +%type a_label +%type target +%type simple_name +%type name +%type attribute_name +%type indexed_name +%type slice_name +%type .simple_name. +%type .constraint. +%type constraint +%type range +%type range_constraint +%type direction +%type abstractlit +%type .mode. +%type type_mark +%type .signal_kind. +%type attribute_designator + + +%type constant_VarAsgn__expression + +%start design_file + +%% + +design_file + : /* empty */ + { + /* ###----------------------------------------------### */ + /* Initializations */ + /* ###----------------------------------------------### */ + FBL_NM1LST = 0; + FBL_GRDLST = 0; + FBL_CNDLST = 0; + FBL_VALLST = 0; + + hshtab = initab (); + + FBL_ERRFLG = 0; + FBL_LINNUM = 1; + FBL_NUMPTP = 0; + FBL_HEADFIG = (fbfig_list *)0; + + FBL_MODNAM = 0; + FBL_BEFPNT = fbh_addfbfig (FBL_HEADFIG,0); + FBL_HEADFIG = FBL_BEFPNT; + FBL_HASH_ASG_FSM = createauthtable( 1000 ); + } + design_unit + ..design_unit.. + { + struct fbbus *fbbus_pnt; + struct fbreg *fbreg_pnt; + struct fbout *fbout_pnt; + struct fbaux *fbaux_pnt; + authelem *Element; + + /* ###----------------------------------------------### */ + /* Checking that each output have at least one driver*/ + /* ###----------------------------------------------### */ + + /*printf("liste des types\n"); + fbtyp_pnt = FBL_BEFPNT->BETYP; + while (fbtyp_pnt != 0) + { + printf("name : %s [%d]\n",fbtyp_pnt->NAME,j); + printf("class : %c \n",fbtyp_pnt->CLASS); + printf("BASE : %d \n",fbtyp_pnt->BASE); + printf("INDEX : %d \n",fbtyp_pnt->INDEX); + printf("TYPE : %d \n",chktab (hshtab,fbtyp_pnt->NAME,FBL_MODNAM,FBL_TYPDFN) ); + if(fbtyp_pnt->VALUE != 0) + for ( i= 0; i< fbtyp_pnt->SIZE ; i++) + printf("VAL : %s \n",*(fbtyp_pnt->VALUE + i)); + fbtyp_pnt = fbtyp_pnt->NEXT; + j++; + }*/ + + fbout_pnt = FBL_BEFPNT->BEOUT; + while (fbout_pnt != 0) + { + Element = searchauthelem( FBL_HASH_ASG_FSM, fbout_pnt->NAME ); + if ( Element != (authelem *)0 ) SetFbhAssignByFsm( fbout_pnt ); + + /* LUDO + if ( (fbout_pnt->ABL == 0) && + (! IsFbhAssignByFsm( fbout_pnt ) ) ) + { + fbl_error (40,fbout_pnt->NAME); + } + */ + fbout_pnt = fbout_pnt->NEXT; + } + + /*fbrin_pnt = FBL_BEFPNT->BERIN; + while (fbout_pnt != 0) + { + printf("%s \n",fbrin_pnt->NAME); + if (fbout_pnt->ABL == 0) + fbl_error (40,fbrin_pnt->NAME); + fbrin_pnt = fbrin_pnt->NEXT; + }*/ + + /*fbpcs_pnt = FBL_BEFPNT->BEPCS; + while (fbpcs_pnt != 0) + { + struct fbpgm *fbpgm; + struct ptype *fbtyp; + printf("label : %s \n",fbpcs_pnt->LABEL); + fbpgm = FBL_BEFPNT->BEPGM; + while(fbpgm) + { + fbpgm = fbpgm->NEXT; + } + fbtyp = fbpcs_pnt->INSTRUCTION; + while(fbtyp) + { + display_fbh(fbtyp); + fbtyp = fbtyp->NEXT; + } + fbpcs_pnt = fbpcs_pnt->NEXT; + }*/ + + fbaux_pnt = FBL_BEFPNT->BEAUX; + while (fbaux_pnt != 0) + { + Element = searchauthelem( FBL_HASH_ASG_FSM, fbaux_pnt->NAME ); + if ( Element != (authelem *)0 ) SetFbhAssignByFsm( fbaux_pnt ); + + if ( (fbaux_pnt->ABL == 0) && + (! IsFbhAssignByFsm( fbaux_pnt ) ) ) + { + fbl_error (40,fbaux_pnt->NAME); + } + fbaux_pnt = fbaux_pnt->NEXT; + } + + fbbus_pnt = FBL_BEFPNT->BEBUS; + while (fbbus_pnt != 0) + { + if (fbbus_pnt->BIABL == 0) + { + fbl_error (40,fbbus_pnt->NAME); + } + fbbus_pnt = fbbus_pnt->NEXT; + } + + fbreg_pnt = FBL_BEFPNT->BEREG; + while (fbreg_pnt != 0) + { + if (fbreg_pnt->BIABL == 0) + { + fbl_error (40,fbreg_pnt->NAME); + } + fbreg_pnt = fbreg_pnt->NEXT; + } + fretab (hshtab); + destroyauthtable( FBL_HASH_ASG_FSM ); + } + ; + +..design_unit.. + : /*empty*/ + | design_unit + ..design_unit.. + ; + +design_unit + : context_clause + library_unit + ; + +library_unit + : primary_unit + { } + | secondary_unit + { } + | error + { } + ; + +primary_unit + : entity_declaration + { } + ; + +secondary_unit + : architecture_body + { } + ; + +library_clause + : LIBRARY + logical_name_list + Semicolon_ERR + { } + ; + +logical_name_list + : Identifier + ...logical_name.. + { } + ; + +...logical_name.. + : /*empty*/ + | ...logical_name.. + Comma + Identifier + { } + ; + +/* 11.3 */ +context_clause + : ..context_item.. + { } + ; + +..context_item.. + : /*empty*/ + | ..context_item.. + context_item + { } + ; + +context_item + : library_clause + { } + | use_clause + { } + ; + +use_clause + : USE + selected_name /* package simple name */ + ...selected_name.. + Semicolon_ERR + { + } + ; + +...selected_name.. + : /*empty*/ + { } + | ...selected_name.. + Comma + selected_name + { } + ; + +selected_name + : prefix + Dot + suffix + { + } + ; + +suffix + : simple_name + { } + | ALL + { } + ; + +prefix + : simple_name + { } + | prefix + Dot + simple_name + { } + ; + +entity_declaration + : ENTITY + simple_name + IS + { + int type,size=0; + struct fbtyp *fbtyp_pnt; + char *name; + char *name_bit; + char *name_bit_vector; + char *name_std_logic; + char *name_std_ulogic; + char *name_std_logic_vector; + char *name_std_ulogic_vector; + FBL_BEFPNT->NAME = $2; + FBL_MODNAM = $2; + + fbtyp_pnt = fbh_prdeftyp(); + FBL_BEFPNT->BETYP = fbtyp_pnt; + FBL_NUMTYP =1; + while(fbtyp_pnt) + { + size++; + fbtyp_pnt = fbtyp_pnt->NEXT; + } + + name_bit = namealloc( "bit" ); + name_bit_vector = namealloc( "bit_vector" ); + name_std_logic = namealloc( "std_logic" ); + name_std_ulogic = namealloc( "std_ulogic" ); + name_std_logic_vector = namealloc( "std_logic_vector" ); + name_std_ulogic_vector = namealloc( "std_ulogic_vector" ); + + fbtyp_pnt =FBL_BEFPNT->BETYP ; + while(fbtyp_pnt) + { + type = val_type(fbtyp_pnt->NAME); + addtab(hshtab,fbtyp_pnt->NAME,FBL_MODNAM,FBL_SIGDFN,FBL_TPEDFN); + addtab(hshtab,fbtyp_pnt->NAME,FBL_MODNAM,FBL_USRDFN,type); + addtab(hshtab,fbtyp_pnt->NAME,FBL_MODNAM,FBL_LBLDFN,fbtyp_pnt->CLASS); + addtab(hshtab,fbtyp_pnt->NAME,FBL_MODNAM,FBL_TYPDFN,size +1 - FBL_NUMTYP); + addtab(hshtab,fbtyp_pnt->NAME,FBL_MODNAM,FBL_PNTDFN,(long)fbtyp_pnt); + if ( ( fbtyp_pnt->NAME == name_bit ) || + ( fbtyp_pnt->NAME == name_bit_vector ) ) + { + if ( fbtyp_pnt->NAME == name_bit ) name = name_std_logic; + else name = name_std_logic_vector; + + addtab(hshtab,name,FBL_MODNAM,FBL_SIGDFN,FBL_TPEDFN); + addtab(hshtab,name,FBL_MODNAM,FBL_USRDFN,type); + addtab(hshtab,name,FBL_MODNAM,FBL_LBLDFN,fbtyp_pnt->CLASS); + addtab(hshtab,name,FBL_MODNAM,FBL_TYPDFN,size +1 - FBL_NUMTYP); + addtab(hshtab,name,FBL_MODNAM,FBL_PNTDFN,(long)fbtyp_pnt); + + if ( fbtyp_pnt->NAME == name_bit ) name = name_std_ulogic; + else name = name_std_ulogic_vector; + + addtab(hshtab,name,FBL_MODNAM,FBL_SIGDFN,FBL_TPEDFN); + addtab(hshtab,name,FBL_MODNAM,FBL_USRDFN,type); + addtab(hshtab,name,FBL_MODNAM,FBL_LBLDFN,fbtyp_pnt->CLASS); + addtab(hshtab,name,FBL_MODNAM,FBL_TYPDFN,size +1 - FBL_NUMTYP); + addtab(hshtab,name,FBL_MODNAM,FBL_PNTDFN,(long)fbtyp_pnt); + } + fbtyp_pnt = fbtyp_pnt->NEXT; + FBL_NUMTYP++; + } + } + .port_clause. + END_ERR + .simple_name. + Semicolon_ERR + { + if (($7 != 0) && ($7 != $2)) + { + fbl_error (1,$7); + } + } + | ENTITY + error + { fbl_error (2,0); } + ; + +.constraint. + : /*empty*/ + { + $$.FLAG = 'U'; + $$.LEFT = -1; + $$.RIGHT = -1; + } + | constraint + { $$ = $1; } + ; + +constraint + : LeftParen + range + RightParen_ERR + { $$ = $2; } + ; + +range_constraint + : RANGE + range + { $$ = $2; } + ; + +range + : abstractlit + direction + abstractlit + { + $$.FLAG = 'A'; + $$.LEFT = $1; + $$.RIGHT = $3; + + if ((($1 > $3) && ($2 == FBL_UPTDFN)) || + (($1 < $3) && ($2 == FBL_DWTDFN)) || + (($1 < 0 ) || ($2 < 0 ))) + { + fbl_error (32,0); + } + } + ; + +direction + : TO + { $$ = FBL_UPTDFN; } + | DOWNTO + { $$ = FBL_DWTDFN; } + ; + +.port_clause. + : /*empty*/ + | port_clause + ; + +port_clause + : PORT + LeftParen + formal_port_list + RightParen_ERR + Semicolon_ERR + | PORT + error + Semicolon_ERR + { fbl_error (3,0); } + ; + +formal_port_list + : formal_port_element + ...formal_port_element.. + ; + +...formal_port_element.. + : /*empty*/ + | ...formal_port_element.. + Semicolon_ERR + formal_port_element + ; + +formal_port_element + : .SIGNAL. + identifier_list + Colon + .mode. + type_mark + .constraint. + .signal_kind. + { + char *signame; + int sigconf; + void *pnt; + + /* ###----------------------------------------------### */ + /* First, check the validity of the declaration. */ + /* Then, for each port, create the apropriate set of */ + /* structures (fbrin, fbpor, fbout, fbbus) */ + /* ###----------------------------------------------### */ + + fbl_chkdcl ('P', $4, val_type($5.NAME), $5.FLAG, $7, $6.FLAG,&sigconf); + + FBL_NM1LST = reverse (FBL_NM1LST); + while (FBL_NM1LST != 0) + { + signame = (char *)FBL_NM1LST->DATA; + if (chktab (hshtab,signame,FBL_MODNAM,FBL_SIGDFN) != 0) + { + fbl_error (4,signame); + } + + pnt = fbl_addstr (FBL_BEFPNT,'P',$4,val_type($5.NAME),$5.TYPE,$5.FLAG,signame, + $6.LEFT,$6.RIGHT); + + addtab (hshtab,signame,FBL_MODNAM,FBL_SIGDFN,sigconf); + addtab (hshtab,signame,FBL_MODNAM,FBL_TYPDFN,$5.TYPE); + addtab (hshtab,signame,FBL_MODNAM,FBL_WMNDFN,$6.LEFT); + addtab (hshtab,signame,FBL_MODNAM,FBL_WMXDFN,$6.RIGHT); + addtab (hshtab,signame,FBL_MODNAM,FBL_LBLDFN,$7); + addtab (hshtab,signame,FBL_MODNAM,FBL_PNTDFN,(int)pnt); + + FBL_NM1LST = delchain (FBL_NM1LST, FBL_NM1LST); + } + } + | error + { + /* ###----------------------------------------------### */ + /* The following 3 lines reject tokens until the */ + /* sync. token 'Semicolon' is found */ + /* ###----------------------------------------------### */ + + /*do + yychar = yylex (); + while ((yychar != Semicolon) && (yychar != 0)); + yyerrok; +*/ + fbl_error (6,0); + } + ; + +.SIGNAL. + : /*empty*/ + | SIGNAL + ; + +.mode. + : /*empty*/ + { $$ = FBL_ICNDFN; } + | _IN + { $$ = FBL_ICNDFN; } + | _OUT + { $$ = FBL_OCNDFN; } + | _INOUT + { $$ = FBL_BCNDFN; } + ; + +architecture_body + : ARCHITECTURE + Identifier + OF + simple_name + IS + { + if ($4 != FBL_MODNAM) + { + fbl_error (1,$4); + } + } + architecture_declarative_part + { + struct fbtyp *listfbtyp; + struct fbtyp *fbtypaux; + struct fbtyp *revfbtyp = 0; + listfbtyp = FBL_BEFPNT->BETYP; + revfbtyp = listfbtyp; + listfbtyp = listfbtyp->NEXT; + revfbtyp->NEXT = 0; + while(listfbtyp != 0) + { + fbtypaux = revfbtyp; + revfbtyp = listfbtyp; + listfbtyp = listfbtyp->NEXT; + revfbtyp->NEXT = fbtypaux; + } + + FBL_BEFPNT->BETYP = fbh_crtfbtyp(revfbtyp); + } + _BEGIN + architecture_statement_part + END_ERR + .simple_name. + Semicolon_ERR + { + if (($12 != 0) && ($12 != $2)) + { + fbl_error (7,$12); + } + } + | ARCHITECTURE + error + { fbl_error (8,0); } + ; + +architecture_declarative_part + : ..block_declarative_item.. + ; + +..block_declarative_item.. + : /*empty*/ + | ..block_declarative_item.. + block_declarative_item + ; + +block_declarative_item + : signal_declaration + | type_declaration + | subtype_declaration + | constant_declaration + | pragma_declaration + | error + Semicolon_ERR + { fbl_error (9,0); } + ; + +pragma_declaration + : Pragma + { + char pragma[30]; + char type[30]; + char name[30]; + sscanf((char *)$1,"-- %s %s %s", pragma,type,name); + + FBL_BEFPNT->BEPGM = fbh_addfbpgm(FBL_BEFPNT->BEPGM,type,name,0); + FBL_BEFPNT->BEPGM->USER = (void *)FBL_LINNUM; + } + ; + +constant_declaration + : CONSTANT + Identifier + Colon + type_mark + .constraint. + constant_VarAsgn__expression + Semicolon_ERR + { + int sigconf; + + if (fbl_chkdcl ('C',0,val_type($4.NAME),$4.FLAG,0,$5.FLAG,&sigconf) == 0) + { + addtab (hshtab,$2,FBL_MODNAM,FBL_WMNDFN,$5.LEFT); + addtab (hshtab,$2,FBL_MODNAM,FBL_WMXDFN,$5.RIGHT); + addtab (hshtab,$2,FBL_MODNAM,FBL_SIGDFN,sigconf); + addtab (hshtab,$2,FBL_MODNAM,FBL_TYPDFN,-1); + addtab (hshtab,$2,0,FBL_PNTDFN,$6); + } + } + ; + +constant_VarAsgn__expression + : VarAsgn + literal + { $$ = $2; } + ; + +signal_declaration + : SIGNAL + identifier_list + Colon + type_mark + .constraint. + .signal_kind. + Semicolon_ERR + { + char *signame; + int sigconf; + void *pnt; + int errflg; + + errflg = fbl_chkdcl ('S',0,val_type($4.NAME),$4.FLAG,$6,$5.FLAG,&sigconf); + + /* ###----------------------------------------------### */ + /* First, check the validity of the declaration. */ + /* Then, for each signal, create the apropriate set of */ + /* structures (fbrin, fbreg, fbaux, fbbux) + */ + /* ###----------------------------------------------### */ + + /*if( val_type($4.NAME) != -1) + fbl_error(81,$4.NAME);*/ + /*else */ + { + FBL_NM1LST = reverse (FBL_NM1LST); + while (FBL_NM1LST != 0) + { + signame = (char *)FBL_NM1LST->DATA; + if (chktab (hshtab,signame,FBL_MODNAM,FBL_SIGDFN) != 0) + { + fbl_error (10,signame); + } + + pnt = fbl_addstr (FBL_BEFPNT,'S',0,val_type($4.NAME),$4.TYPE, + $4.FLAG,signame, $5.LEFT,$5.RIGHT); + + addtab (hshtab,signame,FBL_MODNAM,FBL_SIGDFN,sigconf); + addtab (hshtab,signame,FBL_MODNAM,FBL_TYPDFN,$4.TYPE); + addtab (hshtab,signame,FBL_MODNAM,FBL_WMNDFN,$5.LEFT); + addtab (hshtab,signame,FBL_MODNAM,FBL_WMXDFN,$5.RIGHT); + addtab (hshtab,signame,FBL_MODNAM,FBL_LBLDFN,$6); + addtab (hshtab,signame,FBL_MODNAM,FBL_PNTDFN,(int)pnt); + + FBL_NM1LST = delchain (FBL_NM1LST,FBL_NM1LST); + + } + } + } + ; + +type_declaration + : full_type_declaration + ; + +full_type_declaration + : FBHTYPE + Identifier + IS + type_definition + { + FBL_BEFPNT->BETYP = fbh_addfbtyp(FBL_BEFPNT->BETYP,$2,$4.LEFT, + $4.RIGHT,$4.VALUE,$4.SIZE,$4.BYTE,$4.BASE,$4.INDEX,$4.RESOLV,$4.CLASS); + FBL_BEFPNT->BETYP->USER = (void *)FBL_LINNUM; + addtab(hshtab,$2,FBL_MODNAM,FBL_SIGDFN,FBL_TPEDFN); + addtab(hshtab,$2,FBL_MODNAM,FBL_LBLDFN,$4.CLASS); + addtab(hshtab,$2,FBL_MODNAM,FBL_TYPDFN,FBL_NUMTYP); + addtab (hshtab,$2,FBL_MODNAM,FBL_PNTDFN,(int)FBL_BEFPNT->BETYP); + FBL_NUMTYP++; + } + Semicolon_ERR + ; + +type_definition + : scalar_type_definition + { $$ = $1; } + | composite_type_definition + { $$ = $1; } + | error Semicolon_ERR + { yyerrok; } + ; + +subtype_declaration + : SUBTYPE + Identifier + IS + subtype_indication + { + FBL_BEFPNT->BETYP = fbh_addfbtyp(FBL_BEFPNT->BETYP,$2,$4.LEFT, + $4.RIGHT,$4.VALUE,$4.SIZE,$4.BYTE,$4.BASE,$4.INDEX,$4.RESOLV,$4.CLASS); + FBL_BEFPNT->BETYP->USER = (void *)FBL_LINNUM; + addtab(hshtab,$2,FBL_MODNAM,FBL_SIGDFN,FBL_TPEDFN); + addtab(hshtab,$2,FBL_MODNAM,FBL_LBLDFN,$4.CLASS); + addtab(hshtab,$2,FBL_MODNAM,FBL_TYPDFN,FBL_NUMTYP); + addtab (hshtab,$2,FBL_MODNAM,FBL_PNTDFN,(int)FBL_BEFPNT->BETYP); + FBL_NUMTYP++; + } + Semicolon_ERR + ; + +subtype_indication + : type_mark + .constraint. + { struct fbtyp *fbtyp_pnt; + fbtyp_pnt = (struct fbtyp*)chktab(hshtab,$1,FBL_MODNAM,FBL_PNTDFN); + $$.BASE = $1.TYPE ; + $$.VALUE = 0 ; + $$.SIZE = 0 ; + $$.BYTE = fbtyp_pnt->BYTE ; + $$.LEFT = $2.LEFT ; + $$.RIGHT = $2.RIGHT ; + $$.CLASS = 'S' ; + $$.RESOLV = 0 ; + } + ; + +scalar_type_definition + : enumeration_type_definition + { + $$ = $1; + } + ; +enumeration_type_definition + : LeftParen + enumeration_literal + ...enumeration_literal.. + RightParen_ERR + { + char *enumname; + int size=0; + int indice=0; + char **pnt; + chain_list *nm1lst; + + FBL_NM1LST = reverse (FBL_NM1LST); + + nm1lst = FBL_NM1LST; + while (nm1lst != 0) + { + size++; + nm1lst = nm1lst->NEXT; + } + if( size != 0) + pnt = (char **) malloc(size * sizeof(char*)); + + while (FBL_NM1LST != 0) + { + enumname = namealloc((char *)FBL_NM1LST->DATA); + if (chktab (hshtab,enumname,FBL_MODNAM,FBL_SIGDFN) != 0) + { + fbl_error (82,enumname); + } + + addtab (hshtab,enumname,FBL_MODNAM,FBL_SIGDFN,FBL_CSTDFN); + addtab (hshtab,enumname,FBL_MODNAM,FBL_TYPDFN,FBL_NUMTYP); + addtab (hshtab,enumname,FBL_MODNAM,FBL_USRDFN,size); + addtab (hshtab,enumname,FBL_MODNAM,FBL_WMNDFN,-1); + addtab (hshtab,enumname,FBL_MODNAM,FBL_WMXDFN,-1); + addtab (hshtab,enumname,FBL_MODNAM,FBL_LBLDFN,indice); + addtab (hshtab,enumname,FBL_MODNAM,FBL_PNTDFN,(int)pnt); + + pnt[indice++] = enumname; + FBL_NM1LST = delchain (FBL_NM1LST, FBL_NM1LST); + } + $$.VALUE = pnt ; + $$.SIZE = size ; + $$.LEFT = 0 ; + $$.RIGHT = 0 ; + $$.BYTE = size/256 +1; + $$.CLASS = 'E' ; + $$.BASE = 0 ; + $$.RESOLV = 0 ; + } + ; + + +...enumeration_literal.. + : /*empty*/ + | ...enumeration_literal.. + Comma + enumeration_literal + { yyerrok; } + ; + +enumeration_literal + : Identifier + { FBL_NM1LST = addchain (FBL_NM1LST,$1); } + | CharacterLit + { FBL_NM1LST = addchain (FBL_NM1LST,$1); } + ; + + +composite_type_definition + : array_type_definition + { + $$ = $1; + } + ; + +array_type_definition + : unconstrained_array_definition + { $$ = $1; } + | constrained_array_definition + { $$ = $1; } + ; + +unconstrained_array_definition + : ARRAY + LeftParen + index_subtype_definition + RightParen_ERR + OF + subtype_indication + { + $$ = $6; + $$.CLASS = 'U'; + $$.INDEX = $3.TYPE; + } + ; + +constrained_array_definition + : ARRAY + index_constraint + OF + subtype_indication + { $$ = $4; + $$.CLASS = 'A'; + $$.INDEX = $2.TYPE; + } + ; + +index_subtype_definition + : name /* type_mark - causes conflict */ + RANGE + Box + { + $$.NAME = $1.NAME; + $$.LEFT = $1.LEFT; + $$.RIGHT = $1.RIGHT; + /*$$.TYPE = chktab(hshtab,$1,FBL_MODNAM,FBL_TYPDFN); */ + $$.TYPE = $1.TYPE; + $$.FLAG = chktab(hshtab,$1,FBL_MODNAM,FBL_LBLDFN); + if ($$.TYPE == 0 || $$.FLAG ==0) + { + fbl_error(83,$1.NAME); + } + } + ; + +index_constraint + : LeftParen + discrete_range + RightParen_ERR + { $$ = $2;} + ; + +discrete_range + : range /* includes attribute_name */ + { $$ = $1;} + | name + range_constraint /* subtype_indication - causes conflict */ + { $$ = $2; + $$.NAME = $1.NAME; + } + | type_mark /* type_mark causes 2 r/r conflicts - required for + louie's code */ + { $$ = $1;} + ; + +type_mark + : simple_name + { + int type; + $$.NAME = $1; + $$.LEFT = -1; + $$.RIGHT = -1; + $$.TYPE = chktab(hshtab,$1,FBL_MODNAM,FBL_TYPDFN); + $$.FLAG = chktab(hshtab,$1,FBL_MODNAM,FBL_LBLDFN); + type = chktab(hshtab,$1,FBL_MODNAM,FBL_SIGDFN); + if (type != FBL_TPEDFN || $$.TYPE ==0) + { + fbl_error(84,$1); + } + } + ; + + +.signal_kind. + : /*empty*/ + { $$ = 0; } + | REGISTER + { $$ = REGISTER; } + | BUS + { $$ = BUS; } + ; + +architecture_statement_part + : ..concurrent_statement.. + ; + +..concurrent_statement.. + : /*empty*/ + | ..concurrent_statement.. + concurrent_statement + ; + +concurrent_statement + : process_statement + | block_statement + | concurrent_assertion_statement + | concurrent_signal_assignment_statement + | error + Semicolon_ERR + { fbl_error (18,0); } + ; + +/* DEBUT LUDO */ + +block_statement + : a_label + _BLOCK + .guard_expression. + _BEGIN + { + if (chktab (hshtab,$1,FBL_MODNAM,FBL_LBLDFN) != 0) + { + fbl_error (19,$1); + } + + addtab (hshtab,$1,FBL_MODNAM,FBL_LBLDFN,1); + if ($3 != NULL) + FBL_GRDLST = addchain (FBL_GRDLST,(char *)$3); + } + set_of_statements + END_ERR + _BLOCK + .label. + Semicolon_ERR + { + if ($3 != NULL) + FBL_GRDLST = delchain (FBL_GRDLST,FBL_GRDLST); + if (($9 != NULL) && ($9 != $1)) + { + fbl_error (20,$9); + } + } + ; + +set_of_statements + : ..concurrent_statement.. + ; + +concurrent_assertion_statement + : a_label + unlabeled_concurrent_assertion_statement + { + if (chktab (hshtab,$1,FBL_MODNAM,FBL_LBLDFN) != 0) + { + fbl_error (19,$1); + } + + addtab (hshtab,$1,FBL_MODNAM,FBL_LBLDFN,1); + if (FBL_ERRFLG == 0) + FBL_BEFPNT->BEMSG->LABEL = $1; + } + | unlabeled_concurrent_assertion_statement + ; + +concurrent_signal_assignment_statement + : a_label + unlabeled_conditional_signal_assignment + { + if (chktab (hshtab,$1,FBL_MODNAM,FBL_LBLDFN) != 0) + { + fbl_error (19,$1); + } + addtab (hshtab,$1,FBL_MODNAM,FBL_LBLDFN,1); + } + | unlabeled_conditional_signal_assignment + | a_label + unlabeled_selected_signal_assignment + { + if (chktab (hshtab,$1,FBL_MODNAM,FBL_LBLDFN) != 0) + { + { + fbl_error (19,$1); + } + } + addtab (hshtab,$1,FBL_MODNAM,FBL_LBLDFN,1); + } + | unlabeled_selected_signal_assignment + ; + +unlabeled_concurrent_assertion_statement + : assertion_statement + ; + +unlabeled_conditional_signal_assignment + : target + _LESym + .GUARDED. + ..waveform__WHEN__condition__ELSE.. + waveform + Semicolon_ERR + { + int i; + struct fbout *fbout_pnt; + struct fbbus *fbbus_pnt; + struct fbreg *fbreg_pnt; + struct fbaux *fbaux_pnt; + struct fbbux *fbbux_pnt; + struct chain *abl_pnt; + struct fbl_expr expr0; + struct fbl_expr expr1; + struct fbl_expr expr2; + struct fbl_expr expr3; + struct fbl_expr expr4; + struct fbl_expr expr5; + struct fbl_expr expr6; + int rev_flg = 0; + int left_bnd; + int right_bnd; + int left; + int right; + int in_bound; + int out_bound; + int sig_width; + int sig_conf; + + expr4 = $5; + + while (FBL_CNDLST != NULL) + { + expr5 = *((fbl_ablstr *) FBL_CNDLST->DATA); + expr6 = *((fbl_ablstr *) FBL_VALLST->DATA); + + expr0 = fbl_cpyablstr (expr5); + expr1 = fbl_crtabl (ABL_NOT , expr5, FBL_EMPSTR,-1,-1); + expr5 = expr0; + expr2 = fbl_crtabl (ANDM, expr4, expr1 ,-1,-1); + expr3 = fbl_crtabl (ANDM, expr6, expr5 ,-1,-1); + expr4 = fbl_crtabl (ABL_OR , expr2, expr3 ,-1,-1); + + FBL_CNDLST = delchain (FBL_CNDLST,FBL_CNDLST); + FBL_VALLST = delchain (FBL_VALLST,FBL_VALLST); + } + + left_bnd = chktab (hshtab,$1.NAME,FBL_MODNAM,FBL_WMNDFN); + right_bnd = chktab (hshtab,$1.NAME,FBL_MODNAM,FBL_WMXDFN); + sig_conf = chktab (hshtab,$1.NAME,FBL_MODNAM,FBL_SIGDFN); + + left = $1.LEFT; + right = $1.RIGHT; + + if (left_bnd <= right_bnd) + { + sig_width = right_bnd - left_bnd + 1; + if (left <= right) + { + rev_flg = 0; + in_bound = right_bnd - right; + out_bound = right_bnd - left; + if ((left < left_bnd) || (right > right_bnd)) + { + fbl_error (36,$1.NAME); + } + } + else + { + rev_flg = 1; + in_bound = right_bnd - left; + out_bound = right_bnd - right; + if ((left > right_bnd) || (right < left_bnd)) + { + fbl_error (36,$1.NAME); + } + } + } + else + { + sig_width = left_bnd - right_bnd + 1; + if (left <= right) + { + rev_flg = 1; + in_bound = left - right_bnd; + out_bound = right - right_bnd; + if ((left < right_bnd) || (right > left_bnd)) + { + fbl_error (36,$1.NAME); + } + } + else + { + rev_flg = 0; + in_bound = right - right_bnd; + out_bound = left - right_bnd; + if ((left > left_bnd) || (right < right_bnd)) + { + fbl_error (36,$1.NAME); + } + } + } + + if ((out_bound - in_bound + 1) != expr4.WIDTH) + { + fbl_error (35,$1.NAME); + } + + if (rev_flg == 1) + expr4.LIST_ABL = reverse (expr4.LIST_ABL); + + abl_pnt = expr4.LIST_ABL; + + switch (sig_conf) + { + case (FBL_ICNDFN + FBL_BITDFN + FBL_NORDFN) : + { + fbl_error (21,$1.NAME); + } + break; + + case (FBL_OCNDFN + FBL_BITDFN + FBL_NORDFN) : + case (FBL_BCNDFN + FBL_BITDFN + FBL_NORDFN) : + if ($3 == FBL_GRDDFN) + { + fbl_error (22,$1.NAME); + } + fbout_pnt = (struct fbout *) + chktab (hshtab,$1.NAME,FBL_MODNAM,FBL_PNTDFN); + if (FBL_ERRFLG == 0) + { + for (i=0 ; i= in_bound) + { + if (fbout_pnt->ABL != NULL) + { + fbl_error (39,fbout_pnt->NAME); + } + else + fbout_pnt->ABL = (struct chain *)abl_pnt->DATA; + abl_pnt = abl_pnt->NEXT; + } + if (i >= out_bound) + break; + fbout_pnt = fbout_pnt->NEXT; + } + } + break; + + case (FBL_OCNDFN + FBL_MUXDFN + FBL_BUSDFN) : + case (FBL_OCNDFN + FBL_WORDFN + FBL_BUSDFN) : + case (FBL_BCNDFN + FBL_MUXDFN + FBL_BUSDFN) : + case (FBL_BCNDFN + FBL_WORDFN + FBL_BUSDFN) : + if (($3 != FBL_GRDDFN) || (FBL_GRDLST == NULL)) + { + fbl_error (23,$1.NAME); + } + fbbus_pnt = (struct fbbus *) + chktab (hshtab,$1.NAME,FBL_MODNAM,FBL_PNTDFN); + if (FBL_ERRFLG == 0) + { + for (i=0 ; i= in_bound) + { + fbbus_pnt->BINODE = fbh_addbinode (fbbus_pnt->BINODE, + NULL,NULL); + fbbus_pnt->BIABL = fbh_addbiabl (fbbus_pnt->BIABL, + FBL_LBLNAM, + dupablexpr(FBL_GRDLST->DATA) , + abl_pnt->DATA); + abl_pnt = abl_pnt->NEXT; + } + if (i >= out_bound) + break; + fbbus_pnt = fbbus_pnt->NEXT; + } + } + break; + + case (FBL_BITDFN + FBL_NORDFN): + if ($3 == FBL_GRDDFN) + { + fbl_error (22,$1.NAME); + } + fbaux_pnt = (struct fbaux *) + chktab (hshtab,$1.NAME,FBL_MODNAM,FBL_PNTDFN); + if (FBL_ERRFLG == 0) + { + for (i=0 ; i= in_bound) + { + if (fbaux_pnt->ABL != NULL) + { + fbl_error (39,fbaux_pnt->NAME); + } + else + fbaux_pnt->ABL = (struct chain *)abl_pnt->DATA; + abl_pnt = abl_pnt->NEXT; + } + if (i >= out_bound) + break; + fbaux_pnt = fbaux_pnt->NEXT; + } + } + break; + + case (FBL_RBIDFN + FBL_REGDFN): + if (($3 != FBL_GRDDFN) || (FBL_GRDLST == NULL)) + { + fbl_error (23,$1.NAME); + } + fbreg_pnt = (struct fbreg *) + chktab (hshtab,$1.NAME,FBL_MODNAM,FBL_PNTDFN); + if (FBL_ERRFLG == 0) + { + for (i=0 ; i= in_bound) + { + fbreg_pnt->BINODE = fbh_addbinode (fbreg_pnt->BINODE, + NULL,NULL); + fbreg_pnt->BIABL = fbh_addbiabl (fbreg_pnt->BIABL, + FBL_LBLNAM, + dupablexpr(FBL_GRDLST->DATA) , + abl_pnt->DATA); + abl_pnt = abl_pnt->NEXT; + } + if (i >= out_bound) + break; + fbreg_pnt = fbreg_pnt->NEXT; + } + } + break; + + case (FBL_MUXDFN + FBL_BUSDFN) : + case (FBL_WORDFN + FBL_BUSDFN) : + if (($3 != FBL_GRDDFN) || (FBL_GRDLST == NULL)) + { + fbl_error (23,$1.NAME); + } + fbbux_pnt = (struct fbbux *) + chktab (hshtab,$1.NAME,FBL_MODNAM,FBL_PNTDFN); + if (FBL_ERRFLG == 0) + { + for (i=0 ; i= in_bound) + { + fbbux_pnt->BINODE = fbh_addbinode (fbbux_pnt->BINODE, + NULL,NULL); + fbbux_pnt->BIABL = fbh_addbiabl (fbbux_pnt->BIABL, + FBL_LBLNAM, + dupablexpr(FBL_GRDLST->DATA) , + abl_pnt->DATA); + abl_pnt = abl_pnt->NEXT; + } + if (i >= out_bound) + break; + fbbux_pnt = fbbux_pnt->NEXT; + } + } + break; + + default : + { + fbl_error (17,$1.NAME); + } + break; + } + } + ; + +..waveform__WHEN__condition__ELSE.. + : /*empty*/ + | ..waveform__WHEN__condition__ELSE.. + waveform + WHEN + expression + ELSE + { + struct fbl_expr *expr_pnt; + + expr_pnt = (fbl_ablstr *)mbkalloc(sizeof(fbl_ablstr)); + expr_pnt->WIDTH = $4.WIDTH; + expr_pnt->LIST_ABL = $4.LIST_ABL; + FBL_CNDLST = addchain (FBL_CNDLST,(char *) expr_pnt); + + expr_pnt = (fbl_ablstr *)mbkalloc(sizeof(fbl_ablstr)); + expr_pnt->WIDTH = $2.WIDTH; + expr_pnt->LIST_ABL = $2.LIST_ABL; + FBL_VALLST = addchain (FBL_VALLST,(char *) expr_pnt); + } + ; + +unlabeled_selected_signal_assignment + : WITH + expression + { + FBL_SLCEXP = $2; + FBL_BDDPNT = NULL; + } + SELECT + target + _LESym + .GUARDED. + waveform__WHEN__choices + ...waveform__WHEN__choices.. + Semicolon_ERR + { + int i; + struct fbout *fbout_pnt; + struct fbbus *fbbus_pnt; + struct fbreg *fbreg_pnt; + struct fbaux *fbaux_pnt; + struct fbbux *fbbux_pnt; + struct chain *abl_pnt; + struct fbl_expr expr1; + int rev_flg = 0; + int left_bnd; + int right_bnd; + int left; + int right; + int in_bound; + int out_bound; + int sig_width; + int sig_conf; + + expr1 = fbl_crtabl (ABL_OR ,$8 ,$9,-1,-1); + if (FBL_BDDPNT != getlogbddnodeone()) + { + fbl_error (25,NULL); + } + left_bnd = chktab (hshtab,$5.NAME,FBL_MODNAM,FBL_WMNDFN); + right_bnd = chktab (hshtab,$5.NAME,FBL_MODNAM,FBL_WMXDFN); + sig_conf = chktab (hshtab,$5.NAME,FBL_MODNAM,FBL_SIGDFN); + + left = $5.LEFT; + right = $5.RIGHT; + if (left_bnd <= right_bnd) + { + sig_width = right_bnd - left_bnd + 1; + if (left <= right) + { + rev_flg = 0; + in_bound = right_bnd - right; + out_bound = right_bnd - left; + if ((left < left_bnd) || (right > right_bnd)) + { + fbl_error (36,$5.NAME); + } + } + else + { + rev_flg = 1; + in_bound = right_bnd - left; + out_bound = right_bnd - right; + if ((left > right_bnd) || (right < left_bnd)) + { + fbl_error (36,$5.NAME); + } + } + } + else + { + sig_width = left_bnd - right_bnd + 1; + if (left <= right) + { + rev_flg = 1; + in_bound = left - right_bnd; + out_bound = right - right_bnd; + if ((left < right_bnd) || (right > left_bnd)) + { + fbl_error (36,$5.NAME); + } + } + else + { + rev_flg = 0; + in_bound = right - right_bnd; + out_bound = left - right_bnd; + if ((left > left_bnd) || (right < right_bnd)) + { + fbl_error (36,$5.NAME); + } + } + } + + if ((out_bound - in_bound + 1) != expr1.WIDTH) + { + fbl_error (35,$5.NAME); + } + + if (rev_flg == 1) + expr1.LIST_ABL = reverse (expr1.LIST_ABL); + + abl_pnt = expr1.LIST_ABL; + + switch (sig_conf) + { + case (FBL_ICNDFN + FBL_BITDFN + FBL_NORDFN) : + { + fbl_error (21,$5.NAME); + } + break; + + case (FBL_OCNDFN + FBL_BITDFN + FBL_NORDFN) : + case (FBL_BCNDFN + FBL_BITDFN + FBL_NORDFN) : + if ($7 == FBL_GRDDFN) + { + fbl_error (22,$5.NAME); + } + fbout_pnt = (struct fbout *) + chktab (hshtab,$5.NAME,FBL_MODNAM,FBL_PNTDFN); + if (FBL_ERRFLG == 0) + { + for (i=0 ; i= in_bound) + { + if (fbout_pnt->ABL != NULL) + { + fbl_error (39,fbout_pnt->NAME); + } + else + fbout_pnt->ABL = (struct chain *)abl_pnt->DATA; + abl_pnt = abl_pnt->NEXT; + } + if (i >= out_bound) + break; + fbout_pnt = fbout_pnt->NEXT; + } + } + break; + + case (FBL_OCNDFN + FBL_MUXDFN + FBL_BUSDFN) : + case (FBL_OCNDFN + FBL_WORDFN + FBL_BUSDFN) : + case (FBL_BCNDFN + FBL_MUXDFN + FBL_BUSDFN) : + case (FBL_BCNDFN + FBL_WORDFN + FBL_BUSDFN) : + if (($7 != FBL_GRDDFN) || (FBL_GRDLST == NULL)) + { + fbl_error (23,$5.NAME); + } + fbbus_pnt = (struct fbbus *) + chktab (hshtab,$5.NAME,FBL_MODNAM,FBL_PNTDFN); + if (FBL_ERRFLG == 0) + { + for (i=0 ; i= in_bound) + { + fbbus_pnt->BINODE = fbh_addbinode (fbbus_pnt->BINODE, + NULL,NULL); + fbbus_pnt->BIABL = fbh_addbiabl (fbbus_pnt->BIABL, + FBL_LBLNAM, + dupablexpr(FBL_GRDLST->DATA) , + abl_pnt->DATA); + abl_pnt = abl_pnt->NEXT; + } + if (i >= out_bound) + break; + fbbus_pnt = fbbus_pnt->NEXT; + } + } + break; + + case (FBL_BITDFN + FBL_NORDFN): + if ($7 == FBL_GRDDFN) + { + fbl_error (22,$5.NAME); + } + fbaux_pnt = (struct fbaux *) + chktab (hshtab,$5.NAME,FBL_MODNAM,FBL_PNTDFN); + if (FBL_ERRFLG == 0) + { + for (i=0 ; i= in_bound) + { + if (fbaux_pnt->ABL != NULL) + { + fbl_error (39,fbaux_pnt->NAME); + } + else + { + fbaux_pnt->ABL = (struct chain *)abl_pnt->DATA; + } + abl_pnt = abl_pnt->NEXT; + } + if (i >= out_bound) + break; + fbaux_pnt = fbaux_pnt->NEXT; + } + } + break; + + case (FBL_RBIDFN + FBL_REGDFN): + if (($7 != FBL_GRDDFN) || (FBL_GRDLST == NULL)) + { + fbl_error (23,$5.NAME); + } + fbreg_pnt = (struct fbreg *) + chktab (hshtab,$5.NAME,FBL_MODNAM,FBL_PNTDFN); + if (FBL_ERRFLG == 0) + { + for (i=0 ; i= in_bound) + { + fbreg_pnt->BINODE = fbh_addbinode (fbreg_pnt->BINODE, + NULL,NULL); + fbreg_pnt->BIABL = fbh_addbiabl (fbreg_pnt->BIABL, + FBL_LBLNAM, + dupablexpr(FBL_GRDLST->DATA) , + abl_pnt->DATA); + abl_pnt = abl_pnt->NEXT; + } + if (i >= out_bound) + break; + fbreg_pnt = fbreg_pnt->NEXT; + } + } + break; + + case (FBL_MUXDFN + FBL_BUSDFN) : + case (FBL_WORDFN + FBL_BUSDFN) : + if (($7 != FBL_GRDDFN) || (FBL_GRDLST == NULL)) + { + fbl_error (23,$5.NAME); + } + fbbux_pnt = (struct fbbux *) + chktab (hshtab,$5.NAME,FBL_MODNAM,FBL_PNTDFN); + if (FBL_ERRFLG == 0) + { + for (i=0 ; i= in_bound) + { + fbbux_pnt->BINODE = fbh_addbinode (fbbux_pnt->BINODE, + NULL,NULL); + fbbux_pnt->BIABL = fbh_addbiabl (fbbux_pnt->BIABL, + FBL_LBLNAM, + dupablexpr(FBL_GRDLST->DATA) , + abl_pnt->DATA); + abl_pnt = abl_pnt->NEXT; + } + if (i >= out_bound) + break; + fbbux_pnt = fbbux_pnt->NEXT; + } + } + break; + + default : + { + fbl_error (17,$5.NAME); + } + break; + } + } + ; +/* FIN LUDO */ + +process_statement + : a_label + { + FBL_LBLNAM = namealloc($1); + } + unlabeled_process_statement + | { + char buffer[ 64 ]; + + sprintf( buffer, "process_%d", FBL_LINNUM ); + FBL_LBLNAM = namealloc( buffer ); + } + unlabeled_process_statement + ; + +unlabeled_process_statement + : PROCESS + {FBL_NM1LST = 0 ;} + .sensitivity_list. + { FBL_BEFPNT->BEPCS = fbh_addfbpcs(FBL_BEFPNT->BEPCS,FBL_LBLNAM,FBL_NM1LST,0,0,0); + FBL_BEFPNT->BEPCS->USER = (void *)FBL_LINNUM; + FBL_NM1LST = 0; } + process_declarative_part + _BEGIN + { + void *pnt; + pnt = (void *)(&(FBL_BEFPNT->BEPCS->INSTRUCTION)); + FBL_NM1LST = addchain(0,pnt); + } + + sequence_of_statements + { + struct ptype **pnt; + struct ptype *ptype; + pnt = (struct ptype**)FBL_NM1LST->DATA; + ptype = reversetype(*pnt); + *pnt = ptype; + FBL_NM1LST = delchain (FBL_NM1LST, FBL_NM1LST); + } + END_ERR + PROCESS + .label. + Semicolon_ERR + { + yyerrok; + } + ; + +process_declarative_part + : ..process_declarative_item.. + ; + + +..process_declarative_item.. + : /*empty*/ + | ..process_declarative_item.. + process_declarative_item + { + yyerrok; + } + ; + +process_declarative_item + : constant_declaration + | type_declaration + | subtype_declaration + ; + +.sensitivity_list. + : /*empty*/ + | sensitivity_list + ; + +sensitivity_list + : LeftParen + signal_list + RightParen + ; + +signal_list + : name + ...name.. + { + if($1.TYPE == 0) + { + fbl_error(17,$1.NAME) ; + } + FBL_NM1LST = addchain (FBL_NM1LST,$1.NAME); } + ; + +...name.. + : /*empty*/ + | Comma + name + ...name.. + { + if($2.TYPE == 0) + { + fbl_error(17,$2.NAME) ; + } + FBL_NM1LST = addchain (FBL_NM1LST,$2.NAME); } + ; + +sequence_of_statements + : ..sequential_statement.. + ; + +..sequential_statement.. + : /*empty*/ + | ..sequential_statement.. + sequential_statement + ; + +sequential_statement + : assertion_statement + | signal_assignment_statement + | if_statement + | case_statement + | null_statement + ; + + +assertion_statement + : ASSERT + expression + .REPORT__expression. + .SEVERITY__expression. + Semicolon_ERR + { + FBL_BEFPNT->BEMSG = fbh_addfbmsg(FBL_BEFPNT->BEMSG,0,$4,$3,$2.LIST_ABL->DATA,0); + FBL_BEFPNT->BEMSG->USER = (void *)FBL_LINNUM; + } + ; + +signal_assignment_statement + : target + _LESym + waveform + Semicolon_ERR + { unsigned int type; + int sig_conf,i; + int left_bnd,right_bnd; + int in_bound,out_bound; + int left ,right; + int rev_flg, debut; + int sig_width; + struct chain *abl_pnt; + char extname[100]; + struct fbl_expr expr; + struct ptype **pnt; + struct fbaux *fbaux_pnt; + struct fbout *fbout_pnt; + + type = chktab(hshtab,$1.NAME,FBL_MODNAM,FBL_TYPDFN); + sig_conf = chktab(hshtab,$1.NAME,FBL_MODNAM,FBL_SIGDFN); + + if( type == 0) + { + fbl_error(17,$1.NAME); + } + + addauthelem( FBL_HASH_ASG_FSM, $1.NAME, 1 ); + + left_bnd = chktab (hshtab,$1.NAME,FBL_MODNAM,FBL_WMNDFN); + right_bnd = chktab (hshtab,$1.NAME,FBL_MODNAM,FBL_WMXDFN); + + left = $1.LEFT; + right = $1.RIGHT; + + expr = $3; + + if (left_bnd <= right_bnd) + { + sig_width = right_bnd - left_bnd + 1; + if (left <= right) + { + rev_flg = 0; + in_bound = right_bnd - right; + out_bound = right_bnd - left; + if ((left < left_bnd) || (right > right_bnd)) + { + fbl_error (36,$1.NAME); + } + debut = left; + } + + else + { + rev_flg = 1; + in_bound = right_bnd - left; + out_bound = right_bnd - right; + if ((left > right_bnd) || (right < left_bnd)) + { + fbl_error (36,$1.NAME); + } + debut = right; + } + } + else + { + sig_width = left_bnd - right_bnd + 1; + if (left <= right) + { + rev_flg = 1; + in_bound = left - right_bnd; + out_bound = right - right_bnd; + if ((left < right_bnd) || (right > left_bnd)) + { + fbl_error (36,$1.NAME); + } + debut = left; + } + else + { + rev_flg = 0; + in_bound = right - right_bnd; + out_bound = left - right_bnd; + if ((left > left_bnd) || (right < right_bnd)) + { + fbl_error (36,$1.NAME); + } + debut = right; + } + } + if ((out_bound - in_bound + 1) != expr.WIDTH) + { + fbl_error (35,$1.NAME); + } + + if (rev_flg == 1) + expr.LIST_ABL = reverse (expr.LIST_ABL); + + abl_pnt = expr.LIST_ABL; + + + if( sig_conf == FBL_ICNDFN) + { + fbl_error(21,$1.NAME); + } + /* LUDO + else if( sig_conf == 0) + { + fbl_error(17,$1.NAME); + } + */ + else + { + pnt = (struct ptype**)(FBL_NM1LST->DATA); + if(sig_width >1) + { + for (i=0 ; i= in_bound) + { + *pnt =fbh_addfbasg(*pnt,newname, (struct chain *)abl_pnt->DATA,type); + ((struct fbasg *)((*pnt)->DATA))->USER = (void *)FBL_LINNUM; + abl_pnt = abl_pnt->NEXT; + + addauthelem( FBL_HASH_ASG_FSM, newname, 1 ); + } + if (i >= out_bound) + break; + } + } + else + { + *pnt = fbh_addfbasg(*pnt,$1.NAME,abl_pnt->DATA,type); + ((struct fbasg *)((*pnt)->DATA))->USER = (void *)FBL_LINNUM; + } + } + } + ; + +waveform_element + : expression + { $$ = $1; } + ; + +if_statement + : IF + condition + THEN + { + struct ptype **pnt; + pnt = (struct ptype**)FBL_NM1LST->DATA; + *pnt = fbh_addfbifs(*pnt,$2.LIST_ABL->DATA); + ((struct fbifs *)((*pnt)->DATA))->USER = (void *)FBL_LINNUM; + FBL_NM1LST = addchain(FBL_NM1LST,&(((struct fbifs*)(*pnt)->DATA)->CNDTRUE)); + } + sequence_of_statements + { + struct ptype **pnt; + struct ptype *ptype; + pnt = (struct ptype**)FBL_NM1LST->DATA; + ptype = reversetype(*pnt); + *pnt = ptype; + FBL_NM1LST = delchain (FBL_NM1LST, FBL_NM1LST); + pnt = (struct ptype**)FBL_NM1LST->DATA; + FBL_NM1LST = addchain(FBL_NM1LST,&(((struct fbifs*)(*pnt)->DATA)->CNDFALSE)); + } + ..ELSIF__THEN__seq_of_stmts.. + .ELSE__seq_of_stmts. + END_ERR + IF + Semicolon_ERR + ; + +..ELSIF__THEN__seq_of_stmts.. + : /*empty*/ + | ..ELSIF__THEN__seq_of_stmts.. + ELSIF + condition + THEN + { + struct ptype **pnt; + pnt = (struct ptype**)FBL_NM1LST->DATA; + *pnt = fbh_addfbifs(*pnt,$3.LIST_ABL->DATA); + ((struct fbifs *)((*pnt)->DATA))->USER = (void *)FBL_LINNUM; + FBL_NM1LST = addchain(FBL_NM1LST,(void*)&((struct fbifs*)(*pnt)->DATA)->CNDTRUE); + } + sequence_of_statements + { + struct ptype **pnt; + struct ptype *ptype; + pnt = (struct ptype**)FBL_NM1LST->DATA; + ptype = reversetype(*pnt); + *pnt = ptype; + FBL_NM1LST = delchain (FBL_NM1LST, FBL_NM1LST); + pnt = (struct ptype**)FBL_NM1LST->DATA; + FBL_NM1LST = delchain (FBL_NM1LST, FBL_NM1LST); + FBL_NM1LST = addchain(FBL_NM1LST,&((struct fbifs*)(*pnt)->DATA)->CNDFALSE); + yyerrok; } + ; + +.ELSE__seq_of_stmts. + : /*empty*/ + { + FBL_NM1LST = delchain (FBL_NM1LST, FBL_NM1LST); + yyerrok; + } + | ELSE + sequence_of_statements + { + struct ptype *ptype; + struct ptype **pnt; + pnt = (struct ptype**)FBL_NM1LST->DATA; + ptype = reversetype(*pnt); + *pnt = ptype; + FBL_NM1LST = delchain (FBL_NM1LST, FBL_NM1LST); + yyerrok; + } + ; + +case_statement + : CASE + expression + { + struct ptype **pnt; + + pnt = (struct ptype**)FBL_NM1LST->DATA; + + /*fbcas = (struct fbcas *)mbkalloc(sizeof(struct fbcas)); + fbcas->CHOICE = 0; + fbcas->USER = 0; + fbcas->SIZE = 0; + fbcas->TYPE = $2.TYPE; + fbcas->ABL = $2.LIST_ABL->DATA;*/ + FBL_OTHPNT = 0; + *pnt = fbh_addfbcas(*pnt,$2.LIST_ABL->DATA,$2.TYPE); + ((struct fbcas *)((*pnt)->DATA))->USER = (void *)FBL_LINNUM; + FBL_NM1LST = addchain(FBL_NM1LST,(void*)&(((struct fbcas*)((*pnt)->DATA))->SIZE)); + FBL_NM1LST = addchain(FBL_NM1LST,(void*)&(((struct fbcas*)(*pnt)->DATA)->CHOICE)); + } + IS + case_statement_alternative + ..case_statement_alternative.. + END_ERR + CASE + Semicolon_ERR + { + unsigned int size=1; + unsigned int *size1; + int indice=0; + struct choice_chain *ch; + struct fbcho **pnt; + struct fbcho *tab; + struct choice_chain *nm1lst; + + + nm1lst = FBL_CASPNT; + while (nm1lst != 0) + { + size++; + nm1lst = nm1lst->NEXT; + } + pnt = (struct fbcho**)FBL_NM1LST->DATA; + FBL_NM1LST = delchain(FBL_NM1LST,FBL_NM1LST); + if( size != 0) + tab = (struct fbcho*)mbkalloc(size*sizeof(struct fbcho)); + while(FBL_CASPNT) + { + tab[indice].INSTRUCTION = reversetype(FBL_CASPNT->INSTRUCTION); + tab[indice].SIZE = FBL_CASPNT->SIZE; + tab[indice++].VALUE = FBL_CASPNT->VALUE; + ch = FBL_CASPNT; + FBL_CASPNT =FBL_CASPNT->NEXT; + /*free(ch);*/ + } + tab[indice].INSTRUCTION = reversetype(FBL_OTHPNT); + tab[indice].SIZE = -1; + tab[indice++].VALUE = namealloc("others"); + (*pnt) = tab; + size1 = (unsigned int*) FBL_NM1LST->DATA; + *size1 = size; + FBL_NM1LST = delchain(FBL_NM1LST,FBL_NM1LST); + FBL_OTHPNT = 0; + } + ; + +..case_statement_alternative.. + : /*empty*/ + | ..case_statement_alternative.. + case_statement_alternative + { yyerrok; } + ; + +case_statement_alternative + : WHEN + choices + Arrow { + FBL_PTYPE = 0; + FBL_NM1LST = addchain(FBL_NM1LST,(void*)&FBL_PTYPE); + } + sequence_of_statements + { + if( FBL_CNDLST == 0) + { + fbl_error(85,"case"); + } + else if ( FBL_CNDLST->DATA == 0) + { + FBL_OTHPNT = FBL_PTYPE ; + while (FBL_CNDLST ) + { + FBL_CNDLST = delchain(FBL_CNDLST,FBL_CNDLST); + } + } + else + while(FBL_CNDLST) + { + char* val; + val = (char *)FBL_CNDLST->DATA; + FBL_CASPNT = order_choice(FBL_CASPNT,FBL_PTYPE,val,strlen(val)); + FBL_CNDLST = delchain(FBL_CNDLST,FBL_CNDLST); + } + FBL_NM1LST = delchain(FBL_NM1LST,FBL_NM1LST); + } + ; + +/* DEBUT LUDO */ + +...waveform__WHEN__choices.. + : /*empty*/ + { + $$ = FBL_EMPSTR; + } + | ...waveform__WHEN__choices.. + Comma + waveform__WHEN__choices + { + $$ = fbl_crtabl (ABL_OR,$1,$3,-1,-1); + } + ; + +waveform__WHEN__choices + : waveform + WHEN + choices2 + { + fbl_ablstr expr1; + + fbl_select (&expr1,FBL_NM1LST,&FBL_BDDPNT,&FBL_SLCEXP); + freechain (FBL_NM1LST); + FBL_NM1LST = NULL; + + $$ = fbl_crtabl(ANDM,$1,expr1,-1,-1); + } + ; + +choices2 + : choice + { + FBL_NM1LST = addchain (NULL ,$1.NAME); + } + ..Bar__choice2.. + { yyerrok; } + ; + +..Bar__choice2.. + : /*empty*/ + | ..Bar__choice2.. + Bar + choice + { + if ($3.NAME == "others") + { + fbl_error (30,NULL); + } + FBL_NM1LST = addchain (FBL_NM1LST ,$3.NAME); + fprintf( stdout, "%s%d: %s\n", __FILE__,__LINE__,$3.NAME ); + } + ; + + +/* FIN LUDO */ + +waveform + : waveform_element + { $$ = $1; } + ; + +choices + : choice + { + if (strcmp($1.NAME , "others")) + FBL_CNDLST = addchain (0 ,(void*)$1.NAME); + else + FBL_CNDLST = addchain (0 ,0); + } + ..Bar__choice.. + { yyerrok; } + ; + +null_statement + : _NULL + Semicolon_ERR + ; + +..Bar__choice.. + : /*empty*/ + | ..Bar__choice.. + Bar + choice + { + if (!strcmp($3.NAME , "others") || FBL_CNDLST->DATA == 0) + { + fbl_error (31,0); + } + FBL_CNDLST = addchain (FBL_CNDLST ,(void*)$3.NAME); + } + ; + +choice + : literal + { + $$.NAME = $1; + $$.RIGHT = -1; + $$.TYPE = -1; + $$.LEFT = -1;} + | OTHERS + { + $$.RIGHT = -1; + $$.TYPE = -1; + $$.LEFT = -1; + $$.NAME = namealloc("others");} + | name + { + char *val; + char val2[256]; + int left; + int right; + int in_bound; + int out_bound; + int left_bnd; + int right_bnd; + int sig_conf; + + strcpy (val2,"B\""); + sig_conf = chktab (hshtab,$1.NAME,FBL_MODNAM,FBL_SIGDFN); + val = (char *) chktab (hshtab,$1.NAME,0,FBL_PNTDFN); + if (sig_conf == 0) + { + fbl_error (17,$1.NAME); + } + else + { + if (sig_conf != FBL_CSTDFN) + { + fbl_error (76,$1.NAME); + } + } + + left_bnd = chktab (hshtab,$1.NAME,FBL_MODNAM,FBL_WMNDFN); + right_bnd = chktab (hshtab,$1.NAME,FBL_MODNAM,FBL_WMXDFN); + + left = $1.LEFT; + right = $1.RIGHT; + + if (left_bnd <= right_bnd) + { + if (left <= right) + { + in_bound = left - left_bnd; + out_bound = right - left_bnd; + if ((left < left_bnd) || (right > right_bnd)) + { + fbl_error (36,$1.NAME); + } + } + else + { + in_bound = left - right_bnd; + out_bound = right - right_bnd; + if ((left > right_bnd) || (right < left_bnd)) + { + fbl_error (36,$1.NAME); + } + } + } + else + { + if (left <= right) + { + in_bound = right - left_bnd; + out_bound = left - left_bnd; + if ((left < right_bnd) || (right > left_bnd)) + { + fbl_error (36,$1.NAME); + } + } + else + { + in_bound = right - right_bnd; + out_bound = left - right_bnd; + if ((left > left_bnd) || (right < right_bnd)) + { + fbl_error (36,$1.NAME); + } + } + } + if( chktab (hshtab,$1.NAME,FBL_MODNAM,FBL_TYPDFN) == -1) + { + fbl_tobin (&val2[2],val,in_bound,out_bound); + strcat (val2,"\""); + $$.NAME = namealloc (val2); + $$.LEFT = -1; + $$.RIGHT = -1; + $$.TYPE = -1; + } + else + { + $$.LEFT = $1.LEFT; + $$.RIGHT = $1.RIGHT; + $$.TYPE = $1.TYPE; + /* sig_conf = chktab(hshtab,$1.NAME,FBL_MODNAM,FBL_LBLDFN) ; + $$.NAME = (char *)fbl_numtobin(sig_conf); */ + $$.NAME = $1.NAME; + } + } + ; + +condition + : expression + { $$ = $1; } + ; + +.REPORT__expression. + : /*empty*/ + { $$ = 0;} + | REPORT + report__message + { $$ = $2;} + ; + +.SEVERITY__expression. + : /*empty*/ + { $$ = 'E';} + | SEVERITY + severity__message + { $$ = $1;} + ; + +report__message + : StringLit + { fbl_stostr($1);} + ; + +severity__message + : ERROR + { $$ = 'E';} + | WARNING + { $$ = 'W';} + ; + +expression + : relation..AND__relation.. + { $$ = $1; } + | relation..OR__relation.. + { $$ = $1; } + | relation.NAND_NOR__relation. + { $$ = $1; } + | relation..XOR__relation.. + { $$ = $1; } + ; + +relation..AND__relation.. + : relation + _AND + relation + { $$ = fbl_crtabl (ABL_AND ,$1 ,$3 ,-1,-1); } + | relation..AND__relation.. + _AND + relation + { $$ = fbl_crtabl (ABL_AND ,$1 ,$3 ,-1,-1);} + ; + +relation..OR__relation.. + : relation + _OR + relation + { $$ = fbl_crtabl (ABL_OR ,$1 ,$3 ,-1,-1); } + | relation..OR__relation.. + _OR + relation + { $$ = fbl_crtabl (ABL_OR ,$1 ,$3 ,-1,-1); } + ; + +relation.NAND_NOR__relation. + : relation + { $$ = $1; } + | relation + _NAND + relation + { $$ = fbl_crtabl (ABL_NAND ,$1 ,$3 ,-1,-1); } + | relation + _NOR + relation + { $$ = fbl_crtabl (ABL_NAND ,$1 ,$3 ,-1,-1); } + ; + +relation..XOR__relation.. + : relation + _XOR + relation + { $$ = fbl_crtabl (ABL_XOR ,$1 ,$3 ,-1,-1); } + | relation..XOR__relation.. + _XOR + relation + { $$ = fbl_crtabl (ABL_XOR ,$1 ,$3 ,-1,-1); } + ; + +relation + : simple_expression + { $$ = $1; } + | simple_expression + relational_operator + simple_expression + { $$ = fbl_crtabl ($2 ,$1 ,$3 ,-1,-1); } + ; + +simple_expression + : .sign.term..add_op__term.. + { $$ = $1; } + ; + +.sign.term..add_op__term.. + : term + { $$ = $1; } + | .sign.term..add_op__term.. + Ampersand + term + { $$ = fbl_crtabl (CONC,$1,$3,-1,-1); } + ; + +term + : factor + { $$ = $1; } + ; + +factor + : primary + { $$ = $1; } + | _NOT + primary + { $$ = fbl_crtabl (ABL_NOT,$2,FBL_EMPSTR,-1,-1); } + ; + +primary + : literal + { + struct fbl_expr expr1; + + expr1.IDENT = $1; + expr1.TYPE = -1; + $$ = fbl_crtabl (NOPS,expr1,FBL_EMPSTR,-1,-1); + } + | aggregate + { $$ = $1; } + | name + { + struct fbl_expr expr1; + int left; + int right; + int left_bnd; + int right_bnd; + int in_bound; + int out_bound; + int mode; + int prtype; + int type; + + mode = chktab (hshtab,$1.NAME,FBL_MODNAM,FBL_SIGDFN); + type = chktab(hshtab,$1.NAME,FBL_MODNAM,FBL_TYPDFN); + if( mode == FBL_OCNDFN) + { + { + fbl_error (26,$1.NAME); + } + $$.IDENT = 0; + $$.LIST_ABL = 0; + $$.WIDTH = 0; + $$.TYPE = 0; + } + else if( type == 0 || mode == FBL_TPEDFN) + { + { + fbl_error (17,$1.NAME); + } + $$.IDENT = 0; + $$.LIST_ABL = 0; + $$.WIDTH = 0; + $$.TYPE = 0; + } + else + { + left_bnd = chktab (hshtab,$1.NAME,FBL_MODNAM,FBL_WMNDFN); + right_bnd = chktab (hshtab,$1.NAME,FBL_MODNAM,FBL_WMXDFN); + + left = $1.LEFT; + right = $1.RIGHT; + + if (left_bnd <= right_bnd) + { + if (left <= right) + { + in_bound = left - left_bnd; + out_bound = right - left_bnd; + if ((left < left_bnd) || (right > right_bnd)) + { + fbl_error (36,$1.NAME); + } + } + else + { + in_bound = right - left_bnd; + out_bound = left - left_bnd; + if ((left > right_bnd) || (right < left_bnd)) + { + fbl_error (36,$1.NAME); + } + } + } + else + { + if (left <= right) + { + in_bound = left - right_bnd; + out_bound = right - right_bnd; + if ((left < right_bnd) || (right > left_bnd)) + { + fbl_error (36,$1.NAME); + } + } + else + { + in_bound = right - right_bnd; + out_bound = left - right_bnd; + if ((left > left_bnd) || (right < right_bnd)) + { + fbl_error (36,$1.NAME); + } + } + } + + /* LUDO + if ( mode == FBL_VARDFN) + { + expr1.IDENT = 0; + expr1.TYPE = chktab(hshtab,$1.NAME,FBL_MODNAM,FBL_TYPDFN); + + expr1.LIST_ABL = (struct chain *)chktab(hshtab,$1.NAME,FBL_MODNAM,FBL_PNTDFN); + $$ = fbl_crtabl (SUBVAR,expr1,FBL_EMPSTR,in_bound,out_bound); + } + else + */ + if ((mode != FBL_CSTDFN)|| + (chktab(hshtab,$1.NAME,FBL_MODNAM,FBL_TYPDFN) != -1)) + { + expr1.IDENT = $1.NAME; + prtype = chktab(hshtab,$1.NAME,FBL_MODNAM,FBL_USRDFN); + if(val_type((FBL_BEFPNT->BETYP + type -1)->NAME) !=-1) + expr1.TYPE = chktab(hshtab,namealloc("bit"),FBL_MODNAM,FBL_TYPDFN); + else + expr1.TYPE = type; + if($1.FLAG == 'X') + { + expr1 = fbl_crtabl (NOPI,expr1,FBL_EMPSTR,left,right); + $$ = fbl_crtabl (ABL_STABLE,expr1,FBL_EMPSTR,left,right); + } + else + if($1.FLAG == 'x') + { + expr1 = fbl_crtabl (NOPI,expr1,FBL_EMPSTR,left,right); + expr1 = fbl_crtabl (ABL_STABLE,expr1,FBL_EMPSTR,left,right); + $$ = fbl_crtabl (ABL_NOT,expr1,FBL_EMPSTR,left,right); + } + else + { + $$ = fbl_crtabl (NOPI,expr1,FBL_EMPSTR,left,right); + } + } + else + { + expr1.IDENT = (char *)chktab(hshtab,$1.NAME,0,FBL_PNTDFN); + expr1.TYPE =(int)-1;/*dec, cast int */ + $$ = fbl_crtabl (NOPS,expr1,FBL_EMPSTR,in_bound,out_bound); + } + } + } + ; + +relational_operator + : _EQSym + { $$ = EQ; } + | _NESym + { $$ = NE; } + | _GESym + { $$ = GE; } + | _GTSym + { $$ = GT; } + | _LESym + { $$ = LE; } + | _LTSym + { $$ = LT; } + ; + +literal + : CharacterLit + { $$ = $1; } + | StringLit + { $$ = $1; } + | BitStringLit + { $$ = $1; } + ; + +aggregate + : LeftParen + expression + RightParen + { $$ = $2; } + ; + +name + : simple_name + { + $$.NAME = $1; + $$.TYPE = chktab (hshtab,$1,FBL_MODNAM,FBL_TYPDFN); + $$.LEFT = chktab (hshtab,$1,FBL_MODNAM,FBL_WMNDFN); + $$.RIGHT = chktab (hshtab,$1,FBL_MODNAM,FBL_WMXDFN); + } + | indexed_name + { $$ = $1; } + | slice_name + { $$ = $1; } + | attribute_name + { $$ = $1; } + ; + +indexed_name + : simple_name + LeftParen + abstractlit + RightParen_ERR + { + $$.NAME = $1; + $$.LEFT = $3; + $$.TYPE = chktab (hshtab,$1,FBL_MODNAM,FBL_TYPDFN); + $$.RIGHT = $3; + } + ; + +slice_name + : simple_name + LeftParen + abstractlit + direction + abstractlit + RightParen_ERR + { + if ((($3 > $5) && ($4 == FBL_UPTDFN)) || + (($3 < $5) && ($4 == FBL_DWTDFN))) + { + fbl_error (32,$1); + } + + $$.NAME = $1; + $$.TYPE = chktab (hshtab,$1,FBL_MODNAM,FBL_TYPDFN); + $$.LEFT = $3; + $$.RIGHT = $5; + } + ; + +attribute_name + : simple_name + Apostrophe + attribute_designator + { + char extname[100]; + char *lclname; + int sig_conf; + int type; + int kind; + struct fbl_expr expr1; + struct fbl_expr expr2; + struct chain *ptabl; + + sprintf (extname,"%s'delayed",$1); + lclname = namealloc (extname); + + if (chktab (hshtab,lclname,FBL_MODNAM,FBL_SIGDFN) == 0 ) + { + sig_conf = chktab (hshtab,$1,FBL_MODNAM,FBL_SIGDFN); + switch (sig_conf) + { + case (FBL_ICNDFN + FBL_BITDFN + FBL_NORDFN) : + case (FBL_BCNDFN + FBL_BITDFN + FBL_NORDFN) : + case (FBL_BCNDFN + FBL_MUXDFN + FBL_BUSDFN) : + case (FBL_BCNDFN + FBL_WORDFN + FBL_BUSDFN) : + case (FBL_BITDFN + FBL_NORDFN): + case (FBL_MUXDFN + FBL_BUSDFN): + case (FBL_WORDFN + FBL_BUSDFN): + case (FBL_RBIDFN + FBL_REGDFN): + break; + default : + { + fbl_error (79,$1); + } + } + type = chktab (hshtab,$1,FBL_MODNAM,FBL_TYPDFN); + kind = chktab (hshtab,$1,FBL_MODNAM,FBL_LBLDFN); + + if (chktab (hshtab,$1,FBL_MODNAM,FBL_WMNDFN) != -1) + { + fbl_error (79,$1); + } + + if (FBL_ERRFLG == 0) + { + expr1.IDENT = $1; + expr1.WIDTH = 1; + expr2 = fbl_crtabl (NOPI,expr1,FBL_EMPSTR,-1,-1); + ptabl = (struct chain*)expr2.LIST_ABL->DATA; + FBL_BEFPNT->BEDLY = fbh_addfbaux(FBL_BEFPNT->BEDLY,lclname, + ptabl,0,type); + FBL_BEFPNT->BEDLY->USER = (void *)FBL_LINNUM; + /* LUDO addtab (hshtab,$1,FBL_MODNAM,FBL_STBDFN,1); */ + addtab (hshtab,lclname,FBL_MODNAM,FBL_WMNDFN,-1); + addtab (hshtab,lclname,FBL_MODNAM,FBL_WMXDFN,-1); + addtab (hshtab,lclname,FBL_MODNAM,FBL_TYPDFN, type); + addtab (hshtab,lclname,FBL_MODNAM,FBL_LBLDFN, kind); + addtab (hshtab,lclname,FBL_MODNAM,FBL_SIGDFN, + (FBL_ICNDFN + FBL_BITDFN + FBL_NORDFN)); + } + } + $$.NAME = $1; + $$.LEFT = -1; + $$.RIGHT = -1; + if ( $3 == FBL_STABLE ) $$.FLAG = 'X'; + else $$.FLAG = 'x'; + } + ; + +attribute_designator + : _STABLE { $$ = FBL_STABLE; } + | _EVENT { $$ = FBL_EVENT; } + ; + +identifier_list + : Identifier + { FBL_NM1LST = addchain (FBL_NM1LST,$1); } + ...identifier.. + ; + +...identifier.. + : /*empty*/ + | ...identifier.. + Comma + Identifier + { FBL_NM1LST = addchain (FBL_NM1LST,$3); } + ; + +.label. + : /*empty*/ + { $$ = 0; } + | label + { $$ = $1; } + ; + +/* DEBUT LUDO */ + +.guard_expression. + : /*empty*/ + { $$ = NULL; } + | guard_expression + { $$ = $1; } + ; + +guard_expression + : LeftParen + expression + RightParen_ERR + { $$ = (char *)$2.LIST_ABL->DATA; } + ; + +.GUARDED. + : /*empty*/ + { $$ = FBL_UNGDFN ; } + | GUARDED + { $$ = FBL_GRDDFN; } + ; + +/* FIN LUDO */ + +.simple_name. + : /*empty*/ + { $$ = 0; } + | simple_name + { $$ = $1; } + ; + +simple_name + : Identifier + { $$ = $1; } + ; + +target + : name + { $$ = $1; } + ; + +a_label + : label + Colon + { + FBL_LBLNAM = $1; + $$ = $1; + } + ; + +label + : Identifier + { $$ = $1; } + ; + +abstractlit + : AbstractLit + { $$ = atoi($1); } + ; + +RightParen_ERR + : RightParen + { yyerrok; } + ; + +Semicolon_ERR + : Semicolon + { yyerrok; } + ; + +END_ERR + : _END + { yyerrok; } + ; +%% +static struct dct_entry *addent (head , key) +struct dct_entry *head; +char *key; + + { + struct dct_entry *entry; + int i; + + if (FBL_DCEHED == 0) + { + FBL_DCEHED = (struct dct_entry *) + mbkalloc (sizeof(struct dct_entry) * FBL_ALODFN); + + entry = FBL_DCEHED; + for (i=1 ; inext = entry + 1; + entry++; + } + entry->next = 0; + } + + entry = FBL_DCEHED; + FBL_DCEHED = FBL_DCEHED->next; + + entry->next = head; + entry->data = 0; + entry->key = key; + + return (entry); + } + +static struct dct_recrd *addrcd (head , key) + +struct dct_recrd *head; +char *key; + + { + struct dct_recrd *recrd; + int i; + + if (FBL_DCRHED == 0) + { + FBL_DCRHED = (struct dct_recrd *) + mbkalloc (sizeof(struct dct_recrd) * FBL_ALODFN); + + recrd = FBL_DCRHED; + for (i=1 ; inext = recrd + 1; + recrd++; + } + recrd->next = 0; + } + + recrd = FBL_DCRHED; + FBL_DCRHED = FBL_DCRHED->next; + + recrd->next = head; + recrd->fd0_val = 0; + recrd->fd1_val = 0; + recrd->fd2_val = 0; + recrd->fd3_val = 0; + recrd->fd4_val = 0; + recrd->fd5_val = 0; + recrd->fd6_val = 0; + recrd->pnt_val = 0; + recrd->key = key; + + return (recrd); + } + +static struct dct_entry **initab () + + { + struct dct_entry **head; + int i; + + head = (struct dct_entry **) + mbkalloc (sizeof(struct dct_entry *) * FBL_HSZDFN); + + for (i=0 ; ikey == key_str) + { + found = 1; + break; + } + entry_pnt = entry_pnt->next; + } + + if (found == 0) + { + head[index] = addent (head[index],key_str); + entry_pnt = head[index]; + } + + found = 0; + recrd_pnt = entry_pnt->data; + while (recrd_pnt != 0) + { + if (recrd_pnt->key == ctx_str) + { + found = 1; + break; + } + recrd_pnt = recrd_pnt->next; + } + + if (found == 0) + { + entry_pnt->data = addrcd (entry_pnt->data,ctx_str); + recrd_pnt = entry_pnt->data ; + } + + switch (field) + { + case 0 : + recrd_pnt->fd0_val = valu; + break; + case 1 : + recrd_pnt->fd1_val = valu; + break; + case 2 : + recrd_pnt->fd2_val = valu; + break; + case 3 : + recrd_pnt->fd3_val = valu; + break; + case 4 : + recrd_pnt->fd4_val = valu; + break; + case 5 : + recrd_pnt->fd5_val = valu; + break; + case 6 : + recrd_pnt->fd6_val = valu; + break; + case 7 : + recrd_pnt->pnt_val = valu; + break; + } + + } + +static long chktab (head,key_str,ctx_str,field) + +struct dct_entry **head; +char *key_str; +char *ctx_str; +int field; + + { + int found = 0; + int valu = 0; + struct dct_entry *entry_pnt; + struct dct_recrd *recrd_pnt; + + entry_pnt = head [((unsigned long)key_str) % FBL_HSZDFN]; + + while (entry_pnt != 0) + { + if (entry_pnt->key == key_str) + { + found = 1; + break; + } + entry_pnt = entry_pnt->next; + } + + if (found == 1) + { + found = 0; + recrd_pnt = entry_pnt->data; + while (recrd_pnt != 0) + { + if (recrd_pnt->key == ctx_str) + { + found = 1; + break; + } + recrd_pnt = recrd_pnt->next; + } + if (found == 1) + { + switch (field) + { + case 0 : + valu = recrd_pnt->fd0_val; + break; + case 1 : + valu = recrd_pnt->fd1_val; + break; + case 2 : + valu = recrd_pnt->fd2_val; + break; + case 3 : + valu = recrd_pnt->fd3_val; + break; + case 4 : + valu = recrd_pnt->fd4_val; + break; + case 5 : + valu = recrd_pnt->fd5_val; + break; + case 6 : + valu = recrd_pnt->fd6_val; + break; + case 7 : + valu = recrd_pnt->pnt_val; + break; + } + } + } + + return (valu); + } + +static void fretab (pt_hash) + +struct dct_entry **pt_hash; + { + struct dct_entry *pt_entry; + struct dct_entry *pt_nxtentry; + struct dct_recrd *pt_record; + int i; + + if (pt_hash != 0) + { + for (i=0 ; idata; + + while (pt_record->next != 0) + pt_record = pt_record->next; + + pt_record->next = FBL_DCRHED; + FBL_DCRHED = pt_entry->data; + + pt_nxtentry = pt_entry->next; + pt_entry->next = FBL_DCEHED; + FBL_DCEHED = pt_entry; + pt_entry = pt_nxtentry; + } + } + } + free (pt_hash); + } + } + +void *fbl_addstr (ptfig,object,mode,prtype,type,flag,name,left,right) + +struct fbfig *ptfig; +char object; +int mode; +int prtype; +unsigned char type; +char flag; +char *name; +short left; +short right; + +{ + void *pnt = 0; + char porflg = 0; + char rinflg = 0; + char outflg = 0; + char busflg = 0; + char auxflg = 0; + char buxflg = 0; + char regflg = 0; + char lclmod; + char lcltyp = type; + char extname[100]; + short i; + short inc = 1; + + switch (object) + { + case 'P': + + /* ###------------------------------------------------------### */ + /* if object is a port ... */ + /* ###------------------------------------------------------### */ + + porflg = 1; + switch (mode) + { + case FBL_ICNDFN: + lclmod = 'I'; lcltyp = type ; rinflg = 1; break; + case FBL_OCNDFN: + switch (prtype) + { + case BIT : + lclmod = 'O'; lcltyp = type ; outflg = 1; break; + case MUX_BIT : + lclmod = 'Z'; lcltyp = type; busflg = 1; break; + case WOR_BIT : + lclmod = 'Z'; lcltyp = type; busflg = 1; break; + } + break; + case FBL_BCNDFN: + rinflg = 1; + switch (prtype) + { + case BIT: + lclmod = 'B'; lcltyp = type; outflg = 1; rinflg =1;break; + case MUX_BIT: + lclmod = 'T'; lcltyp = type; busflg = 1;rinflg =1; break; + case WOR_BIT: + lclmod = 'T'; lcltyp = type; busflg = 1; rinflg =1;break; + } + break; + } + break; + + case 'S': + + /* ###------------------------------------------------------### */ + /* if object is a signal ... */ + /* ###------------------------------------------------------### */ + + switch (prtype) + { + case BIT: + lcltyp = type; auxflg = 1; break; + case REG_BIT : + rinflg = 1; regflg = 1; break; + case MUX_BIT : + lcltyp = type; rinflg = 1; buxflg = 1; break; + case WOR_BIT : + lcltyp = type; rinflg = 1; buxflg = 1; break; + default : lcltyp = type ; auxflg =1;break; + } + break; + } + + if (flag == 'A' || flag == 'U') + { + /* ###------------------------------------------------------### */ + /* if object is an array ... */ + /* ###------------------------------------------------------### */ + + if (left >= right) + inc = -1; + + for (i=left ; i!=(right+inc) ; i+=inc) + { + sprintf (extname,"%s %d",name,i); + + if (porflg == 1) + { + ptfig->BEPOR = fbh_addfbpor (ptfig->BEPOR,extname,lclmod,lcltyp); + ptfig->BEPOR->USER = (void *)FBL_LINNUM; + } + if (rinflg == 1) + { + ptfig->BERIN = fbh_addfbrin (ptfig->BERIN,extname); + ptfig->BERIN->USER = (void *)FBL_LINNUM; + } + if (outflg == 1) + { + ptfig->BEOUT = fbh_addfbout (ptfig->BEOUT,extname,0,0,lcltyp); + ptfig->BEOUT->USER = (void *)FBL_LINNUM; + } + if (busflg == 1) + { + ptfig->BEBUS = fbh_addfbbus (ptfig->BEBUS,extname,0,0,lcltyp); + ptfig->BEBUS->USER = (void *)FBL_LINNUM; + } + if (auxflg == 1) + { + ptfig->BEAUX = fbh_addfbaux (ptfig->BEAUX,extname,0,0,lcltyp); + ptfig->BEAUX->USER = (void *)FBL_LINNUM; + } + if (buxflg == 1) + { + ptfig->BEBUX = fbh_addfbbux (ptfig->BEBUX,extname,0,0,lcltyp); + ptfig->BEBUX->USER = (void *)FBL_LINNUM; + } + if (regflg == 1) + { + ptfig->BEREG = fbh_addfbreg (ptfig->BEREG,extname,0,0); + ptfig->BEREG->USER = (void *)FBL_LINNUM; + } + } + } + else + { + /* ###------------------------------------------------------### */ + /* if object is a scalar ... */ + /* ###------------------------------------------------------### */ + + if (porflg == 1) + { + ptfig->BEPOR = fbh_addfbpor (ptfig->BEPOR,name,lclmod,lcltyp); + ptfig->BEPOR->USER = (void *)FBL_LINNUM; + } + if (rinflg == 1) + { + ptfig->BERIN = fbh_addfbrin (ptfig->BERIN,name); + ptfig->BERIN->USER = (void *)FBL_LINNUM; + } + if (outflg == 1) + { + ptfig->BEOUT = fbh_addfbout (ptfig->BEOUT,name,0,0,lcltyp); + ptfig->BEOUT->USER = (void *)FBL_LINNUM; + } + if (busflg == 1) + { + ptfig->BEBUS = fbh_addfbbus (ptfig->BEBUS,name,0,0,lcltyp); + ptfig->BEBUS->USER = (void *)FBL_LINNUM; + } + if (auxflg == 1) + { + ptfig->BEAUX = fbh_addfbaux (ptfig->BEAUX,name,0,0,lcltyp); + ptfig->BEAUX->USER = (void *)FBL_LINNUM; + } + if (buxflg == 1) + { + ptfig->BEBUX = fbh_addfbbux (ptfig->BEBUX,name,0,0,lcltyp); + ptfig->BEBUX->USER = (void *)FBL_LINNUM; + } + if (regflg == 1) + { + ptfig->BEREG = fbh_addfbreg (ptfig->BEREG,name,0,0); + ptfig->BEREG->USER = (void *)FBL_LINNUM; + } + + } + + if (outflg == 1) + { + pnt = (void *) ptfig->BEOUT; + } + if (busflg == 1) + { + pnt = (void *) ptfig->BEBUS; + } + if (auxflg == 1) + { + pnt = (void *) ptfig->BEAUX; + } + if (buxflg == 1) + { + pnt = (void *) ptfig->BEBUX; + } + if (regflg == 1) + { + pnt = (void *) ptfig->BEREG; + } + + return (pnt); +} + +int fbl_chkdcl (object,mode,type,flag,kind,constraint,conf) + +char object; +int mode; +int type; +char flag; +int kind; +char constraint; +int *conf; + +{ + int errflg = 0; + int lclcnf = 0; + + if (flag != constraint && constraint !='U' && flag !='U') + { + errflg = 1; + { + fbl_error (33,0); + } + } + else + { + switch (object) + { + case 'P': + /* ###------------------------------------------------------### */ + /* If object is a port : */ + /* - if type is bit, no guard indication can be used */ + /* - if type is wor_bit or mux_bit, bus kind must be used */ + /* - other types are illegal */ + /* ###------------------------------------------------------### */ + + switch (type) + { + case BIT : + + lclcnf += FBL_BITDFN + FBL_NORDFN; + switch (mode) + { + case _IN : + lclcnf += FBL_ICNDFN; break; + case _OUT: + lclcnf += FBL_OCNDFN; break; + case _INOUT : + lclcnf += FBL_BCNDFN; break; + case _LINKAGE : + case 0 : + errflg = 1; break; + } + if (kind != 0) + errflg = 1; + break; + + case MUX_BIT : + + lclcnf += FBL_MUXDFN + FBL_BUSDFN; + switch (mode) + { + case _OUT : + lclcnf += FBL_OCNDFN; break; + case _INOUT : + lclcnf += FBL_BCNDFN; break; + case _IN : + case _LINKAGE : + case 0 : + errflg = 1; break; + } + if (kind != BUS) + errflg = 1; + break; + + case WOR_BIT : + + lclcnf += FBL_WORDFN + FBL_BUSDFN; + switch (mode) + { + case _OUT : + lclcnf += FBL_OCNDFN; break; + case _INOUT : + lclcnf += FBL_BCNDFN; break; + case _IN : + case _LINKAGE : + case 0 : + errflg = 1; break; + } + if (kind != BUS) + errflg = 1; + break; + + case REG_BIT : + case NATURAL: + + errflg = 1; + break; + } + if (errflg == 1) + { + fbl_error (5,0); + } + break; + + case 'G': + /* ###------------------------------------------------------### */ + /* If object is a generic : */ + /* - only natural type is allowed */ + /* ###------------------------------------------------------### */ + + if ((type != NATURAL) || (mode != 0) || (kind != 0)) + { + errflg = 1; + { + fbl_error (77,0); + } + } + break; + + case 'S': + /* ###------------------------------------------------------### */ + /* If object is a signal : */ + /* - no mode can be specified */ + /* - if type is bit no guard indication can be used */ + /* - if type is wor_bit or mux_bit, bus kind must be used */ + /* - if type is reg_bit, register kind must be used */ + /* - other types are illegal */ + /* ###------------------------------------------------------### */ + + switch (type) + { + case BIT: + lclcnf += FBL_BITDFN + FBL_NORDFN; + if ((mode != 0) || (kind != 0)) + errflg = 1; + break; + case MUX_BIT: + lclcnf += FBL_MUXDFN + FBL_BUSDFN; + if ((mode != 0) || (kind != BUS)) + errflg = 1; + break; + case WOR_BIT: + lclcnf += FBL_WORDFN + FBL_BUSDFN; + if ((mode != 0) || (kind != BUS)) + errflg = 1; + break; + case REG_BIT: + lclcnf += FBL_RBIDFN + FBL_REGDFN; + if ((mode != 0) || (kind != REGISTER)) + errflg = 1; + break; + case NATURAL: + errflg = 1; break; + } + + if (mode != 0) + errflg = 1; + + if (errflg == 1) + { + fbl_error (11,NULL); + } + break; + + case 'C': + /* ###------------------------------------------------------### */ + /* If object is a constant : */ + /* - only bit type without any other indication is legal */ + /* ###------------------------------------------------------### */ + + lclcnf += FBL_CSTDFN; + if ((type != BIT) || (mode != 0) || (kind != 0)) + { + errflg = 1; + { + fbl_error (78,NULL); + } + } + break; + } + } + + *conf = lclcnf; + return (errflg); +} + +int val_type(name) + char *name; +{ + if(!name) + return(-1); + if (!strcmp(name,"severity_level")) + return(SEVERITY_LEVEL); + if (!strcmp(name,"boolean")) + return(BOOLEAN); + if (!strcmp(name,"bit")) + return(BIT); + if (!strcmp(name,"mux_bit")) + return(MUX_BIT); + if (!strcmp(name,"wor_bit")) + return(WOR_BIT); + if (!strcmp(name,"reg_bit")) + return(REG_BIT); + if (!strcmp(name,"bit_vector")) + return(BIT); + if (!strcmp(name,"mux_vector")) + return(MUX_BIT); + if (!strcmp(name,"wor_vector")) + return(WOR_BIT); + if (!strcmp(name,"reg_vector")) + return(REG_BIT); + if (!strcmp(name,"integer")) + return(INTEGER); + if (!strcmp(name,"natural")) + return(NATURAL); + if (!strcmp(name,"std_logic")) + return(BIT); + if (!strcmp(name,"std_ulogic")) + return(BIT); + if (!strcmp(name,"std_logic_vector")) + return(BIT); + if (!strcmp(name,"std_ulogic_vector")) + return(BIT); + return( -1 ); +} + struct ptype *reversetype(pnt) + struct ptype *pnt; + { + struct ptype* revtype; + struct ptype* aux2; + struct ptype* aux1; + + if(pnt == 0 || pnt->NEXT == 0) + return(pnt); + revtype = pnt; + aux1 = pnt->NEXT; + revtype->NEXT = 0; + while(aux1) + { + aux2 = revtype; + revtype = aux1; + aux1 = aux1->NEXT; + revtype->NEXT = aux2; + } + return(revtype); + } + + struct choice_chain *addchoice(lastpnt,type,val,size) + struct choice_chain *lastpnt; + struct ptype *type; + char *val; + unsigned int size; + { + struct choice_chain *pnt; + + pnt = (struct choice_chain*)mbkalloc(sizeof(struct choice_chain)); + pnt->VALUE = val; + pnt->SIZE = size; + pnt->INSTRUCTION = type; + pnt->NEXT = lastpnt; + return(pnt); + } + + struct choice_chain *order_choice(pnt,type,val,size) + struct choice_chain *pnt; + struct ptype *type; + char *val; + unsigned int size; + { + struct choice_chain *aux1; + struct choice_chain *aux2; + + if(!pnt) + { + aux1 = addchoice (pnt,type,val,size); + return(aux1); + } + + if(strcmp(pnt->VALUE,val)>0) + { + aux1 =addchoice(pnt,type,val,size); + return(aux1); + } + + aux1 =pnt; + aux2 =pnt->NEXT; + while(aux2) + { + if(strcmp(aux2->VALUE, val)>0) + { + aux2 = addchoice (aux2,type,val,size); + aux1->NEXT = aux2; + return(pnt); + } + aux1 = aux2; + aux2 = aux2->NEXT; + } + aux2 = addchoice (aux2,type,val,size); + aux1->NEXT = aux2; + return(pnt); + } + diff --git a/alliance/src/fvh/src/fbl_bedef.h b/alliance/src/fvh/src/fbl_bedef.h new file mode 100644 index 00000000..42a762bb --- /dev/null +++ b/alliance/src/fvh/src/fbl_bedef.h @@ -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. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbl_bedef.h */ +/* date : Jun 15 1992 */ +/* version : v102 */ +/* author : P.BAZARGAN, M.HANAFI */ +/* content : declaration of define used by yacc */ +/* */ +/* ###--------------------------------------------------------------### */ + +#define FBL_LG_MC 15 +#define FBL_NB_MC ((tab_mc -1 + sizeof(tab_mc)/ (sizeof(tab_mc[0])) - tab_mc+1)) + +#define FBL_ICNDFN 1 /* input port */ +#define FBL_OCNDFN 2 /* output port */ +#define FBL_BCNDFN 3 /* inout port */ +#define FBL_CSTDFN 4 /* constant */ +#define FBL_TPEDFN 5 /* type */ +#define FBL_SGNDFN 6 /* signal */ + +/* LUDO #define FBL_STBDFN 7 stable's signal +#define FBL_VARDFN 7 variable */ + +#define FBL_BITDFN 8 /* bit type */ +#define FBL_MUXDFN 16 /* mux_bit type */ +#define FBL_WORDFN 24 /* wor_bit type */ +#define FBL_RBIDFN 32 /* reg_bit type */ +#define FBL_BTVDFN 40 /* bit_vector type */ +#define FBL_MXVDFN 48 /* mux_vector type */ +#define FBL_WRVDFN 56 /* wor_vector type */ +#define FBL_RGVDFN 64 /* reg_vector type */ +#define FBL_NATDFN 88 /* natural type */ +#define FBL_NTVDFN 96 /* nat_vector type */ + +#define FBL_NORDFN 128 /* non guarded signal */ +#define FBL_BUSDFN 256 /* guarded signal (bus) */ +#define FBL_REGDFN 384 /* guarded signal (register)*/ + +#define FBL_MODDFN 0 /* mod_val field of dct_recrd */ +#define FBL_SIGDFN 1 /* sig_val field of dct_recrd */ +#define FBL_TYPDFN 2 /* type_val field of dct_recrd */ +#define FBL_USRDFN 3 /* user_val field of dct_recrd */ +#define FBL_LBLDFN 4 /* lbl_val field of dct_recrd */ +#define FBL_WMXDFN 5 /* wmx_val field of dct_recrd */ +#define FBL_WMNDFN 6 /* wmn_val field of dct_recrd */ +#define FBL_PNTDFN 7 /* pnt_val field of dct_recrd */ + +#define FBL_UPTDFN 1 /* direction is up */ +#define FBL_DWTDFN 0 /* direction is down */ + +#define SEVERITY_LEVEL FBH_TYPE_SEVERITY +#define BOOLEAN FBH_TYPE_BOOLEAN +#define BIT FBH_TYPE_BIT +#define MUX_BIT FBH_TYPE_MUX_BIT +#define WOR_BIT FBH_TYPE_WOR_BIT +#define REG_BIT FBH_TYPE_REG_BIT +#define BIT_VEC FBH_TYPE_BIT_VEC +#define MUX_VEC FBH_TYPE_MUX_VEC +#define WOR_VEC FBH_TYPE_WOR_VEC +#define REG_VEC FBH_TYPE_REG_VEC +#define NATURAL FBH_TYPE_NATURAL +#define INTEGER FBH_TYPE_INTEGER + +/* ###---------------------------------------------------------------### */ + +#define NE 109 +#define EQ 110 +#define GT 111 +#define GE 112 +#define LT 113 +#define LE 114 +#define NOPI 115 +#define NOPS 116 +#define ANDM 117 +#define CONC 118 +#define CONVRT 119 +#define SUBVAR 120 + +#define FBL_UNGDFN 0 +#define FBL_GRDDFN 1 + +#define FBL_STABLE 0 +#define FBL_EVENT 1 + +/* ###---------------------------------------------------------------### */ + +#define FBL_INTDFN 0 /* int_val field of dtc_recrd */ + +#define FBL_ALODFN 60 /* nbr of allocations */ +#define FBL_HSZDFN 97 /* size of dictionnary: entries */ diff --git a/alliance/src/fvh/src/fbl_blex.h b/alliance/src/fvh/src/fbl_blex.h new file mode 100644 index 00000000..293902d1 --- /dev/null +++ b/alliance/src/fvh/src/fbl_blex.h @@ -0,0 +1,55 @@ +/*------------------------------------------------------------\ +| | +| 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 + +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbl_blex.h */ +/* date : Jun 15 1992 */ +/* version : v102 */ +/* author : TABUSSE L.A. */ +/* content : declaration of functions and global variables used by */ +/* lex */ +/* */ +/* ###--------------------------------------------------------------### */ + +#include +#include "fbl_bedef.h" + +extern int FBL_LINNUM; /* file's line number */ + +typedef struct +{ char nom[FBL_LG_MC]; + int kval; +} el_mc; + diff --git a/alliance/src/fvh/src/fbl_bspec.c b/alliance/src/fvh/src/fbl_bspec.c new file mode 100644 index 00000000..74fd4d8d --- /dev/null +++ b/alliance/src/fvh/src/fbl_bspec.c @@ -0,0 +1,1020 @@ +/*------------------------------------------------------------\ +| | +| 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. | +| | +\------------------------------------------------------------*/ +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbl_bspec.c */ +/* date : Nouv 05 1992 */ +/* version : v100 */ +/* authors : M.HANAFI,Pirouz BAZARGAN SABET */ +/* content : contains all specific functions used to build */ +/* fbhaviour data structures : */ +/* fbl_addgen , fbl_tobin , fbl_stostr, fbl_cpyabllst, */ +/* fbl_cpyablstr, fbl_crtabl, fbl_select */ +/* */ +/* ###--------------------------------------------------------------### */ + +#include +#include +#include + +#include "mut.h" +#include "aut.h" +#include "abl.h" +#include "bdd.h" +#include "fvh.h" + +#include "fbl_bspec.h" +#include "fbl_bedef.h" + +/* ###--------------------------------------------------------------### */ +/* function : fbl_addgen */ +/* description : create one or more BEGEN structures */ +/* For a scalar a BEGEN is created at the head of */ +/* existing BEGEN list. */ +/* For an array (including arraies of one element) a set */ +/* of BEGENs are created in a sorted list. BEGEN related */ +/* to the index i of the array is named `name(i)`. The */ +/* head of the list represents the right bound of the */ +/* array. This list is then chained to the head of */ +/* existing BEGEN list. */ +/* called func. : fbh_addfbgen, namealloc */ +/* ###--------------------------------------------------------------### */ + +struct fbgen *fbl_addgen (lastgeneric,nat_lst,nam_lst,type,left,right) + +struct fbgen *lastgeneric; /* pointer on the last fbgen structure */ +struct chain *nam_lst; /* generic's name list */ +struct chain *nat_lst; /* generic's value list */ +char *type; /* generic's type */ +short left; /* array's left bound (= -1 if scalar) */ +short right; /* array's right bound (= -1 if scalar) */ + + { + char extname[100]; + char *name; + struct fbgen *ptgen; + struct chain *ptauxnam; + struct chain *ptauxnat; + int i; + int inc = 1; + + ptgen = lastgeneric; + ptauxnam = nam_lst; + ptauxnat = nat_lst; + + if ((left == -1) && (right == -1)) + if ((ptauxnat != 0) && (ptauxnat->NEXT == 0)) + while (ptauxnam != 0) + { + name = namealloc((char *)ptauxnam->DATA); + ptgen = fbh_addfbgen (ptgen,name,type,(void *)ptauxnat->DATA); + ptauxnam = ptauxnam->NEXT; + } + else + { + fbl_error(75,0); + } + else + { + if (left >= right) + inc = -1; + while (ptauxnam != 0) + { + for (i=left ; i!=(right+inc) ; i+=inc) + { + sprintf (extname,"%s %d",(char *)ptauxnam->DATA,i); + name = namealloc(extname); + if (ptauxnat != 0) + { + ptgen = fbh_addfbgen (ptgen,name,type,(void *)ptauxnat->DATA); + ptauxnat = ptauxnat->NEXT; + } + else + { + fbl_error(75,0); + } + } + if (ptauxnat != 0) + { + fbl_error (75,0); + } + ptauxnat = nat_lst; + ptauxnam = ptauxnam->NEXT; + } + } + return (ptgen); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbl_stostr */ +/* description : purge double % (percent) or Quote (") from string */ +/* called func. : mbkalloc */ +/* ###--------------------------------------------------------------### */ + +char *fbl_stostr(str) + +char *str; + + { + char *resstr; + int i; + int j=0; + + resstr = (char *)mbkalloc(100); + resstr[0] = '\0'; + + for ( i=1;str[i+1]!='\0';i++) + { + resstr[j++]=str[i]; + if ((str[i]==str[0])&&(str[i+1]==str[0])) + i++; + } + + return( &resstr[0] ); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbl_cpyabllst */ +/* description : duplicate fbl_abllst structure */ +/* called func. : addchain, reverse, dupablexpr */ +/* ###--------------------------------------------------------------### */ + +struct chain *fbl_cpyabllst (abllst) + +struct chain *abllst; + { + struct chain *pt_abllst = 0; + + while (abllst != 0) + { + pt_abllst = addchain (pt_abllst,dupablexpr((struct chain *)abllst->DATA)); + abllst = abllst->NEXT; + } + pt_abllst = reverse (pt_abllst); + return (pt_abllst); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbl_cpyablstr */ +/* description : duplicate fbl_ablstr structure */ +/* called func. : mbkalloc , fbl_cpyabllst */ +/* ###--------------------------------------------------------------### */ + +fbl_ablstr fbl_cpyablstr (ablstr) + +fbl_ablstr ablstr; + { + fbl_ablstr pt_ablstr; + + pt_ablstr.IDENT = 0; + pt_ablstr.WIDTH = ablstr.WIDTH; + pt_ablstr.TYPE = ablstr.TYPE; + pt_ablstr.LIST_ABL = fbl_cpyabllst (ablstr.LIST_ABL); + return (pt_ablstr); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbl_crtabl */ +/* description : combine at most two ABLs and build a new one */ +/* The following operations can be performed : */ +/* CONC perform concatenation */ +/* NOPI initialize a structure for a signal (scalar */ +/* or array) */ +/* NOPS initialize a structure for a literal */ +/* NE create a structure with an ABL representing */ +/* the 'non equality' of two expressions */ +/* EQ create a structure with an ABL representing */ +/* the 'equality' of two expressions */ +/* NOT perform logical not of an expression */ +/* AND perform logical and between two expressions*/ +/* OR perform logical or between two expressions*/ +/* NAND perform logical nand between two expressions*/ +/* NOR perform logical nor between two expressions*/ +/* XOR perform logical xor between two expressions*/ +/* ANDM perform logical and between two expressions*/ +/* (the second expression is a scalar) */ +/* called func. : createablatom , createabloper, addablhexpr , fbl_toolbug, */ +/* fbl_error , addchain , freechain */ +/* ###--------------------------------------------------------------### */ + +fbl_ablstr fbl_crtabl ( oper, expr1, expr2, left, right ) + +short oper; +fbl_ablstr expr1; +fbl_ablstr expr2; +int left; +int right; + +{ + char name[256]; + char *name2; + struct chain *pt_abl1; + struct chain *pt_abl2; + struct chain *pt_aux1; + struct chain *pt_aux2; + fbl_ablstr result; + char lcl_buffer[256]; + short inc; + short i; + + result.IDENT = 0; + result.LIST_ABL = 0; + result.WIDTH = 0; + result.TYPE = 0; + + switch (oper) + { + case CONC : + if ((expr1.LIST_ABL == 0) || (expr2.LIST_ABL == 0)) + fbl_toolbug (4,"fbl_crtabl","CONC",0); + else + { + if (expr1.LIST_ABL == expr2.LIST_ABL) + fbl_toolbug (16,"fbl_crtabl",0,0); + else + { + pt_aux2 = expr2.LIST_ABL; + while (pt_aux2->NEXT != 0) + pt_aux2 = pt_aux2->NEXT; + + pt_aux2->NEXT = expr1.LIST_ABL; + + result.LIST_ABL = expr2.LIST_ABL; + result.WIDTH = expr1.WIDTH + expr2.WIDTH; + result.TYPE = expr1.TYPE; + expr1.LIST_ABL = 0; + expr2.LIST_ABL = 0; + } + } + break; + + case SUBVAR : + if ( expr1.LIST_ABL == 0 ) + fbl_toolbug (2,"fbl_crtabl",0,0); + else + { + if ((left == -1) && (right == -1)) + { + result.IDENT = 0; + result.LIST_ABL = addchain (result.LIST_ABL,dupablexpr((struct chain*)(expr1.LIST_ABL->DATA))); + result.WIDTH = 1; + result.TYPE = expr1.TYPE; + } + else + { + struct chain * abl = expr1.LIST_ABL ; + + for (i=0 ; i< left ; i++) + { + if( abl ) + abl = abl->NEXT ; + else + fbl_toolbug (2,"fbl_crtabl",0,0); + } + for (i=left ; i<= right ; i++) + { + if( abl ) + { + result.LIST_ABL = addchain (result.LIST_ABL,dupablexpr((struct chain*)(abl->DATA))); + abl = abl->NEXT ; + } + else + fbl_toolbug (2,"fbl_crtabl",0,0); + } + } + result.IDENT = 0; + result.TYPE = expr1.TYPE; + result.WIDTH = right - left + 1; + } + break; + + case NOPI : + if ( expr1.IDENT == 0 ) + fbl_toolbug (2,"fbl_crtabl",0,0); + else + { + if ((left == -1) && (right == -1)) + { + result.LIST_ABL = addchain(result.LIST_ABL,createablatom(expr1.IDENT)); + result.WIDTH = 1; + result.TYPE = expr1.TYPE; + } + else + { + if (left <= right) + { + inc = 1; + result.WIDTH = right - left + 1; + } + else + { + inc = -1; + result.WIDTH = left - right + 1; + } + + for (i=left ; i!=(right+inc) ; i+=inc) + { + sprintf (name,"%s %i",expr1.IDENT,i); + name2 = namealloc (name); + result.LIST_ABL = addchain (result.LIST_ABL,createablatom(name2)); + } + } + result.TYPE = expr1.TYPE; + expr1.IDENT = 0; + } + break; + + case NOPS : + if ( expr1.IDENT == 0 ) + fbl_toolbug (2,"fbl_crtabl",0,0); + else + { + fbl_tobin (lcl_buffer,expr1.IDENT,-1,-1); + if ((left == -1) && (right == -1)) + { + left = 0; + right = strlen (lcl_buffer) - 1; + } + + for (i=left ; i<=right ; i++) + { + switch ( lcl_buffer[i] ) + { + case '0' : + result.LIST_ABL = addchain (result.LIST_ABL,createablatomzero()); + break; + case '1' : + result.LIST_ABL = addchain (result.LIST_ABL,createablatomone()); + break; +/*----------- Beware Not VHDL -------------*/ + case 'd' : + case '-' : + result.LIST_ABL = addchain (result.LIST_ABL,createablatomdc()); + break; + default : + fbl_toolbug (15,"fbl_crtabl",0,expr1.IDENT[i]); + } + } + result.WIDTH = right - left + 1; + } + result.TYPE = expr1.TYPE; + break; + + case ABL_STABLE : + if (expr1.LIST_ABL == 0) + fbl_toolbug (3,"fbl_crtabl",0,0); + else + { + pt_aux1 = expr1.LIST_ABL; + while (pt_aux1 != 0) + { + pt_abl1 = createabloper (ABL_STABLE); + addablhexpr (pt_abl1, (struct chain *)pt_aux1->DATA); + pt_aux1->DATA = (void *)pt_abl1; + pt_aux1 = pt_aux1->NEXT; + } + + result.LIST_ABL = expr1.LIST_ABL; + result.WIDTH = expr1.WIDTH; + result.TYPE = expr1.TYPE; + + expr1.LIST_ABL = 0; + } + break; + + case ABL_NOT : + if (expr1.LIST_ABL == 0) + fbl_toolbug (3,"fbl_crtabl",0,0); + else + { + pt_aux1 = expr1.LIST_ABL; + while (pt_aux1 != 0) + { + pt_abl1 = createabloper (ABL_NOT); + addablhexpr (pt_abl1, (struct chain *)pt_aux1->DATA); + pt_aux1->DATA = (void *)pt_abl1; + pt_aux1 = pt_aux1->NEXT; + } + + result.LIST_ABL = expr1.LIST_ABL; + result.WIDTH = expr1.WIDTH; + result.TYPE = expr1.TYPE; + + expr1.LIST_ABL = 0; + } + break; + + case EQ : + if ((expr1.LIST_ABL == 0) || (expr2.LIST_ABL == 0)) + fbl_toolbug (4,"fbl_crtabl","EQ",0); + else + { + result.TYPE = expr1.TYPE; + if (expr1.WIDTH != expr2.WIDTH || (expr1.TYPE != expr2.TYPE && expr2.TYPE !=-1)) + { + fbl_error (38,0); + pt_abl2 = createablatomone(); + + pt_aux1 = expr1.LIST_ABL; + while (pt_aux1 != 0) + { + delablexpr (pt_aux1->DATA); + pt_aux1 = pt_aux1->NEXT; + } + pt_aux2 = expr2.LIST_ABL; + while (pt_aux2 != 0) + { + delablexpr (pt_aux2->DATA); + pt_aux2 = pt_aux2->NEXT; + } + } + else + { + pt_aux1 = expr1.LIST_ABL; + pt_aux2 = expr2.LIST_ABL; + + pt_abl1 = createabloper (ABL_XOR); + addablhexpr (pt_abl1, (struct chain *)pt_aux1->DATA); + addablhexpr (pt_abl1, (struct chain *)pt_aux2->DATA); + + pt_aux1 = pt_aux1->NEXT; + pt_aux2 = pt_aux2->NEXT; + + while (pt_aux1 != 0) + { + pt_abl2 = createabloper (ABL_OR); + addablhexpr (pt_abl2,pt_abl1); + + pt_abl1 = createabloper (ABL_XOR); + addablhexpr (pt_abl1, (struct chain *)pt_aux1->DATA); + addablhexpr (pt_abl1, (struct chain *)pt_aux2->DATA); + + addablhexpr (pt_abl2, pt_abl1); + pt_abl1 = pt_abl2; + + pt_aux1 = pt_aux1->NEXT; + pt_aux2 = pt_aux2->NEXT; + } + pt_abl2 = createabloper (ABL_NOT); + addablhexpr (pt_abl2, pt_abl1); + + } + result.LIST_ABL = addchain (result.LIST_ABL,pt_abl2); + result.WIDTH = 1; + result.TYPE = expr1.TYPE; + freechain (expr1.LIST_ABL); + freechain (expr2.LIST_ABL); + expr1.LIST_ABL = 0; + expr2.LIST_ABL = 0; + } + break; + + case NE : + + if ((expr1.LIST_ABL == 0) || (expr2.LIST_ABL == 0)) + fbl_toolbug (4,"fbl_crtabl",0,0); + else + { + result.TYPE = expr1.TYPE; + if (expr1.WIDTH != expr2.WIDTH || (expr1.TYPE != expr2.TYPE && expr2.TYPE !=-1)) + { + fbl_error(38,0); + pt_abl1 = createablatomone(); + + pt_aux1 = expr1.LIST_ABL; + while (pt_aux1 != 0) + { + delablexpr (pt_aux1->DATA); + pt_aux1 = pt_aux1->NEXT; + } + pt_aux2 = expr2.LIST_ABL; + while (pt_aux2 != 0) + { + delablexpr (pt_aux2->DATA); + pt_aux2 = pt_aux2->NEXT; + } + } + else + { + pt_aux1 = expr1.LIST_ABL; + pt_aux2 = expr2.LIST_ABL; + + pt_abl1 = createabloper (ABL_XOR); + addablhexpr (pt_abl1, (struct chain *)pt_aux1->DATA); + addablhexpr (pt_abl1, (struct chain *)pt_aux2->DATA); + + pt_aux1 = pt_aux1->NEXT; + pt_aux2 = pt_aux2->NEXT; + + for (i=2 ; i<=expr1.WIDTH ; i++) + { + pt_abl2 = createabloper (ABL_OR); + addablhexpr (pt_abl2, pt_abl1); + + pt_abl1 = createabloper (ABL_XOR); + addablhexpr (pt_abl1, (struct chain *)pt_aux1->DATA); + addablhexpr (pt_abl1, (struct chain *)pt_aux2->DATA); + addablhexpr (pt_abl2, pt_abl1); + pt_abl1 = pt_abl2; + + pt_aux1 = pt_aux1->NEXT; + pt_aux2 = pt_aux2->NEXT; + } + + } + result.LIST_ABL = addchain(result.LIST_ABL,pt_abl1); + result.TYPE = expr1.TYPE; + result.WIDTH = 1; + freechain (expr1.LIST_ABL); + freechain (expr2.LIST_ABL); + expr1.LIST_ABL = 0; + expr2.LIST_ABL = 0; + } + break; + + case ABL_AND : + case ABL_NAND : + case ABL_OR : + case ABL_NOR : + case ABL_XOR : + + if (expr1.LIST_ABL == 0) + { + if (expr2.LIST_ABL == 0) + fbl_toolbug (4,"fbl_crtabl",0,0); + else + { + result.LIST_ABL = expr2.LIST_ABL; + result.WIDTH = expr2.WIDTH; + result.TYPE = expr2.TYPE; + expr2.LIST_ABL = 0; + } + } + else + { + if (expr2.LIST_ABL == 0) + { + result.LIST_ABL = expr1.LIST_ABL; + result.WIDTH = expr1.WIDTH; + result.TYPE = expr1.TYPE; + expr1.LIST_ABL = 0; + } + else + { + if (expr1.LIST_ABL == expr2.LIST_ABL) + fbl_toolbug (16,"fbl_crtabl",0,0); + else + { + /* LUDO + if ((expr1.WIDTH != expr2.WIDTH) + || (expr1.TYPE != expr2.TYPE && expr2.TYPE !=-1)) */ + if (expr1.WIDTH != expr2.WIDTH) + { + fbl_error(38,0); + } + else + { + pt_aux1 = expr1.LIST_ABL; + pt_aux2 = expr2.LIST_ABL; + + for (i=1 ; i<=expr1.WIDTH ; i++) + { + pt_abl1 = createabloper (oper); + addablhexpr (pt_abl1, (struct chain *)pt_aux1->DATA); + addablhexpr (pt_abl1, (struct chain *)pt_aux2->DATA); + pt_aux1->DATA = (void *)pt_abl1; + + pt_aux1 = pt_aux1->NEXT; + pt_aux2 = pt_aux2->NEXT; + } + } + result.LIST_ABL = expr1.LIST_ABL; + result.WIDTH = expr1.WIDTH; + result.TYPE = expr1.TYPE; + freechain (expr2.LIST_ABL); + expr1.LIST_ABL = 0; + expr2.LIST_ABL = 0; + } + } + } + break; + + case ANDM : + if ((expr1.LIST_ABL == 0) || (expr2.LIST_ABL == 0)) + { + fbl_toolbug (4,"fbl_crtabl",0,0); + } + else + { + if (expr2.WIDTH != 1) + { + fbl_error(38,0); + } + else + { + pt_aux1 = expr1.LIST_ABL; + pt_aux2 = expr2.LIST_ABL; + while (pt_aux1 != 0) + { + pt_abl1 = createabloper (ABL_AND); + addablhexpr (pt_abl1, (struct chain *)pt_aux1->DATA); + addablhexpr (pt_abl1, dupablexpr((struct chain *)pt_aux2->DATA)); + pt_aux1->DATA = (void *)pt_abl1; + + pt_aux1 = pt_aux1->NEXT; + } + } + result.LIST_ABL = expr1.LIST_ABL; + result.WIDTH = expr1.WIDTH; + result.TYPE = expr1.TYPE; + pt_aux2 = expr2.LIST_ABL; + while (pt_aux2 != 0) + { + delablexpr (pt_aux2->DATA); + pt_aux2 = pt_aux2->NEXT; + } + freechain (expr2.LIST_ABL); + expr2.LIST_ABL = 0; + expr1.LIST_ABL = 0; + } + break; + + default : + + fbl_toolbug (1,"fbl_crtabl",0,0); + } + + return (result); +} + + +/* ###--------------------------------------------------------------### */ +/* function : fbl_numtobin */ +/* description : transform a ENUMERATE */ +/* in a string of '0' and '1's */ +/* ###--------------------------------------------------------------### */ +int fbl_bintonum(str) +char* str; + + { + int res,i=0; + + res = 0; + while(str[i]) + { + if(str[i] <'0' || str[i] > '1') + return(-1); + res = res*2 + str[i] -'0'; + i++; + } + return(res); + } +/* ###--------------------------------------------------------------### */ +/* function : fbl_numtobin */ +/* description : transform a ENUMERATE */ +/* in a string of '0' and '1's */ +/* ###--------------------------------------------------------------### */ +char *fbl_numtobin(num) +int num; + + { + char val[256]; + char *str; + int res,i=1; + + val[255] = '\0'; + res = num; + while(res) + { + val[255 - i] = res%2 + '0'; + res = (res / 2); + i++; + } + val[255 - i] = '0'; + str = namealloc((char *)(val + 255-i)); + return(str); + } +/* ###--------------------------------------------------------------### */ +/* function : fbl_tobin */ +/* description : transform a StringLit, BitStringLit or CharacterLit */ +/* in a string of '0' and '1's */ +/* ###--------------------------------------------------------------### */ + +int fbl_tobin (trg,src,left,right) + +char *trg; +char *src; +int left; +int right; + + { + char base; + int indx; + int j = 0; + int errflg = 0; + char lcl_trg[256]; + + lcl_trg[0] = '\0'; + + if (src == 0) + { + strcpy (trg,"0"); + } + else + { + if (!strcmp (src,"others")) + { + strcpy(trg,src); + } + else + { + if ((src[0] != '\'') && (src[0] != '"') && (src[0] != '%')) + { + base = src[0]; + indx = 2; + } + else + { + base = 'B'; + indx = 1; + } + + switch (base) + { + case 'B' : + case 'b' : + while ((lcl_trg[j] = src[indx]) != '\0') + { + switch (src[indx]) + { + case '0': + case '1': + case 'd': /* Beware Not VHDL */ + case '-': + j++; break; + + case '%' : + case '"' : + case '\'': + case '_' : + break; + + default : + errflg = 1; + fbl_error(73,src); + } + indx++; + } + break; + + case 'O' : + case 'o' : + while (src[indx] != '\0') + { + j += 3; + switch (src[indx]) + { + case '0' : + strcat (lcl_trg,"000"); break; + case '1' : + strcat (lcl_trg,"001"); break; + case '2' : + strcat (lcl_trg,"010"); break; + case '3' : + strcat (lcl_trg,"011"); break; + case '4' : + strcat (lcl_trg,"100"); break; + case '5' : + strcat (lcl_trg,"101"); break; + case '6' : + strcat (lcl_trg,"110"); break; + case '7' : + strcat (lcl_trg,"111"); break; + case '"' : + case '%' : + case '_' : + j -= 3; break; + default : + j -= 3; errflg = 1; fbl_error(73,src); + } + indx++; + } + break; + + case 'X' : + case 'x' : + while (src[indx] != '\0') + { + j += 4; + switch (src[indx]) + { + case '0' : + strcat (lcl_trg,"0000"); break; + case '1' : + strcat (lcl_trg,"0001"); break; + case '2' : + strcat (lcl_trg,"0010"); break; + case '3' : + strcat (lcl_trg,"0011"); break; + case '4' : + strcat (lcl_trg,"0100"); break; + case '5' : + strcat (lcl_trg,"0101"); break; + case '6' : + strcat (lcl_trg,"0110"); break; + case '7' : + strcat (lcl_trg,"0111"); break; + case '8' : + strcat (lcl_trg,"1000"); break; + case '9' : + strcat (lcl_trg,"1001"); break; + case 'a' : + case 'A' : + strcat (lcl_trg,"1010"); break; + case 'b' : + case 'B' : + strcat (lcl_trg,"1011"); break; + case 'c' : + case 'C' : + strcat (lcl_trg,"1100"); break; + case 'd' : + case 'D' : + strcat (lcl_trg,"1101"); break; + case 'e' : + case 'E' : + strcat (lcl_trg,"1110"); break; + case 'f' : + case 'F' : + strcat (lcl_trg,"1111"); break; + case '%' : + case '"' : + case '_' : + j -= 4; break; + default : + j -= 4; errflg = 1; fbl_error(73,src); + } + indx++; + } + break; + + default : + fbl_toolbug (17,"fbl_tobin",0,base); + } + + if ((j == 0) || (j <= right)) + { + trg[0] = '0'; + trg[1] = '\0'; + } + else + { + if (left != -1) + { + strcpy (trg, &lcl_trg[left]); + trg[right - left + 1] = '\0'; + } + else + strcpy (trg, lcl_trg); + } + } + } + + return (errflg); + } + + +/* ###--------------------------------------------------------------### */ +/* function : fbl_select */ +/* description : create an abl representing the choice in a selected */ +/* signal assignment and perform unicity verification */ +/* using BDDs. */ +/* called func. : fbl_tobin , convertlogbddnode , addInputCct , */ +/* substPhyExpr, initializeCct, getlogbddnodeterm, */ +/* fbl_error , getlogbddnodenot , applylogbddnode , */ +/* addchain , namealloc */ +/* ###--------------------------------------------------------------### */ + +extern bddcircuit *FblBddCircuit; + +void fbl_select ( result,pt_str, pt_bdd, pt_ablstr) +fbl_ablstr *result; +struct chain *pt_str; /* pointer on a list of choices */ +bddnode **pt_bdd; /* used to check if a choice is legal */ +fbl_ablstr *pt_ablstr; /* tested expression */ +{ + char binstr[512]; + int i; + struct chain *pt_auxabl; + bddnode *pt_bddres; + bddnode *pt_bddnew; + bddnode *pt_bddtmp; + bddnode *pt_bddaux; + char nomvar[10]; + struct chain *pt_newabl; + struct chain *pt_newabl2; + static int oth_flg=0; + static int last_width=0; + + result->LIST_ABL = NULL; + result->IDENT = NULL; + + pt_bddtmp = getlogbddnodezero(); + + if (*pt_bdd == NULL) + { + if (last_width < pt_ablstr->WIDTH) + { + for (; last_widthWIDTH ; last_width++) + { + sprintf (nomvar,"(%d)",last_width); + addlogbddcircuitin(FblBddCircuit,nomvar); + } + } + *pt_bdd = getlogbddnodezero(); + oth_flg = 0; + } + + while (pt_str != NULL) + { + fbl_tobin (binstr, (char *)pt_str->DATA,-1,-1); + if (oth_flg != 0) + { + fbl_error(30,NULL); + } + + if (strcmp("others", (char *)pt_str->DATA)) + { + pt_bddres = getlogbddnodeone(); + + if (strlen (binstr) != pt_ablstr->WIDTH) + { + fbl_error(38,NULL); + } + for (i=0 ; binstr[i]!='\0' ; i++) + { + pt_bddaux = getlogbddnodeterm(i+2); + if (binstr[i] == '0') + pt_bddaux = getlogbddnodenot (pt_bddaux); + pt_bddres = applylogbddnode (ABL_AND, pt_bddaux, pt_bddres); + } + pt_bddnew = applylogbddnode (ABL_OR,*pt_bdd,pt_bddres); + + if (*pt_bdd == pt_bddnew) + { + fbl_error(28,NULL); + } + + *pt_bdd = pt_bddnew; + } + else + { + oth_flg = 1; + pt_bddres = getlogbddnodenot (*pt_bdd); + *pt_bdd = getlogbddnodeone(); + } + pt_bddtmp = applylogbddnode (ABL_OR,pt_bddtmp,pt_bddres); + pt_str = pt_str->NEXT; + } + + pt_newabl = convertlogbddnode (FblBddCircuit, pt_bddtmp); + + pt_auxabl = pt_ablstr->LIST_ABL; + i = pt_ablstr->WIDTH - 1; + while (pt_auxabl != NULL) + { + sprintf (nomvar,"(%i)",i); + pt_newabl2 = substdupablexpr (pt_newabl,namealloc(nomvar), + (struct chain *)pt_auxabl->DATA); + freeablexpr (pt_newabl); + pt_newabl = pt_newabl2; + + i--; + pt_auxabl = pt_auxabl->NEXT; + } + result->LIST_ABL = addchain (NULL, pt_newabl); + result->WIDTH = 1; +} diff --git a/alliance/src/fvh/src/fbl_bspec.h b/alliance/src/fvh/src/fbl_bspec.h new file mode 100644 index 00000000..651f6a24 --- /dev/null +++ b/alliance/src/fvh/src/fbl_bspec.h @@ -0,0 +1,67 @@ +/*------------------------------------------------------------\ +| | +| 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 + +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbl_bspec.h */ +/* date : Jun 15 1992 */ +/* author : TABUSSE L.A. */ +/* content : declaration of functions and global variables used by */ +/* fbl_bspec.c */ +/* */ +/* ###--------------------------------------------------------------### */ + +typedef struct fbl_expr + { + char *IDENT; /* identifier or constant name */ + struct chain *LIST_ABL; /* pointer on fbl_abllst list */ + char TYPE; + short WIDTH; /* width of bit vector */ + } +fbl_ablstr; + +extern fbl_ablstr FBL_EMPSTR; + +extern ablexpr *bddToAbl () ; + + extern struct chain * fbl_cpyabllst __P((struct chain *abllst)); + extern fbl_ablstr fbl_cpyablstr __P((fbl_ablstr ablstr)); + extern fbl_ablstr fbl_crtabl __P((short oper, fbl_ablstr expr1, fbl_ablstr expr2, int left, int right)); + extern char * fbl_numtobin __P((int num)); + extern int fbl_tobin __P((char *trg, char *src, int left, int right)); + extern void loc_fbl_error __P((int code, char *str1)); + extern void fbl_toolbug __P((int code, char *str1, char *str2, int nbr1)); + +# define fbl_error( C, S ) \ + fprintf( stderr, "%s.%d: ", __FILE__,__LINE__ ); loc_fbl_error( C, S ); diff --git a/alliance/src/fvh/src/fbl_byacc.h b/alliance/src/fvh/src/fbl_byacc.h new file mode 100644 index 00000000..a9b6bedb --- /dev/null +++ b/alliance/src/fvh/src/fbl_byacc.h @@ -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. | +| | +\------------------------------------------------------------*/ +#ifndef __P +# if defined(__STDC__) || defined(__GNUC__) +# define __P(x) x +# else +# define __P(x) () +# endif +#endif + +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbl_byacc.h */ +/* date : Jun 15 1992 */ +/* version : v102 */ +/* author : Pirouz BAZARGAN SABET */ +/* content : declaration of external functions and global variables*/ +/* used by yacc */ +/* */ +/* ###--------------------------------------------------------------### */ + +# if 0 +typedef struct fbl_expr + { + char *IDENT; /* identifier or constant name */ + struct chain *LIST_ABL; /* pointer on fbl_abllst list */ + char TYPE; + short WIDTH; /* width of bit vector */ + } +fbl_ablstr; +# endif + +typedef struct + { + char *NAME; /* identifier name */ + short LEFT; /* vector's left index */ + short RIGHT; /* vector's right index */ + char FLAG; /* scalar ('S') or array 'A' */ + char TYPE; /* scalar ('S') or array 'A' */ + } +fbl_name; + +struct g_type + { + int VALU; + char FLAG; + }; + +struct choice_chain + { + struct choice_chain* NEXT; + char *VALUE; + unsigned int SIZE; + struct ptype *INSTRUCTION; + }; + +char *FBL_MODNAM; /* curnennt model name */ +fbl_ablstr FBL_SLCEXP; /* structure filled with the */ +fbl_ablstr FBL_EMPSTR; /* empty structure used with NOT*/ + +struct bddnode *FBL_BDDPNT = NULL; /* BDD pointer */ +static char *FBL_LBLNAM = NULL; /* label */ +static int FBL_NUMTYP = 0; /* nombre de type */ +static struct chain *FBL_NM1LST = NULL; /* 1-st name liste */ +static struct chain *FBL_GRDLST = NULL; /* list of guard's ABL */ +static struct chain *FBL_CNDLST = NULL; /* list of conditions (ABL) */ +static struct chain *FBL_VALLST = NULL; /* list of waveforms (ABL) */ +static struct fbfig *FBL_BEFPNT = NULL; /* current BEFIG pointer */ + +static struct choice_chain *FBL_CASPNT = NULL; +static struct ptype *FBL_OTHPNT = NULL; +static struct ptype *FBL_PTYPE = NULL; + +static struct dct_entry *FBL_DCEHED; /* free dct_entry's head */ +static struct dct_recrd *FBL_DCRHED; /* free dct_recrd's head */ + +static authtable *FBL_HASH_ASG_FSM = (authtable *)0; + +extern char FBL_ERRFLG; /* set to 1 in case of error */ +extern struct fbfig *FBL_HEADFIG; /* head of fbfigs */ +extern int FBL_LINNUM; +extern int FBL_NUMPTP; + + +static struct dct_entry **hshtab; + + extern struct fbgen * fbl_addgen __P((struct fbgen *lastgeneric, struct chain *nam_lst, struct chain *nat_lst, char *type, short left, short right)); + extern int val_type __P((char *name)); + + extern int fbl_tobin __P((char *trg, char *src, int left, int right)); + extern int fbl_bintonum __P((char *str)); + extern fbl_ablstr fbl_crtabl __P((short oper, fbl_ablstr expr1, fbl_ablstr expr2, int left, int right)); + extern fbl_ablstr fbl_cpyablstr __P((fbl_ablstr ablstr)); +extern void fbl_select(); + extern char * fbl_stostr __P((char *str)); + + extern void fbl_y_error __P((char *str)); + extern int fbl_y_lex __P(()); + diff --git a/alliance/src/fvh/src/fbl_drive.c b/alliance/src/fvh/src/fbl_drive.c new file mode 100644 index 00000000..0e16f506 --- /dev/null +++ b/alliance/src/fvh/src/fbl_drive.c @@ -0,0 +1,588 @@ +/*------------------------------------------------------------\ +| | +| 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. | +| | +\------------------------------------------------------------*/ +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbl_drive.c */ +/* date : Nouv 05 1992 */ +/* version : v100 */ +/* author : VUONG H.N., M.HANAFI */ +/* description : This file contains VHDL drivers : */ +/* vhdlsavefbfig() */ +/* */ +/* ###--------------------------------------------------------------### */ + +#include +#include +#include +#include "mut.h" +#include "aut.h" +#include "abl.h" +#include "bdd.h" +#include "fvh.h" +#include "fbl_utype.h" +#include "fbl_utdef.h" +#include "fbl_drive.h" + + FILE *FblDriveFile; + static int synopsys = 0; + +/* ###--------------------------------------------------------------### */ +/* function : vhdlsavefbfig */ +/* description : print out a text file containing a data-flow VHDL */ +/* description */ +/* called func. : vhdlablname, mbkalloc, fbl_message, fbl_error , */ +/* fbl_toolbug , getptype, reverse , fbl_printablfile */ +/* ###--------------------------------------------------------------### */ + +void vhdlsavefbdecl( pthedfbfig, synopsys ) + + fbfig_list *pthedfbfig; + int synopsys; +{ + char *type_mark; + int left,right; + char *name; + + struct fbreg *ptfbreg = 0; /* current BEREG pointer */ + struct fbaux *ptfbaux = 0; /* current BEAUX pointer */ + struct fbbux *ptfbbux = 0; /* current BEBUX pointer */ + /* ###------------------------------------------------------### */ + /* Treatment of the BEREG list */ + /* ###------------------------------------------------------### */ + + pthedfbfig->BEREG = (struct fbreg *)reverse( (chain_list *)pthedfbfig->BEREG); + ptfbreg = pthedfbfig->BEREG; + + while (ptfbreg != 0) + { + ptfbreg = (fbreg_list *)fbl_vectnam(ptfbreg,&left,&right,&name,2); + if(left != -1) + { + if ( synopsys ) + (void)fprintf(FblDriveFile," SIGNAL %s : BIT_VECTOR(%d %s %d);\t-- %s\n", + vhdlablname(name),left,(left>=right)?"DOWNTO":"TO", + right,name); + else + (void)fprintf(FblDriveFile," SIGNAL %s : REG_VECTOR(%d %s %d) REGISTER;\t-- %s\n", + vhdlablname(name),left,(left>=right)?"DOWNTO":"TO", + right,name); + } + else + { + if ( synopsys ) + (void) fprintf (FblDriveFile," SIGNAL %s : BIT;\t-- %s\n", + vhdlablname(name),name); + else + (void) fprintf (FblDriveFile," SIGNAL %s : REG_BIT REGISTER;\t-- %s\n", + vhdlablname(name),name); + } + ptfbreg = ptfbreg->NEXT; + } + + pthedfbfig->BEREG = (struct fbreg *)reverse( (chain_list *)pthedfbfig->BEREG); + + /* ###------------------------------------------------------### */ + /* Treatment of the BEBUX list */ + /* ###------------------------------------------------------### */ + + pthedfbfig->BEBUX = (struct fbbux *)reverse( (chain_list *)pthedfbfig->BEBUX); + ptfbbux = pthedfbfig->BEBUX; + while (ptfbbux != 0) + { + ptfbbux = (fbbux_list *)fbl_vectnam(ptfbbux,&left,&right,&name,1); + if(left != -1) + { + switch (ptfbbux->TYPE) + { + case FBH_TYPE_WOR_VEC : + type_mark = namealloc("WOR_VECTOR"); + break; + case FBH_TYPE_MUX_VEC : + type_mark = namealloc("MUX_VECTOR"); + break; + } + (void)fprintf(FblDriveFile," SIGNAL %s : %s(%d %s %d) BUS;\t-- %s\n", + vhdlablname(name),type_mark,left,(left>=right)?"DOWNTO":"TO", + right,name); + } + else + { + switch (ptfbbux->TYPE) + { + case FBH_TYPE_WOR_BIT : + type_mark = namealloc("WOR_BIT"); + break; + case FBH_TYPE_MUX_BIT : + type_mark = namealloc("MUX_BIT"); + break; + } + (void) fprintf (FblDriveFile," SIGNAL %s : %s BUS;\t\t-- %s\n",vhdlablname(name), + type_mark,name); + } + ptfbbux = ptfbbux->NEXT; + } + pthedfbfig->BEBUX = (struct fbbux *)reverse( (chain_list *)pthedfbfig->BEBUX); + + pthedfbfig->BEAUX = (struct fbaux *)reverse( (chain_list *)pthedfbfig->BEAUX); + ptfbaux = pthedfbfig->BEAUX; + while (ptfbaux != 0) + { + if ( ( ptfbaux->ABL != (chain_list *)0 ) || + ( IsFbhAssignByFsm( ptfbaux ) ) ) + { + ptfbaux = (fbaux_list *)fbl_vectnam(ptfbaux,&left,&right,&name,3); + if(left != -1) + { + (void)fprintf(FblDriveFile," SIGNAL %s : BIT_VECTOR(%d %s %d);\t-- %s\n", + vhdlablname(name),left,(left>=right)?"DOWNTO":"TO", + right,name); + } + else + { + (void) fprintf (FblDriveFile," SIGNAL %s : BIT;\t\t-- %s\n", + vhdlablname(name),name); + } + } + ptfbaux = ptfbaux->NEXT; + } + pthedfbfig->BEAUX = (struct fbaux *)reverse( (chain_list *)pthedfbfig->BEAUX); + +} + +void vhdlsavefbport( pthedfbfig, synopsys ) + + fbfig_list *pthedfbfig; + int synopsys; +{ + char *mode; + char *type_mark; + int left,right; + char *name; + char *bus; + + struct fbpor *ptfbpor = 0; /* correctly ordered port list */ + + ptfbpor = pthedfbfig->BEPOR; + if (ptfbpor != 0) + { + (void) fprintf (FblDriveFile," PORT (\n"); + pthedfbfig->BEPOR = (struct fbpor *)reverse ( (chain_list *)pthedfbfig->BEPOR); + + ptfbpor = pthedfbfig->BEPOR; + while (ptfbpor != 0) + { + switch (ptfbpor->DIRECTION) + { + case 'I': + mode = namealloc("IN"); + break; + case 'O': + case 'Z': + mode = namealloc("OUT"); + break; + case 'B': + case 'T': + mode = namealloc("INOUT"); + break; + default : + { + fbl_error (69,0); + } + } + ptfbpor = (fbpor_list *)fbl_vectnam(ptfbpor,&left,&right,&name,0); + + if(left != -1) + { + switch (ptfbpor->TYPE) + { + case FBH_TYPE_BIT_VEC : + type_mark = namealloc("BIT_VECTOR"); + bus = ""; + break; + case FBH_TYPE_WOR_VEC : + type_mark = namealloc("WOR_VECTOR"); + bus = namealloc("BUS"); + break; + case FBH_TYPE_MUX_VEC : + type_mark = namealloc("MUX_VECTOR"); + bus = namealloc("BUS"); + break; + default : + { + fbl_error (68,0); + } + } + (void)fprintf(FblDriveFile," %s : %s %s(%d %s %d) %s",vhdlablname(name), mode, + type_mark, left, (left>=right)?"DOWNTO":"TO",right,bus); + } + else + { + switch (ptfbpor->TYPE) + { + case FBH_TYPE_BIT : + type_mark = "BIT"; break; + case FBH_TYPE_WOR_BIT : + type_mark = "WOR_BIT BUS"; break; + case FBH_TYPE_MUX_BIT : + type_mark = "MUX_BIT BUS"; break; + default : + { + fbl_error (68,0); + } + } + + (void) fprintf (FblDriveFile," %s : %s %s",vhdlablname(name), + mode,type_mark); + } + + if (ptfbpor->NEXT != 0) + (void) fprintf (FblDriveFile,";\t-- %s\n",name); + else + (void) fprintf (FblDriveFile,"\t-- %s\n );\n",name); + + ptfbpor = ptfbpor->NEXT; + } + + pthedfbfig->BEPOR = (struct fbpor *)reverse ( (chain_list *)pthedfbfig->BEPOR); + } + +} + + +void vhdlsavefbarchi( pthedfbfig, synopsys ) + + fbfig_list *pthedfbfig; + int synopsys; +{ + int nrlabel = 0; + struct fbreg *ptfbreg = 0; /* current BEREG pointer */ + struct fbmsg *ptfbmsg = 0; /* current BEMSG pointer */ + struct fbout *ptfbout = 0; /* current BEOUT pointer */ + struct fbbus *ptfbbus = 0; /* current BEBUS pointer */ + struct fbaux *ptfbaux = 0; /* current BEAUX pointer */ + struct fbbux *ptfbbux = 0; /* current BEBUX pointer */ + struct biabl *ptbiabl = 0; /* current BIABL pointer */ + + /* ###------------------------------------------------------### */ + /* Print out a concurrent assert statement for each BEMSG */ + /* ###------------------------------------------------------### */ + + ptfbmsg = pthedfbfig->BEMSG; + while (ptfbmsg != 0) + { + if (ptfbmsg->LABEL != 0) + (void)fprintf(FblDriveFile," %s :",ptfbmsg->LABEL); + + (void) fprintf (FblDriveFile," ASSERT (" ); + fbl_printablfile(FblDriveFile, ptfbmsg->ABL ); + (void) fprintf (FblDriveFile," = '1')\n" ); + + if (ptfbmsg->MESSAGE != 0) + (void) fprintf (FblDriveFile," REPORT \"%s\"\n",ptfbmsg->MESSAGE); + + if (ptfbmsg->LEVEL == 'W') + (void) fprintf (FblDriveFile," SEVERITY WARNING;"); + else + (void) fprintf (FblDriveFile," SEVERITY ERROR;"); + + (void) fprintf (FblDriveFile,"\n\n"); + ptfbmsg = ptfbmsg->NEXT; + } + + /* ###------------------------------------------------------### */ + /* Print out a concurrent signal assignment for each BEAUX */ + /* ###------------------------------------------------------### */ + + ptfbaux = pthedfbfig->BEAUX; + + while (ptfbaux != 0) + { + if (ptfbaux->ABL != 0) + { + (void) fprintf (FblDriveFile," %s <= ",fbl_vectorize(ptfbaux->NAME)); + fbl_printablfile( FblDriveFile, ptfbaux->ABL); + (void) fprintf (FblDriveFile,";\n"); + } + /* LUDO + else + { + fbl_error (40,ptfbaux->NAME); + } */ + ptfbaux = ptfbaux->NEXT; + } + + /* ###------------------------------------------------------### */ + /* Print out a block statement with one guarded concurrent */ + /* signal assignment for each BIABL of each BEREG */ + /* ###------------------------------------------------------### */ + + ptfbreg = pthedfbfig->BEREG; + + while (ptfbreg != 0) + { + ptbiabl = ptfbreg->BIABL; + while (ptbiabl != 0) + { + if ( synopsys ) + (void) fprintf (FblDriveFile," proc_%d : PROCESS ",nrlabel); + else + (void) fprintf (FblDriveFile," label%d : BLOCK ",nrlabel); + if (ptbiabl->CNDABL != 0) + { + if ( ! synopsys ) + { + (void) fprintf (FblDriveFile,"(" ); + fbl_printablfile( FblDriveFile, ptbiabl->CNDABL ); + (void) fprintf (FblDriveFile," = '1')\n" ); + } + } + else + fbl_toolbug (19,"fbl_decomp",ptfbreg->NAME,0); + + (void) fprintf (FblDriveFile," BEGIN\n" ); + + if ( synopsys ) + { + (void) fprintf (FblDriveFile," WAIT UNTIL (" ); + fbl_printablfile( FblDriveFile, ptbiabl->CNDABL ); + (void) fprintf (FblDriveFile," = '1');\n" ); + } + + (void) fprintf (FblDriveFile," %s <= %s ", + fbl_vectorize(ptfbreg->NAME), + ( synopsys ) ? "" : "GUARDED" ); + if (ptbiabl->VALABL != 0) + { + fbl_printablfile( FblDriveFile, ptbiabl->VALABL ); + (void)fprintf (FblDriveFile,";\n" ); + } + else + fbl_toolbug (20,"fbl_decomp",ptfbreg->NAME,0); + + if ( synopsys ) + (void) fprintf( FblDriveFile," END PROCESS proc_%d;\n",nrlabel); + else + (void) fprintf( FblDriveFile," END BLOCK label%d;\n",nrlabel); + ptbiabl = ptbiabl->NEXT; + nrlabel++; + } + + ptfbreg = ptfbreg->NEXT; + } + + /* ###------------------------------------------------------### */ + /* Print out a block statement with one guarded concurrent */ + /* signal assignment for each BIABL of each BEBUX */ + /* ###------------------------------------------------------### */ + + ptfbbux = pthedfbfig->BEBUX; + while (ptfbbux != 0) + { + ptbiabl = ptfbbux->BIABL; + while (ptbiabl != 0) + { + (void) fprintf (FblDriveFile," label%d : BLOCK (",nrlabel); + if (ptbiabl->CNDABL != 0) + { + fbl_printablfile( FblDriveFile, ptbiabl->CNDABL ); + (void) fprintf (FblDriveFile," = '1')\n" ); + } + else + fbl_toolbug (19,"fbl_decomp",ptfbbux->NAME,0); + + (void) fprintf (FblDriveFile," BEGIN\n %s <= GUARDED ", + fbl_vectorize(ptfbbux->NAME)); + if (ptbiabl->VALABL != 0) + { + fbl_printablfile( FblDriveFile, ptbiabl->VALABL ); + (void) fprintf (FblDriveFile,";\n" ); + } + else + fbl_toolbug (20,"fbl_decomp",ptfbbux->NAME,0); + + (void) fprintf (FblDriveFile," END BLOCK label%d;\n",nrlabel); + ptbiabl = ptbiabl->NEXT; + nrlabel++; + } + + ptfbbux = ptfbbux->NEXT; + } + + /* ###------------------------------------------------------### */ + /* Print out a block statement with one guarded concurrent */ + /* signal assignment for each BIABL of each BEBUS */ + /* ###------------------------------------------------------### */ + + ptfbbus = pthedfbfig->BEBUS; + while (ptfbbus != 0) + { + ptbiabl = ptfbbus->BIABL; + while (ptbiabl != 0) + { + (void) fprintf (FblDriveFile,"\tlabel%d : BLOCK (",nrlabel); + if (ptbiabl->CNDABL != 0) + { + fbl_printablfile ( FblDriveFile, ptbiabl->CNDABL ); + (void) fprintf (FblDriveFile," = '1')\n" ); + } + else + fbl_toolbug (19,"fbl_decomp",ptfbbus->NAME,0); + + (void) fprintf (FblDriveFile,"\tBEGIN\n\t%s <= GUARDED ",fbl_vectorize(ptfbbus->NAME)); + if (ptbiabl->VALABL != 0) + { + fbl_printablfile( FblDriveFile, ptbiabl->VALABL ); + (void) fprintf (FblDriveFile,";\n" ); + } + else + fbl_toolbug (20,"fbl_decomp",ptfbbus->NAME,0); + + (void) fprintf (FblDriveFile,"\tEND BLOCK label%d;\n",nrlabel); + ptbiabl = ptbiabl->NEXT; + nrlabel++; + } + + ptfbbus = ptfbbus->NEXT; + } + + /* ###------------------------------------------------------### */ + /* Print out a concurrent signal assignment for each BEOUT */ + /* ###------------------------------------------------------### */ + + ptfbout = pthedfbfig->BEOUT; + + while (ptfbout != 0) + { + if (ptfbout->ABL != 0) + { + (void) fprintf (FblDriveFile,"\n%s <= ",fbl_vectorize(ptfbout->NAME) ); + fbl_printablfile( FblDriveFile, ptfbout->ABL ); + (void) fprintf (FblDriveFile,";\n" ); + } + else + { + fbl_error (40,ptfbout->NAME); + } + + ptfbout = ptfbout->NEXT; + } + +} + +void vhdlsavefbfig( pthedfbfig, FileName, synopsys ) + +fbfig_list *pthedfbfig; +char *FileName; +int synopsys; +{ + time_t clock; + + struct fbgen *ptgeneric = 0; /* current ptype pnt (generic) */ + struct ptype *ptptype = 0; /* current ptype pointer (USER) */ + + if (pthedfbfig == 0) + fbl_toolbug (10,"fbl_decomp",0,0); + + fbl_message (11,0,0); + + /* ###------------------------------------------------------### */ + /* Opening result file */ + /* ###------------------------------------------------------### */ + + if ((FblDriveFile = mbkfopen( FileName, ( synopsys ) ? "vhd" : "vbe",WRITE_TEXT)) == 0) + { + fbl_error (107,0); + autexit (1); + } + + fbl_message (12,pthedfbfig->NAME,0); + fbl_message (13,pthedfbfig->NAME,0); + + time (&clock); + (void) fprintf (FblDriveFile,"-- VHDL data flow description generated from `%s`\n", + pthedfbfig->NAME); + (void) fprintf (FblDriveFile,"--\t\tdate : %s\n\n",ctime(&clock)); + + /* ###------------------------------------------------------### */ + /* Entity declaration */ + /* ###------------------------------------------------------### */ + + (void) fprintf (FblDriveFile,"-- Entity Declaration\n\n"); + (void) fprintf (FblDriveFile,"ENTITY %s IS\n",vhdlablname(pthedfbfig->NAME)); + + /* ###------------------------------------------------------### */ + /* Generic declaration */ + /* ###------------------------------------------------------### */ + + ptptype = getptype (pthedfbfig->USER,FBH_GENERIC); + if (ptptype != 0) + { + ptptype->DATA = (void *)reverse (ptptype->DATA); + ptgeneric = (struct fbgen *)ptptype->DATA; + (void) fprintf (FblDriveFile," GENERIC (\n"); + while (ptgeneric != 0) + { + (void) fprintf (FblDriveFile," CONSTANT %s : NATURAL := %ld", + vhdlablname(ptgeneric->NAME),*((long *)ptgeneric->VALUE)); + if (ptgeneric->NEXT != 0) + (void)fprintf(FblDriveFile,";\t-- %s\n",(char *)ptgeneric->NAME); + else + (void)fprintf(FblDriveFile,"\t-- %s\n",(char *)ptgeneric->NAME); + + ptgeneric = ptgeneric->NEXT; + } + (void) fprintf (FblDriveFile," );\n"); + ptptype->DATA = (void *)reverse (ptptype->DATA); + } + + /* ###------------------------------------------------------### */ + /* Port declaration */ + /* ###------------------------------------------------------### */ + + vhdlsavefbport( pthedfbfig, synopsys ); + + (void) fprintf (FblDriveFile,"END %s;\n\n\n",vhdlablname(pthedfbfig->NAME)); + + /* ###------------------------------------------------------### */ + /* Architecture declaration */ + /* ###------------------------------------------------------### */ + + (void) fprintf (FblDriveFile,"-- Architecture Declaration\n\n"); + (void) fprintf (FblDriveFile,"ARCHITECTURE VBE OF %s IS\n", + vhdlablname(pthedfbfig->NAME)); + + vhdlsavefbdecl( pthedfbfig, synopsys ); + + (void) fprintf (FblDriveFile,"\nBEGIN\n"); + + vhdlsavefbarchi( pthedfbfig, synopsys ); + + (void) fprintf (FblDriveFile,"END;\n"); + fbl_message (14,pthedfbfig->NAME,0); + (void) fclose (FblDriveFile); + +} diff --git a/alliance/src/fvh/src/fbl_drive.h b/alliance/src/fvh/src/fbl_drive.h new file mode 100644 index 00000000..423bfaf7 --- /dev/null +++ b/alliance/src/fvh/src/fbl_drive.h @@ -0,0 +1,56 @@ +/*------------------------------------------------------------\ +| | +| 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 +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbl_drive.h */ +/* date : Nouv 05 1992 */ +/* version : v100 */ +/* author : VUONG H.N. */ +/* content : declaration of functions and global variables used by */ +/* the fbhavioural decompiler */ +/* */ +/* ###--------------------------------------------------------------### */ + + +extern char *fbl_vhdlname(); + extern void fbl_printablfile __P((FILE *AblFile, ablexpr *Expr)); +extern char *fbl_printabl(); + extern void fbl_toolbug __P((int code, char *str1, char *str2, int nbr1)); + extern void fbl_message __P((int code, char *str1, int nmb1)); + extern void loc_fbl_error __P((int code, char *str1)); + extern void * fbl_vectnam __P((void *pt_list, int *left, int *right, char **name, char type)); + extern char * fbl_vectorize __P((char *Name)); + +# define fbl_error( C, S ) \ + fprintf( stderr, "%s.%d: ", __FILE__,__LINE__ ); loc_fbl_error( C, S ) diff --git a/alliance/src/fvh/src/fbl_utdef.h b/alliance/src/fvh/src/fbl_utdef.h new file mode 100644 index 00000000..729f5310 --- /dev/null +++ b/alliance/src/fvh/src/fbl_utdef.h @@ -0,0 +1,85 @@ +/*------------------------------------------------------------\ +| | +| 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 + +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbl_utdef.h */ +/* date : Jun 18 1992 */ +/* version : v100 */ +/* author : L.A.TABUSSE */ +/* content : declaration of external functions and global variables */ +/* used by yacc */ +/* */ +/* ###--------------------------------------------------------------### */ +#define FBL_ICNDFN 1 /* input port */ +#define FBL_OCNDFN 2 /* output port */ +#define FBL_BCNDFN 3 /* inout port */ +#define FBL_CSTDFN 4 /* constant */ +#define FBL_TPEDFN 5 /* type */ +#define FBL_SGNDFN 6 /* signal */ +#define FBL_STBDFN 7 /* stable's signal */ +#define FBL_VARDFN 7 /* variable */ + +#define FBL_BITDFN 8 /* bit type */ +#define FBL_MUXDFN 16 /* mux_bit type */ +#define FBL_WORDFN 24 /* wor_bit type */ +#define FBL_RBIDFN 32 /* reg_bit type */ +#define FBL_BTVDFN 40 /* bit_vector type */ +#define FBL_MXVDFN 48 /* mux_vector type */ +#define FBL_WRVDFN 56 /* wor_vector type */ +#define FBL_RGVDFN 64 /* reg_vector type */ +#define FBL_NATDFN 88 /* natural type */ +#define FBL_NTVDFN 96 /* nat_vector type */ + +#define FBL_NORDFN 128 /* non guarded signal */ +#define FBL_BUSDFN 256 /* guarded signal (bus) */ +#define FBL_REGDFN 384 /* guarded signal (register)*/ + +#define FBL_MODDFN 0 /* mod_val field of dct_recrd */ +#define FBL_SIGDFN 1 /* sig_val field of dct_recrd */ +#define FBL_TYPDFN 2 /* type_val field of dct_recrd */ +#define FBL_USRDFN 3 /* user_val field of dct_recrd */ +#define FBL_LBLDFN 4 /* lbl_val field of dct_recrd */ +#define FBL_WMXDFN 5 /* wmx_val field of dct_recrd */ +#define FBL_WMNDFN 6 /* wmn_val field of dct_recrd */ +#define FBL_PNTDFN 7 /* pnt_val field of dct_recrd */ + +#define FBL_NAMDFN 0 +#define FBL_NEWDFN 1 + +#define FBL_ALODFN 60 /* minimal size of allocation */ + /* for dct_entry and dct_recrd */ +#define FBL_HSZDFN 97 /* number of entry points in the */ + /* dictionnary */ +#define FBL_MXRDFN 30 diff --git a/alliance/src/fvh/src/fbl_util.c b/alliance/src/fvh/src/fbl_util.c new file mode 100644 index 00000000..67cf0aa7 --- /dev/null +++ b/alliance/src/fvh/src/fbl_util.c @@ -0,0 +1,762 @@ +/*------------------------------------------------------------\ +| | +| 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. | +| | +\------------------------------------------------------------*/ + +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbl_util.c */ +/* date : Sep 14 1992 */ +/* version : v100 */ +/* author : Pirouz BAZARGAN SABET, M.HANAFI */ +/* description : This file contains some utility functions : */ +/* fbl_error , fsp_y_error, fsp_toolbug, fsp_message, */ +/* */ +/* ###--------------------------------------------------------------### */ + +#include +#include +#include +#include + +#include "mut.h" +#include "abl.h" +#include "aut.h" +#include "bdd.h" +#include "fvh.h" +#include "fbl_utype.h" +#include "fbl_util.h" +#include "fbl_utdef.h" + +char FBL_ERRFLG = 0; /* if = 1 no structure is made */ +int FBL_LINNUM = 1; /* file's line number */ +int FBL_NUMPTP = 0; /* file's line number */ +fbfig_list *FBL_HEADFIG = (fbfig_list *)0; + + +/* ###--------------------------------------------------------------### */ +/* function : fbl_toolbug */ +/* ###--------------------------------------------------------------### */ +void fbl_toolbug (code,str1,str2,nbr1) + +int code; +char *str1; +char *str2; +int nbr1; + + { + (void) fprintf (stderr,"Fatal error %d executing `%s`: ", code,str1); + switch (code) + { + case 1: + (void) fprintf (stderr,"unknown operator\n"); + break; + case 2: + (void) fprintf (stderr,"cannot create empty atom\n"); + break; + case 3: + (void) fprintf (stderr,"cannot build NOT of empty expression\n"); + break; + case 4: + (void) fprintf (stderr,"cannot combine empty expressions\n"); + break; + case 5: + (void) fprintf (stderr,"cannot find terminal\n"); + break; + case 6: + (void) fprintf (stderr,"cannot make BDD of empty expression\n"); + break; + case 7: + (void) fprintf (stderr,"unknown type `%c` for IO `%s`\n",nbr1,str2); + break; + case 8: + (void) fprintf (stderr,"illegal signal value : hex `%x`\n",nbr1); + break; + case 9: + (void) fprintf (stderr,"unknown mode `%c` for IO `%s`\n",nbr1,str2); + break; + case 10: + (void) fprintf (stderr,"decompiler called on empty fbfig\n"); + break; + case 12: + (void) fprintf (stderr,"illegal user value '%c' for IO\n",nbr1); + break; + case 13 : + (void) fprintf (stderr,"cannot find model of `%s`\n",str2); + break; + case 14 : + (void) fprintf (stderr,"cannot convert empty expression\n"); + break; + case 15 : + (void) fprintf (stderr,"illegal bit string value : `%c`\n",nbr1); + break; + case 16 : + (void) fprintf (stderr,"the same expression cannot be used twice\n"); + break; + case 17 : + (void) fprintf (stderr,"unknown base specifier : `%c`\n",nbr1); + break; + case 18: + (void) fprintf (stderr,"unknown mode `%c` for port `%s`\n",nbr1,str2); + break; + case 19: + (void) fprintf (stderr,"empty guard expression: `%s`\n",str2); + break; + case 20: + (void) fprintf (stderr,"empty waveform expression: `%s`\n",str2); + break; + case 21: + (void) fprintf (stderr,"cannot find structural level\n"); + break; + case 22: + (void) fprintf (stderr,"`%s` : `%c` unknown resolution function\n",str2,nbr1); + break; + } + autexit (1); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbl_message */ +/* ###--------------------------------------------------------------### */ +void fbl_message (code,str1,nmb1) + +int code; +char *str1; +int nmb1; + + { + switch (code) + { + case 1: + (void) fprintf (stderr,"Usage : asimut [ ] [-option]\n"); + (void) fprintf (stderr,"or asimut -help\n"); + break; + case 2: + (void) fprintf (stdout,"Initializing ...\n"); + break; + case 3: + (void) fprintf (stdout,"Compiling `%s` (Behaviour) ...\n",str1); + break; + case 4: + (void) fprintf (stdout,"Compiling `%s` (Structural) ...\n\n",str1); + break; + case 5: + (void) fprintf (stdout,"Searching `%s` ...\n",str1); + break; + case 8: + (void) fprintf (stdout,"Compiling `%s` (Pattern) ...\n\n",str1); + break; + case 9: + (void) fprintf (stdout,"Linking ...\n"); + break; + case 10: + (void) fprintf (stdout,"###----- processing pattern %d -----###\n",nmb1); + break; + case 11: +/*\ + (void) fprintf (stdout,"Decompiling ...\n"); +\*/ + break; + case 12: +/*\ + (void) fprintf (stdout,"Generating the file '%s' ...\n",str1); +\*/ + break; + case 13: +/*\ + (void) fprintf (stdout,"Saving '%s' in a vhdl file\n",str1); +\*/ + break; + case 14: +/*\ + (void) fprintf (stdout,"File '%s' has been generated.\n",str1); +\*/ + break; + case 15: + (void) fprintf (stdout,"Making Bdd ...\n\n"); + break; + case 16: + (void) fprintf (stdout,"Restoring ...\n\n"); + break; + default: + (void) fprintf (stderr,"fbl_message : code %d unknown.\n",code); + } + } + +/* ###--------------------------------------------------------------### */ +/* function : fbl_error */ +/* ###--------------------------------------------------------------### */ + +void loc_fbl_error (code,str1) + +int code; +char *str1; + + { + FBL_ERRFLG++; + if (code < 100) + (void)fprintf (stderr,"Error %d line %d :",code,FBL_LINNUM); + else + { + if (code < 200) + (void)fprintf (stderr,"Error %d :",code); + } + + switch (code) + { + case 1: + (void) fprintf (stderr,"`%s` is incompatible with the entity name\n",str1); + break; + case 2: + (void) fprintf (stderr,"bad entity declaration\n"); + break; + case 3: + (void) fprintf (stderr,"bad port clause declaration\n"); + break; + case 4: + (void) fprintf (stderr,"port `%s` already declared\n",str1); + break; + case 5: + (void) fprintf (stderr,"illegal port declaration (mode, type, kind)\n"); + break; + case 6: + (void) fprintf (stderr,"bad port declaration\n"); + break; + case 7: + (void) fprintf (stderr,"`%s` is incompatible with the architecture name\n",str1); + break; + case 8: + (void) fprintf (stderr,"bad architecture declaration\n"); + break; + case 9: + (void) fprintf (stderr,"illegal declaration\n"); + break; + case 10: + (void) fprintf (stderr,"signal `%s` already declared\n",str1); + break; + case 11: + (void) fprintf (stderr,"illegal signal declaration (type, kind)\n"); + break; + case 17: + (void) fprintf (stderr,"`%s` unknown port or signal\n",str1); + break; + case 18: + (void) fprintf (stderr,"illegal concurrent statement\n"); + break; + case 19: + (void) fprintf (stderr,"label `%s` already used\n",str1); + break; + case 20: + (void) fprintf (stderr,"`%s` is incompatible with the block's label\n",str1); + break; + case 21: + (void) fprintf (stderr,"input port `%s` cannot be assigned\n",str1); + break; + case 22: + (void) fprintf (stderr,"unguarded signal `%s` assigned by guarded assignment\n",str1); + break; + case 23: + (void) fprintf (stderr,"guarded signal `%s` assigned by unguarded assignment\n",str1); + break; + case 25: + (void) fprintf (stderr,"some choices missing in the selected signal assignment\n"); + break; + case 26: + (void) fprintf (stderr,"output port `%s` cannot be read\n",str1); + break; + case 27: + (void) fprintf (stderr," '%s' only variable can be assigned with ':=' \n",str1); + break; + case 28: + (void) fprintf (stderr,"duplicate choice in selected signal assignment\n"); + break; + case 30: + (void) fprintf (stderr,"illegal use of OTHERS in selected signal assignment\n"); + break; + case 31: + (void) fprintf (stderr,"illegal use of OTHERS in case statement \n"); + break; + case 32: + (void) fprintf (stderr,"null array not supported\n"); + break; + case 33: + (void) fprintf (stderr,"incompatible constraint and type\n"); + break; + case 35: + (void) fprintf (stderr,"illegal assignment of `%s` (widths mismatch)\n",str1); + break; + case 36: + (void) fprintf (stderr,"signal `%s` used out of declared range\n",str1); + break; + case 38: + (void) fprintf (stderr,"width or/and type mismatch\n"); + break; + case 39: + (void) fprintf (stderr,"signal `%s` assigned more than once\n",str1); + break; + case 40: + (void) fprintf (stderr,"signal `%s` never assigned\n",str1); + break; + + case 68: + (void) fprintf (stderr,"BEPOR type is unknown\n"); + break; + case 73: + (void) fprintf (stderr,"`%s` is not a bit string litteral\n",str1); + break; + case 74: + (void) fprintf (stderr,"bad generic declaration\n"); + break; + case 75: + (void) fprintf (stderr,"bad generic element\n"); + break; + case 76: + (void) fprintf (stderr,"`%s`: when expression must be a constant\n",str1); + break; + case 77: + (void) fprintf (stderr,"illegal generic declaration (type, kind)\n"); + break; + case 78: + (void) fprintf (stderr,"illegal constant declaration (type, kind)\n"); + break; + case 79: + (void) fprintf (stderr,"illegal use of attribute STABLE on `%s`\n",str1); + break; + case 80: + (void) fprintf (stderr,"variable `%s` already declared\n",str1); + break; + case 81: + (void) fprintf (stderr,"internal signal not allowed `%s`\n",str1); + break; + case 82: + (void) fprintf (stderr,"enumerate valu `%s` already declared\n",str1); + break; + case 83: + (void) fprintf (stderr,"'%s' illegal index subtype definition \n",str1); + break; + case 84: + (void) fprintf (stderr,"'%s' illegal type mark definition \n",str1); + break; + case 85: + (void) fprintf (stderr,"when choice is empty in case statement \n"); + break; + + case 100: + (void) fprintf (stderr,"cannot find `%s`\n",str1); + break; + case 107: + (void) fprintf (stderr,"Cannot open result file\n"); + break; + case 112: + (void) fprintf (stderr,"multiple driver on guarded signal `%s`\n",str1); + break; + + default: + (void) fprintf (stderr,"syntax error\n"); + break; + } + + if (FBL_ERRFLG > FBL_MXRDFN) + { + (void) fprintf (stderr,"Too many errors. Cannot continue further more\n"); + (void) fprintf (stderr,"\n Have a nice day...\n"); + autexit (1); + } + + } + +/* ###--------------------------------------------------------------### */ +/* function : fbl_y_error */ +/* ###--------------------------------------------------------------### */ +void fbl_y_error (str) + +char *str; + { + FBL_ERRFLG++; + (void)fprintf (stderr,"Error line %d : %s\n",FBL_LINNUM,str); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbl_vectorize */ +/* content : put parenthesis for bused signals */ +/* ###--------------------------------------------------------------### */ + +char *fbl_vectorize( Name ) + + char *Name; +{ + char *Blank; + char *VhdlName; + +static char Buffer[ 1024 ]; + + Blank = strchr( Name, ' ' ); + + if ( Blank != (char *)0 ) + { + strcpy( Buffer, Name ); + Buffer[ Blank - Name ] = '\0'; + + VhdlName = vhdlablname( Buffer ); + + sprintf( Buffer, "%s(%s)", VhdlName, Blank + 1 ); + + Name = namealloc( Buffer ); + } + else + { + if ( strchr( Name, '\'' ) == (char *)0 ) + { + Name = vhdlablname( Name ); + } + } + + return( Name ); +} + +/* ###--------------------------------------------------------------### */ +/* function : fbl_vectnam */ +/* analyze a list of signal and return the bounds of the vectorised */ +/* signals, if they occure. */ +/* ###--------------------------------------------------------------### */ +void *fbl_vectnam(pt_list,left,right,name,type) + +void *pt_list; +int *left, *right; +char **name; +char type; /* If type = 0 fbpor_list, type = 1 fbbux_list */ + /* If type = 2 fbreg_list, type = 3 fbaux_list */ + + { + char *blank_space; + char *sig_name; + char name_tmp[200]; + char number[200]; + fbpor_list *ptpor; + fbbux_list *ptbux; + fbaux_list *ptaux; + fbreg_list *ptreg; + char END = 0; + + /* Case fbpor_list */ + if(type==0) + { + ptpor = (fbpor_list *)pt_list; + *left = *right = -1; + sig_name = ptpor->NAME; + *name = (char*)mbkalloc(strlen(sig_name) + 1); + strcpy(*name,sig_name); + blank_space = strchr(*name,' '); + if (blank_space != 0) + { + strcpy(number,blank_space); + *left = atoi(number); + *right = *left; + *blank_space = '\0'; + } + + while(!END) + { + if(ptpor->NEXT != 0) + { + strcpy(name_tmp,(ptpor->NEXT)->NAME); + blank_space = strchr(name_tmp,' '); + if(blank_space!=0) + { + strcpy(number,blank_space); + *blank_space = '\0'; + if(!strcmp(*name,name_tmp)) + { + *right = atoi(number); + ptpor = ptpor->NEXT; + } + else + END = 1; + } + else + END = 1; + } + else + END = 1; + } + return((void *)ptpor); + } + + /*case fbbux_list */ + if(type==1) + { + ptbux = (fbbux_list *)pt_list; + /* Extract the name and number of an element */ + *left = *right = -1; + sig_name = ptbux->NAME; + *name = (char *)mbkalloc(strlen(sig_name) + 1); + strcpy(*name,sig_name); + blank_space = strchr(*name,' '); + if (blank_space != 0) + { + strcpy(number,blank_space); + *right = atoi(number); + *left = *right; + *blank_space = '\0'; + } + + while(END != 1) + { + if(ptbux->NEXT != 0) + { + strcpy(name_tmp,ptbux->NEXT->NAME); + blank_space = strchr(name_tmp,' '); + if(blank_space!=0) + { + strcpy(number,blank_space); + *blank_space = '\0'; + if(!strcmp(*name,name_tmp)) + { + *right = atoi(number); + ptbux = ptbux->NEXT; + } + else + END = 1; + } + else + END = 1; + } + else + END = 1; + } + return((void *)ptbux); + } + + /*case fbreg_list */ + if(type==2) + { + ptreg = (fbreg_list *)pt_list; + /* Extract the name and number of an element */ + *left = *right = -1; + sig_name = ptreg->NAME; + *name = (char *)mbkalloc(strlen(sig_name) + 1); + strcpy(*name,sig_name); + blank_space = strchr(*name,' '); + if (blank_space != 0) + { + strcpy(number,blank_space); + *right = atoi(number); + *left = *right; + *blank_space = '\0'; + } + + while(END != 1) + { + if(ptreg->NEXT != 0) + { + strcpy(name_tmp,ptreg->NEXT->NAME); + blank_space = strchr(name_tmp,' '); + if(blank_space!=0) + { + strcpy(number,blank_space); + *blank_space = '\0'; + if(!strcmp(*name,name_tmp)) + { + *right = atoi(number); + ptreg = ptreg->NEXT; + } + else + END = 1; + } + else + END = 1; + } + else + END = 1; + } + return((void *)ptreg); + } + + /*case fbaux_list */ + if(type==3) + { + ptaux = (fbaux_list *)pt_list; + /* Extract the name and number of an element */ + *left = *right = -1; + sig_name = ptaux->NAME; + *name = (char *)mbkalloc(strlen(sig_name) + 1); + strcpy(*name,sig_name); + blank_space = strchr(*name,' '); + if (blank_space != 0) + { + strcpy(number,blank_space); + *right = atoi(number); + *left = *right; + *blank_space = '\0'; + } + + while(END != 1) + { + if(ptaux->NEXT != 0) + { + strcpy(name_tmp,ptaux->NEXT->NAME); + blank_space = strchr(name_tmp,' '); + if(blank_space!=0) + { + strcpy(number,blank_space); + *blank_space = '\0'; + if(!strcmp(*name,name_tmp)) + { + *right = atoi(number); + ptaux = ptaux->NEXT; + } + else + END = 1; + } + else + END = 1; + } + else + END = 1; + } + return((void *)ptaux); + } + return((void *)0); + } + +/* ###--------------------------------------------------------------### */ +/* function : fbl_printabl */ +/* ###--------------------------------------------------------------### */ + +/*\ +void fbl_printabl( Expr ) + + chain_list *Expr; +{ + int Oper; + char *String; + int Length; + + if ( fbl_abllength > 80 ) + { + fprintf( fbl_ablfile, "\n " ); + fbl_abllength = 0; + } + + if ( ABL_ATOM( Expr ) ) + { + String = fbl_vectorize( ABL_ATOM_VALUE( Expr ) ); + fbl_abllength += strlen( String ); + fprintf( fbl_ablfile, String ); + } + else + { + Oper = ABL_OPER( Expr ); + String = getablopername( Oper ); + Length = strlen( String ); + + if ( Oper == ABL_NOT ) + { + fbl_abllength += Length + 1; + fprintf( fbl_ablfile, "%s(", String ); + + fbl_printabl( ABL_CADR( Expr ) ); + + fprintf( fbl_ablfile, ")" ); + fbl_abllength += 1; + } + else + if ( Oper == ABL_STABLE ) + { + fbl_printabl( ABL_CADR( Expr ) ); + fbl_abllength += Length + 1; + fprintf( fbl_ablfile, "'%s", String ); + } + else + { + if ( Oper != ABL_NXOR ) + { + fprintf( fbl_ablfile, "(" ); + fbl_abllength += 1; + } + else + { + fprintf( fbl_ablfile, "not(" ); + fbl_abllength += 4; + + String = getablopername( ABL_XOR ); + Length = strlen( String ); + } + + while ( ( Expr = ABL_CDR( Expr ) ) != (chain_list *)0 ) + { + fbl_printabl( ABL_CAR( Expr ) ); + + if ( ABL_CDR( Expr ) ) + { + fbl_abllength += Length + 2; + fprintf( fbl_ablfile, " %s ", String ); + } + } + + fprintf( fbl_ablfile, ")" ); + fbl_abllength += 2; + } + } +} +\*/ + +void fbl_printablfile( AblFile, Expr ) + + FILE *AblFile; + ablexpr *Expr; +{ + viewablexprfile( AblFile, Expr, ABL_VIEW_VHDL ); +} + +/*\ + +void fbl_printsens( AblFile, Expr ) + + FILE *AblFile; +{ + chain_list *Support; + chain_list *ScanSupport; + int First; + + Support = getablexprsupport( Expr, ABL_SUPPORT_CHAIN ); + First = 1; + + for ( ScanSupport = Support; + ScanSupport != (chain_list *)0; + ScanSupport = ScanSupport->NEXT ) + { + if ( First ) fprintf( AblFile, "( %s", fbl_vectorize( ScanSupport->DATA ) ); + else fprintf( AblFile, ", %s", fbl_vectorize( ScanSupport->DATA ) ); + + First = 0; + } + + freechain( Support ); + + if ( ! First ) (void) fprintf( AblFile, " )" ); +} + +\*/ diff --git a/alliance/src/fvh/src/fbl_util.h b/alliance/src/fvh/src/fbl_util.h new file mode 100644 index 00000000..15d9b6af --- /dev/null +++ b/alliance/src/fvh/src/fbl_util.h @@ -0,0 +1,48 @@ +/*------------------------------------------------------------\ +| | +| 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 +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbl_util.h */ +/* date : Jun 15 1992 */ +/* version : v100 */ +/* author : Pirouz BAZARGAN SABET */ +/* description : This file contains declaration of global and external */ +/* variables and, functions used in `fbl_util.c` */ +/* */ +/* ###--------------------------------------------------------------### */ + + +extern int FBL_LINNUM; /* file's line number */ +extern char FBL_ERRFLG; /* Error flag */ +extern char FBL_CURFIL[]; /* current file name */ diff --git a/alliance/src/fvh/src/fbl_utype.h b/alliance/src/fvh/src/fbl_utype.h new file mode 100644 index 00000000..77ddff59 --- /dev/null +++ b/alliance/src/fvh/src/fbl_utype.h @@ -0,0 +1,65 @@ +/*------------------------------------------------------------\ +| | +| 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 + +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fbl_utype.h */ +/* date : Jun 15 1992 */ +/* version : v100 */ +/* author : P.BAZARGAN L.A.TABUSSE VUONG H.N. */ +/* content : declaration of external functions and global variables */ +/* used by yacc */ +/* */ +/* ###--------------------------------------------------------------### */ + +struct dct_entry + { + struct dct_entry *next; + struct dct_recrd *data; + char *key; + }; + +struct dct_recrd + { + struct dct_recrd *next; + char *key; + short fd0_val; + short fd1_val; + short fd2_val; + short fd3_val; + short fd4_val; + short fd5_val; + short fd6_val; + long pnt_val; + }; diff --git a/alliance/src/fvh/src/fvh.h b/alliance/src/fvh/src/fvh.h new file mode 100644 index 00000000..44f1fc1c --- /dev/null +++ b/alliance/src/fvh/src/fvh.h @@ -0,0 +1,387 @@ +/*------------------------------------------------------------\ +| | +| 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 +/* ###--------------------------------------------------------------### */ +/* */ +/* file : fvh.h */ +/* date : Aug 28 1992 */ +/* version : 102 */ +/* authors : Pirouz BAZARGAN SABET */ +/* contents : defines and structure definitions used in FBH library */ +/* */ +/* ###--------------------------------------------------------------### */ + +#ifndef FBH_DEFINE +#define FBH_DEFINE + + /* ###------------------------------------------------------### */ + /* defines */ + /* ###------------------------------------------------------### */ + +#define FBH_GENERIC 203698 /* generic ptype code */ +#define FBH_BEIFS 205635 /* if statement ptype code */ +#define FBH_BECAS 423240 /* case statement ptype code */ +#define FBH_BEMSG 153676 /* assert statement ptype code */ +#define FBH_BEASG 967324 /* assign statement ptype code */ + +#define FBH_TYPE_SEVERITY 1 +#define FBH_TYPE_BOOLEAN 2 +#define FBH_TYPE_BIT 3 +#define FBH_TYPE_INTEGER 4 +#define FBH_TYPE_MUX_BIT 5 +#define FBH_TYPE_WOR_BIT 6 +#define FBH_TYPE_REG_BIT 7 +#define FBH_TYPE_NATURAL 8 +#define FBH_TYPE_BIT_VEC 9 +#define FBH_TYPE_MUX_VEC 10 +#define FBH_TYPE_WOR_VEC 11 +#define FBH_TYPE_REG_VEC 12 + +# define FBH_ASSIGN_BY_FSM_MASK 0x1 + +# define SetFbhAssignByFsm( O ) ( (O)->FLAG |= FBH_ASSIGN_BY_FSM_MASK ) +# define ClearFbhAssignByFsm( O ) ( (O)->FLAG &= ~FBH_ASSIGN_BY_FSM_MASK ) +# define IsFbhAssignByFsm( O ) ( (O)->FLAG & FBH_ASSIGN_BY_FSM_MASK ) + + /* ###------------------------------------------------------### */ + /* structure definitions */ + /* ###------------------------------------------------------### */ + +typedef struct fbfig /* fbhaviour figure */ + { + struct fbfig *NEXT; /* next figure */ + char *NAME; /* figure's name */ + struct fbreg *BEREG; /* internal signals (REGISTER) */ + struct fbmsg *BEMSG; /* concurrent assert instructions */ + struct fbrin *BERIN; /* inputs (registers and ports) */ + struct fbout *BEOUT; /* output ports */ + struct fbbus *BEBUS; /* output ports (BUS) */ + struct fbaux *BEAUX; /* internal signals */ + struct fbaux *BEDLY; /* internal delayed signals */ + struct fbbux *BEBUX; /* internal signals (BUS) */ + struct fbpor *BEPOR; /* ports (reverse order of declaration) */ + struct fbpcs *BEPCS; /* list of processes */ + struct bddcircuit *CIRCUI; /* Circuit's pointer used for BDDs */ + struct ptype *USER; /* reserved for user's applications */ + unsigned char FLAG; /* error flags */ + unsigned char TYPE; /* type of the description (not used) */ + struct fbtyp *BETYP; /* list of declared types */ + struct fbpgm *BEPGM; /* list of pragmas */ + } +fbfig_list; + +typedef struct fbreg /* register */ + { + struct fbreg *NEXT; /* next register */ + char *NAME; /* register's name */ + struct biabl *BIABL; /* list of drivers (ABL) */ + struct binode *BINODE; /* list of drivers (BDD) */ + unsigned char FLAG; + void *USER; + } +fbreg_list; + +typedef struct fbmsg /* assert instruction */ + { + struct fbmsg *NEXT; /* next assertion */ + char LEVEL; /* severity level of the assertion */ + char *LABEL; /* instruction's label */ + char *MESSAGE; /* assertion's message */ + struct chain *ABL; /* assertion's condition (ABL) */ + bddnode *NODE; /* assertion's condition (BDD) */ + void *USER; + } +fbmsg_list; + +typedef struct fbout /* output port */ + { + struct fbout *NEXT; /* next output */ + char *NAME; /* port's name */ + struct chain *ABL; /* port's equation (ABL) */ + bddnode *NODE; /* port's equation (BDD) */ + unsigned char TYPE; /* port's type */ + unsigned char FLAG; + void *USER; + } +fbout_list; + +typedef struct fbbus /* output port (BUS) */ + { + struct fbbus *NEXT; /* next bus port */ + char *NAME; /* port's name */ + struct biabl *BIABL; /* list of drivers (ABL) */ + struct binode *BINODE; /* list of drivers (BDD) */ + unsigned char TYPE; /* port's type : W or M */ + unsigned char FLAG; + void *USER; + } +fbbus_list; + +typedef struct fbaux /* auxiliary signal */ + { + struct fbaux *NEXT; /* next signal */ + char *NAME; /* signal's name */ + struct chain *ABL; /* signal's equation (ABL) */ + bddnode *NODE; /* signal's equation (BDD) */ + unsigned char TYPE; /* signal's type */ + unsigned char FLAG; + void *USER; + } +fbaux_list; + +typedef struct fbbux /* internal signal (BUS) */ + { + struct fbbux *NEXT; /* next signal */ + char *NAME; /* signal's name */ + struct biabl *BIABL; /* list of drivers (ABL) */ + struct binode *BINODE; /* list of drivers (BDD) */ + unsigned char TYPE; /* signal's type : W or M */ + unsigned char FLAG; + void *USER; + } +fbbux_list; + +typedef struct fbpor /* port */ + { + struct fbpor *NEXT; /* next port */ + char *NAME; /* port's name */ + char DIRECTION; /* port's mode (same as LOCON) */ + unsigned char TYPE; /* port's type (B, M or W) */ + void *USER; + } +fbpor_list; + +typedef struct biabl /* couple of ABL */ + { + struct biabl *NEXT; /* next couple */ + char *LABEL; /* driver's label */ + struct chain *CNDABL; /* driver's connection condition (ABL) */ + struct chain *VALABL; /* equation of driven value (ABL) */ + void *USER; + } +biabl_list; + +typedef struct binode /* couple of BDD */ + { + struct binode *NEXT; /* next figure */ + bddnode *CNDNODE; /* driver's connection condition (BDD) */ + bddnode *VALNODE; /* equation of driven value (BDD) */ + void *USER; + } +binode_list; + +typedef struct fbrin /* primary inputs */ + { + struct fbrin *NEXT; /* next input */ + char *NAME; /* input's name */ + void *USER; + } +fbrin_list; + +typedef struct fbgen /* generic */ + { + struct fbgen *NEXT; /* next generic */ + char *NAME; /* generic's name */ + char *TYPE; /* generic type's name */ + void *VALUE; /* generic's value */ + void *USER; + } +fbgen_list; + +typedef struct fbpcs /* process */ + { + struct fbpcs *NEXT; /* next process */ + char *LABEL; /* process's label */ + struct chain *SENSITIVITY; /* list of sensitivity */ + struct ptype *INSTRUCTION; /* list of instructions */ + struct chain *OUTPUTS; /* list of assigned signals */ + unsigned char FLAG; /* flag (not used) */ + void *USER; + } +fbpcs_list; + +typedef struct fbifs /* if statement */ + { + struct chain *CND; /* condition (abl) */ + struct ptype *CNDTRUE; /* list of instructions when true */ + struct ptype *CNDFALSE; /* list of instructions when false */ + void *USER; + } +fbifs_list; + +typedef struct fbasg /* signal assignment statement */ + { + char *NAME; /* target's name */ + struct chain *ABL; /* condition (abl) */ + unsigned char TYPE; /* signal's type */ + void *USER; + } +fbasg_list; + +typedef struct fbcas /* case statement */ + { + struct chain *ABL; /* expression (ABL) */ + struct fbcho *CHOICE; /* table of choices */ + unsigned char TYPE; /* expression's type */ + unsigned int SIZE; /* size of choices' table */ + void *USER; + } +fbcas_list; + +typedef struct fbcho /* a choice in a case instruction */ + { + char *VALUE; /* the value of the choice */ + unsigned int SIZE; /* size of the value in byte */ + struct ptype *INSTRUCTION; /* list of instructions */ + void *USER; + } +fbcho_list; + +typedef struct fbtyp /* type or subtype */ + { + struct fbtyp *NEXT; /* next fbtyp */ + char *NAME; /* type's name */ + int LEFT; /* left bound */ + int RIGHT; /* right bound */ + char **VALUE; /* list of values */ + unsigned int SIZE; /* number of values */ + unsigned int BYTE; /* number of bytes needed to code values*/ + char CLASS; /* type's class (E, I, A, S) */ + unsigned char INDEX; /* the type of the index for an array */ + unsigned char BASE; /* the base type or element's type */ + unsigned char RESOLV; /* index of resolution function */ + void *USER; + } +fbtyp_list; + +typedef struct fbpgm /* pragma */ + { + struct fbpgm *NEXT; /* next pragma */ + char *TYPE; /* prgma's type */ + char *NAME; /* object's name */ + void *VALUE; /* prgma's content */ + void *USER; + } +fbpgm_list; + + + /* ###------------------------------------------------------### */ + /* low-level functions */ + /* ###------------------------------------------------------### */ + +extern fbfig_list *FBL_HEADFIG; + + extern struct fbaux * fbh_addfbaux __P((struct fbaux *lastfbaux, char *name, struct chain *abl_expr, bddnode *bdd_expr, unsigned char type)); + extern struct fbbux * fbh_addfbbux __P((struct fbbux *lastfbbux, char *name, struct biabl *biabl, struct binode *binode, char type)); + extern struct fbbus * fbh_addfbbus __P((struct fbbus *lastfbbus, char *name, struct biabl *biabl, struct binode *binode, char type)); + extern struct fbfig * fbh_addfbfig __P((struct fbfig *lastfbfig, char *name)); + extern struct fbgen * fbh_addfbgen __P((struct fbgen *lastfbgen, char *name, char *type, void *value )); + extern struct fbmsg * fbh_addfbmsg __P((struct fbmsg *lastfbmsg, char *label, char level, char *message, struct chain *abl_expr, bddnode *bdd_expr)); + extern struct fbout * fbh_addfbout __P((struct fbout *lastfbout, char *name, struct chain *abl_expr, bddnode *bdd_expr, unsigned char type)); + extern struct fbpor * fbh_addfbpor __P((struct fbpor *lastfbpor, char *name, char dir, unsigned char type)); + extern struct fbreg * fbh_addfbreg __P((struct fbreg *lastfbreg, char *name, struct biabl *biabl, struct binode *binode)); + extern struct fbrin * fbh_addfbrin __P((struct fbrin *lastfbrin, char *name)); + extern struct biabl * fbh_addbiabl __P((struct biabl *lastbiabl, char *label,struct chain *condition, struct chain *value)); + extern struct binode * fbh_addbinode __P((struct binode *lastbinode, bddnode *condition, bddnode *value)); + extern struct ptype * fbh_addfbifs __P((struct ptype *lastptype, struct chain *abl)); + extern struct ptype * fbh_addfbasg __P((struct ptype *lastptype, char *name, struct chain *abl, unsigned char type)); + extern struct ptype * fbh_addfbcas __P((struct ptype *lastptype, struct chain *abl, unsigned char type)); + extern struct fbpcs * fbh_addfbpcs __P((struct fbpcs *lastfbpcs, char *label, struct chain *sens, struct ptype *inst, struct chain *outs, char flag)); + extern struct fbtyp * fbh_addfbtyp __P((struct fbtyp *lastfbtyp, char *name, int left, int right, char **value, unsigned int size, unsigned int byte, unsigned char base, unsigned char index, unsigned char resolv, char class)); + extern struct fbpgm * fbh_addfbpgm __P((struct fbpgm *lastfbpgm, char *type, char *name, void *value)); + extern struct fbtyp * fbh_crtfbtyp __P((struct fbtyp *listfbtyp)); + extern struct fbaux * fbh_delfbaux __P((struct fbaux *listfbaux, struct fbaux *ptfbaux, char mode)); + extern struct fbbux * fbh_delfbbux __P((struct fbbux *listfbbux, struct fbbux *ptfbbux, char mode)); + extern struct fbbus * fbh_delfbbus __P((struct fbbus *listfbbus, struct fbbus *ptfbbus, char mode)); + extern struct fbfig * fbh_delfbfig __P((struct fbfig *listfbfig, struct fbfig *ptfbfig, char mode)); + extern struct fbgen * fbh_delfbgen __P((struct fbgen *listfbgen, struct fbgen *ptfbgen, char mode)); + extern struct fbmsg * fbh_delfbmsg __P((struct fbmsg *listfbmsg, struct fbmsg *ptfbmsg, char mode)); + extern struct fbout * fbh_delfbout __P((struct fbout *listfbout, struct fbout *ptfbout, char mode)); + extern struct fbpor * fbh_delfbpor __P((struct fbpor *listfbpor, struct fbpor *ptfbpor)); + extern struct fbreg * fbh_delfbreg __P((struct fbreg *listfbreg, struct fbreg *ptfbreg, char mode)); + extern struct fbrin * fbh_delfbrin __P((struct fbrin *listfbrin, struct fbrin *ptfbrin)); + extern struct biabl * fbh_delbiabl __P((struct biabl *listbiabl, struct biabl *ptbiabl, char mode)); + extern struct binode * fbh_delbinode __P((struct binode *listbinode, struct binode *ptbinode, char mode)); + extern void fbh_frefbaux __P((struct fbaux *listfbaux)); + extern void fbh_frefbbux __P((struct fbbux *listfbbux)); + extern void fbh_frefbbus __P((struct fbbus *listfbbus)); + extern void fbh_frefbfig __P((struct fbfig *listfbfig)); + extern void fbh_frefbgen __P((struct fbgen *listfbgen)); + extern void fbh_frefbmsg __P((struct fbmsg *listfbmsg)); + extern void fbh_frefbout __P((struct fbout *listfbout)); + extern void fbh_frefbpor __P((struct fbpor *listfbpor)); + extern void fbh_frefbreg __P((struct fbreg *listfbreg)); + extern void fbh_frefbrin __P((struct fbrin *listfbrin)); + extern void fbh_frefbpgm __P((struct fbpgm *listfbpgm)); + extern void fbh_frebiabl __P((struct biabl *listbiabl)); + extern void fbh_frebinode __P((struct binode *listbinode)); + extern void fbh_frefbtyp __P((struct fbtyp *listfbtyp)); + extern void * fbh_getgenval __P((struct fbgen *listfbgen, char *fbgenname)); + extern struct fbaux * fbh_rmvfbaux __P((struct fbaux *listfbaux, char *fbauxname, char mode)); + extern struct fbbux * fbh_rmvfbbux __P((struct fbbux *listfbbux, char *fbbuxname, char mode)); + extern struct fbbus * fbh_rmvfbbus __P((struct fbbus *listfbbus, char *fbbusname, char mode)); + extern struct fbfig * fbh_rmvfbfig __P((struct fbfig *listfbfig, char *fbfigname, char mode)); + extern struct fbgen * fbh_rmvfbgen __P((struct fbgen *listfbgen, char *fbgenname, char mode)); + extern struct fbmsg * fbh_rmvfbmsg __P((struct fbmsg *listfbmsg, char *fbmsglabl, char mode)); + extern struct fbout * fbh_rmvfbout __P((struct fbout *listfbout, char *fboutname, char mode)); + extern struct fbpor * fbh_rmvfbpor __P((struct fbpor *listfbpor, char *fbporname)); + extern struct fbreg * fbh_rmvfbreg __P((struct fbreg *listfbreg, char *fbregname, char mode)); + extern struct fbrin * fbh_rmvfbrin __P((struct fbrin *listfbrin, char *fbrinname)); + + extern struct fbtyp * fbh_prdeftyp __P(()); + /* ###------------------------------------------------------### */ + /* high-level functions */ + /* ###------------------------------------------------------### */ + +extern void fbh_debug (); + + /* ###------------------------------------------------------### */ + /* system-level functions */ + /* ###------------------------------------------------------### */ + +extern FILE *fbh_opnfile (); + + /* ###------------------------------------------------------### */ + /* parser-driver functions */ + /* ###------------------------------------------------------### */ + +extern struct fbfig *fbh_prsvhdl (); +extern struct fbfig *vhdlloadfbfig(); + extern void vhdlsavefbfig __P((fbfig_list *pthedfbfig, char *FileName, int synopsys)); + +extern void vhdlsavefbdecl __P(( fbfig_list *pthedfbfig, int synopsys )); +extern void vhdlsavefbport __P(( fbfig_list *pthedfbfig, int synopsys )); +extern void vhdlsavefbarchi __P(( fbfig_list *pthedfbfig, int synopsys )); + extern FILE *FblDriveFile; + +#endif diff --git a/alliance/src/fvh/src/fvhdrive.c b/alliance/src/fvh/src/fvhdrive.c new file mode 100644 index 00000000..126c78ee --- /dev/null +++ b/alliance/src/fvh/src/fvhdrive.c @@ -0,0 +1,650 @@ +/*------------------------------------------------------------\ +| | +| 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 : FVH | +| | +| File : fvhdrive.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 04.12.96 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "fsm.h" +# include "fvh.h" + +# include "fvherror.h" +# include "fvhdrive.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static FILE *VhdlFile; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| VhdlWriteHeader | +| | +\------------------------------------------------------------*/ + +static void VhdlWriteHeader( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + time_t VhdlTime; + + time( &VhdlTime ); + fprintf( VhdlFile, "-- VHDL FSM : `%s`\n", FsmFigure->NAME ); + fprintf( VhdlFile, "-- DATE : %s\n\n", ctime( &VhdlTime ) ); +} + +/*------------------------------------------------------------\ +| | +| VhdlWriteEntity | +| | +\------------------------------------------------------------*/ + +static void VhdlWriteEntity( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + fsmport_list *Port; + fsmport_list *ScanPort; + char *Name; + char *Vector; + char *NextVector; + char *Direction; + char *Type; + char *Bus; + long Index; + long NextIndex; + long Left; + long Right; + long Way; + + Name = vhdlablname( FsmFigure->NAME ); + + fprintf( VhdlFile, "ENTITY %s IS\n", Name ); + + if ( IsFsmFigMixedRtl( FsmFigure ) ) + { + vhdlsavefbport( (fbfig_list *)FsmFigure->FIGURE, 0 ); + } + else + { + fprintf( VhdlFile, "PORT\n(\n" ); + + Port = FsmFigure->PORT; + + while ( Port != (fsmport_list *)0 ) + { + Vector = vhdlablvector( Port->NAME, &Index ); + + if ( Port->DIR == FSM_DIR_IN ) Direction = "IN"; + else + if ( Port->DIR == FSM_DIR_OUT ) Direction = "OUT"; + else Direction = "INOUT"; + + if ( Vector != (char *)0 ) + { + Left = Right = Index; + Way = -1; + + for ( ScanPort = Port->NEXT; + ScanPort != (fsmport_list *)0; + ScanPort = ScanPort->NEXT ) + { + NextVector = vhdlablvector( ScanPort->NAME, &NextIndex ); + + if ( NextVector != Vector ) break; + + if ( Way == -1 ) + { + if ( NextIndex < Left ) Way = 0; /* downto */ + else Way = 1; /* to */ + } + + Right = NextIndex; + } + + if ( Port->TYPE == FSM_TYPE_BIT_VEC ) Type = "BIT_VECTOR"; + else + if ( Port->TYPE == FSM_TYPE_WOR_VEC ) Type = "WOR_VECTOR"; + else Type = "MUX_VECTOR"; + + if ( Port->TYPE != FSM_TYPE_BIT_VEC ) Bus = "BUS"; + else Bus = ""; + + fprintf( VhdlFile, " %s : %s %s(%ld %s %ld) %s", + vhdlablname( Vector ), Direction, Type, Left, + ( Way ) ? "TO" : "DOWNTO", Right, Bus ); + + Port = ScanPort; + } + else + { + if ( Port->TYPE == FSM_TYPE_BIT ) Type = "BIT"; + else + if ( Port->TYPE == FSM_TYPE_WOR_BIT ) Type = "WOR_BIT BUS"; + else Type = "MUX_BIT BUS"; + + fprintf( VhdlFile, " %s : %s %s", + vhdlablname( Port->NAME ), Direction, Type ); + + Port = Port->NEXT; + } + + if ( Port != (fsmport_list *)0 ) + { + fprintf( VhdlFile, ";\n" ); + } + } + + fprintf( VhdlFile, "\n);\n" ); + } + + fprintf( VhdlFile, "END %s;\n\n", Name ); +} + +/*------------------------------------------------------------\ +| | +| VhdlWriteStack | +| | +\------------------------------------------------------------*/ + +static void VhdlWriteStack( ScanState ) + + fsmstate_list *ScanState; +{ + fsmstack_list *ScanStack; + chain_list *ScanChain; + + for ( ScanChain = ScanState->STACK; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + ScanStack = (fsmstack_list *)ScanChain->DATA; + + if ( IsFsmStarStack( ScanStack ) ) continue; + + if ( ScanStack->ABL != (ablexpr *)0 ) + { + fprintf( VhdlFile, " IF ( " ); + viewablexprfile( VhdlFile, ScanStack->ABL, ABL_VIEW_VHDL ); + fprintf( VhdlFile, " )\n THEN CONTROL <= %s;\n", + FSM_CTRL_NAME[ (long)ScanStack->CTRL ] ); + + if ( ScanStack->CTRL == FSM_CTRL_PUSH ) + { + fprintf( VhdlFile, " RETURN_STATE <= %s;\n", + vhdlablname( ScanStack->RETURN->NAME ) ); + } + else + if ( ScanStack->CTRL == FSM_CTRL_POP ) + { + fprintf( VhdlFile, " NEXT_STATE <= STACK_0;\n" ); + } + + fprintf( VhdlFile, " END IF;\n" ); + } + } +} + +/*------------------------------------------------------------\ +| | +| VhdlWriteLocout | +| | +\------------------------------------------------------------*/ + +static void VhdlWriteLocout( ScanState ) + + fsmstate_list *ScanState; +{ + fsmlocout_list *ScanLocout; + + for ( ScanLocout = ScanState->LOCOUT; + ScanLocout != (fsmlocout_list *)0; + ScanLocout = ScanLocout->NEXT ) + { + if ( ScanLocout->ABL != (ablexpr *)0 ) + { + fprintf( VhdlFile, " %s <= ", vhdlablname( ScanLocout->OUT->NAME ) ); + viewablexprfile( VhdlFile, ScanLocout->ABL, ABL_VIEW_VHDL ); + fprintf( VhdlFile, ";\n" ); + } + + if ( ScanLocout->ABL_DC != (ablexpr *)0 ) + { + if ( ( ABL_ATOM( ScanLocout->ABL_DC ) ) && + ( ABL_ATOM_VALUE( ScanLocout->ABL_DC ) == ABL_ATOM_NAME_ONE ) ) + { + fprintf( VhdlFile, " %s <= 'd';\n", + vhdlablname( ScanLocout->OUT->NAME ) ); + } + else + { + fprintf( VhdlFile, " IF ( " ); + viewablexprfile( VhdlFile, ScanLocout->ABL_DC, ABL_VIEW_VHDL ); + fprintf( VhdlFile, " )\n" ); + fprintf( VhdlFile, " THEN %s <= 'd';\n", + vhdlablname( ScanLocout->OUT->NAME ) ); + fprintf( VhdlFile, " END IF;\n" ); + } + } + } +} + +/*------------------------------------------------------------\ +| | +| VhdlWriteArchitecture | +| | +\------------------------------------------------------------*/ + +static void VhdlWriteArchitecture( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + fsmstate_list *ScanState; + fsmtrans_list *ScanTrans; + fsmtrans_list *NextTrans; + fsmin_list *ScanIn; + chain_list *ScanChain; + chain_list *NextChain; + char *Vector; + char *LastVector; + long NumberState; + long Counter; + long Index; + int FirstOne; + + FsmFigure->STATE = (fsmstate_list *)reverse( (chain_list *)FsmFigure->STATE ); + + fprintf( VhdlFile, "ARCHITECTURE FSM OF %s IS\n\n", + vhdlablname( FsmFigure->NAME ) ); + + fprintf( VhdlFile, "TYPE STATE_TYPE IS\n( " ); + + if ( FsmFigure->STAR_STATE != (fsmstate_list *)0 ) + { + NumberState = FsmFigure->NUMBER_STATE - 1; + } + else + { + NumberState = FsmFigure->NUMBER_STATE; + } + + if ( FsmFigure->FIRST_STATE != (fsmstate_list *)0 ) + { + fprintf( VhdlFile, "\n %s", vhdlablname( FsmFigure->FIRST_STATE->NAME ) ); + + if ( NumberState > 1 ) + { + fprintf( VhdlFile, "," ); + } + + Counter = 1; + } + else + { + Counter = 0; + } + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + if ( ( IsFsmFirstState( ScanState ) ) || + ( IsFsmStarState( ScanState ) ) ) continue; + + Counter = Counter + 1; + + if ( ! ( Counter & 0x7 ) ) + { + fprintf( VhdlFile, "\n %s", vhdlablname( ScanState->NAME ) ); + } + else + { + fprintf( VhdlFile, "%s", vhdlablname( ScanState->NAME ) ); + } + + if ( Counter < NumberState ) + { + fprintf( VhdlFile, "," ); + } + } + + if ( Counter & 0x7 ) + { + fprintf( VhdlFile, "\n" ); + } + + fprintf( VhdlFile, ");\n\n" ); + + if ( FsmFigure->STACK != (fsmstack_list *)0 ) + { + fprintf( VhdlFile, "TYPE CONTROL_TYPE IS\n(\n" ); + + for ( Index = 0; Index < FSM_MAX_CTRL; Index++ ) + { + if ( Index != 0 ) + { + fprintf( VhdlFile, ", " ); + } + + fprintf( VhdlFile, "%s", FSM_CTRL_NAME[ Index ] ); + } + + fprintf( VhdlFile, "\n);\n\n" ); + fprintf( VhdlFile, "SIGNAL CONTROL : CONTROL_TYPE;\n\n" ); + fprintf( VhdlFile, "SIGNAL RETURN_STATE : STATE_TYPE;\n" ); + fprintf( VhdlFile, "SIGNAL STACK_0" ); + + for ( Index = 1; Index < FsmFigure->STACK_SIZE; Index++ ) + { + fprintf( VhdlFile, ", STACK_%ld", Index ); + + if ( ! ( Index & 0x7 ) ) + { + fprintf( VhdlFile, "\n" ); + } + } + + fprintf( VhdlFile, " : STATE_TYPE;\n" ); + } + + fprintf( VhdlFile, "SIGNAL CURRENT_STATE, NEXT_STATE: STATE_TYPE;\n\n" ); + + if ( FsmFigure->FIRST_STATE != (fsmstate_list *)0 ) + { + fprintf( VhdlFile, "--PRAGMA FIRST_STATE %s\n\n", + vhdlablname( FsmFigure->FIRST_STATE->NAME ) ); + } + + if ( FsmFigure->CLOCK != (char *)0 ) + { + fprintf( VhdlFile, "--PRAGMA CLOCK %s\n\n", + vhdlablname( FsmFigure->CLOCK ) ); + } + + if ( IsFsmFigMixedRtl( FsmFigure ) ) + { + vhdlsavefbdecl( (fbfig_list *)FsmFigure->FIGURE, 0 ); + } + + fprintf( VhdlFile, "BEGIN\n" ); + + fprintf( VhdlFile, " PROCESS( CURRENT_STATE" ); + + LastVector = (char *)0; + + for ( ScanIn = FsmFigure->IN; + ScanIn != (fsmin_list *)0; + ScanIn = ScanIn->NEXT ) + { + Vector = vhdlablvector( ScanIn->NAME, &Index ); + + if ( Vector == (char *)0 ) + { + fprintf( VhdlFile, ", %s", vhdlablname( ScanIn->NAME ) ); + LastVector = (char *)0; + } + else + if ( Vector != LastVector ) + { + fprintf( VhdlFile, ", %s", vhdlablname( Vector ) ); + LastVector = Vector; + } + } + + fprintf( VhdlFile, ")\n BEGIN\n" ); + + Counter = 0; + + if ( FsmFigure->STAR_STATE != (fsmstate_list *)0 ) + { + for ( ScanChain = FsmFigure->STAR_STATE->FROM; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + ScanTrans = (fsmtrans_list *)ScanChain->DATA; + + if ( ScanTrans->ABL != (ablexpr *)0 ) + { + if ( Counter > 0 ) fprintf( VhdlFile, " ELSE\n" ); + fprintf( VhdlFile, " IF (( " ); + viewablexprfile( VhdlFile, ScanTrans->ABL, ABL_VIEW_VHDL ); + fprintf( VhdlFile, ") = '1')\n THEN NEXT_STATE <= %s;\n", + vhdlablname( ScanTrans->TO->NAME ) ); + + VhdlWriteLocout( FsmFigure->STAR_STATE ); + + Counter = Counter + 1; + } + } + + while ( Counter > 1 ) + { + fprintf( VhdlFile, " END IF;\n" ); + Counter = Counter - 1; + } +/* +** Treat STACK in STAR_STATE, seems to be crazy +*/ + } + + if ( Counter > 0 ) fprintf( VhdlFile, " ELSE\n" ); + fprintf( VhdlFile, " CASE CURRENT_STATE IS\n" ); + + for ( ScanState = FsmFigure->STATE; + ScanState != (fsmstate_list *)0; + ScanState = ScanState->NEXT ) + { + if ( IsFsmStarState( ScanState ) ) continue; + + fprintf( VhdlFile, " WHEN %s =>\n", vhdlablname( ScanState->NAME ) ); + +/* +** Treat TRANS +*/ + FirstOne = 1; + + for ( ScanChain = ScanState->FROM; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + ScanTrans = (fsmtrans_list *)ScanChain->DATA; + + if ( IsFsmStarTrans( ScanTrans ) ) continue; + + for ( NextChain = ScanChain->NEXT; + NextChain != (chain_list *)0; + NextChain = NextChain->NEXT ) + { + NextTrans = (fsmtrans_list *)ScanChain->DATA; + if ( ! IsFsmStarTrans( NextTrans ) ) break; + } + + if ( ScanTrans->ABL != (ablexpr *)0 ) + { + if ( FirstOne ) + { + fprintf( VhdlFile, " IF (( " ); + viewablexprfile( VhdlFile, ScanTrans->ABL, ABL_VIEW_VHDL ); + fprintf( VhdlFile, ") = '1')\n THEN" ); + FirstOne = 0; + } + else + if ( NextChain != (chain_list *)0 ) + { + fprintf( VhdlFile, " ELSIF (( " ); + viewablexprfile( VhdlFile, ScanTrans->ABL, ABL_VIEW_VHDL ); + fprintf( VhdlFile, ") = '1')\n THEN" ); + } + else + { + fprintf( VhdlFile, " ELSE" ); + } + + fprintf( VhdlFile, " NEXT_STATE <= %s;\n", vhdlablname( ScanTrans->TO->NAME ) ); + + if ( NextChain == (chain_list *)0 ) + { + fprintf( VhdlFile, " END IF;\n" ); + } + } + } + + VhdlWriteStack( ScanState ); + VhdlWriteLocout( ScanState ); + } + + fprintf( VhdlFile, " END CASE;\n" ); + if ( Counter > 0 ) fprintf( VhdlFile, " END IF;\n" ); + + fprintf( VhdlFile, " END PROCESS;\n\n" ); + + fprintf( VhdlFile, " PROCESS( %s )\n", FsmFigure->CLOCK ); + fprintf( VhdlFile, " BEGIN\n" ); + + fprintf( VhdlFile, " IF ( " ); + viewablexprfile( VhdlFile, FsmFigure->CLOCK_ABL, ABL_VIEW_VHDL ); + fprintf( VhdlFile, " )\n THEN CURRENT_STATE <= NEXT_STATE;\n" ); + + if ( FsmFigure->STACK != (fsmstack_list *)0 ) + { + fprintf( VhdlFile, " CASE CONTROL IS\n" ); + + for ( Index = 0; Index < FSM_MAX_CTRL; Index++ ) + { + fprintf( VhdlFile, " WHEN %s =>\n", + FSM_CTRL_NAME[ Index ] ); + + if ( Index == FSM_CTRL_POP ) + { + for ( Counter = 1; Counter < FsmFigure->STACK_SIZE; Counter++ ) + { + fprintf( VhdlFile, " STACK_%ld <= STACK_%ld;\n", + Counter - 1, Counter ); + } + + if ( Counter == 1 ) + { + fprintf( VhdlFile, " NULL;\n" ); + } + } + else + if ( Index == FSM_CTRL_PUSH ) + { + fprintf( VhdlFile, " STACK_0 <= RETURN_STATE;\n" ); + + for ( Counter = 1; Counter < FsmFigure->STACK_SIZE; Counter++ ) + { + fprintf( VhdlFile, " STACK_%ld <= STACK_%ld;\n", + Counter, Counter - 1 ); + } + } + else + { + fprintf( VhdlFile, " NULL;\n" ); + } + } + + fprintf( VhdlFile, " END CASE;\n" ); + } + + fprintf( VhdlFile, " END IF;\n" ); + + fprintf( VhdlFile, " END PROCESS;\n" ); + + if ( IsFsmFigMixedRtl( FsmFigure ) ) + { + vhdlsavefbarchi( (fbfig_list *)FsmFigure->FIGURE, 0 ); + } + + fprintf( VhdlFile, "END;\n" ); + + FsmFigure->STATE = (fsmstate_list *)reverse( (chain_list *)FsmFigure->STATE ); +} + +/*------------------------------------------------------------\ +| | +| vhdlsavefsmfig | +| | +\------------------------------------------------------------*/ + +void vhdlsavefsmfig( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + VhdlFile = mbkfopen( FsmFigure->NAME, "fsm", "w" ); + FblDriveFile = VhdlFile; + + if ( VhdlFile == (FILE *)0 ) + { + fvherror( FVH_ERROR_OPEN_FILE, FsmFigure->NAME, 0 ); + } + + VhdlWriteHeader( FsmFigure ); + VhdlWriteEntity( FsmFigure ); + VhdlWriteArchitecture( FsmFigure ); + + fclose( VhdlFile ); +} diff --git a/alliance/src/fvh/src/fvhdrive.h b/alliance/src/fvh/src/fvhdrive.h new file mode 100644 index 00000000..c6f811eb --- /dev/null +++ b/alliance/src/fvh/src/fvhdrive.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 : FVH | +| | +| File : fksdrive.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 04.12.96 | +| | +\------------------------------------------------------------*/ + +# ifndef FVH_DRIVE_H +# define FVH_DRIVE_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/fvh/src/fvherror.c b/alliance/src/fvh/src/fvherror.c new file mode 100644 index 00000000..c2a4df85 --- /dev/null +++ b/alliance/src/fvh/src/fvherror.c @@ -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. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Tool : FVH | +| | +| File : fvherror.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 04.12.96 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include +# include + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "fsm.h" + +# include "fvherror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +void fvh_error( Error, Text, Value, File, Line ) + + char Error; + char *Text; + long Value; + char *File; + long Line; +{ + char *Name; + + Name = mbkstrdup( File ); + Name[ strlen( File ) - 1 ] = '\0'; + + fprintf( stderr, "%s%ld ", Name, Line ); + + switch( Error ) + { + case FVH_ERROR_OPEN_FILE : + fprintf( stderr, "Unable to open file \"%s\"\n", Text ); + break; + case FVH_ERROR_PARSE_FILE : + fprintf( stderr, "Unable to parse file \"%s\"\n", Text ); + break; + case FVH_ERROR_SIGNAL_NOT_FOUND : + fprintf( stderr, "Signal \"%s\" not found line %ld\n", Text, Value ); + break; + case FVH_ERROR_ILLEGAL_DEFAULT_ASSIGN : + fprintf( stderr, "Illegal default output assignation\n" ); + break; + case FVH_ERROR_NO_STATE : + fprintf( stderr, "Number of state is zero in \"%s\"\n", Text ); + break; + case FVH_ERROR_CONTROL_TYPE : + fprintf( stderr, "Bad control type size in \"%s\" line %ld\n", Text, Value ); + break; + case FVH_ERROR_ILLEGAL_CASE : + fprintf( stderr, "Illegal case condition, type \"%s\" line %ld\n", Text, Value ); + break; + case FVH_ERROR_ILLEGAL_STATE : + fprintf( stderr, "Illegal state name \"%s\" in case condition line %ld\n", Text, Value ); + break; + case FVH_ERROR_ILLEGAL_CONTROL : + fprintf( stderr, "Illegal control name \"%s\" in case condition line %ld\n", Text, Value ); + break; + case FVH_ERROR_ILLEGAL_INSTRUCTION : + fprintf( stderr, "Illegal instruction type %ld\n", (long)Text ); + break; + case FVH_ERROR_ILLEGAL_STATE_ASSIGN : + fprintf( stderr, "Illegal state name \"%s\" in assignation line %ld\n", Text, Value ); + break; + case FVH_ERROR_ILLEGAL_STACK_ASSIGN : + fprintf( stderr, "Illegal stack name \"%s\" in assignation line %ld\n", Text, Value ); + break; + case FVH_ERROR_ILLEGAL_CONTROL_ASSIGN : + fprintf( stderr, "Illegal control name \"%s\" in assignation line %ld\n", Text, Value ); + break; + case FVH_ERROR_ILLEGAL_ASSIGNATION : + fprintf( stderr, "Illegal use of \"%s\" in main process line %ld\n", Text, Value ); + break; + case FVH_ERROR_MAIN_PROCESS : + fprintf( stderr, "Illegal figure \"%s\" missing main process\n", Text ); + break; + case FVH_ERROR_CLOCK_PROCESS : + fprintf( stderr, "Illegal figure \"%s\" missing clock process\n", Text ); + break; + case FVH_ERROR_PROCESS_SENSITIVITY : + fprintf( stderr, "Illegal sensitivity list in the process \"%s\"\n", Text ); + break; + case FVH_ERROR_MISSING_SIGNAL : + fprintf( stderr, "\"%s\" must be in the sensitivity list line %ld\n", Text, Value ); + break; + case FVH_ERROR_IN_MAIN_PROCESS : + fprintf( stderr, "Illegal use of \"%s\" in main process line %ld\n", Text, Value ); + break; + case FVH_ERROR_IN_CLOCK_PROCESS : + fprintf( stderr, "Illegal use of \"%s\" in clock process line %ld\n", Text, Value ); + break; + case FVH_ERROR_ILLEGAL_OUT_ASSIGN : + fprintf( stderr, "Illegal output \"%s\" assignation line %ld\n", Text, Value ); + break; + case FVH_ERROR_MISSING_CLOCK_PORT : + fprintf( stderr, "Missing clock declaration in figure \"%s\"\n", Text ); + break; + case FVH_ERROR_STACK_SIZE_ZERO : + fprintf( stderr, "Size of stack is zero in \"%s\"\n", Text ); + break; + case FVH_ERROR_MISSING_STACK_CONTROL : + fprintf( stderr, "Missing stack control in figure \"%s\" line %ld\n", Text, Value ); + break; + case FVH_ERROR_MISSING_STATE_CONTROL : + fprintf( stderr, "Missing state control in figure \"%s\"\n", Text ); + break; + case FVH_ERROR_NO_CONTROL_CONDITION : + fprintf( stderr, "Missing control condition in figure \"%s\" line %ld\n", Text, Value ); + break; + case FVH_ERROR_BAD_STACK_CONTROL : + fprintf( stderr, "Bad stack control in figure \"%s\"\n", Text ); + break; + case FVH_ERROR_ILLEGAL_IF_CONDITION : + fprintf( stderr, "Illegal IF condition line %ld\n", Value ); + break; + case FVH_ERROR_TWO_PROCESS : + fprintf( stderr, "Should have two process in figure \"%s\"\n", Text ); + break; + case FVH_ERROR_ILLEGAL_PROCESS_BODY : + fprintf( stderr, "Illegal body structure for process \"%s\" line %ld\n", Text, Value ); + break; + default : + fprintf( stderr, "Internal error number %d\n", Error ); + } + + autexit( 1 ); +} + +void fvh_warning( Warning, Text, Value, File, Line ) + + char Warning; + char *Text; + long Value; + 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, "Internal warning number %d\n", Warning ); + } +} diff --git a/alliance/src/fvh/src/fvherror.h b/alliance/src/fvh/src/fvherror.h new file mode 100644 index 00000000..5ff6ed1e --- /dev/null +++ b/alliance/src/fvh/src/fvherror.h @@ -0,0 +1,119 @@ +/*------------------------------------------------------------\ +| | +| 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 : FVH | +| | +| File : fvherror.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 04.12.96 | +| | +\------------------------------------------------------------*/ + +# ifndef FVH_ERROR_H +# define FVH_ERROR_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define FVH_ERROR_OPEN_FILE 1 +# define FVH_ERROR_PARSE_FILE 2 +# define FVH_ERROR_SIGNAL_NOT_FOUND 3 +# define FVH_ERROR_ILLEGAL_DEFAULT_ASSIGN 4 +# define FVH_ERROR_NO_STATE 5 +# define FVH_ERROR_CONTROL_TYPE 6 +# define FVH_ERROR_ILLEGAL_CASE 7 +# define FVH_ERROR_ILLEGAL_STATE 8 +# define FVH_ERROR_ILLEGAL_CONTROL 9 +# define FVH_ERROR_ILLEGAL_INSTRUCTION 10 +# define FVH_ERROR_ILLEGAL_STATE_ASSIGN 11 +# define FVH_ERROR_ILLEGAL_STACK_ASSIGN 12 +# define FVH_ERROR_ILLEGAL_CONTROL_ASSIGN 13 +# define FVH_ERROR_ILLEGAL_ASSIGNATION 14 +# define FVH_ERROR_MAIN_PROCESS 15 +# define FVH_ERROR_PROCESS_SENSITIVITY 16 +# define FVH_ERROR_IN_MAIN_PROCESS 17 +# define FVH_ERROR_IN_CLOCK_PROCESS 18 +# define FVH_ERROR_ILLEGAL_OUT_ASSIGN 19 +# define FVH_ERROR_MISSING_CLOCK_PORT 22 +# define FVH_ERROR_STACK_SIZE_ZERO 23 +# define FVH_ERROR_MISSING_STACK_CONTROL 24 +# define FVH_ERROR_MISSING_STATE_CONTROL 25 +# define FVH_ERROR_NO_CONTROL_CONDITION 26 +# define FVH_ERROR_BAD_STACK_CONTROL 27 +# define FVH_ERROR_ILLEGAL_IF_CONDITION 28 +# define FVH_ERROR_TWO_PROCESS 29 +# define FVH_ERROR_CLOCK_PROCESS 30 +# define FVH_ERROR_MISSING_SIGNAL 31 +# define FVH_ERROR_ILLEGAL_PROCESS_BODY 32 + +/*------------------------------------------------------------\ +| | +| Warnings | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ + +# define fvherror( E, T, V ) (fvh_error((int)(E),(char *)(T),(long)(V),__FILE__,__LINE__)) +# define fvhwarning( E, T, V ) (fvh_warning((int)(E),(char *)(T),(long)(V),__FILE__,__LINE__)) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void fvh_error __P((char Error, char *Text, long Value, char *File, long Line)); + extern void fvh_warning __P((char Warning, char *Text, long Value, char *File, long Line)); + +# endif diff --git a/alliance/src/fvh/src/fvhfbh2fsm.c b/alliance/src/fvh/src/fvhfbh2fsm.c new file mode 100644 index 00000000..6e2c2ddd --- /dev/null +++ b/alliance/src/fvh/src/fvhfbh2fsm.c @@ -0,0 +1,1544 @@ +/*------------------------------------------------------------\ +| | +| 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 : FVH | +| | +| File : fvhfbh2fsm.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 04.12.96 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "fsm.h" +# include "fvh.h" + +# include +# include +# include +# include "fvherror.h" +# include "fvhfbh2fsm.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Private Variables | +| | +\------------------------------------------------------------*/ + + static char *FvhClockKeyword = (char *)0; + static char *FvhCurrentStateKeyword = (char *)0; + static char *FvhNextStateKeyword = (char *)0; + static char *FvhFirstStateKeyword = (char *)0; + static char *FvhReturnStateKeyword = (char *)0; + static char *FvhControlKeyword = (char *)0; + static char *FvhOthersKeyword = (char *)0; + + static char *FvhStackControlKeyword[ FSM_MAX_CTRL ]; + + static char *FvhClockName; + static char *FvhCurrentStateName; + static char *FvhNextStateName; + static char *FvhFirstStateName; + static char *FvhReturnStateName; + static char *FvhControlName; + static char *FvhStackControlName[ FSM_MAX_CTRL ]; + + static fbtyp_list *FvhStateType; + static fbtyp_list *FvhControlType; + + static chain_list *FvhDefaultStackName = (chain_list *)0; + static long FvhDefaultStackSize = 0; + static long FvhStackPushSize = 0; + static long FvhStackPopSize = 0; + static char *FvhStackHeadName = (char *)0; + + static char FvhTreatMainProcess = 0; + static char FvhTreatStackControl = 0; + static char FvhTreatStateControl = 0; + + static char FvhWhenCondition = 0; + static char FvhStarStateLocout = 0; + + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| FvhInitializeKeyword | +| | +\------------------------------------------------------------*/ + +void FvhInitializeKeyword() +{ + if ( FvhClockKeyword == (char *)0 ) + { + FvhClockKeyword = namealloc( "clock" ); + FvhCurrentStateKeyword = namealloc( "current_state" ); + FvhReturnStateKeyword = namealloc( "return_state" ); + FvhNextStateKeyword = namealloc( "next_state" ); + FvhFirstStateKeyword = namealloc( "first_state" ); + FvhControlKeyword = namealloc( "control" ); + FvhOthersKeyword = namealloc( "others" ); + + FvhStackControlKeyword[ FSM_CTRL_NOP ] = namealloc( "nop" ); + FvhStackControlKeyword[ FSM_CTRL_PUSH ] = namealloc( "push" ); + FvhStackControlKeyword[ FSM_CTRL_POP ] = namealloc( "pop" ); + } + + FvhClockName = FvhClockKeyword; + FvhCurrentStateName = FvhCurrentStateKeyword; + FvhReturnStateName = FvhReturnStateKeyword; + FvhNextStateName = FvhNextStateKeyword; + FvhFirstStateName = FvhFirstStateKeyword; + FvhControlName = FvhControlKeyword; + + FvhStackControlName[ FSM_CTRL_NOP ] = FvhStackControlKeyword[ FSM_CTRL_NOP ]; + FvhStackControlName[ FSM_CTRL_PUSH ] = FvhStackControlKeyword[ FSM_CTRL_PUSH ]; + FvhStackControlName[ FSM_CTRL_POP ] = FvhStackControlKeyword[ FSM_CTRL_POP ]; + + + FvhStateType = (fbtyp_list *)0; + FvhControlType = (fbtyp_list *)0; + + FvhStarStateLocout = 0; + FvhWhenCondition = 0; +} + +/*------------------------------------------------------------\ +| | +| FvhFbhGetControl | +| | +\------------------------------------------------------------*/ + +int FvhFbhGetControl( Name ) + + char *Name; +{ + int Index; + + for ( Index = 0; Index < FSM_MAX_CTRL; Index++ ) + { + if ( Name == FvhStackControlName[ Index ] ) return( Index ); + } + + return( -1 ); +} + +/*------------------------------------------------------------\ +| | +| FvhFbhGetStack | +| | +\------------------------------------------------------------*/ + +int FvhFbhGetStack( Name ) + + char *Name; +{ + chain_list *ScanChain; + int Index; + + Index = 0; + + for ( ScanChain = FvhDefaultStackName; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + if ( ScanChain->DATA == (void *)Name ) + { + return( Index ); + } + + Index = Index + 1; + } + + return( -1 ); +} + +/*------------------------------------------------------------\ +| | +| FvhFbhTreatPragma | +| | +\------------------------------------------------------------*/ + +void FvhFbhTreatPragma( FbhFigure, FsmFigure ) + + fbfig_list *FbhFigure; + fsmfig_list *FsmFigure; +{ + fbpgm_list *ScanPragma; + + for ( ScanPragma = FbhFigure->BEPGM; + ScanPragma != (fbpgm_list *)0; + ScanPragma = ScanPragma->NEXT ) + { + if ( ScanPragma->NAME != (char *)0 ) + { + if ( ScanPragma->TYPE == FvhCurrentStateKeyword ) + { + FvhCurrentStateName = ScanPragma->NAME; + } + else + if ( ScanPragma->TYPE == FvhNextStateKeyword ) + { + FvhNextStateName = ScanPragma->NAME; + } + else + if ( ScanPragma->TYPE == FvhFirstStateKeyword ) + { + FvhFirstStateName = ScanPragma->NAME; + } + else + if ( ScanPragma->TYPE == FvhReturnStateKeyword ) + { + FvhReturnStateName = ScanPragma->NAME; + } + else + if ( ScanPragma->TYPE == FvhControlKeyword ) + { + FvhControlName = ScanPragma->NAME; + } + else + if ( ScanPragma->TYPE == FvhClockKeyword ) + { + FvhClockName = ScanPragma->NAME; + } + else + if ( ScanPragma->TYPE == FvhStackControlKeyword[ FSM_CTRL_NOP ] ) + { + FvhStackControlName[ FSM_CTRL_NOP ] = ScanPragma->NAME; + } + else + if ( ScanPragma->TYPE == FvhStackControlKeyword[ FSM_CTRL_PUSH ] ) + { + FvhStackControlName[ FSM_CTRL_PUSH ] = ScanPragma->NAME; + } + else + if ( ScanPragma->TYPE == FvhStackControlKeyword[ FSM_CTRL_POP ] ) + { + FvhStackControlName[ FSM_CTRL_POP ] = ScanPragma->NAME; + } + } + + FsmFigure->PRAGMA = addptype( FsmFigure->PRAGMA, + (long)ScanPragma->TYPE, + ScanPragma->NAME ); + } +} + +/*------------------------------------------------------------\ +| | +| FvhFbhTreatAux | +| | +\------------------------------------------------------------*/ + +void FvhFbhTreatAux( FbhFigure, FsmFigure ) + + fbfig_list *FbhFigure; + fsmfig_list *FsmFigure; +{ + fbaux_list *ScanAux; + fbout_list *ScanOut; + + int StateType; + int Index; + int MixedFsmRtl; + + if ( ( FbhFigure->BEREG != (fbreg_list *)0 ) || + ( FbhFigure->BEBUS != (fbbus_list *)0 ) || + ( FbhFigure->BEBUX != (fbbux_list *)0 ) ) + { + MixedFsmRtl = 1; + } + else + { + MixedFsmRtl = 0; + + for ( ScanOut = FbhFigure->BEOUT; + ScanOut != (fbout_list *)0; + ScanOut = ScanOut->NEXT ) + { + if ( ScanOut->ABL != (ablexpr *)0 ) + { + MixedFsmRtl = 1; break; + } + } + } + + StateType = 0; + + for ( ScanAux = FbhFigure->BEAUX; + ScanAux != (fbaux_list *)0; + ScanAux = ScanAux->NEXT ) + { + if ( ScanAux->NAME == FvhCurrentStateName ) + { + StateType = ScanAux->TYPE; + FvhStateType = ( FbhFigure->BETYP + StateType - 1 ); + + ClearFbhAssignByFsm( ScanAux ); + } + else + if ( ScanAux->NAME == FvhControlName ) + { + FvhControlType = ( FbhFigure->BETYP + ScanAux->TYPE - 1 ); + + if ( FvhControlType->SIZE != FSM_MAX_CTRL ) + { + fvherror( FVH_ERROR_CONTROL_TYPE, FbhFigure->NAME, FvhControlType->USER ); + } + + ClearFbhAssignByFsm( ScanAux ); + } + else + if ( ScanAux->NAME == FvhNextStateName ) + { + ClearFbhAssignByFsm( ScanAux ); + } + else + { + MixedFsmRtl = 1; + } + } + + if ( ( FvhStateType == (fbtyp_list *)0 ) || + ( FvhStateType->SIZE == 0 ) ) + { + fvherror( FVH_ERROR_NO_STATE, FbhFigure->NAME, 0 ); + } + + FsmFigure->STAR_STATE = addfsmstate( FsmFigure, "*" ); + SetFsmStarState( FsmFigure->STAR_STATE ); + + for ( Index = 0; Index < FvhStateType->SIZE; Index++ ) + { + if ( FvhStateType->VALUE[ Index ] == FvhFirstStateName ) + { + FsmFigure->FIRST_STATE = addfsmstate( FsmFigure, FvhFirstStateName ); + SetFsmFirstState( FsmFigure->FIRST_STATE ); + } + else + { + addfsmstate( FsmFigure, FvhStateType->VALUE[ Index ] ); + } + } + + if ( FvhDefaultStackName != (chain_list *)0 ) + { + freechain( FvhDefaultStackName ); + FvhDefaultStackName = (chain_list *)0; + } + + if ( FvhControlType != (fbtyp_list *)0 ) + { + FsmFigure->STACK_SIZE = 1; + + FvhDefaultStackSize = 0; + FvhStackPushSize = 0; + FvhStackPopSize = 0; + FvhDefaultStackName = (chain_list *)0; + + for ( ScanAux = FbhFigure->BEAUX; + ScanAux != (fbaux_list *)0; + ScanAux = ScanAux->NEXT ) + { + if ( ScanAux->TYPE == StateType ) + { + if ( ( ScanAux->NAME != FvhCurrentStateName ) && + ( ScanAux->NAME != FvhNextStateName ) && + ( ScanAux->NAME != FvhReturnStateName ) ) + { + FvhDefaultStackSize++; + + FvhDefaultStackName = addchain( FvhDefaultStackName, (void *)ScanAux->NAME ); + } + } + } + + if ( FvhDefaultStackSize == 0 ) + { + fvherror( FVH_ERROR_STACK_SIZE_ZERO, FsmFigure->NAME, 0 ); + } + } + + if ( MixedFsmRtl ) + { + SetFsmFigMixedRtl( FsmFigure ); + FsmFigure->FIGURE = (void *)FbhFigure; + } +} + +/*------------------------------------------------------------\ +| | +| FvhFbhTreatPort | +| | +\------------------------------------------------------------*/ + +void FvhFbhTreatPort( FbhFigure, FsmFigure ) + + fbfig_list *FbhFigure; + fsmfig_list *FsmFigure; +{ + fbpor_list *ScanPort; + fbaux_list *ScanAux; + fbaux_list *FreeAux; + fbaux_list *ListAux; + fbaux_list **PrevAux; + fbout_list *ScanOut; + fbout_list *FreeOut; + fbout_list *ListOut; + fbout_list **PrevOut; + fbreg_list *ScanReg; + fbbux_list *ScanBux; + fbbus_list *ScanBus; + char ClockOk; + char Direction; + + ClockOk = 0; + + if ( ! IsFsmFigMixedRtl( FsmFigure ) ) + { + for ( ScanPort = FbhFigure->BEPOR; + ScanPort != (fbpor_list *)0; + ScanPort = ScanPort->NEXT ) + { + if ( ScanPort->DIRECTION != 'O' ) + { + if ( ScanPort->NAME == FvhClockName ) + { + ClockOk = 1; + } + else + { + addfsmin( FsmFigure, ScanPort->NAME ); + } + } + + if ( ScanPort->DIRECTION != 'I' ) + { + addfsmout( FsmFigure, ScanPort->NAME ); + } + + addfsmport( FsmFigure, ScanPort->NAME, ScanPort->DIRECTION, ScanPort->TYPE ); + } + } + else + { + for ( ScanPort = FbhFigure->BEPOR; + ScanPort != (fbpor_list *)0; + ScanPort = ScanPort->NEXT ) + { + if ( ScanPort->DIRECTION != 'O' ) + { + if ( ScanPort->NAME == FvhClockName ) + { + ClockOk = 1; + } + else + { + addfsmin( FsmFigure, ScanPort->NAME ); + } + } + + addfsmport( FsmFigure, ScanPort->NAME, ScanPort->DIRECTION, ScanPort->TYPE ); + } + + for ( ScanAux = FbhFigure->BEAUX; + ScanAux != (fbaux_list *)0; + ScanAux = ScanAux->NEXT ) + { + if ( ( ScanAux->NAME == FvhNextStateName ) || + ( ScanAux->NAME == FvhCurrentStateName ) || + ( ScanAux->NAME == FvhReturnStateName ) ) continue; + + if ( ScanAux->NAME == FvhClockName ) + { + ClockOk = 1; + } + else + { + addfsmin( FsmFigure, ScanAux->NAME ); + } + + if ( IsFbhAssignByFsm( ScanAux ) ) + { + addfsmout( FsmFigure, ScanAux->NAME ); + Direction = 'B'; + } + else + { + Direction = 'I'; + } + + addfsmport( FsmFigure, ScanAux->NAME, 'B', ScanAux->TYPE ); + } + + for ( ScanOut = FbhFigure->BEOUT; + ScanOut != (fbout_list *)0; + ScanOut = ScanOut->NEXT ) + { + if ( IsFbhAssignByFsm( ScanOut ) ) + { + addfsmout( FsmFigure, ScanOut->NAME ); + } + } + + for ( ScanReg = FbhFigure->BEREG; + ScanReg != (fbreg_list *)0; + ScanReg = ScanReg->NEXT ) + { + addfsmin( FsmFigure, ScanReg->NAME ); + addfsmport( FsmFigure, ScanReg->NAME, 'I', 'B' ); + } + + for ( ScanBus = FbhFigure->BEBUS; + ScanBus != (fbbus_list *)0; + ScanBus = ScanBus->NEXT ) + { + addfsmin( FsmFigure, ScanBus->NAME ); + addfsmport( FsmFigure, ScanBus->NAME, 'I', ScanBus->TYPE ); + } + + for ( ScanBux = FbhFigure->BEBUX; + ScanBux != (fbbux_list *)0; + ScanBux = ScanBux->NEXT ) + { + addfsmin( FsmFigure, ScanBus->NAME ); + addfsmport( FsmFigure, ScanBus->NAME, 'I', ScanBus->TYPE ); + } + +/* +** Clean Up the FbhFigure ! +*/ + PrevAux = &FbhFigure->BEAUX; + ListAux = (fbaux_list *)0; + + ScanAux = FbhFigure->BEAUX; + + while ( ScanAux != (fbaux_list *)0 ) + { + if ( ( ScanAux->ABL == (ablexpr *)0 ) && + ( ! IsFbhAssignByFsm( ScanAux ) ) ) + { + FreeAux = ScanAux; + ScanAux = ScanAux->NEXT; + *PrevAux = ScanAux; + + FreeAux->NEXT = ListAux; + ListAux = FreeAux; + } + else + { + PrevAux = &ScanAux->NEXT; + ScanAux = ScanAux->NEXT; + } + } + + fbh_frefbaux( ListAux ); + + PrevOut = &FbhFigure->BEOUT; + ListOut = (fbout_list *)0; + + ScanOut = FbhFigure->BEOUT; + + while ( ScanOut != (fbout_list *)0 ) + { + if ( ScanOut->ABL == (ablexpr *)0 ) + { + FreeOut = ScanOut; + ScanOut = ScanOut->NEXT; + *PrevOut = ScanOut; + + FreeOut->NEXT = ListOut; + ListOut = FreeOut; + } + else + { + PrevOut = &ScanOut->NEXT; + ScanOut = ScanOut->NEXT; + } + } + + fbh_frefbout( ListOut ); + } + + if ( ClockOk != 1 ) + { + fvherror( FVH_ERROR_MISSING_CLOCK_PORT, FsmFigure->NAME, 0 ); + } +} + +/*------------------------------------------------------------\ +| | +| FvhFbhTreatIf | +| | +\------------------------------------------------------------*/ + +void FvhFbhTreatIf( FbhFigure, FsmFigure, ScanIfs, + StateFrom, StateTo, Return, + Control, Equation ) + + fbfig_list *FbhFigure; + fsmfig_list *FsmFigure; + fbifs_list *ScanIfs; + fsmstate_list *StateFrom; + fsmstate_list *StateTo; + fsmstate_list *Return; + int Control; + ablexpr *Equation; +{ + ablexpr *NewEquation; + +/* +** IF ( Condition ) +*/ + if ( isablnameinexpr( ScanIfs->CND, ABL_ATOM_NAME_DC ) ) + { + fvherror( FVH_ERROR_ILLEGAL_IF_CONDITION, (char *)0, ScanIfs->USER ); + } + + NewEquation = dupablexpr( ScanIfs->CND ); + + if ( Equation != (ablexpr *)0 ) + { + NewEquation = optimablbinexpr( ABL_AND, dupablexpr( Equation ), NewEquation ); + } +/* +** THEN +*/ + FvhFbhTreatInstruction( FbhFigure, FsmFigure, + ScanIfs->CNDTRUE, + StateFrom, StateTo, Return, + Control, NewEquation ); + + delablexpr( NewEquation ); + + NewEquation = optimablnotexpr( dupablexpr( ScanIfs->CND ) ); + + if ( Equation != (ablexpr *)0 ) + { + NewEquation = optimablbinexpr( ABL_AND, dupablexpr( Equation ), NewEquation ); + } +/* +** ELSE +*/ + FvhFbhTreatInstruction( FbhFigure, FsmFigure, + ScanIfs->CNDFALSE, + StateFrom, StateTo, Return, + Control, NewEquation ); + + delablexpr( NewEquation ); +} + +/*------------------------------------------------------------\ +| | +| FvhFbhTreatAsg | +| | +\------------------------------------------------------------*/ + +void FvhFbhTreatAsg( FbhFigure, FsmFigure, ScanAsg, + PStateFrom, PStateTo, PReturn, + PControl, Equation ) + + fbfig_list *FbhFigure; + fsmfig_list *FsmFigure; + fbasg_list *ScanAsg; + fsmstate_list **PStateFrom; + fsmstate_list **PStateTo; + fsmstate_list **PReturn; + int *PControl; + ablexpr *Equation; +{ + fbtyp_list *ScanType; + ablexpr *NewEquation; + ablexpr *NewEquationDc; + fsmout_list *Output; + int Stack; + + ScanType = (fbtyp_list *)(FbhFigure->BETYP + ScanAsg->TYPE - 1); + + Output = searchfsmout( FsmFigure, ScanAsg->NAME ); + + if ( Output != (fsmout_list *)0 ) + { + if ( ! FvhTreatMainProcess ) + { + fvherror( FVH_ERROR_IN_CLOCK_PROCESS, ScanAsg->NAME, ScanAsg->USER ); + } + + NewEquationDc = (ablexpr *)0; + NewEquation = (ablexpr *)0; +/* +** O(i) <= Equation +*/ + if ( Equation != (ablexpr *)0 ) + { + if ( ! ABL_ATOM( ScanAsg->ABL ) ) + { + if ( isablnameinexpr( ScanAsg->ABL, ABL_ATOM_NAME_DC ) ) + { + fvherror( FVH_ERROR_ILLEGAL_OUT_ASSIGN, ScanAsg->NAME, ScanAsg->USER ); + } + + NewEquation = optimablbinexpr( ABL_AND, + dupablexpr( ScanAsg->ABL ), + dupablexpr( Equation ) ); + } + else + { + if ( ABL_ATOM_VALUE( ScanAsg->ABL ) == ABL_ATOM_NAME_ONE ) + { + NewEquation = dupablexpr( Equation ); + } + else + if ( ABL_ATOM_VALUE( ScanAsg->ABL ) == ABL_ATOM_NAME_ZERO ) + { + NewEquation = createablatomzero(); + } + else + if ( ABL_ATOM_VALUE( ScanAsg->ABL ) == ABL_ATOM_NAME_DC ) + { + NewEquationDc = dupablexpr( Equation ); + } + else + { + NewEquation = optimablbinexpr( ABL_AND, + dupablexpr( ScanAsg->ABL ), + dupablexpr( Equation ) ); + } + } + } + else + { + if ( *PStateFrom == (fsmstate_list *)0 ) + { + fvherror( FVH_ERROR_ILLEGAL_OUT_ASSIGN, ScanAsg->NAME, ScanAsg->USER ); + } + + if ( ! ABL_ATOM( ScanAsg->ABL ) ) + { + if ( isablnameinexpr( ScanAsg->ABL, ABL_ATOM_NAME_DC ) ) + { + fvherror( FVH_ERROR_ILLEGAL_OUT_ASSIGN, ScanAsg->NAME, ScanAsg->USER ); + } + + NewEquation = dupablexpr( ScanAsg->ABL ); + } + else + { + if ( ABL_ATOM_VALUE( ScanAsg->ABL ) == ABL_ATOM_NAME_ZERO ) + { + NewEquation = createablatomzero(); + } + else + if ( ABL_ATOM_VALUE( ScanAsg->ABL ) == ABL_ATOM_NAME_DC ) + { + NewEquationDc = createablatomone(); + } + else + { + NewEquation = dupablexpr( ScanAsg->ABL ); + } + } + } + + if ( ( NewEquation != (ablexpr *)0 ) || + ( NewEquationDc != (ablexpr *)0 ) ) + { + if ( *PStateFrom == (fsmstate_list *)0 ) + { + *PStateFrom = FsmFigure->STAR_STATE; + } + + if ( *PStateFrom == FsmFigure->STAR_STATE ) + { + FvhStarStateLocout = 1; + } + + addfsmlocout( *PStateFrom, Output, NewEquation, NewEquationDc ); + } + else + { + if ( ( *PStateFrom == (fsmstate_list *)0 ) || + ( *PStateFrom == FsmFigure->STAR_STATE ) ) + { + FvhStarStateLocout = 1; + } + } + } + else + if ( ScanType == FvhStateType ) + { + if ( ABL_ATOM( ScanAsg->ABL ) ) + { + if ( ScanAsg->NAME == FvhNextStateName ) + { + if ( ! FvhTreatMainProcess ) + { + fvherror( FVH_ERROR_IN_CLOCK_PROCESS, FvhNextStateName, ScanAsg->USER ); + } + + *PStateTo = searchfsmstate( FsmFigure, ABL_ATOM_VALUE( ScanAsg->ABL ) ); + + if ( *PStateTo == (fsmstate_list *)0 ) + { + if ( FsmFigure->STACK_SIZE ) + { + Stack = FvhFbhGetStack( ABL_ATOM_VALUE( ScanAsg->ABL ) ); + + if ( Stack != -1 ) + { +/* +** NEXT_STATE <= STACK(0) +*/ + if ( ( FvhStackHeadName != (char *)0 ) && + ( ABL_ATOM_VALUE( ScanAsg->ABL ) != FvhStackHeadName ) ) + { + fvherror( FVH_ERROR_ILLEGAL_STACK_ASSIGN, + ABL_ATOM_VALUE( ScanAsg->ABL ), ScanAsg->USER ); + } + + *PStateTo = FsmFigure->STAR_STATE; + FvhStackHeadName = ABL_ATOM_VALUE( ScanAsg->ABL ); + } + else + { + fvherror( FVH_ERROR_ILLEGAL_STACK_ASSIGN, + ABL_ATOM_VALUE( ScanAsg->ABL ), ScanAsg->USER ); + } + } + else + { + fvherror( FVH_ERROR_ILLEGAL_STATE_ASSIGN, ScanAsg->NAME, ScanAsg->USER ); + } + } + else + { +/* +** NEXT_STATE <= E(i) +*/ + if ( Equation == (ablexpr *)0 ) + { + NewEquation = createablatomone(); + } + else + { + NewEquation = dupablexpr( Equation ); + } + + if ( *PStateFrom == (fsmstate_list *)0 ) + { + *PStateFrom = FsmFigure->STAR_STATE; + } + + addfsmtrans( FsmFigure, *PStateFrom, *PStateTo, NewEquation ); + } + } + else + if ( ScanAsg->NAME == FvhCurrentStateName ) + { + if ( ( FvhTreatMainProcess ) || + ( FvhTreatStateControl ) ) + { + fvherror( FVH_ERROR_IN_MAIN_PROCESS, ScanAsg->NAME, ScanAsg->USER ); + } +/* +** CURRENT_STATE <= NEXT_STATE +*/ + if ( ABL_ATOM_VALUE( ScanAsg->ABL ) != FvhNextStateName ) + { + fvherror( FVH_ERROR_ILLEGAL_STATE_ASSIGN, ScanAsg->NAME, ScanAsg->USER ); + } + else + { + if ( Equation == (ablexpr *)0 ) + { + fvherror( FVH_ERROR_NO_CONTROL_CONDITION, FsmFigure->NAME, ScanAsg->USER ); + } + + FsmFigure->CLOCK_ABL = dupablexpr( Equation ); + FvhTreatStateControl = 1; + } + } + else + if ( FsmFigure->STACK_SIZE ) + { + if ( ScanAsg->NAME == FvhReturnStateName ) + { + if ( ! FvhTreatMainProcess ) + { + fvherror( FVH_ERROR_IN_CLOCK_PROCESS, FvhReturnStateName, ScanAsg->USER ); + } +/* +** RETURN_STATE <= E(i) +*/ + if ( ( *PReturn == (fsmstate_list *)0 ) && + ( FvhTreatMainProcess ) ) + { + *PReturn = searchfsmstate( FsmFigure, ABL_ATOM_VALUE( ScanAsg->ABL ) ); + + if ( *PReturn == (fsmstate_list *)0 ) + { + fvherror( FVH_ERROR_ILLEGAL_STATE_ASSIGN, ScanAsg->NAME, ScanAsg->USER ); + } + } + else + { + fvherror( FVH_ERROR_ILLEGAL_STATE_ASSIGN, ScanAsg->NAME, ScanAsg->USER ); + } + } + else + { + if ( FvhTreatMainProcess ) + { + fvherror( FVH_ERROR_IN_MAIN_PROCESS, ScanAsg->NAME, ScanAsg->USER ); + } + + Stack = FvhFbhGetStack( ScanAsg->NAME ); + + if ( Stack == -1 ) + { + fvherror( FVH_ERROR_ILLEGAL_STACK_ASSIGN, ScanAsg->NAME, ScanAsg->USER ); + } + + if ( ABL_ATOM_VALUE( ScanAsg->ABL ) == FvhReturnStateName ) + { +/* +** STACK(0) <= RETURN_STATE +*/ + if ( ( *PControl != FSM_CTRL_PUSH ) || + ( ( FvhStackHeadName != (char *)0 ) && + ( FvhStackHeadName != ScanAsg->NAME ) ) ) + { + fvherror( FVH_ERROR_ILLEGAL_STACK_ASSIGN, ScanAsg->NAME, ScanAsg->USER ); + } + + FvhStackPushSize = FvhStackPushSize + 1; + + FvhStackHeadName = ScanAsg->NAME; + } + else + { + Stack = FvhFbhGetStack( ABL_ATOM_VALUE( ScanAsg->ABL ) ); + + if ( Stack != -1 ) + { + if ( ( FvhStackHeadName != (char *)0 ) && + ( ScanAsg->NAME == FvhStackHeadName ) ) + { +/* +** STACK(0) <= STACK(j) +*/ + if ( *PControl != FSM_CTRL_POP ) + { + fvherror( FVH_ERROR_ILLEGAL_STACK_ASSIGN, + ABL_ATOM_VALUE( ScanAsg->ABL ), ScanAsg->USER ); + } + } +/* +** STACK(i) <= STACK(j) +*/ + if ( *PControl == FSM_CTRL_PUSH ) + { + FvhStackPushSize = FvhStackPushSize + 1; + } + else + if ( *PControl == FSM_CTRL_POP ) + { + FvhStackPopSize = FvhStackPopSize + 1; + } + else + { + fvherror( FVH_ERROR_ILLEGAL_STACK_ASSIGN, ScanAsg->NAME, ScanAsg->USER ); + } + } + else + { + fvherror( FVH_ERROR_ILLEGAL_STACK_ASSIGN, + ABL_ATOM_VALUE( ScanAsg->ABL ), ScanAsg->USER ); + } + } + } + } + else + { + fvherror( FVH_ERROR_ILLEGAL_STATE_ASSIGN, ScanAsg->NAME, ScanAsg->USER ); + } + } + else + { + fvherror( FVH_ERROR_ILLEGAL_STATE_ASSIGN, ScanAsg->NAME, ScanAsg->USER ); + } + } + else + if ( ScanType == FvhControlType ) + { + if ( ABL_ATOM( ScanAsg->ABL ) ) + { + if ( ScanAsg->NAME == FvhControlName ) + { +/* +** CTRL <= PUSH | POP | NOP +*/ + if ( *PControl == -1 ) + { + if ( ! FvhTreatMainProcess ) + { + fvherror( FVH_ERROR_IN_CLOCK_PROCESS, FvhControlName, ScanAsg->USER ); + } + + *PControl = FvhFbhGetControl( ABL_ATOM_VALUE( ScanAsg->ABL ) ); + } + else + { + fvherror( FVH_ERROR_ILLEGAL_ASSIGNATION, ScanAsg->NAME, ScanAsg->USER ); + } + } + else + { + fvherror( FVH_ERROR_ILLEGAL_ASSIGNATION, ScanAsg->NAME, ScanAsg->USER ); + } + } + else + { + fvherror( FVH_ERROR_ILLEGAL_CONTROL_ASSIGN, + ABL_ATOM_VALUE( ScanAsg->ABL ), ScanAsg->USER ); + } + } + else + { + fvherror( FVH_ERROR_ILLEGAL_ASSIGNATION, ScanAsg->NAME, ScanAsg->USER ); + } +} + +/*------------------------------------------------------------\ +| | +| FvhFbhTreatWhen | +| | +\------------------------------------------------------------*/ + +void FvhFbhTreatWhen( FbhFigure, FsmFigure, ScanCase, + PStateFrom, StateTo, Return, + PControl, Equation ) + + fbfig_list *FbhFigure; + fsmfig_list *FsmFigure; + fbcas_list *ScanCase; + fsmstate_list **PStateFrom; + fsmstate_list *StateTo; + fsmstate_list *Return; + int *PControl; + ablexpr *Equation; +{ + fbtyp_list *ScanType; + int Index; + char *ChoiceValue; + + if ( FvhTreatMainProcess ) + { + if ( Equation != (ablexpr *)0 ) + { + FvhWhenCondition = 1; + } + } + +/* +** CASE CURRENT_STATE | CTRL +*/ + ScanType = (fbtyp_list *)(FbhFigure->BETYP + ScanCase->TYPE - 1); + + if ( ScanType == FvhStateType ) + { + if ( ( ABL_ATOM( ScanCase->ABL ) ) && + ( ABL_ATOM_VALUE( ScanCase->ABL ) == FvhCurrentStateName ) ) + { + if ( *PStateFrom == (fsmstate_list *)0 ) + { + if ( ! FvhTreatMainProcess ) + { + fvherror( FVH_ERROR_IN_CLOCK_PROCESS, FvhCurrentStateName, ScanCase->USER ); + } +/* +** WHEN E(i) => +*/ + for ( Index = 0; Index < ScanCase->SIZE; Index++ ) + { + ChoiceValue = ScanCase->CHOICE[ Index ].VALUE; + + if ( ChoiceValue == FvhOthersKeyword ) continue; + + *PStateFrom = searchfsmstate( FsmFigure, ChoiceValue ); + + FvhFbhTreatInstruction( FbhFigure, FsmFigure, + ScanCase->CHOICE[ Index ].INSTRUCTION, + *PStateFrom, StateTo, Return, + *PControl, Equation ); + } + } + else + { + fvherror( FVH_ERROR_ILLEGAL_CASE, ScanType->NAME, ScanCase->USER ); + } + } + else + { + fvherror( FVH_ERROR_ILLEGAL_STATE, + ABL_ATOM_VALUE( ScanCase->ABL ), ScanCase->USER ); + } + } + else + if ( ScanType == FvhControlType ) + { + if ( ( ABL_ATOM( ScanCase->ABL ) ) && + ( ABL_ATOM_VALUE( ScanCase->ABL ) == FvhControlName ) ) + { + if ( *PControl == -1 ) + { + if ( FvhTreatMainProcess ) + { + fvherror( FVH_ERROR_IN_MAIN_PROCESS, FvhControlName, ScanCase->USER ); + } +/* +** WHEN CTRL => +*/ + for ( Index = 0; Index < ScanCase->SIZE; Index++ ) + { + ChoiceValue = ScanCase->CHOICE[ Index ].VALUE; + + if ( ChoiceValue == FvhOthersKeyword ) continue; + + *PControl = FvhFbhGetControl( ChoiceValue ); + + FvhTreatStackControl = 1; + + FvhFbhTreatInstruction( FbhFigure, FsmFigure, + ScanCase->CHOICE[ Index ].INSTRUCTION, + *PStateFrom, StateTo, Return, + *PControl, Equation ); + } + } + else + { + fvherror( FVH_ERROR_ILLEGAL_CASE, ScanType->NAME, ScanCase->USER ); + } + } + else + { + fvherror( FVH_ERROR_ILLEGAL_CONTROL, + ABL_ATOM_VALUE( ScanCase->ABL ), ScanCase->USER ); + } + } + else + { + fvherror( FVH_ERROR_ILLEGAL_CASE, ScanType->NAME, ScanCase->USER ); + } +} + +/*------------------------------------------------------------\ +| | +| FvhFbhTreatInstruction | +| | +\------------------------------------------------------------*/ + +void FvhFbhTreatInstruction( FbhFigure, FsmFigure, Instruct, + StateFrom, StateTo, Return, + Control, Equation ) + + fbfig_list *FbhFigure; + fsmfig_list *FsmFigure; + ptype_list *Instruct; + fsmstate_list *StateFrom; + fsmstate_list *StateTo; + fsmstate_list *Return; + int Control; + ablexpr *Equation; +{ + ptype_list *ScanIns; + ablexpr *NewEquation; + + for ( ScanIns = Instruct; + ScanIns != (ptype_list *)0; + ScanIns = ScanIns->NEXT ) + { + switch ( ScanIns->TYPE ) + { + case FBH_BECAS : + + FvhFbhTreatWhen( FbhFigure, FsmFigure, ScanIns->DATA, + &StateFrom, StateTo, Return, + &Control, Equation ); + + StateFrom = (fsmstate_list *)0; + + break; + + case FBH_BEIFS : + + FvhFbhTreatIf( FbhFigure, FsmFigure, ScanIns->DATA, + StateFrom, StateTo, Return, + Control, Equation ); + break; + + case FBH_BEASG : + + FvhFbhTreatAsg( FbhFigure, FsmFigure, ScanIns->DATA, + &StateFrom, &StateTo, &Return, + &Control, Equation ); + break; + + default : + + fvherror( FVH_ERROR_ILLEGAL_INSTRUCTION, + (char *)( ScanIns->TYPE ), 0 ); + + break; + } + } + + if ( ( FvhTreatMainProcess ) && + ( ( Control != -1 ) || + ( Return != (fsmstate_list *)0 ) ) ) + { + switch ( Control ) + { + case FSM_CTRL_NOP : + case FSM_CTRL_POP : + + if ( Return != (fsmstate_list *)0 ) + { + fvherror( FVH_ERROR_ILLEGAL_ASSIGNATION, + FvhReturnStateName, 0 ); + } + + break; + + case FSM_CTRL_PUSH : + + if ( Return == (fsmstate_list *)0 ) + { + fvherror( FVH_ERROR_ILLEGAL_CONTROL_ASSIGN, + FSM_CTRL_NAME[ Control ], 0 ); + } + + break; + } + + if ( Equation == (ablexpr *)0 ) + { + NewEquation = createablatomone(); + } + else + { + NewEquation = dupablexpr( Equation ); + } + + addfsmstack( FsmFigure, Control, StateFrom, Return, NewEquation ); + } +} + +/*------------------------------------------------------------\ +| | +| FvhFbhTreatProcess | +| | +\------------------------------------------------------------*/ + +void FvhFbhTreatProcess( FbhFigure, FsmFigure ) + + fbfig_list *FbhFigure; + fsmfig_list *FsmFigure; +{ + fbpcs_list *ScanProc; + chain_list *ScanSens; + fbpcs_list *MainProc; + fbpcs_list *ClockProc; + ptype_list *ScanInst; + fbifs_list *ScanIf; + char SensCurrent; + + MainProc = (fbpcs_list *)0; + + FvhStackHeadName = (char *)0; + FvhTreatStackControl = 0; + FvhTreatStateControl = 0; + FvhTreatMainProcess = 0; +/* +** First Verify there are two VHDL process +*/ + ScanProc = FbhFigure->BEPCS; + + if ( ( ScanProc == (fbpcs_list *)0 ) || + ( ScanProc->NEXT == (fbpcs_list *)0 ) || + ( ScanProc->NEXT->NEXT != (fbpcs_list *)0 ) ) + { + fvherror( FVH_ERROR_TWO_PROCESS, FsmFigure->NAME, 0 ); + } + + ClockProc = (fbpcs_list *)0; +/* +** Find the clock process +*/ + for ( ScanProc = FbhFigure->BEPCS; + ScanProc != (fbpcs_list *)0; + ScanProc = ScanProc->NEXT ) + { + ScanSens = ScanProc->SENSITIVITY; + + if ( ScanSens == (chain_list *)0 ) + { + fvherror( FVH_ERROR_PROCESS_SENSITIVITY, ScanProc->LABEL, ScanProc->USER ); + } + + if ( ( ScanSens->NEXT == (chain_list *)0 ) && + ( ScanSens->DATA == (void *)FvhClockName ) ) + { + FsmFigure->CLOCK = FvhClockName; + + ClockProc = ScanProc; break; + } + } + + if ( ClockProc == (fbpcs_list *)0 ) + { + fvherror( FVH_ERROR_CLOCK_PROCESS, FsmFigure->NAME, 0 ); + } + + if ( FbhFigure->BEPCS == ClockProc ) + { + MainProc = ClockProc->NEXT; + } + else + { + MainProc = FbhFigure->BEPCS; + } +/* +** Verify the sensitivity list of the main process (to be done better) +*/ + SensCurrent = 0; + + for ( ScanSens = MainProc->SENSITIVITY; + ScanSens != (chain_list *)0; + ScanSens = ScanSens->NEXT ) + { + if ( ScanSens->DATA == (void *)FvhCurrentStateName ) + { + SensCurrent = 1; + } + } + + if ( ! SensCurrent ) + { + fvherror( FVH_ERROR_MISSING_SIGNAL, FvhCurrentStateName, ScanProc->USER ); + } +/* +** Check the body of the clock process +*/ + ScanInst = ClockProc->INSTRUCTION; + + if ( ( ScanInst == (ptype_list *)0 ) || + ( ScanInst->NEXT != (ptype_list *)0 ) || + ( ScanInst->TYPE != FBH_BEIFS ) ) + { + fvherror( FVH_ERROR_ILLEGAL_PROCESS_BODY, ClockProc->LABEL, ClockProc->USER ); + } + + ScanIf = (fbifs_list *)ScanInst->DATA; + + if ( ( ScanIf->CNDTRUE == (ptype_list *)0 ) || + ( ScanIf->CNDFALSE != (ptype_list *)0 ) ) + { + fvherror( FVH_ERROR_ILLEGAL_PROCESS_BODY, ClockProc->LABEL, ClockProc->USER ); + } +/* +** Check the body of the main process +*/ + ScanInst = MainProc->INSTRUCTION; + + if ( ScanInst == (ptype_list *)0 ) + { + fvherror( FVH_ERROR_ILLEGAL_PROCESS_BODY, MainProc->LABEL, MainProc->USER ); + } + + for ( ScanInst = MainProc->INSTRUCTION; + ScanInst != (ptype_list *)0; + ScanInst = ScanInst->NEXT ) + { + if ( ( ScanInst->TYPE != FBH_BEIFS ) && + ( ScanInst->TYPE != FBH_BECAS ) ) + { + fvherror( FVH_ERROR_ILLEGAL_PROCESS_BODY, MainProc->LABEL, MainProc->USER ); + } + } + + for ( ScanProc = FbhFigure->BEPCS; + ScanProc != (fbpcs_list *)0; + ScanProc = ScanProc->NEXT ) + { + if ( ScanProc == MainProc ) + { + FvhTreatMainProcess = 1; + } + + FvhFbhTreatInstruction( FbhFigure, FsmFigure, ScanProc->INSTRUCTION, + (fsmstate_list *)0, (fsmstate_list *)0, + (fsmstate_list *)0, -1, (ablexpr *)0 ); + } + + if ( ! FvhTreatStateControl ) + { + fvherror( FVH_ERROR_MISSING_STATE_CONTROL, FsmFigure->NAME, 0 ); + } + + if ( FsmFigure->STACK_SIZE ) + { + if ( ! FvhTreatStackControl ) + { + fvherror( FVH_ERROR_MISSING_STACK_CONTROL, FsmFigure->NAME, 0 ); + } + + if ( ( FvhStackPushSize > FvhDefaultStackSize ) || + ( FvhStackPopSize > FvhDefaultStackSize ) || + ( FvhStackPopSize != FvhStackPushSize - 1 ) ) + { + fvherror( FVH_ERROR_BAD_STACK_CONTROL, FsmFigure->NAME, 0 ); + } + + FsmFigure->STACK_SIZE = FvhStackPushSize; + } +} + +/*------------------------------------------------------------\ +| | +| FvhFbhPostTreat | +| | +\------------------------------------------------------------*/ + +void FvhFbhPostTreat( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + fsmstate_list *StarState; + chain_list *StarChain; + fsmtrans_list *ScanTrans; + ablexpr *Equation; + + if ( ! FvhWhenCondition ) + { + if ( FvhStarStateLocout ) + { + fvherror( FVH_ERROR_ILLEGAL_DEFAULT_ASSIGN, (char *)0, 0 ); + } + + StarState = FsmFigure->STAR_STATE; + Equation = createabloper( ABL_OR ); + + for ( StarChain = StarState->FROM; + StarChain != (chain_list *)0; + StarChain = StarChain->NEXT ) + { + ScanTrans = (fsmtrans_list *)StarChain->DATA; + addablhexpr( Equation, dupablexpr( ScanTrans->ABL ) ); + } + + if ( ABL_CDR( Equation ) == (ablexpr *)0 ) + { + delablexpr( Equation ); + + return; + } + else + if ( ABL_CDDR( Equation ) == (ablexpr *)0 ) + { + StarChain = ABL_CADR( Equation ); + ABL_CADR( Equation ) = (ablexpr *)0; + freeablexpr( Equation ); + Equation = StarChain; + } + + Equation = optimablnotexpr( Equation ); + + for ( ScanTrans = FsmFigure->TRANS; + ScanTrans != (fsmtrans_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + if ( IsFsmStarTrans( ScanTrans ) ) continue; + + ScanTrans->ABL = optimablbinexpr( ABL_AND, + ScanTrans->ABL, + dupablexpr( Equation ) ); + } + + delablexpr( Equation ); + } +} + +/*------------------------------------------------------------\ +| | +| FvhFbh2Fsm | +| | +\------------------------------------------------------------*/ + +fsmfig_list *FvhFbh2Fsm( FbhFigure, FsmFigure ) + + fbfig_list *FbhFigure; + fsmfig_list *FsmFigure; +{ + FvhInitializeKeyword(); + + FsmFigure->NAME = FbhFigure->NAME; + + FvhFbhTreatPragma( FbhFigure, FsmFigure ); + FvhFbhTreatAux( FbhFigure, FsmFigure ); + FvhFbhTreatPort( FbhFigure, FsmFigure ); + FvhFbhTreatProcess( FbhFigure, FsmFigure ); + + FvhFbhPostTreat( FsmFigure ); + + return( FsmFigure ); +} diff --git a/alliance/src/fvh/src/fvhfbh2fsm.h b/alliance/src/fvh/src/fvhfbh2fsm.h new file mode 100644 index 00000000..d0470bf5 --- /dev/null +++ b/alliance/src/fvh/src/fvhfbh2fsm.h @@ -0,0 +1,83 @@ +/*------------------------------------------------------------\ +| | +| 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 : FVH | +| | +| File : fvhfbh2fsm.h | +| | +| Author : Jacomme Ludovic | +| | +| Date : 04.12.96 | +| | +\------------------------------------------------------------*/ + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# ifndef FVH_FBH2FSM_H +# define FVH_FBH2FSM_H + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern fsmfig_list * FvhFbh2Fsm __P((fbfig_list *FbhFigure, fsmfig_list *FsmFigure)); + + extern void FvhFbhTreatInstruction __P((fbfig_list *FbhFigure, fsmfig_list *FsmFigure, ptype_list *Instruct, fsmstate_list *StateFrom, fsmstate_list *StateTo, fsmstate_list *Return, int Control, ablexpr *Equation)); + extern void FvhFbhTreatWhen __P((fbfig_list *FbhFigure, fsmfig_list *FsmFigure, fbcas_list *ScanCase, fsmstate_list **PStateFrom, fsmstate_list *StateTo, fsmstate_list *Return, int *PControl, ablexpr *Equation)); + extern void FvhFbhTreatIf __P((fbfig_list *FbhFigure, fsmfig_list *FsmFigure, fbifs_list *ScanIfs, fsmstate_list *StateFrom, fsmstate_list *StateTo, fsmstate_list *Return, int Control, ablexpr *Equation)); + extern void FvhFbhTreatAsg __P((fbfig_list *FbhFigure, fsmfig_list *FsmFigure, fbasg_list *ScanAsg, fsmstate_list **PStateFrom, fsmstate_list **PStateTo, fsmstate_list **PReturn, int *PControl, ablexpr *Equation)); + +# endif diff --git a/alliance/src/fvh/src/fvhparse.c b/alliance/src/fvh/src/fvhparse.c new file mode 100644 index 00000000..2ee20f1f --- /dev/null +++ b/alliance/src/fvh/src/fvhparse.c @@ -0,0 +1,145 @@ +/*------------------------------------------------------------\ +| | +| 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 : FVH | +| | +| File : fvhparse.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 04.12.96 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "abl.h" +# include "bdd.h" +# include "fsm.h" +# include "fvh.h" + +# include +# include +# include +# include "fvherror.h" +# include "fvhfbh2fsm.h" +# include "fvhparse.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + extern FILE *fbl_y_in; + extern char FBL_ERRFLG; + + bddcircuit *FblBddCircuit = (bddcircuit *)0; + bddsystem *FblBddSystem = (bddsystem *)0; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| vhdlloadfsmfig | +| | +\------------------------------------------------------------*/ + +static void loc_trap_signal() +{ + fprintf( stderr, "fvh: Internal error !\n" ); + autexit( 1 ); +} + +void vhdlloadfsmfig( FsmFigure, FigureName ) + + fsmfig_list *FsmFigure; + char *FigureName; +{ + bddsystem *SaveBddSystem; + bddcircuit *SaveBddCircuit; + int Error; + void (*PreviousHandler)(); + + fbl_y_in = mbkfopen( FigureName, "fsm", "r" ); + + if ( fbl_y_in == (FILE *)0 ) + { + fvherror( FVH_ERROR_OPEN_FILE, FigureName, 0 ); + } + + SaveBddSystem = BddLocalSystem; + SaveBddCircuit = BddLocalCircuit; + + if ( FblBddSystem == (bddsystem *)0 ) + { + FblBddSystem = createbddsystem( 50, 1000, 200, 50000000 ); + FblBddCircuit = createbddcircuit( "-select-", 200, 0, FblBddSystem ); + } + + BddLocalSystem = FblBddSystem; + BddLocalCircuit = FblBddCircuit; + + PreviousHandler = signal( SIGSEGV, loc_trap_signal ); + Error = fbl_y_parse(); + signal( SIGSEGV, PreviousHandler ); + + BddLocalSystem = SaveBddSystem; + BddLocalCircuit = SaveBddCircuit; + + if ( ( Error ) || + ( FBL_ERRFLG ) ) + { + fvherror( FVH_ERROR_PARSE_FILE, FigureName, 0 ); + } + + FvhFbh2Fsm( FBL_HEADFIG, FsmFigure ); + + if ( ! IsFsmFigMixedRtl( FsmFigure ) ) + { + fbh_delfbfig( FBL_HEADFIG, FBL_HEADFIG, 'Y' ); + } +} diff --git a/alliance/src/fvh/src/fvhparse.h b/alliance/src/fvh/src/fvhparse.h new file mode 100644 index 00000000..6ae81895 --- /dev/null +++ b/alliance/src/fvh/src/fvhparse.h @@ -0,0 +1,77 @@ +/*------------------------------------------------------------\ +| | +| 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 : FVH | +| | +| File : fksparse.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 04.12.96 | +| | +\------------------------------------------------------------*/ + +# ifndef FVH_PARSE_H +# define FVH_PARSE_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern int fbl_y_nerrs; int fbl_y_parse __P(()); + +# endif