From 3d8c01051ef67fb8c40100eb4c1718925b0069ba Mon Sep 17 00:00:00 2001 From: Ludovic Jacomme Date: Wed, 20 Mar 2002 14:28:19 +0000 Subject: [PATCH] Hello --- alliance/src/fks/Makefile.am | 1 + alliance/src/fks/configure.in | 45 +++ alliance/src/fks/src/fks.h | 71 +++++ alliance/src/fks/src/fksdrive.c | 397 +++++++++++++++++++++++ alliance/src/fks/src/fksdrive.h | 81 +++++ alliance/src/fks/src/fkserror.c | 148 +++++++++ alliance/src/fks/src/fkserror.h | 92 ++++++ alliance/src/fks/src/fksparse.c | 538 ++++++++++++++++++++++++++++++++ alliance/src/fks/src/fksparse.h | 90 ++++++ 9 files changed, 1463 insertions(+) create mode 100644 alliance/src/fks/Makefile.am create mode 100644 alliance/src/fks/configure.in create mode 100644 alliance/src/fks/src/fks.h create mode 100644 alliance/src/fks/src/fksdrive.c create mode 100644 alliance/src/fks/src/fksdrive.h create mode 100644 alliance/src/fks/src/fkserror.c create mode 100644 alliance/src/fks/src/fkserror.h create mode 100644 alliance/src/fks/src/fksparse.c create mode 100644 alliance/src/fks/src/fksparse.h diff --git a/alliance/src/fks/Makefile.am b/alliance/src/fks/Makefile.am new file mode 100644 index 00000000..af437a64 --- /dev/null +++ b/alliance/src/fks/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/alliance/src/fks/configure.in b/alliance/src/fks/configure.in new file mode 100644 index 00000000..88452646 --- /dev/null +++ b/alliance/src/fks/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:28:19 ludo Exp $ +dnl +dnl +AC_INIT(src/fks.h) +AM_INIT_AUTOMAKE(fks, 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/fks/src/fks.h b/alliance/src/fks/src/fks.h new file mode 100644 index 00000000..377b3b20 --- /dev/null +++ b/alliance/src/fks/src/fks.h @@ -0,0 +1,71 @@ +/*------------------------------------------------------------\ +| | +| 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 FKS | +| | +| Date : 28.01.95 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------*/ + +# ifndef FKS_103_H +# define FKS_103_H + +/*------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------*/ +/*------------------------------------------------------\ +| | +| Structures | +| | +\------------------------------------------------------*/ +/*------------------------------------------------------\ +| | +| Global Variables | +| | +\------------------------------------------------------*/ +/*------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------*/ + + extern void kissloadfsmfig __P((fsmfig_list *FsmFigure, char *FigureName)); + extern void kisssavefsmfig __P((fsmfig_list *FsmFigure)); + +# endif diff --git a/alliance/src/fks/src/fksdrive.c b/alliance/src/fks/src/fksdrive.c new file mode 100644 index 00000000..27a4860d --- /dev/null +++ b/alliance/src/fks/src/fksdrive.c @@ -0,0 +1,397 @@ +/*------------------------------------------------------------\ +| | +| 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 : FSM | +| | +| File : fksdrive.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 +# include +# include +# include +# include "fkserror.h" +# include "fksdrive.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + static FILE *KissFile; + + static char *KissBitString; + static long KissBitLength; + + static char *KissStateFrom; + static char *KissStateTo; + + static long KissBitInput; + + static bddsystem *KissBddSystem; + static bddcircuit *KissBddCircuit; + + static long KissNumberLine; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| KissMakeFsmBddNode | +| | +\------------------------------------------------------------*/ + +static void KissMakeFsmBddNode( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + fsmin_list *ScanIn; + fsmout_list *ScanOut; + fsmstate_list *ScanState; + fsmtrans_list *ScanTrans; + fsmlocout_list *ScanLocout; + bddnode *BddNode; + bddnode *BddNodeOut; + bddnode *BddNodeLocOn; + bddnode *BddNodeLocOff; + bddnode *BddNodeLocDc; + bddnode *BddNodeLocout; + + KissBddSystem = createbddsystem( FKS_BDD_MODEL_VAR, FKS_BDD_MODEL_OPER, + FKS_BDD_MAX_VAR , FKS_BDD_MAX_NODE ); + + KissBddCircuit = createbddcircuit( FsmFigure->NAME, + FsmFigure->NUMBER_IN, + FsmFigure->NUMBER_OUT, KissBddSystem ); + + for ( ScanIn = FsmFigure->IN; + ScanIn != (fsmin_list *)0; + ScanIn = ScanIn->NEXT ) + { + addbddcircuitin( (bddcircuit *)0, ScanIn->NAME, + (bddindex )0, BDD_IN_MODE_LAST ); + } + + for ( ScanOut = FsmFigure->OUT; + ScanOut != (fsmout_list *)0; + ScanOut = ScanOut->NEXT ) + { + addbddcircuitin( (bddcircuit *)0, ScanOut->NAME, + (bddindex )0, BDD_IN_MODE_LAST ); + } + + for ( ScanTrans = FsmFigure->TRANS; + ScanTrans != (fsmtrans_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + ScanTrans->USER = (void *)addbddcircuitabl( (bddcircuit *)0, ScanTrans->ABL ); + } + + ScanState = FsmFigure->STATE; + + while ( ScanState != (fsmstate_list *)0 ) + { + BddNode = BddLocalSystem->ONE; + + for ( ScanLocout = ScanState->LOCOUT; + ScanLocout != (fsmlocout_list *)0; + ScanLocout = ScanLocout->NEXT ) + { + BddNodeOut = searchbddcircuitin( (bddcircuit *)0, ScanLocout->OUT->NAME ); + + if ( ScanLocout->ABL != (ablexpr *)0 ) + { + BddNodeLocOn = addbddcircuitabl( (bddcircuit *)0, ScanLocout->ABL ); + } + else + { + BddNodeLocOn = BddLocalSystem->ZERO; + } + + if ( ScanLocout->ABL_DC != (ablexpr *)0 ) + { + BddNodeLocDc = addbddcircuitabl( (bddcircuit *)0, ScanLocout->ABL_DC ); + BddNodeLocOff = applybddnode( (bddsystem *)0, ABL_OR, + BddNodeLocDc , BddNodeOut ); + } + else + { + BddNodeLocDc = BddLocalSystem->ZERO; + BddNodeLocOff = BddNodeOut; + } + + BddNodeLocOff = applybddnode( (bddsystem *)0, ABL_NOR, + decbddrefext( BddNodeLocOff ), + BddNodeLocOn ); + + BddNodeLocOn = applybddnode( (bddsystem *)0, ABL_AND, + decbddrefext( BddNodeLocOn ), + BddNodeOut ); + + BddNodeLocout = applybddnode( (bddsystem *)0, ABL_OR , + decbddrefext( BddNodeLocOn ), + decbddrefext( BddNodeLocOff ) ); + + BddNodeLocout = applybddnode( (bddsystem *)0, ABL_OR, + decbddrefext( BddNodeLocout ), + decbddrefext( BddNodeLocDc ) ); + + BddNode = applybddnode( (bddsystem *)0, ABL_AND, + decbddrefext( BddNode ), + decbddrefext( BddNodeLocout ) ); + } + + BddNode = addbddcircuitout( (bddcircuit *)0, ScanState->NAME, BddNode ); + + ScanState->USER = (void *)BddNode; + ScanState = ScanState->NEXT; + } +} + +/*------------------------------------------------------------\ +| | +| KissDestroyFsmBddNode | +| | +\------------------------------------------------------------*/ + +static void KissDestroyFsmBddNode( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + fsmstate_list *ScanState; + fsmtrans_list *ScanTrans; + + for ( ScanTrans = FsmFigure->TRANS; + ScanTrans != (fsmtrans_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + ScanTrans->USER = (void *)0; + } + + ScanState = FsmFigure->STATE; + + while ( ScanState != (fsmstate_list *)0 ) + { + ScanState->USER = (void *)0; + ScanState = ScanState->NEXT; + } + + destroybddcircuit( KissBddCircuit ); + destroybddsystem( KissBddSystem ); +} + +/*------------------------------------------------------------\ +| | +| KissDriveBitString | +| | +\------------------------------------------------------------*/ + +static void KissDriveBitString( BddNode ) + + bddnode *BddNode; +{ + bddindex Index; + char Cut; + + if ( BddNode->INDEX < BDD_INDEX_MIN ) + { + if ( BddNode->INDEX == BDD_INDEX_ONE ) + { + KissNumberLine++; + + Cut = KissBitString[ KissBitInput ]; + KissBitString[ KissBitInput ] = '\0';; + + fprintf( KissFile, "%s %s %s", + KissBitString, KissStateFrom, KissStateTo ); + + KissBitString[ KissBitInput ] = Cut; + + fprintf( KissFile, " %s\n", KissBitString + KissBitInput ); + } + } + else + { + Index = BddNode->INDEX - BDD_INDEX_MIN; + + KissBitString[ Index ] = '1'; + KissDriveBitString( BddNode->HIGH ); + + KissBitString[ Index ] = '0'; + KissDriveBitString( BddNode->LOW ); + + KissBitString[ Index ] = '-'; + } +} + +/*------------------------------------------------------------\ +| | +| KissDriveFigure | +| | +\------------------------------------------------------------*/ + +static void KissDriveFigure( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + fsmtrans_list *ScanTrans; + bddnode *BddNode; + bddnode *BddTrans; + bddnode *BddOut; + + KissNumberLine = 0; + KissBitInput = FsmFigure->NUMBER_IN; + KissBitLength = KissBitInput + FsmFigure->NUMBER_OUT + 1; + KissBitString = (char *)autallocblock( KissBitLength ); + + memset( (void *)KissBitString, '-', (size_t)( KissBitLength - 1 ) ); + + FsmFigure->TRANS = (fsmtrans_list *)reverse( (chain_list *)FsmFigure->TRANS ); + + for ( ScanTrans = FsmFigure->TRANS; + ScanTrans != (fsmtrans_list *)0; + ScanTrans = ScanTrans->NEXT ) + { + KissStateFrom = ScanTrans->FROM->NAME; + KissStateTo = ScanTrans->TO->NAME; + + BddOut = (bddnode *)ScanTrans->FROM->USER; + BddTrans = (bddnode *)ScanTrans->USER; + +/*\ + if ( BddOut->INDEX < BDD_INDEX_MIN ) + { + BddNode = BddTrans; + } + else +\*/ + { + BddNode = applybddnode( (bddsystem *)0 , ABL_AND, BddTrans, BddOut ); + } + + KissDriveBitString( BddNode ); + } + + FsmFigure->TRANS = (fsmtrans_list *)reverse( (chain_list *)FsmFigure->TRANS ); + + autfreeblock( KissBitString ); +} + +/*------------------------------------------------------------\ +| | +| kisssavefsmfig | +| | +\------------------------------------------------------------*/ + +void kisssavefsmfig( FsmFigure ) + + fsmfig_list *FsmFigure; +{ + bddsystem *BddSystem; + bddcircuit *BddCircuit; + long Position; + long NumberState; + + if ( FsmFigure->STACK != (fsmstack_list *)0 ) + { + fkserror( KISS_ERROR_FSM_STACK, FsmFigure->NAME ); + } + + KissFile = mbkfopen( FsmFigure->NAME, "kiss2", "w" ); + + if ( KissFile == (FILE *)0 ) + { + fkserror( KISS_ERROR_OPEN_FILE, FsmFigure->NAME ); + } + + NumberState = FsmFigure->NUMBER_STATE; + + if ( FsmFigure->STAR_STATE != (fsmstate_list *)0 ) + { + NumberState = NumberState - 1; + } + + fprintf( KissFile, ".i %ld\n", FsmFigure->NUMBER_IN ); + fprintf( KissFile, ".o %ld\n", FsmFigure->NUMBER_OUT ); + fprintf( KissFile, ".s %ld\n", NumberState ); + + if ( FsmFigure->FIRST_STATE != (fsmstate_list *)0 ) + { + fprintf( KissFile, ".r %s\n", FsmFigure->FIRST_STATE->NAME ); + } + + Position = ftell( KissFile ); + fprintf( KissFile, ".p \n" ); + + BddSystem = BddLocalSystem; + BddCircuit = BddLocalCircuit; + + KissMakeFsmBddNode( FsmFigure ); + KissDriveFigure( FsmFigure ); + KissDestroyFsmBddNode( FsmFigure ); + + BddLocalSystem = BddSystem; + BddLocalCircuit = BddCircuit; + + fprintf( KissFile, ".e\n" ); + + fseek( KissFile, Position, 0 ); + fprintf( KissFile, ".p %ld\n", KissNumberLine ); + + fclose( KissFile ); +} diff --git a/alliance/src/fks/src/fksdrive.h b/alliance/src/fks/src/fksdrive.h new file mode 100644 index 00000000..2ce39874 --- /dev/null +++ b/alliance/src/fks/src/fksdrive.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 +/*------------------------------------------------------------\ +| | +| Tool : FSM | +| | +| File : fksdrive.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 04.12.96 | +| | +\------------------------------------------------------------*/ + +# ifndef FKS_DRIVE_H +# define FKS_DRIVE_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define FKS_BDD_MODEL_VAR 50 +# define FKS_BDD_MODEL_OPER 1000 +# define FKS_BDD_MAX_VAR (BDD_MAX_VAR - 1) +# define FKS_BDD_MAX_NODE 9000000 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif diff --git a/alliance/src/fks/src/fkserror.c b/alliance/src/fks/src/fkserror.c new file mode 100644 index 00000000..5d01845f --- /dev/null +++ b/alliance/src/fks/src/fkserror.c @@ -0,0 +1,148 @@ +/*------------------------------------------------------------\ +| | +| 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 : FSM | +| | +| File : fkserror.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 "fkserror.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +void fks_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 KISS_ERROR_OPEN_FILE : + + fprintf( stderr, "unable to open file \"%s\"\n", Text ); + + break; + + case KISS_ERROR_PARSE : + + fprintf( stderr, "parse error line %ld\n", (long)Text ); + + break; + + case KISS_ERROR_END : + + fprintf( stderr, "unexpected end of file line %ld\n", (long)Text ); + + break; + + case KISS_ERROR_VALUE : + + fprintf( stderr, "bad value line %ld\n", (long)Text ); + + break; + + case KISS_ERROR_NAME : + + fprintf( stderr, "bad name line %ld\n", (long)Text ); + + break; + + case KISS_ERROR_PORT : + + fprintf( stderr, "missing port(s) declaration line %ld\n", (long)Text ); + + break; + + case KISS_ERROR_STATE : + + fprintf( stderr, "missing state(s) declaration line %ld\n", (long)Text ); + + break; + + case KISS_ERROR_FSM_STACK : + + fprintf( stderr, "unable to drive FSM stack of \"%s\"\n", Text ); + + break; + + + default : + + fprintf( stderr, "unknown internal error %d !\n", Error ); + } + + autexit( 1 ); +} diff --git a/alliance/src/fks/src/fkserror.h b/alliance/src/fks/src/fkserror.h new file mode 100644 index 00000000..9baba21d --- /dev/null +++ b/alliance/src/fks/src/fkserror.h @@ -0,0 +1,92 @@ +/*------------------------------------------------------------\ +| | +| 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 : FSM | +| | +| File : fkserror.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 04.12.96 | +| | +\------------------------------------------------------------*/ + +# ifndef FKS_ERROR_H +# define FKS_ERROR_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define KISS_ERROR_OPEN_FILE 0 +# define KISS_ERROR_PARSE 1 +# define KISS_ERROR_END 2 +# define KISS_ERROR_VALUE 3 +# define KISS_ERROR_NAME 4 +# define KISS_ERROR_PORT 5 +# define KISS_ERROR_STATE 6 +# define KISS_ERROR_FSM_STACK 7 + +# define KISS_MAX_ERROR 8 + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ + +# define fkserror( E, V ) (fks_error( (int)(E), (char *)(V), __FILE__, __LINE__ )) + +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + + extern void fks_error __P((char Error, char *Text, char *File, long Line)); + +# endif diff --git a/alliance/src/fks/src/fksparse.c b/alliance/src/fks/src/fksparse.c new file mode 100644 index 00000000..d030d57a --- /dev/null +++ b/alliance/src/fks/src/fksparse.c @@ -0,0 +1,538 @@ +/*------------------------------------------------------------\ +| | +| 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 : FSM | +| | +| File : fksparse.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 "fkserror.h" +# include "fksparse.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Privates | +| | +\------------------------------------------------------------*/ + + static int KissLineNumber = 0; + static char KissBuffer[ KISS_BUFFER_SIZE ]; + static char *KissScanBuffer; + static FILE *KissFile; + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| KissSpipBlank | +| | +\------------------------------------------------------------*/ + +static void KissSkipBlank( End ) + + int End; +{ + int Index; + + do + { + if ( ( KissScanBuffer == (char *)0 ) || + ( *KissScanBuffer == '\0' ) ) + { + KissScanBuffer = fgets( KissBuffer, KISS_BUFFER_SIZE, KissFile ); + + KissLineNumber++; + + if ( KissScanBuffer == (char *)0 ) + { + if ( End ) return; + + fkserror( KISS_ERROR_END, KissLineNumber ); + } + + for ( Index = 0; KissScanBuffer[ Index ] != '\0'; Index++ ) + { + KissScanBuffer[ Index ] = tolower( KissScanBuffer[ Index ] ); + } + } + + while ( ( *KissScanBuffer != '\0' ) && + ( isspace( *KissScanBuffer ) ) ) + { + KissScanBuffer++; + } + } + while ( *KissScanBuffer == '\0' ); +} + +/*------------------------------------------------------------\ +| | +| KissGetValue | +| | +\------------------------------------------------------------*/ + +static int KissGetValue() +{ + char *Scan; + int Value; + + Value = 0; + + for ( Scan = KissScanBuffer; *Scan != '\0'; Scan++ ) + { + if ( isspace( *Scan ) ) break; + } + + if ( Scan != KissScanBuffer ) + { + *Scan = '\0'; + Value = atoi( KissScanBuffer ); + *Scan = ' '; + + KissScanBuffer = Scan; + } + + if ( Value <= 0 ) + { + fkserror( KISS_ERROR_VALUE, KissLineNumber ); + } + + return( Value ); +} + +/*------------------------------------------------------------\ +| | +| KissGetName | +| | +\------------------------------------------------------------*/ + +static char *KissGetName() +{ + char *Scan; + char *Name; + + Name = (char *)0; + + for ( Scan = KissScanBuffer; *Scan != '\0'; Scan++ ) + { + if ( isspace( *Scan ) ) break; + } + + if ( Scan != KissScanBuffer ) + { + *Scan = '\0'; + Name = namealloc( KissScanBuffer ); + *Scan = ' '; + + KissScanBuffer = Scan; + } + + if ( Name == (char *)0 ) + { + fkserror( KISS_ERROR_NAME, KissLineNumber ); + } + + return( Name ); +} + +/*------------------------------------------------------------\ +| | +| kissloadfsmfig | +| | +\------------------------------------------------------------*/ + +void kissloadfsmfig( FsmFigure, FigureName ) + + fsmfig_list *FsmFigure; + char *FigureName; +{ + fsmstate_list *StateFrom; + fsmstate_list *StateTo; + fsmstate_list *StarState; + fsmout_list *Output; + fsmin_list *Input; + ablexpr *Atom; + ablexpr *Equation; + ablexpr *Transition; + char *StateName; + char *StateVoidName; + char *StarStateName; + char *PortName; + int NumberIn; + int NumberOut; + int NumberState; + char Instruction; + char DeclarationType; + int Index; + int Value; + char BufferName[ 30 ]; + + KissFile = mbkfopen( FigureName, "kiss2", "r" ); + + if ( KissFile == (FILE *)0 ) + { + fkserror( KISS_ERROR_OPEN_FILE, FigureName ); + } + + KissLineNumber = 0; + Instruction = 0; + KissScanBuffer = (char *)0; + Atom = (ablexpr *)0; + + StateVoidName = namealloc( "void" ); + StarStateName = namealloc( "*" ); + + StarState = addfsmstate( FsmFigure, StarStateName ); + FsmFigure->STAR_STATE = StarState; + SetFsmStarState( StarState ); +/* +** clock AND NOT clock'STABLE ) +*/ + FsmFigure->CLOCK = namealloc( "clock" ); + + Equation = createabloper( ABL_STABLE ); + addablhexpr( Equation, createablatom( FsmFigure->CLOCK ) ); + Equation = optimablnotexpr( Equation ); + Equation = optimablbinexpr( ABL_AND, Equation, + createablatom( FsmFigure->CLOCK ) ); + + FsmFigure->CLOCK_ABL = Equation; + + addfsmport( FsmFigure, FsmFigure->CLOCK, FSM_DIR_IN, FSM_TYPE_BIT ); + + KissSkipBlank( 0 ); + + while ( KissScanBuffer != (char *)0 ) + { + if ( Instruction == 0 ) + { +/* +** Declaration Part +*/ + if ( KissScanBuffer[ 0 ] == '.' ) + { + DeclarationType = KissScanBuffer[ 1 ]; + KissScanBuffer = KissScanBuffer + 2; + + if ( ( DeclarationType == KISS_KEYWORD_IN ) || + ( DeclarationType == KISS_KEYWORD_OUT ) || + ( DeclarationType == KISS_KEYWORD_STATE ) || + ( DeclarationType == KISS_KEYWORD_R ) || + ( DeclarationType == KISS_KEYWORD_P ) ) + { + KissSkipBlank( 0 ); + + if ( DeclarationType != KISS_KEYWORD_R ) + { + Value = KissGetValue(); + } + else + { + StateName = KissGetName(); + FsmFigure->FIRST_STATE = addfsmstate( FsmFigure, StateName ); + SetFsmFirstState( FsmFigure->FIRST_STATE ); + } + + if ( DeclarationType == KISS_KEYWORD_IN ) + { + NumberIn = Value; +/* +** Initialize input +*/ + for ( Index = 0; Index < NumberIn; Index++ ) + { + sprintf( BufferName, "I%d", Index ); + PortName = namealloc( BufferName ); + addfsmin( FsmFigure, PortName ); + addfsmport( FsmFigure, PortName, FSM_DIR_IN, FSM_TYPE_BIT ); + } + + FsmFigure->IN = + (fsmin_list *)reverse( (chain_list *)FsmFigure->IN ); + } + else + if ( DeclarationType == KISS_KEYWORD_OUT ) + { + NumberOut = Value; + + for ( Index = 0; Index < NumberOut; Index++ ) + { +/* +** Initialize output +*/ + sprintf( BufferName, "O%d", Index ); + PortName = namealloc( BufferName ); + addfsmout( FsmFigure, PortName ); + addfsmport( FsmFigure, PortName, FSM_DIR_OUT, FSM_TYPE_BIT ); + + FsmFigure->OUT = + (fsmout_list *)reverse( (chain_list *)FsmFigure->OUT ); + } + } + else + if ( DeclarationType == KISS_KEYWORD_STATE ) + { + NumberState = Value; +/* +** Initialize state +*/ + } + } + else + { + KissScanBuffer = (char *)0; + } + } + else + { + if ( NumberState == 0 ) + { + fkserror( KISS_ERROR_STATE, FsmFigure->NAME ); + } + + if ( ( NumberIn == 0 ) || + ( NumberOut == 0 ) ) + { + fkserror( KISS_ERROR_PORT, FsmFigure->NAME ); + } + + Instruction = 1; + } + } + + if ( Instruction == 1 ) + { +/* +** Instruction Part +*/ + if ( ( KissScanBuffer[0] == '.' ) && + ( KissScanBuffer[1] == 'e' ) ) break; +/* +** Input list +*/ + Input = FsmFigure->IN; + Equation = createabloper( ABL_AND ); + + for ( Index = 0; Index < NumberIn; Index++ ) + { + if ( *KissScanBuffer == '0' ) + { + addablhexpr( Equation, optimablnotexpr( createablatom( Input->NAME ) ) ); + } + else + if ( *KissScanBuffer == '1' ) + { + addablhexpr( Equation, createablatom( Input->NAME ) ); + } + else + if ( *KissScanBuffer != '-' ) + { + fkserror( KISS_ERROR_PARSE, KissLineNumber ); + } + + KissScanBuffer++; + Input = Input->NEXT; + } + + if ( ABL_CDR( Equation ) == (ablexpr *)0 ) + { + delablexpr( Equation ); + Transition = createablatomone(); + } + else + if ( ABL_CDDR( Equation ) == (ablexpr *)0 ) + { + Transition = dupablexpr( ABL_CADR( Equation ) ); + delablexpr( Equation ); + } + else + { + Transition = Equation; + } + + KissSkipBlank(); +/* +** State From +*/ + StateName = KissGetName(); + + if ( StateName == StarStateName ) + { + StateFrom = StarState; + } + else + { + StateFrom = searchfsmstate( FsmFigure, StateName ); + } + + if ( StateFrom == (fsmstate_list *)0 ) + { + if ( FsmFigure->NUMBER_STATE > NumberState ) + { + fkserror( KISS_ERROR_NAME, KissLineNumber ); + } + + StateFrom = searchfsmstate( FsmFigure, StateName ); + + if ( StateFrom == (fsmstate_list *)0 ) + { + StateFrom = addfsmstate( FsmFigure, StateName ); + } + } + + KissSkipBlank(); +/* +** State To +*/ + StateName = KissGetName(); + + if ( StateName != StateVoidName ) + { + if ( StateName == StarStateName ) + { + StateTo = StarState; + } + else + { + StateTo = searchfsmstate( FsmFigure, StateName ); + } + + if ( StateTo == (fsmstate_list *)0 ) + { + if ( FsmFigure->NUMBER_STATE > NumberState ) + { + fkserror( KISS_ERROR_NAME, KissLineNumber ); + } + + StateTo = searchfsmstate( FsmFigure, StateName ); + + if ( StateTo == (fsmstate_list *)0 ) + { + StateTo = addfsmstate( FsmFigure, StateName ); + } + } + } + + if ( StateTo != (fsmstate_list *)0 ) + { + Equation = dupablexpr( Transition ); + addfsmtrans( FsmFigure, StateFrom, StateTo, Equation ); + } + + KissSkipBlank(); +/* +** Output +*/ + Output = FsmFigure->OUT; + + for ( Index = 0; Index < NumberOut; Index++ ) + { + if ( *KissScanBuffer == '1' ) + { + if ( Transition != (ablexpr *)0 ) + { + Equation = dupablexpr( Transition ); + addfsmlocout( StateFrom, Output, Equation, (ablexpr *)0 ); + } + } + else + if ( *KissScanBuffer == '-' ) + { + if ( Transition != (ablexpr *)0 ) + { + Equation = dupablexpr( Transition ); + addfsmlocout( StateFrom, Output, (ablexpr *)0, Equation ); + } + } + else + if ( *KissScanBuffer == '0' ) + { + Atom = createablatomzero(); + addfsmlocout( StateFrom, Output, Atom, (ablexpr *)0 ); + } + else + { + fkserror( KISS_ERROR_PARSE, KissLineNumber ); + } + + KissScanBuffer++; + Output = Output->NEXT; + } + + if ( Transition != (ablexpr *)0 ) + { + delablexpr( Transition ); + } + } + + KissSkipBlank( 1 ); + } + + FsmFigure->PORT = (fsmport_list *)reverse( (chain_list *)FsmFigure->PORT ); + + fclose( KissFile ); +} diff --git a/alliance/src/fks/src/fksparse.h b/alliance/src/fks/src/fksparse.h new file mode 100644 index 00000000..641ee2e3 --- /dev/null +++ b/alliance/src/fks/src/fksparse.h @@ -0,0 +1,90 @@ +/*------------------------------------------------------------\ +| | +| 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 : FSM | +| | +| File : fksparse.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 04.12.96 | +| | +\------------------------------------------------------------*/ + +# ifndef FKS_PARSE_H +# define FKS_PARSE_H + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ + +# define KISS_BUFFER_SIZE 256 + +/*------------------------------------------------------------\ +| | +| Keywords | +| | +\------------------------------------------------------------*/ + +# define KISS_KEYWORD_IN 'i' +# define KISS_KEYWORD_OUT 'o' +# define KISS_KEYWORD_STATE 's' +# define KISS_KEYWORD_R 'r' +# define KISS_KEYWORD_P 'p' + +/*------------------------------------------------------------\ +| | +| Macro | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +# endif