diff --git a/alliance/src/ctp/Makefile.am b/alliance/src/ctp/Makefile.am new file mode 100644 index 00000000..af437a64 --- /dev/null +++ b/alliance/src/ctp/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/alliance/src/ctp/configure.in b/alliance/src/ctp/configure.in new file mode 100644 index 00000000..095026c1 --- /dev/null +++ b/alliance/src/ctp/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/05/02 13:37:03 ludo Exp $ +dnl +dnl +AC_INIT(src/ctp.h) +AM_INIT_AUTOMAKE(ctp, 1.1) +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/ctp/src/Makefile.am b/alliance/src/ctp/src/Makefile.am new file mode 100644 index 00000000..9f5fa480 --- /dev/null +++ b/alliance/src/ctp/src/Makefile.am @@ -0,0 +1,22 @@ +AM_CFLAGS = @ALLIANCE_CFLAGS@ +lib_LIBRARIES = libCtp.a +include_HEADERS = ctp.h +libCtp_a_SOURCES = ctp_y.y ctp_l.l ctp.h \ +ctp_bedef.h ctp_bspec.c ctp_byacc.h ctp_parse.c ctp_util.h \ +ctp_blex.h ctp_bspec.h ctp_util.c ctp_utype.h + +CLEANFILES = ctp_y.c ctp_y.h ctp_l.c + + +ctp_y.c ctp_y.h : $(srcdir)/ctp_y.y + $(YACC) -d $(YFLAGS) $(srcdir)/ctp_y.y && sed -e "s/yy/ctp_y_/g" -e "s/YY/CTL_Y_/g" y.tab.c > ctp_y.c && sed -e "s/yy/ctp_y_/g" -e "s/YY/CTL_Y_/g" y.tab.h > ctp_y.h +ctp_l.c : $(srcdir)/ctp_l.l ctp_y.h + $(LEX) -t $(srcdir)/ctp_l.l | sed -e "s/yy/ctp_y_/g" -e "s/YY/CTL_Y_/g" > ctp_l.c + +EXTRA_PROGRAMS = ctptest + +ctptest_LDADD = @ALLIANCE_LIBS@ \ + $(top_builddir)/src/libCtp.a \ + -lCtl -lVex -lAut -lMut + +ctptest_SOURCES = main.c diff --git a/alliance/src/ctp/src/ctp.h b/alliance/src/ctp/src/ctp.h new file mode 100644 index 00000000..c6ac4753 --- /dev/null +++ b/alliance/src/ctp/src/ctp.h @@ -0,0 +1,70 @@ +/*------------------------------------------------------------\ +| | +| 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 : Fonctions to parse a CTL file | +| | +| Date : 04.22.02 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------*/ + +# ifndef CTP_H +# define CTP_H + +/*------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------*/ +/*------------------------------------------------------\ +| | +| Structures | +| | +\------------------------------------------------------*/ +/*------------------------------------------------------\ +| | +| Global Variables | +| | +\------------------------------------------------------*/ +/*------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------*/ + + extern ctlfig_list *loadctlfig __P((char *InputFileName)); + +# endif diff --git a/alliance/src/ctp/src/ctp_bedef.h b/alliance/src/ctp/src/ctp_bedef.h new file mode 100644 index 00000000..e4f533c0 --- /dev/null +++ b/alliance/src/ctp/src/ctp_bedef.h @@ -0,0 +1,96 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ + +/* ###--------------------------------------------------------------### */ +/* */ +/* file : bvl_bedef.h */ +/* date : Jun 15 1992 */ +/* version : v102 */ +/* author : P.BAZARGAN, M.HANAFI */ +/* content : declaration of define used by yacc */ +/* */ +/* ###--------------------------------------------------------------### */ + +#define CTP_LG_MC 15 +#define CTP_NB_MC ((tab_mc -1 + sizeof(tab_mc)/ (sizeof(tab_mc[0])) - tab_mc+1)) + +#define CTP_CSTDFN 1 /* constant */ +#define CTP_TPEDFN 2 /* type */ +#define CTP_FORDFN 3 /* formula */ +#define CTP_VARDFN 4 /* variable */ +#define CTP_LABDFN 5 /* label */ + +#define CTP_MODDFN 0 /* mod_val field of dct_recrd */ +#define CTP_SYMDFN 1 /* sym_val field of dct_recrd */ +#define CTP_TYPDFN 2 /* type_val field of dct_recrd */ +#define CTP_SUNDFN 3 /* sign_val */ +#define CTP_LBLDFN 4 /* lbl_val field of dct_recrd */ +#define CTP_WMXDFN 5 /* wmx_val field of dct_recrd */ +#define CTP_WMNDFN 6 /* wmn_val field of dct_recrd */ +#define CTP_ATLDFN 7 /* attr_left_val */ +#define CTP_ATRDFN 8 /* attr_left_val */ +#define CTP_PNTDFN 9 /* pnt_val field of dct_recrd */ + +#define CTP_UPTDFN 1 /* direction is up */ +#define CTP_DWTDFN 2 /* direction is down */ +#define CTP_IDXDFN 3 + +#define CTP_EVENT 1 +#define CTP_STABLE 2 +#define CTP_LEFT 3 +#define CTP_RIGHT 4 +#define CTP_HIGH 5 +#define CTP_LOW 6 +#define CTP_LENGTH 7 +#define CTP_RANGE 8 +#define CTP_REV_RANGE 9 + +/* ###---------------------------------------------------------------### */ + +#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 EMPTYOP 121 + +#define CTP_UNGDFN 0 +#define CTP_GRDDFN 1 + +/* ###---------------------------------------------------------------### */ + +#define CTP_INTDFN 0 /* int_val field of dtc_recrd */ + +#define CTP_ALODFN 60 /* nbr of allocations */ +#define CTP_HSZDFN 97 /* size of dictionnary: entries */ diff --git a/alliance/src/ctp/src/ctp_blex.h b/alliance/src/ctp/src/ctp_blex.h new file mode 100644 index 00000000..408f3581 --- /dev/null +++ b/alliance/src/ctp/src/ctp_blex.h @@ -0,0 +1,47 @@ +/*------------------------------------------------------------\ +| | +| 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 : bvl_blex.h */ +/* date : Jun 15 1992 */ +/* version : v102 */ +/* author : TABUSSE L.A. */ +/* content : declaration of functions and global variables used by */ +/* lex */ +/* */ +/* ###--------------------------------------------------------------### */ + +#include "ctp_bedef.h" + +extern long CTP_LINNUM; /* file's line number */ + +typedef struct +{ char nom[CTP_LG_MC]; + int kval; +} el_mc; + diff --git a/alliance/src/ctp/src/ctp_bspec.c b/alliance/src/ctp/src/ctp_bspec.c new file mode 100644 index 00000000..900b4c19 --- /dev/null +++ b/alliance/src/ctp/src/ctp_bspec.c @@ -0,0 +1,1164 @@ +/*------------------------------------------------------------\ +| | +| 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 "mut.h" +#include "vex.h" +#include "aut.h" +#include "ctl.h" + +#include "ctp_bedef.h" +#include "ctp_bspec.h" + +static int CtpEvalError = 0; + +# ifndef NO_DEBUG +# define my_ctp_toolbug(V1,V2,V3,V4) \ + do { fprintf( stderr, "%s.%d:", basename(__FILE__), __LINE__);\ + ctp_toolbug(V1,V2,V3,V4); } while(0) +# define my_ctp_error(N,V) \ + do { fprintf( stderr, "%s.%d:", basename(__FILE__), __LINE__);\ + ctp_error(N,V); } while(0) +# else +# define my_ctp_toolbug ctp_toolbug +# define my_ctp_error ctp_error +# endif + +/* ###--------------------------------------------------------------### */ +/* function : ctp_stostr */ +/* description : purge double % (percent) or Quote (") from string */ +/* called func. : mbkalloc */ +/* ###--------------------------------------------------------------### */ + +char *ctp_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++; + } + + mbkfree( str ); + return( &resstr[0] ); +} + +/* ###--------------------------------------------------------------### */ +/* function : ctp_crtvex */ +/* 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 */ +/* EMPTYOP initialize a structure for an empty op */ +/* 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 */ +/* VEX_AND perform logical and between two expressions*/ +/* VEX_OR perform logical or between two expressions*/ +/* VEX_NAND perform logical nand between two expressions*/ +/* NOR perform logical nor between two expressions*/ +/* XOR perform logical xor between two expressions*/ +/* called func. : createvexatom , createvexoper, addvexqexpr , my_ctp_toolbug, */ +/* ctp_error , addchain , freechain */ +/* ###--------------------------------------------------------------### */ + +ctltype_list *ctp_getbasetype( type ) + + int type; +{ + ctltype_list *ScanType; + + for ( ScanType = CTP_HEADFIG->TYPE; + ScanType != (ctltype_list *)0; + ScanType = ScanType->NEXT ) + { + if ( ScanType->INDEX == type ) + { + if ( ScanType->BASE != (ctltype_list *)0 ) + { + ScanType = ScanType->BASE; + } + + break; + } + } + + return( ScanType ); +} + +vexexpr *ctp_vexatom( Name, Left, Right ) + + char *Name; + long Left; + long Right; +{ + vexexpr *Result = (vexexpr *)0; + + if ( ( Left == -1 ) && + ( Right == -1 ) ) + { + Result = createvexatombit( Name ); + } + else + { + Result = createvexatomvec( Name, Left, Right ); + } + + return( Result ); + +} + +ctp_vexstr ctp_crtvex( oper, expr1, expr2, left, right) + +short oper; +ctp_vexstr expr1; +ctp_vexstr expr2; +long left; +long right; +{ + char name[128]; + ctp_vexstr result; + char lcl_buffer[128]; + int Length; + ctltype_list *BaseType1; + ctltype_list *BaseType2; + ctltype_list *CtlType; + + result.IDENT = NULL; + result.VEX = NULL; + result.WIDTH = 0; + result.AGGREG = 0; + + switch (oper) + { + case VEX_CONCAT : + if ((expr1.VEX == NULL) || (expr2.VEX == NULL)) + my_ctp_toolbug (4,"ctp_crtvex","CONC",0); + else + { + if (expr1.VEX == expr2.VEX) + my_ctp_toolbug (16,"ctp_crtvex",NULL,0); + else + { + result.VEX = createvexbinexpr( VEX_CONCAT, 1, expr1.VEX, expr2.VEX ); + + /* TYPE ET LEFT, RIGHT A VERIFIER !!! */ + + result.WIDTH = expr1.WIDTH + expr2.WIDTH; + result.TYPE = VEX_TYPE_BIT_VECTOR; + result.SIGNED = expr1.SIGNED; + + result.VEX->WIDTH = result.WIDTH; + result.VEX->LEFT = 0; + result.VEX->RIGHT = result.WIDTH - 1; + + if ( result.SIGNED ) SetVexNodeSigned( result.VEX ); + + expr1.VEX = NULL; + expr2.VEX = NULL; + } + } + break; + + case SUBVAR : + if ( expr1.VEX == NULL ) + my_ctp_toolbug (2,"ctp_crtvex","SUBVAR VEX NIL ",0); + else + { + result.VEX = expr1.VEX; + result.WIDTH = result.VEX->WIDTH; + result.TYPE = expr1.TYPE; + result.SIGNED = expr1.SIGNED; + + if ( result.SIGNED ) SetVexNodeSigned( result.VEX ); + } + break; + + case NOPI : + if ( expr1.IDENT == NULL ) + my_ctp_toolbug (2,"ctp_crtvex","NOPI IDENT = ) ",0); + else + { + result.VEX = ctp_vexatom( expr1.IDENT, left, right ); + + result.WIDTH = result.VEX->WIDTH; + result.TYPE = expr1.TYPE; + result.SIGNED = expr1.SIGNED; + + if ( result.SIGNED ) SetVexNodeSigned( result.VEX ); + + if ( result.TYPE >= VEX_MAX_TYPE ) + { + CtlType = ctp_getbasetype( result.TYPE ); + + if ( ( CtlType != (ctltype_list *)0 ) && + ( CtlType->CLASS == 'A' ) ) + { + if ( CtlType->LEFT > CtlType->RIGHT ) + { + result.WIDTH = CtlType->LEFT - CtlType->RIGHT + 1; + } + else + { + result.WIDTH = CtlType->RIGHT - CtlType->LEFT + 1; + } + } + } + + expr1.IDENT = NULL; + } + break; + + case NOPS : + + if ( expr1.IDENT == NULL ) + my_ctp_toolbug (2,"ctp_crtvex","NOPS",0); + else + { + if ( expr1.VEX == (vexexpr *)0 ) + { + result.TYPE = ctp_tobin(lcl_buffer,expr1.IDENT,left,right); + Length = strlen( lcl_buffer ); + + if ( ( left == -1 ) && + ( right == -1 ) ) + { + if ( ( result.TYPE == VEX_TYPE_INTEGER ) || + ( result.TYPE == VEX_TYPE_NATURAL ) ) + { + left = Length - 1; right = 0; + } + else + { + left = 0; right = Length - 1; + } + } + + if ( left == right ) + { + name[ 0 ] = '\''; + name[ 1 ] = lcl_buffer[ 0 ]; + name[ 2 ] = '\''; + name[ 3 ] = '\0'; + + result.VEX = createvexatombit( name ); + } + else + if ((left+right+1) != Length ) + { + my_ctp_error(97,NULL); + } + else + { + sprintf( name, "\"%s\"", lcl_buffer ); + result.VEX = createvexatomvec( name, left, right ); + } + + if ( result.TYPE == VEX_TYPE_INTEGER ) result.SIGNED = 1; + else result.SIGNED = 0; + } + else + { + result.VEX = dupvexexpr( expr1.VEX ); + result.TYPE = expr1.TYPE; + result.SIGNED = expr1.SIGNED; + } + } + + result.WIDTH = result.VEX->WIDTH; + if ( result.SIGNED ) SetVexNodeSigned( result.VEX ); + + break; + + case VEX_EVENT : + if (expr1.VEX == NULL) + my_ctp_toolbug (3,"ctp_crtvex","EVENT",0); + else + { + result.VEX = createvexunaryexpr( VEX_EVENT, 1, expr1.VEX ); + result.WIDTH = 1; + result.TYPE = VEX_TYPE_BIT; + result.SIGNED = expr1.SIGNED; + + if ( result.SIGNED ) SetVexNodeSigned( result.VEX ); + + expr1.VEX = NULL; + } + break; + + case VEX_NOT : + if (expr1.VEX == NULL) + my_ctp_toolbug (3,"ctp_crtvex","NOT",0); + else + { + result.VEX = createvexunaryexpr( VEX_NOT, expr1.WIDTH, expr1.VEX ); + result.VEX->WIDTH = expr1.WIDTH; + result.VEX->LEFT = expr1.VEX->LEFT; + result.VEX->RIGHT = expr1.VEX->RIGHT; + + if ( IsVexNodeVarWidth( expr1.VEX ) ) + { + SetVexNodeVarWidth( result.VEX ); + } + + result.WIDTH = expr1.WIDTH; + result.SIGNED = expr1.SIGNED; + result.TYPE = expr1.TYPE; + + if ( result.SIGNED ) SetVexNodeSigned( result.VEX ); + + expr1.VEX = NULL; + } + break; + case VEX_AF : + case VEX_AG : + case VEX_AX : + case VEX_EF : + case VEX_EG : + case VEX_EX : + if (expr1.VEX == NULL) + my_ctp_toolbug (3,"ctp_crtvex",getvexopername( oper ),0); + else + { + if ( expr1.WIDTH != 1 ) + { + my_ctp_error(38,NULL); + } + + result.VEX = createvexunaryexpr( oper, 1, expr1.VEX ); + result.WIDTH = 1; + result.TYPE = VEX_TYPE_BOOLEAN; + result.SIGNED = 0; + + expr1.VEX = NULL; + } + break; + case VEX_AU : + case VEX_EU : + case VEX_EQUIV : + case VEX_IMPLY : + + if ( (expr1.VEX == NULL) || + (expr2.VEX == NULL) ) + my_ctp_toolbug (4,"ctp_crtvex","AU/EU/EQUIV or IMPLY",0); + else + { + if ( ( expr1.WIDTH != 1 ) || + ( expr2.WIDTH != 1 ) ) + { + my_ctp_error(38,NULL); + } + + result.VEX = createvexbinexpr( oper, 1, expr1.VEX, expr2.VEX ); + result.WIDTH = 1; + result.TYPE = VEX_TYPE_BOOLEAN; + result.SIGNED = 0; + + expr1.VEX = NULL; + expr2.VEX = NULL; + + } + break; + case VEX_OTHERS : + if ((expr1.VEX == NULL)|| + (! IsVexNodeAtom(expr1.VEX))|| + (! IsVexAtomLiteral( expr1.VEX ))) + my_ctp_toolbug (3,"ctp_crtvex","OTHERS",0); + else + { + result.VEX = createvexunaryexpr( VEX_OTHERS, expr1.WIDTH, expr1.VEX ); + result.VEX->WIDTH = expr1.WIDTH; + result.VEX->LEFT = expr1.VEX->LEFT; + result.VEX->RIGHT = expr1.VEX->RIGHT; + + if ( IsVexNodeVarWidth( expr1.VEX ) ) + { + SetVexNodeVarWidth( result.VEX ); + } + + result.WIDTH = expr1.WIDTH; + result.SIGNED = expr1.SIGNED; + result.TYPE = expr1.TYPE; + + if ( result.SIGNED ) SetVexNodeSigned( result.VEX ); + + expr1.VEX = NULL; + } + break; + + case VEX_NEG : + case VEX_ABS : + if (expr1.VEX == NULL) + my_ctp_toolbug (3,"ctp_crtvex","NEG/ABS",0); + else + { + result.VEX = createvexunaryexpr( oper, 0, expr1.VEX ); + + result.VEX->WIDTH = expr1.WIDTH; + result.VEX->LEFT = expr1.VEX->LEFT; + result.VEX->RIGHT = expr1.VEX->RIGHT; + + if ( IsVexNodeVarWidth( expr1.VEX ) ) + { + SetVexNodeVarWidth( result.VEX ); + } + + result.WIDTH = expr1.WIDTH; + result.TYPE = expr1.TYPE; + + if ( oper == VEX_NEG ) + { + result.SIGNED = 1; + SetVexNodeSigned( result.VEX ); + } + + expr1.VEX = NULL; + } + break; + + case VEX_EQ : + case VEX_NE : + + if ( (expr1.VEX == NULL) || + (expr2.VEX == NULL) ) + my_ctp_toolbug (4,"ctp_crtvex","EQ or NE",0); + else + { + BaseType1 = ctp_getbasetype( expr1.TYPE ); + BaseType2 = ctp_getbasetype( expr2.TYPE ); + + if ( ( BaseType1->INDEX != VEX_TYPE_INTEGER ) && + ( BaseType2->INDEX != VEX_TYPE_INTEGER ) ) + { + if ( ( expr1.WIDTH != expr2.WIDTH ) && + ( ! IsVexNodeVarWidth( expr1.VEX ) ) && + ( ! IsVexNodeVarWidth( expr2.VEX ) ) ) + { + my_ctp_error(38,NULL); + } + } + + result.VEX = createvexbinexpr( oper, 1, expr1.VEX, expr2.VEX ); + result.WIDTH = 1; + result.TYPE = VEX_TYPE_BIT; + result.SIGNED = 0; + + expr1.VEX = NULL; + expr2.VEX = NULL; + } + break; + + case VEX_LT : + case VEX_LE : + case VEX_GT : + case VEX_GE : + + if ((expr1.VEX == NULL) || (expr2.VEX == NULL)) + my_ctp_toolbug (4,"ctp_crtvex","LT, LE, GT or GE",0); + else + { + BaseType1 = ctp_getbasetype( expr1.TYPE ); + BaseType2 = ctp_getbasetype( expr2.TYPE ); + + if ( ( BaseType1->INDEX != VEX_TYPE_INTEGER ) && + ( BaseType2->INDEX != VEX_TYPE_INTEGER ) ) + { + if ( ( expr1.WIDTH != expr2.WIDTH ) && + ( ! IsVexNodeVarWidth( expr1.VEX ) ) && + ( ! IsVexNodeVarWidth( expr2.VEX ) ) ) + { + my_ctp_error (38,NULL); + } + } + + result.VEX = createvexbinexpr( oper, 1, expr1.VEX, expr2.VEX ); + result.WIDTH = 1; + result.TYPE = VEX_TYPE_BIT; + result.SIGNED = 0; + + expr1.VEX = NULL; + expr2.VEX = NULL; + } + + break; + + case VEX_AND : + case VEX_NAND : + case VEX_OR : + case VEX_NOR : + case VEX_XOR : + case VEX_NXOR : + + if ((expr1.VEX == NULL) || (expr2.VEX == NULL)) + my_ctp_toolbug (4,"ctp_crtvex","logical operators",0); + else + { + if ( expr1.WIDTH != expr2.WIDTH ) + { + my_ctp_error (38,NULL); + } + + result.VEX = createvexbinexpr( oper, 1, expr1.VEX, expr2.VEX ); + result.VEX->WIDTH = expr1.WIDTH; + result.VEX->LEFT = expr1.VEX->LEFT; + result.VEX->RIGHT = expr1.VEX->RIGHT; + result.TYPE = expr1.TYPE; + result.WIDTH = expr1.WIDTH; + result.SIGNED = 0; + + if ( IsVexNodeVarWidth( expr1.VEX ) ) + { + SetVexNodeVarWidth( result.VEX ); + } + + expr1.VEX = NULL; + expr2.VEX = NULL; + } + break; + + case VEX_IFT : + + if ((expr1.VEX == NULL) || (expr2.VEX == NULL)) + my_ctp_toolbug (4,"ctp_crtvex","logical operators",0); + else + { + result.VEX = createvexbinexpr( oper, 1, expr1.VEX, expr2.VEX ); + result.VEX->WIDTH = expr2.WIDTH; + result.VEX->LEFT = expr2.VEX->LEFT; + result.VEX->RIGHT = expr2.VEX->RIGHT; + result.TYPE = expr2.TYPE; + result.WIDTH = expr2.WIDTH; + result.SIGNED = 0; + + if ( IsVexNodeVarWidth( expr2.VEX ) ) + { + SetVexNodeVarWidth( result.VEX ); + } + + + expr1.VEX = NULL; + expr2.VEX = NULL; + } + break; + + case VEX_ADD : + case VEX_SUB : + case VEX_MUL : + case VEX_DIV : + case VEX_MOD : + case VEX_REM : + case VEX_EXP : + + if ((expr1.VEX == NULL) || (expr2.VEX == NULL)) + my_ctp_toolbug (4,"ctp_crtvex","arithmetic operators",0); + else + { + int Width; + + result.VEX = createvexbinexpr( oper, 1, expr1.VEX, expr2.VEX ); + + if ((oper == VEX_ADD) || + (oper == VEX_SUB)) + { + if ( expr2.WIDTH > expr1.WIDTH ) Width = expr2.WIDTH; + else Width = expr1.WIDTH; + } + else + if (oper == VEX_MUL) + { + if ( ( ( expr1.TYPE == VEX_TYPE_INTEGER ) || + ( expr1.TYPE == VEX_TYPE_NATURAL ) ) && + ( ( expr2.TYPE == VEX_TYPE_INTEGER ) || + ( expr2.TYPE == VEX_TYPE_NATURAL ) ) ) + { + if ( expr1.WIDTH > expr2.WIDTH ) Width = expr1.WIDTH; + else Width = expr2.WIDTH; + } + else + if ( ( expr1.TYPE == VEX_TYPE_INTEGER ) || + ( expr1.TYPE == VEX_TYPE_NATURAL ) ) + { + Width = expr2.WIDTH * 2; + } + else + if ( ( expr2.TYPE == VEX_TYPE_INTEGER ) || + ( expr2.TYPE == VEX_TYPE_NATURAL ) ) + { + Width = expr1.WIDTH * 2; + } + else + { + Width = expr1.WIDTH + expr2.WIDTH; + } + } + else + if (oper == VEX_DIV) + { + Width = expr1.WIDTH; + } + else + if (oper == VEX_EXP) + { + Width = expr1.WIDTH * expr2.WIDTH; + } + else /* VEX_MOD VEX_REM */ + { + Width = expr2.WIDTH; + } + + result.VEX->WIDTH = Width; + result.VEX->LEFT = Width - 1; + result.VEX->RIGHT = 0; + result.TYPE = expr1.TYPE; + result.WIDTH = expr1.WIDTH; + result.SIGNED = expr1.SIGNED || expr2.SIGNED; + + if ( ( IsVexNodeVarWidth( expr1.VEX ) ) || + ( IsVexNodeVarWidth( expr2.VEX ) ) ) + { + SetVexNodeVarWidth( result.VEX ); + } + + if ( result.SIGNED ) SetVexNodeSigned( result.VEX ); + + expr1.VEX = NULL; + expr2.VEX = NULL; + } + break; + + case EMPTYOP : + result.VEX = NULL; + break; + + case VEX_TO : + case VEX_DOWNTO : + if (expr1.VEX == NULL) + my_ctp_toolbug (3,"ctp_crtvex","VEX_SLICE",0); + else + { + if ( right == 0 ) + { + result.VEX = createvexbinexpr( VEX_INDEX, 1, expr1.VEX, + dupvexexpr((vexexpr *)left) ); + } + else + { + result.VEX = createvexternaryexpr( oper, 1, expr1.VEX, + dupvexexpr((vexexpr *)left), dupvexexpr((vexexpr *)right) ); + + SetVexNodeVarWidth( result.VEX ); + } + + /* + result.VEX->WIDTH = expr1.WIDTH; + result.VEX->LEFT = expr1.VEX->LEFT; + result.VEX->RIGHT = expr1.VEX->RIGHT; + */ + + result.WIDTH = result.VEX->WIDTH; + result.TYPE = expr1.TYPE; + result.SIGNED = expr1.SIGNED; + + if ( result.SIGNED ) SetVexNodeSigned( result.VEX ); + + expr1.VEX = NULL; + } + break; + default : my_ctp_toolbug (1,"ctp_crtvex","Default",0); + } + + return (result); +} + +/* ###--------------------------------------------------------------### */ +/* function : ctp_numtobin */ +/* description : transform a ENUMERATE */ +/* in a string of '0' and '1's */ +/* ###--------------------------------------------------------------### */ +long ctp_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 : ctp_numtobin */ +/* description : transform a ENUMERATE */ +/* in a string of '0' and '1's */ +/* ###--------------------------------------------------------------### */ +char *ctp_numtobin(num) +long num; + +{ + char val[256]; + char *str; + long 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 : ctp_intSize, compute the number of bits to */ +/* store an integer value, given the left and right */ +/*------------------------------------------------------------*/ + +int ctp_intSize( Left, Right ) + + long Left; + long Right; +{ + return( getvexintervalnumbit( Left, Right ) ); +} + + +/* ###--------------------------------------------------------------### */ +/* function : ctp_tobin */ +/* description : transform a StringLit, BitStringLit or CharacterLit */ +/* AbstractLit in a string of '0' and '1's */ +/* ###--------------------------------------------------------------### */ + +static char *long_bin(s, i, n) +char *s; +long i, n; +{ +long j, k; + + *(s + n) = '\0'; /* end of string */ + for (j = 1, k = 0; k < n; k++, j <<= 1) + *(s + n - k - 1) = (i & j) ? '1' : '0'; + return s; +} + +int ctp_tobin (trg,src,left,right) + +char *trg; +char *src; +int left; +int right; + +{ + char base; + int indx; + int j = 0; + int type = -1; + char lcl_trg[256]; + unsigned long Value; + unsigned long Mask; + char *endp; + + lcl_trg[0] = '\0'; + + if (src == NULL) + { + strcpy (trg,"0"); + } + else + { + if (!strcmp (src,"others")) + { + strcpy(trg,src); + } + else + { + if ( (src[0] != '\'') && + (src[0] != '"' ) && + (src[0] != '_' ) && + (src[0] != '%' ) ) + { + base = src[0]; + indx = 2; + + if ( ( ( base >= '0' ) && + ( base <= '9' ) ) || + ( base == '-' ) ) + { + indx = 1; + base = 'D'; + } + } + else + { + base = 'B'; + indx = 1; + } + + switch (base) + { + case 'B' : + case 'b' : + + type = VEX_TYPE_BIT_VECTOR; + + while ((lcl_trg[j] = src[indx]) != '\0') + { + switch (src[indx]) + { + case 'd': lcl_trg[j]='-'; + + case 'u': + case 'x': + case '0': + case '1': + case 'z': + case 'w': + case 'l': + case 'h': + case '-': /* Beware Not VHDL */ + j++; break; + + case '%' : + case '"' : + case '\'': + case '_' : + break; + + default : for ( indx = 1; src[ indx ] != '\0'; indx++ ) + { + trg[ indx - 1] = src[ indx ]; + } + trg[ indx - 2 ] = '\0'; + + return( VEX_TYPE_STRING ); + } + 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; type = -1; my_ctp_error(73,src); + } + indx++; + } + + type = VEX_TYPE_BIT_VECTOR; + + 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; type = -1; my_ctp_error(73,src); + } + indx++; + } + type = VEX_TYPE_BIT_VECTOR; + break; + + case 'D' : + + Value = strtol( src, &endp, 10); + if (*endp == '#') /* This is base specifier in the n#num# form */ + { + (void)long_bin(lcl_trg, strtol(endp + 1, NULL, Value), 32); + type = VEX_TYPE_INTEGER; + } + else + { + /*\ + if ( src[ 0 ] == '-' ) lcl_trg[ 0 ] = '1'; + else lcl_trg[ 0 ] = '0'; + + j = 1; + \*/ + + type = VEX_TYPE_NATURAL; + + if ( Value != 0 ) + { + Mask = 1L << 31; + + if ( src[ 0 ] == '-' ) + { + while ( ( Value & Mask ) != 0 ) + { + Mask = Mask >> 1; + } + + if ( Mask == 0 ) Mask = 0x1; + else Mask = Mask << 1; + + type = VEX_TYPE_INTEGER; + } + else + { + while ( ( Value & Mask ) == 0 ) + { + Mask = Mask >> 1; + } + } + } + else + { + Mask = 0x1; + } + + do + { + if ( Value & Mask ) lcl_trg[ j ] = '1'; + else lcl_trg[ j ] = '0'; + + j++; + + Mask = Mask >> 1; + } + while ( Mask != 0 ); + + lcl_trg[ j ] = '\0'; + } + + break; + + default : + + type = -1; + my_ctp_toolbug (17,"ctp_tobin",NULL,base); + } + + strcpy (trg, lcl_trg); + } + } + + return (type); +} + +static long ctp_vexliteval( Vex ) + + vexexpr *Vex; +{ + long Value; + + if ( evalvexatomlong( Vex, &Value ) ) + { + CtpEvalError = 1; + } + + return( Value ); +} + +static long ctp_vexeval( Vex ) + + vexexpr *Vex; +{ + chain_list *ScanOper; + long Value; + long Operand; + long Oper; + + Value = 1; + + if ( IsVexNodeOper( Vex ) ) + { + Oper = GetVexOperValue( Vex ); + ScanOper = Vex->OPERAND; + Vex = GetVexOperand( ScanOper ); + ScanOper = ScanOper->NEXT; + Value = ctp_vexeval( Vex ); + + if ( Oper == VEX_NEG ) + { + Value = - Value; + } + else + if ( Oper == VEX_ABS ) + { + if ( Value < 0 ) Value = - Value; + } + else + if ( ScanOper == (chain_list *)0 ) + { + CtpEvalError = 1; + } + + while ( ScanOper != (chain_list *)0 ) + { + Vex = GetVexOperand( ScanOper ); + Operand = ctp_vexeval( Vex ); + + if ( CtpEvalError ) break; + + switch ( Oper ) + { + case VEX_ADD : Value += Operand; + break; + + case VEX_SUB : Value -= Operand; + break; + + case VEX_MUL : Value *= Operand; + break; + + case VEX_DIV : if ( Operand == 0 ) CtpEvalError = 1; + else Value /= Operand; + break; + + default : CtpEvalError = 1; + break; + } + + ScanOper = ScanOper->NEXT; + } + } + else + if ( ( IsVexNodeAtom( Vex ) ) && + ( IsVexAtomLiteral( Vex ) ) ) + { + Value = ctp_vexliteval( Vex ); + } + else + { + CtpEvalError = 1; + } + + return( Value ); +} + +int ctp_vextonum( Vex, PValue ) + + vexexpr *Vex; + long *PValue; +{ + CtpEvalError = 0; + *PValue = ctp_vexeval( Vex ); + +# ifdef DEBUG +fprintf( stdout, "ctp_vextonum " ); +viewvexexprbound( Vex ); +fprintf( stdout, "\n%ld %d\n", *PValue, CtpEvalError ); +# endif + + return( CtpEvalError ); +} diff --git a/alliance/src/ctp/src/ctp_bspec.h b/alliance/src/ctp/src/ctp_bspec.h new file mode 100644 index 00000000..fa233477 --- /dev/null +++ b/alliance/src/ctp/src/ctp_bspec.h @@ -0,0 +1,74 @@ +/*------------------------------------------------------------\ +| | +| 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 : bvl_bspec.h */ +/* date : Jun 15 1992 */ +/* author : TABUSSE L.A. */ +/* content : declaration of functions and global variables used by */ +/* bvl_bspec.c */ +/* */ +/* ###--------------------------------------------------------------### */ + +typedef struct ctp_expr + { + char *IDENT; /* identifier or constant name */ + vexexpr *VEX; /* pointer on bvl_abllst list */ + short TYPE; + int WIDTH; /* width of bit vector */ + char SIGNED; + char AGGREG; + } +ctp_vexstr; + +typedef struct + { + char *NAME; /* identifier name */ + long LEFT; /* vector's left index */ + long RIGHT; /* vector's right index */ + char FLAG; /* scalar ('S') or array 'A' */ + char TYPE; /* scalar ('S') or array 'A' */ + char SIGNED; + } +ctp_name; + +extern ctp_vexstr CTP_EMPSTR; +extern ctlfig_list *CTP_HEADFIG; +extern char *CTP_FILENAME; + +extern ctp_vexstr ctp_crtvex (); +extern char *ctp_numtobin (); +extern char *ctp_enumbitstring(); +extern int ctp_codeSize(); +extern vexexpr *ctp_dynamicvexatom(); +extern int ctp_intSize(); +extern int ctp_vextonum(); +extern ctltype_list *ctp_getbasetype(); + extern void ctp_error(); + extern int ctp_tobin(); + diff --git a/alliance/src/ctp/src/ctp_byacc.h b/alliance/src/ctp/src/ctp_byacc.h new file mode 100644 index 00000000..0188f2b3 --- /dev/null +++ b/alliance/src/ctp/src/ctp_byacc.h @@ -0,0 +1,82 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ + +/* ###--------------------------------------------------------------### */ +/* */ +/* file : ctp_byacc.h */ +/* date : Jun 15 1992 */ +/* version : v102 */ +/* author : Pirouz BAZARGAN SABET */ +/* content : declaration of external functions and global variables*/ +/* used by yacc */ +/* */ +/* ###--------------------------------------------------------------### */ + +static struct dct_entry *addent (); +static struct dct_recrd *addrcd (); +static struct dct_entry **initab (); +static void addtab (); +static int chktab (); +static void fretab (); +static void *ctp_addstr (); +static ctltype_list *val_type(); +static ctltype_list *get_type(); +static struct ptype *reversetype(); + +extern char CTP_ERRFLG; /* set to 1 in case of error */ +extern ctlfig_list *CTP_HEADFIG; /* head of vbfigs */ +extern long CTP_LINNUM; +extern int CTP_NUMPTP; +extern char *CTP_MODNAM; + +/*\ +pNode CTP_BDDPNT; +\*/ + /* BDD pointer */ +ctp_vexstr CTP_SLCEXP; /* structure filled with the */ +ctp_vexstr CTP_EMPSTR; /* empty structure used with NOT*/ + +static int CTP_NUMTYP = 0; /* nombre de type */ +static struct chain *CTP_NM1LST = NULL; /* 1-st name liste */ +static struct chain *CTP_NM2LST = NULL; /* 2-st name liste */ +static struct chain *CTP_INSLST = NULL; /* 3-st name liste */ +static struct chain *CTP_LINLST = NULL; /* list of line */ +static struct chain *CTP_VALLST = NULL; /* list of waveforms (ABL) */ + +static struct ptype *CTP_PTYPE = NULL; + +static struct dct_entry *CTP_DCEHED; /* free dct_entry's head */ +static struct dct_recrd *CTP_DCRHED; /* free dct_recrd's head */ + +static struct dct_entry **hshtab; + +extern ctp_vexstr ctp_crtvex(); +extern ctp_vexstr ctp_cpyvexstr(); +extern ctp_vexstr ctp_select(); +extern char *ctp_stostr(); +extern void ctp_error(); + diff --git a/alliance/src/ctp/src/ctp_l.l b/alliance/src/ctp/src/ctp_l.l new file mode 100644 index 00000000..83eb101f --- /dev/null +++ b/alliance/src/ctp/src/ctp_l.l @@ -0,0 +1,220 @@ +/*------------------------------------------------------------\ +| | +| 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 "vex.h" +#include "ctl.h" + +typedef struct ctp_expr +{ + vexexpr *IDENT; /* identifier or constant name */ + vexexpr *VEX; /* pointer on bvl_abllst list */ + short WIDTH; + short TYPE; +} +ctp_vexstr; + +typedef struct + { + char *NAME; /* identifier name */ + long LEFT; /* vector's left index */ + long RIGHT; /* vector's right index */ + short WIDTH; + char FLAG; + } +ctp_name; + +#include "ctp_y.h" +#include "ctp_bedef.h" +#include "ctp_blex.h" + +static el_mc tab_mc []= + { + {"abs" ,ABS}, + {"af" ,_AF}, + {"ag" ,_AG}, + {"and" ,_AND}, + {"array" ,ARRAY}, + {"au" ,_AU}, + {"ax" ,_AX}, + {"begin" ,_BEGIN}, + {"constant" ,CONSTANT}, + {"downto" ,DOWNTO}, + {"ef" ,_EF}, + {"eg" ,_EG}, + {"end" ,_END}, + {"error" ,ERROR}, + {"eu" ,_EU}, + {"event" ,_EVENT}, + {"ex" ,_EX}, + {"false" ,_FALSE}, + {"high" ,_HIGH}, + {"ift" ,_IFT}, + {"is" ,IS}, + {"left" ,_LEFT}, + {"length" ,_LENGTH}, + {"low" ,_LOW}, + {"mod" ,MOD}, + {"nand" ,_NAND}, + {"nor" ,_NOR}, + {"not" ,_NOT}, + {"nxor" ,_NXOR}, + {"of" ,OF}, + {"or" ,_OR}, + {"others" ,OTHERS}, + {"range" ,_RANGE}, + {"rem" ,REM}, + {"reverse_range" ,_REV_RANGE}, + {"right" ,_RIGHT}, + {"stable" ,_STABLE}, + {"subtype" ,SUBTYPE}, + {"to" ,TO}, + {"true" ,_TRUE }, + {"type" ,_TYPE}, + {"variable" ,_VARIABLE}, + {"xnor" ,_NXOR}, + {"xor" ,_XOR} + }; + + +static int find_mc(s) + + char *s; +{ + char loc[512]; + int l; + el_mc *pt; + + l=strlen(s); + strcpy(loc,s); + while(l--) loc[l]=tolower(loc[l]); /* conversion en minuscules */ + pt= (el_mc *) bsearch(loc, (char *)tab_mc,CTP_NB_MC,sizeof(el_mc), + (int (*)(const void *, const void *)) 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(Equiv); } +"->" { return(Imply); } +"**" { 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); } +\/ { return(Slash); } + +{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 { + CTP_LINNUM++; + } +\-\-.*$ { + /* comment */ + /* nothing */ + } +. { + return (*yytext); + } +%% diff --git a/alliance/src/ctp/src/ctp_parse.c b/alliance/src/ctp/src/ctp_parse.c new file mode 100644 index 00000000..01ee99cd --- /dev/null +++ b/alliance/src/ctp/src/ctp_parse.c @@ -0,0 +1,114 @@ +/*------------------------------------------------------------\ +| | +| 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 : CTP | +| | +| File : ctp_parse.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 01.01.95 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include "mut.h" +# include "aut.h" +# include "vex.h" +# include "ctl.h" +# include "ctp.h" + +# include +# include +# include + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + extern FILE *ctp_y_in; + extern int ctp_y_parse(); + extern char CTP_ERRFLG; + extern ctlfig_list *CTP_HEADFIG; + extern char *CTP_FILENAME; + +/*------------------------------------------------------------\ +| | +| vpnloadvpnfig | +| | +\------------------------------------------------------------*/ + +ctlfig_list *loadctlfig( InputFileName ) + + char *InputFileName; +{ + int Value; + int Index; + + fprintf( stdout, "loadctlfig InputFileName %s\n", InputFileName ); + + ctp_y_in = mbkfopen( InputFileName, "ctl", "r" ); + + if ( ctp_y_in == (FILE *)0 ) + { + fprintf( stdout, "Error opening file %s\n", InputFileName ); + autexit( 1 ); + } + + CTP_FILENAME = InputFileName; + + Value = ctp_y_parse(); + + fclose( ctp_y_in ); + + if ( ( Value ) || + ( CTP_ERRFLG ) ) + { + fprintf( stdout, "Error parsing file %s\n", InputFileName ); + autexit( 1 ); + } + + return( CTP_HEADFIG ); +} + diff --git a/alliance/src/ctp/src/ctp_util.c b/alliance/src/ctp/src/ctp_util.c new file mode 100644 index 00000000..26c24bad --- /dev/null +++ b/alliance/src/ctp/src/ctp_util.c @@ -0,0 +1,365 @@ +/*------------------------------------------------------------\ +| | +| 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 : ctp_util.c */ +/* date : Sep 14 1992 */ +/* version : v100 */ +/* author : Pirouz BAZARGAN SABET, M.HANAFI */ +/* description : This file contains some utility functions : */ +/* ctp_error , ctp_y_error, ctp_toolbug, ctp_message, */ +/* */ +/* ###--------------------------------------------------------------### */ + +#include +#include +#include +#include +#include + +#include "mut.h" +#include "aut.h" +#include "vex.h" +#include "ctl.h" + +#include "ctp_utype.h" +#include "ctp_util.h" + +char CTP_ERRFLG = 0; /* if = 1 no structure is made */ +char *CTP_FILENAME = (char *)0; +long CTP_LINNUM = 1; /* file's line number */ +int CTP_NUMPTP = 0; /* file's line number */ +int CTP_NUMCHOICE = 0; +char *CTP_MODNAM = (char *)0; +ctlfig_list *CTP_HEADFIG = (ctlfig_list *)0; + + char *ctp_func_std_logic_1164[] = + { + "to_bit", + "to_bitvector", + "to_stdulogic", + "to_stdlogicvector", + "to_stdulogicvector", + "to_x01", + "to_x01z", + "to_ux01", + "rising_edge", + "falling_edge", + "is_x", + NULL + }; + + char *ctp_func_std_logic_arith[] = + { + "abs", + "shl", + "shr", + "conv_integer", + "conv_unsigned", + "conv_signed", + "conv_std_logic_vector", + "ext", + "sxt", + NULL + }; + + char *ctp_func_std_numeric_std[] = + { + "shift_left", + "shift_right", + "rotate_left", + "rotate_right", + "resize", + "to_integer", + "to_unsigned", + "to_signed", + NULL + }; + + +/* ###--------------------------------------------------------------### */ +/* function : ctp_toolbug */ +/* ###--------------------------------------------------------------### */ +void ctp_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 : %s\n",str2); + 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 vbfig\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 : ctp_message */ +/* ###--------------------------------------------------------------### */ +void ctp_message (code,str1,nmb1) + +int code; +char *str1; +int nmb1; + +{ + switch (code) + { + case 1: + (void) fprintf(stderr,"USAGE is ctp [filename1],[filename2],.. \n\n\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 (vbe)\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; + case 17: + (void) fprintf (stdout,"Parsing the file %s .........\n\n",str1); + break; + case 18: + (void) fprintf (stderr,"ERROR: %s VHDL file does not exist !!! \n",str1); + (void) fprintf (stderr," Verify the file and restart \n"); + break; + default: + (void) fprintf (stderr,"ctp_message : code %d unknown.\n",code); + } +} + +/* ###--------------------------------------------------------------### */ +/* function : ctp_error */ +/* ###--------------------------------------------------------------### */ + +void ctp_error (code,str1) + +int code; +char *str1; + +{ + CTP_ERRFLG++; + if (code < 100) + (void)fprintf (stderr,"Error %d line %ld in file %s :",code,CTP_LINNUM, CTP_FILENAME); + else + { + if (code < 200) + (void)fprintf (stderr,"Error %d :",code); + } + + switch (code) + { + case 9: + (void) fprintf (stderr,"illegal declaration\n"); + break; + case 10: + (void) fprintf (stderr,"symbol `%s` already declared\n",str1); + break; + case 18: + (void) fprintf (stderr,"illegal 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,"symbol `%s` used out of declared range\n",str1); + break; + case 38: + (void) fprintf (stderr,"width or/and type mismatch %s\n",str1); + break; + case 73: + (void) fprintf (stderr,"`%s` is not a bit string litteral\n",str1); + break; + case 78: + (void) fprintf (stderr,"illegal constant declaration\n"); + break; + case 79: + (void) fprintf (stderr,"illegal use of attribute on `%s`\n",str1); + break; + case 80: + (void) fprintf (stderr,"variable `%s` already declared\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 86: + (void) fprintf (stderr,"illegal variable declaration\n"); + break; + case 87: + (void) fprintf (stderr,"illegal type declaration\n"); + break; + case 97: + (void) fprintf (stderr,"width mismatch on signal initialisation\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 114: + (void) fprintf (stderr,"illegal aggregate\n"); + break; + case 123: + (void) fprintf (stderr,"such array type definition is not supported\n"); + break; + + default: + (void) fprintf (stderr,"syntax error\n"); + break; + } + + if (CTP_ERRFLG > CTP_MXRDFN) + { + (void) fprintf (stderr,"Too many errors. Cannot continue further more\n"); + (void) fprintf (stderr,"\n Have a nice day...\n"); + EXIT (1); + } + + autexit(1); +} + +/* ###--------------------------------------------------------------### */ +/* function : ctp_y_error */ +/* ###--------------------------------------------------------------### */ +void ctp_y_error (str) + +char *str; +{ + CTP_ERRFLG++; + (void)fprintf (stderr,"Error line %ld : %s\n",CTP_LINNUM,str); +} diff --git a/alliance/src/ctp/src/ctp_util.h b/alliance/src/ctp/src/ctp_util.h new file mode 100644 index 00000000..9d25267d --- /dev/null +++ b/alliance/src/ctp/src/ctp_util.h @@ -0,0 +1,42 @@ +/*------------------------------------------------------------\ +| | +| 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 : ctp_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 `ctp_util.c` */ +/* */ +/* ###--------------------------------------------------------------### */ + +#define CTP_MXRDFN 30 + + extern long CTP_LINNUM; /* file's line number */ + extern char CTP_ERRFLG; /* Error flag */ + extern char CTP_CURFIL[]; /* current file name */ diff --git a/alliance/src/ctp/src/ctp_utype.h b/alliance/src/ctp/src/ctp_utype.h new file mode 100644 index 00000000..4b496c50 --- /dev/null +++ b/alliance/src/ctp/src/ctp_utype.h @@ -0,0 +1,60 @@ +/*------------------------------------------------------------\ +| | +| 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 : ctp_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; + long fd0_val; + long fd1_val; + long fd2_val; + long fd3_val; + long fd4_val; + long fd5_val; + long fd6_val; + long fd7_val; + long fd8_val; + long pnt_val; + }; diff --git a/alliance/src/ctp/src/ctp_y.y b/alliance/src/ctp/src/ctp_y.y new file mode 100644 index 00000000..ee959902 --- /dev/null +++ b/alliance/src/ctp/src/ctp_y.y @@ -0,0 +1,2120 @@ +/*------------------------------------------------------------\ +| | +| 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 : ctp_bcomp.yac */ +/* date : April 29 1993 */ +/* version : v1.0 */ +/* content : yacc rules for behavioural VHDL for Petri Net */ +/* ###--------------------------------------------------------------### */ +%{ +#include +#include +#include +#include "mut.h" +#include "aut.h" +#include "vex.h" +#include "ctl.h" + +#include "ctp_utype.h" +#include "ctp_bedef.h" +#include "ctp_bspec.h" +#include "ctp_byacc.h" + +#if 1 +# define my_fprintf fprintf( stdout, "%s.%d:", basename(__FILE__), __LINE__ ); fprintf +# define my_ctp_error(N,V) \ + do { fprintf( stderr, "%s.%d:", basename(__FILE__), __LINE__); ctp_error(N,V); } while(0) +#else +# define my_fprintf fprintf +# define my_ctp_error ctp_error +#endif + +#ifdef CTP_DEBUG +#define YYDEBUG 1 +#endif + +%} + +%union { + int valu; + char *text; + chain_list *pcha; + ctp_name name; + ctp_vexstr list; + ctltype_list type; + }; + +%token _AF +%token _AG +%token _AX +%token _AU +%token _EF +%token _EG +%token _EX +%token _EU +%token Imply +%token Equiv +%token _AND +%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 _IFT +%token _NXOR +%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 BUS +%token _BUFFER +%token Bar +%token BasedInt +%token BasedReal +%token BitStringLit +%token _TRUE +%token _FALSE +%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 _EVENT +%token _LEFT +%token _LENGTH +%token _RIGHT +%token _HIGH +%token _LOW +%token FOR +%token FUNCTION +%token GENERATE +%token GENERIC +%token GUARDED +%token IF +%token IS +%token _NS +%token _PS +%token _FS +%token _MS +%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 _REV_RANGE +%token RECORD +%token REGISTER +%token REM +%token REPORT +%token _RETURN +%token RightParen +%token SELECT +%token SEVERITY +%token SIGNAL +%token _STABLE +%token SUBTYPE +%token Semicolon +%token Slash +%token Star +%token StringLit +%token THEN +%token TO +%token TRANSPORT +%token _TYPE +%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 _LTSym _LESym _GTSym _GESym +%left Plus Minus Ampersand +%left Star Slash MOD REM +%left DoubleStar +%right ABS _NOT + +%type .VarAsgn__expression. +%type expression +%type relation..AND__relation.. +%type relation..OR__relation.. +%type relation.NAND_NOR_NXOR_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 sign +%type adding_operator +%type multiplying_operator +%type literal +%type aggregate +%type element_association +%type ...element_association.. + +%type type_definition +%type scalar_type_definition +%type composite_type_definition +%type enumeration_type_definition +%type subtype_indication +%type constrained_array_definition +%type array_type_definition + +%type index_constraint +%type discrete_range +%type qualified_expression + +%type simple_name +%type type_or_function_name +%type name +%type attribute_name +%type indexed_name +%type slice_name +%type .constraint. +%type constraint +%type range +%type range_constraint +%type direction +%type type_mark +%type attribute_designator + +%type constant_VarAsgn__expression + +%start ctl_file + +%% + +ctl_file + : { + ctltype_list *CtlType; + + CTP_HEADFIG = addctlfig( CTP_FILENAME );; + CTP_MODNAM = CTP_HEADFIG->NAME; + addctlpredefinedtype( CTP_HEADFIG ); + + hshtab = initab (); + + CTP_NM1LST = NULL; + CTP_INSLST = NULL; + CTP_LINLST = NULL; + CTP_VALLST = NULL; + + CTP_ERRFLG = 0; + CTP_LINNUM = 1; + CTP_NUMTYP = 0; + + CtlType = CTP_HEADFIG->TYPE; + + while( CtlType ) + { + addtab(hshtab,CtlType->NAME,CTP_MODNAM,CTP_SYMDFN,CTP_TPEDFN); + addtab(hshtab,CtlType->NAME,CTP_MODNAM,CTP_LBLDFN,CtlType->CLASS); + addtab(hshtab,CtlType->NAME,CTP_MODNAM,CTP_TYPDFN,CtlType->INDEX); + addtab(hshtab,CtlType->NAME,CTP_MODNAM,CTP_WMNDFN,CtlType->LEFT); + addtab(hshtab,CtlType->NAME,CTP_MODNAM,CTP_WMXDFN,CtlType->RIGHT); + addtab(hshtab,CtlType->NAME,CTP_MODNAM,CTP_PNTDFN,(long)CtlType); + + CtlType = CtlType->NEXT; + } + + CTP_NUMTYP = VEX_MAX_TYPE; + } + ctl_body + { + fretab( hshtab ); + } + ; + +ctl_body + : ctl_declarative_part + _BEGIN + ctl_statement_part + END_ERR + Semicolon_ERR + { + } + ; + +ctl_declarative_part + : ..block_declarative_item.. + ; + +..block_declarative_item.. + : /*empty*/ + | ..block_declarative_item.. + block_declarative_item + ; + +block_declarative_item + : constant_declaration + | variable_declaration + | type_declaration + | subtype_declaration + | error + Semicolon_ERR + { + my_ctp_error(9,NULL); + } + ; + +constant_declaration + : CONSTANT + Identifier + Colon + type_mark + .constraint. + constant_VarAsgn__expression + Semicolon_ERR + { + ctltype_list *Type; + ctldecl_list *CtlCst; + vexexpr *VexValue; + chain_list *HeadChain; + chain_list *ScanChain; + ctp_vexstr *VexStr; + short Signed; + long Left; + long Right; + short Width; + long AttrLeft; + long AttrRight; + + VexValue = simpvexexpr( $6.VEX ); + + Type = val_type( $4.NAME ); + + if ( ( $5.LEFT == -1 ) && + ( $5.RIGHT == -1 ) ) + { + AttrLeft = Type->LEFT; + AttrRight = Type->RIGHT; + } + else + { + AttrLeft = $5.LEFT; + AttrRight = $5.RIGHT; + } + + CtlCst = (ctldecl_list *)ctp_addstr( 'C',0,val_type($4.NAME), + $4.TYPE,$4.FLAG,$2,AttrLeft,AttrRight,VexValue); + + Signed = ( IsVexNodeSigned( CtlCst->VEX_ATOM ) != 0 ); + + { + if ( IsVexAtomBit( CtlCst->VEX_ATOM ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = CtlCst->VEX_ATOM->LEFT; + Right = CtlCst->VEX_ATOM->RIGHT; + } + } + + addtab(hshtab,$2,CTP_MODNAM,CTP_SYMDFN,CTP_CSTDFN); + addtab(hshtab,$2,CTP_MODNAM,CTP_TYPDFN,$4.TYPE); + addtab(hshtab,$2,CTP_MODNAM,CTP_WMNDFN,Left); + addtab(hshtab,$2,CTP_MODNAM,CTP_WMXDFN,Right); + addtab(hshtab,$2,CTP_MODNAM,CTP_ATLDFN,AttrLeft); + addtab(hshtab,$2,CTP_MODNAM,CTP_ATRDFN,AttrRight); + addtab(hshtab,$2,CTP_MODNAM,CTP_LBLDFN,0); + addtab(hshtab,$2,CTP_MODNAM,CTP_PNTDFN,(long)CtlCst->VEX_ATOM); + addtab(hshtab,$2,CTP_MODNAM,CTP_SUNDFN,Signed ); + } + ; + +constant_VarAsgn__expression + : VarAsgn + expression + { $$ = $2; } + ; + +.VarAsgn__expression. + : /*empty*/ + { $$.VEX = NULL ;} + | VarAsgn + expression + { $$ = $2 ;} + ; + +variable_declaration + : _VARIABLE + identifier_list + Colon + type_mark + .constraint. + .VarAsgn__expression. + Semicolon_ERR + { + char *LocalName; + char *signame; + char *codedsigname; + char buffer[ 128 ]; + ctltype_list *Type; + ctldecl_list *CtlVar; + short Signed; + long Left; + long Right; + long AttrLeft; + long AttrRight; + char StrFlag; + vexexpr *VexInit; + struct ctp_expr expr1; + + LocalName = CTP_MODNAM; + Type = val_type( $4.NAME ); + + if ( ( $5.LEFT == -1 ) && + ( $5.RIGHT == -1 ) ) + { + AttrLeft = Type->LEFT; + AttrRight = Type->RIGHT; + } + else + { + AttrLeft = $5.LEFT; + AttrRight = $5.RIGHT; + } + + CTP_NM1LST = reverse (CTP_NM1LST); + + while (CTP_NM1LST != NULL) + { + signame = (char *)CTP_NM1LST->DATA; + if (chktab (hshtab,signame,LocalName,CTP_SYMDFN) != 0) + my_ctp_error (80,signame); + + CtlVar = (ctldecl_list *)ctp_addstr( 'V', 0, + val_type($4.NAME),$4.TYPE, + $4.FLAG,signame, AttrLeft, AttrRight, NULL ); + + Signed = ( IsVexNodeSigned( CtlVar->VEX_ATOM ) != 0 ); + + if ( IsVexAtomBit( CtlVar->VEX_ATOM ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = CtlVar->VEX_ATOM->LEFT; + Right = CtlVar->VEX_ATOM->RIGHT; + } + + addtab (hshtab,signame,LocalName,CTP_SYMDFN,CTP_VARDFN); + addtab (hshtab,signame,LocalName,CTP_TYPDFN,$4.TYPE); + addtab (hshtab,signame,LocalName,CTP_WMNDFN,Left); + addtab (hshtab,signame,LocalName,CTP_WMXDFN,Right); + addtab (hshtab,signame,LocalName,CTP_ATLDFN,AttrLeft); + addtab (hshtab,signame,LocalName,CTP_ATRDFN,AttrRight); + addtab (hshtab,signame,LocalName,CTP_LBLDFN,0); + addtab (hshtab,signame,LocalName,CTP_PNTDFN,(long)CtlVar->VEX_ATOM); + addtab (hshtab,signame,LocalName,CTP_SUNDFN,Signed); + + CTP_NM1LST = delchain (CTP_NM1LST,CTP_NM1LST); + } + } + ; + + +type_declaration + : full_type_declaration + ; + +full_type_declaration + : _TYPE + Identifier + IS + type_definition + Semicolon_ERR + { + ctltype_list *CtlType; + + CtlType = addctltype( CTP_HEADFIG,$2, CTP_NUMTYP, $4.LEFT, + $4.RIGHT,$4.SIZE,$4.VALUE, $4.CLASS, $4.BASE ); + addctlline( CTP_HEADFIG, &CtlType->LINE, CTP_LINNUM); + + addtab(hshtab,$2,CTP_MODNAM,CTP_SYMDFN,CTP_TPEDFN); + addtab(hshtab,$2,CTP_MODNAM,CTP_LBLDFN,$4.CLASS); + addtab(hshtab,$2,CTP_MODNAM,CTP_TYPDFN,CTP_NUMTYP); + addtab(hshtab,$2,CTP_MODNAM,CTP_WMNDFN,$4.LEFT); + addtab(hshtab,$2,CTP_MODNAM,CTP_WMXDFN,$4.RIGHT); + addtab(hshtab,$2,CTP_MODNAM,CTP_PNTDFN,(long)CtlType ); + CTP_NUMTYP++; + } + ; + +type_definition + : scalar_type_definition + { $$ = $1; } + | composite_type_definition + { $$ = $1; } + | error Semicolon_ERR + { yyerrok; } + ; + +subtype_declaration + : SUBTYPE + Identifier + IS + subtype_indication + Semicolon_ERR + { + ctltype_list *CtlType; + + CtlType = addctltype(CTP_HEADFIG,$2,$4.INDEX,$4.LEFT, + $4.RIGHT, $4.SIZE, $4.VALUE, $4.CLASS,$4.BASE ); + addctlline( CTP_HEADFIG, &CtlType->LINE, CTP_LINNUM); + addtab(hshtab,$2,CTP_MODNAM,CTP_SYMDFN,CTP_TPEDFN); + addtab(hshtab,$2,CTP_MODNAM,CTP_LBLDFN,$4.CLASS); + addtab(hshtab,$2,CTP_MODNAM,CTP_TYPDFN,$4.INDEX); + addtab(hshtab,$2,CTP_MODNAM,CTP_WMNDFN,$4.LEFT); + addtab(hshtab,$2,CTP_MODNAM,CTP_WMXDFN,$4.RIGHT); + addtab(hshtab,$2,CTP_MODNAM,CTP_PNTDFN,(long)CTP_HEADFIG->TYPE); + CTP_NUMTYP++; + } + ; + +subtype_indication + : type_or_function_name + type_mark + .constraint. + { + ctltype_list *ctltype_pnt; + int mode; + + mode = chktab(hshtab,$1,CTP_MODNAM,CTP_SYMDFN); + + ctltype_pnt = (ctltype_list *)chktab(hshtab,$2.NAME,CTP_MODNAM,CTP_PNTDFN); + + $$.NAME = NULL; + $$.BASE = ctltype_pnt; + $$.VALUE = NULL ; + $$.SIZE = 0 ; + $$.INDEX = CTP_NUMTYP; + $$.LEFT = $3.LEFT ; + $$.RIGHT = $3.RIGHT ; + $$.CLASS = $3.FLAG ; + } + | type_mark + .constraint. + { + ctltype_list *ctltype_pnt; + + ctltype_pnt = (ctltype_list *)chktab(hshtab,$1.NAME,CTP_MODNAM,CTP_PNTDFN); + + $$.NAME = NULL; + $$.BASE = ctltype_pnt; + $$.VALUE = NULL ; + $$.SIZE = 0 ; + $$.INDEX = CTP_NUMTYP; + $$.CLASS = $2.FLAG; + + $$.LEFT = $2.LEFT ; + $$.RIGHT = $2.RIGHT ; + } + ; + +type_or_function_name + : simple_name + { $$ = $1; } + ; + + +scalar_type_definition + : enumeration_type_definition + { + $$ = $1; + } + ; +enumeration_type_definition + : LeftParen + enumeration_literal + ...enumeration_literal.. + RightParen_ERR + { + char *enumname; + char *enumval; + int size; + int indice; + int numbit; + char **pnt; + chain_list *nm1lst; + + CTP_NM1LST = reverse (CTP_NM1LST); + + nm1lst = CTP_NM1LST; + size = 0; + + while (nm1lst != NULL) + { + size++; + nm1lst = nm1lst->NEXT; + } + + pnt = (char **) autallocblock(size * sizeof(char*)); + + indice = 0; + + while (CTP_NM1LST != NULL) + { + enumname = (char *)CTP_NM1LST->DATA; + + if (chktab (hshtab,enumname,CTP_MODNAM,CTP_SYMDFN) != 0) + my_ctp_error (82,enumname); + + addtab (hshtab,enumname,CTP_MODNAM,CTP_SYMDFN,CTP_CSTDFN); + addtab (hshtab,enumname,CTP_MODNAM,CTP_TYPDFN,CTP_NUMTYP); + addtab (hshtab,enumname,CTP_MODNAM,CTP_WMNDFN,-1); + addtab (hshtab,enumname,CTP_MODNAM,CTP_WMXDFN,-1); + addtab (hshtab,enumname,CTP_MODNAM,CTP_LBLDFN,indice); + addtab (hshtab,enumname,CTP_MODNAM,CTP_PNTDFN,(long)pnt); + + pnt[indice++] = enumname; + CTP_NM1LST = delchain (CTP_NM1LST, CTP_NM1LST); + } + + $$.VALUE = pnt ; + $$.SIZE = size ; + $$.LEFT = -1 ; + $$.RIGHT = -1 ; + $$.INDEX = CTP_NUMTYP; + $$.CLASS = 'E' ; + $$.BASE = 0 ; + } + ; + + +...enumeration_literal.. + : /*empty*/ + | ...enumeration_literal.. + Comma + enumeration_literal + { yyerrok; } + ; + +enumeration_literal + : Identifier + { + CTP_NM1LST = addchain (CTP_NM1LST,$1); + } + | CharacterLit + { + CTP_NM1LST = addchain (CTP_NM1LST,$1); + } + ; + +composite_type_definition + : array_type_definition + { + $$ = $1; + } + ; + +array_type_definition + : constrained_array_definition + { $$ = $1; } + ; + +constrained_array_definition + : ARRAY + index_constraint + OF + subtype_indication + { + ctltype_list *NewType; + char *name; + char buffer[ 32 ]; + + $$ = $4; + + if ( $4.CLASS == 'U' ) + { + if ( $4.BASE->CLASS != 'A' ) + { + my_ctp_error(123,NULL); + } + } + else + if ( $4.CLASS == 'A' ) + { + if ( $4.BASE->CLASS != 'U' ) + { + my_ctp_error(123,NULL); + } + + sprintf( buffer, "_subtype_%d", CTP_NUMTYP ); + name = namealloc( buffer ); + + NewType = addctltype(CTP_HEADFIG,name,$4.INDEX, $4.LEFT, + $4.RIGHT,$4.SIZE,$4.VALUE,$4.CLASS,$4.BASE ); + addctlline( CTP_HEADFIG, &NewType->LINE, CTP_LINNUM); + addtab(hshtab,name,CTP_MODNAM,CTP_SYMDFN,CTP_TPEDFN); + addtab(hshtab,name,CTP_MODNAM,CTP_LBLDFN,$4.CLASS); + addtab(hshtab,name,CTP_MODNAM,CTP_TYPDFN,$4.INDEX); + addtab(hshtab,name,CTP_MODNAM,CTP_WMNDFN,$4.LEFT); + addtab(hshtab,name,CTP_MODNAM,CTP_WMXDFN,$4.RIGHT); + addtab(hshtab,name,CTP_MODNAM,CTP_PNTDFN,(long)CTP_HEADFIG->TYPE ); + CTP_NUMTYP++; + + $$.BASE = NewType; + } + else + { + my_ctp_error(123,NULL); + } + + $$.CLASS = 'A'; + $$.INDEX = $2.TYPE; + + $$.LEFT = $2.LEFT; + $$.RIGHT = $2.RIGHT; + } + ; + +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;} + ; + +.constraint. + : /*empty*/ + { + $$.FLAG = 'U'; + $$.LEFT = -1; + $$.RIGHT = -1; + } + | constraint + { + $$ = $1; + } + ; + +constraint + : range_constraint + { + $$ = $1; + } + | + LeftParen + range + RightParen_ERR + { + $$ = $2; + } + ; + +range_constraint + : _RANGE + range + { $$ = $2; } + ; + +range + : attribute_name + { + if ( ( $1.FLAG != CTP_RANGE ) && + ( $1.FLAG != CTP_REV_RANGE ) ) + { + my_ctp_error (32,NULL); + } + + $$ = $1; + } + | simple_expression + direction + simple_expression + { + long Left; + long Right; + int ErrorL; + int ErrorR; + + ErrorL = ctp_vextonum( $1.VEX, &Left ); + ErrorR = ctp_vextonum( $3.VEX, &Right ); + + $$.NAME = NULL; + $$.TYPE = $1.TYPE; + $$.SIGNED = 0; + $$.FLAG = 'A'; + + if ( ( ! ErrorL ) && ( ! ErrorR ) ) + { + if (((Left > Right) && ($2 == CTP_UPTDFN)) || + ((Left < Right) && ($2 == CTP_DWTDFN))) + { + my_ctp_error (32,NULL); + } + + $$.LEFT = Left; + $$.RIGHT = Right; + } + else + { + $$.LEFT = (long)$1.VEX; + $$.RIGHT = (long)$3.VEX; + } + } + ; + +direction + : TO + { $$ = CTP_UPTDFN; } + | DOWNTO + { $$ = CTP_DWTDFN; } + ; + + +type_mark + : + simple_name + { + int type; + $$.NAME = $1; + $$.LEFT = -1; + $$.RIGHT = -1; + $$.TYPE = chktab(hshtab,$1,CTP_MODNAM,CTP_TYPDFN); + $$.FLAG = chktab(hshtab,$1,CTP_MODNAM,CTP_LBLDFN); + type = chktab(hshtab,$1,CTP_MODNAM,CTP_SYMDFN); + + if (type != CTP_TPEDFN || $$.TYPE ==0) + { + my_ctp_error(84,$1); + } + } + ; + +ctl_statement_part + : ..concurrent_statement.. + ; + +..concurrent_statement.. + : /*empty*/ + | ..concurrent_statement.. + concurrent_statement + ; + +concurrent_statement + : formula_assignment_statement + | error + Semicolon_ERR + { my_ctp_error (18,NULL); } + ; + +formula_assignment_statement + : simple_name + Colon + expression + Semicolon_ERR + { + ctlform_list *CtlForm; + vexexpr *VexForm; + + VexForm = simpvexexpr( $3.VEX ); + + if (chktab (hshtab,$1, CTP_MODNAM,CTP_SYMDFN) != 0) + { + my_ctp_error (80,$1); + } + + CtlForm = addctlform( CTP_HEADFIG, $1, VexForm ); + addctlline( CTP_HEADFIG, &CtlForm->LINE, CTP_LINNUM); + + addtab(hshtab,$1,CTP_MODNAM,CTP_SYMDFN,CTP_LABDFN); + } + ; + +expression + : relation..AND__relation.. + { $$ = $1; } + | relation..OR__relation.. + { $$ = $1; } + | relation.NAND_NOR_NXOR_relation. + { $$ = $1; } + | relation..XOR__relation.. + { $$ = $1; } + ; + +relation..AND__relation.. + : relation + _AND + relation + { + $$ = ctp_crtvex (VEX_AND ,$1 ,$3 ,-1,-1); + } + | relation..AND__relation.. + _AND + relation + { + $$ = ctp_crtvex (VEX_AND ,$1 ,$3 ,-1,-1); + } + ; + +relation..OR__relation.. + : relation + _OR + relation + { + $$ = ctp_crtvex (VEX_OR ,$1 ,$3 ,-1,-1); + } + | relation..OR__relation.. + _OR + relation + { + $$ = ctp_crtvex (VEX_OR ,$1 ,$3 ,-1,-1); + } + ; + +relation.NAND_NOR_NXOR_relation. + : relation + { $$ = $1; } + | relation + _NAND + relation + { + $$ = ctp_crtvex (VEX_NAND ,$1 ,$3 ,-1,-1); + } + | relation + _NOR + relation + { + $$ = ctp_crtvex (VEX_NOR ,$1 ,$3 ,-1,-1); + } + | relation + _NXOR + relation + { + $$ = ctp_crtvex (VEX_NXOR ,$1 ,$3 ,-1,-1); + } + | relation + _IFT + relation + { + $$ = ctp_crtvex (VEX_IFT,$1 ,$3 ,-1,-1); + } + | relation + _AU + relation + { + $$ = ctp_crtvex (VEX_AU,$1 ,$3 ,-1,-1); + } + | relation + _EU + relation + { + $$ = ctp_crtvex (VEX_EU,$1 ,$3 ,-1,-1); + } + ; + +relation..XOR__relation.. + : relation + _XOR + relation + { + $$ = ctp_crtvex (VEX_XOR ,$1 ,$3 ,-1,-1); + } + | relation..XOR__relation.. + _XOR + relation + { + $$ = ctp_crtvex (VEX_XOR ,$1 ,$3 ,-1,-1); + } + ; + +relation + : simple_expression + { $$ = $1; } + | simple_expression + relational_operator + simple_expression + { + $$ = ctp_crtvex ($2 ,$1 ,$3 ,-1,-1); + } + ; + +simple_expression + : .sign.term..add_op__term.. + { $$ = $1; } + ; + +.sign.term..add_op__term.. + : term + { $$ = $1; } + | sign + term + { + if ( $1 == VEX_NEG ) + { + $$ = ctp_crtvex( VEX_NEG,$2,NULL,-1,-1); + } + else + { + $$ = $2; + } + } + | .sign.term..add_op__term.. + adding_operator + term + { + $$ = ctp_crtvex($2,$1,$3,-1,-1); + } + ; + +adding_operator + : Plus + { $$ = VEX_ADD; } + | Minus + { $$ = VEX_SUB; } + | Ampersand + { $$ = VEX_CONCAT; } + ; +sign + : Plus + { $$ = 0; } + | Minus + { $$ = VEX_NEG; } + ; + +multiplying_operator + : Star + { $$ = VEX_MUL; } + | Slash + { $$ = VEX_DIV; } + | MOD + { $$ = VEX_MOD; } + | REM + { $$ = VEX_REM; } + ; + +term + : factor + { $$ = $1; } + | term + multiplying_operator + factor + { + $$ = ctp_crtvex( $2, $1, $3,-1,-1); + } + ; + +factor + : primary + { + $$ = $1; + } + | primary + DoubleStar + primary + { + $$ = ctp_crtvex( VEX_EXP,$1,$3,-1,-1); + } + | ABS + primary + { + $$ = ctp_crtvex( VEX_ABS,$2,CTP_EMPSTR,-1,-1); + } + | _NOT + primary + { + $$ = ctp_crtvex( VEX_NOT,$2,CTP_EMPSTR,-1,-1); + } + | _AG + primary + { + $$ = ctp_crtvex( VEX_AG,$2,CTP_EMPSTR,-1,-1); + } + | _AF + primary + { + $$ = ctp_crtvex( VEX_AF,$2,CTP_EMPSTR,-1,-1); + } + | _AX + primary + { + $$ = ctp_crtvex( VEX_AX,$2,CTP_EMPSTR,-1,-1); + } + | _EF + primary + { + $$ = ctp_crtvex( VEX_EF,$2,CTP_EMPSTR,-1,-1); + } + | _EG + primary + { + $$ = ctp_crtvex( VEX_EG,$2,CTP_EMPSTR,-1,-1); + } + | _EX + primary + { + $$ = ctp_crtvex( VEX_EX,$2,CTP_EMPSTR,-1,-1); + } + ; + +primary + : literal + { + struct ctp_expr expr1; + + expr1.IDENT = $1; + expr1.TYPE = -1; + expr1.VEX = (vexexpr *)0; + + $$ = ctp_crtvex( NOPS,expr1,CTP_EMPSTR,-1,-1); + } + | aggregate + { + ctp_vexstr *VexStr; + chain_list *ScanChain; + + ScanChain = $1; + + if ( ScanChain == (chain_list *)0 ) + { + my_ctp_error(114,NULL); + } + + if ( ScanChain->NEXT == (chain_list *)0 ) + { + VexStr = (ctp_vexstr *)ScanChain->DATA; + + $$ = *VexStr; + + autfreeheap( VexStr, sizeof( ctp_vexstr ) ); + freechain( ScanChain ); + } + else + { + $$.IDENT = (char *)$1; + $$.AGGREG = 1; + } + } + | name + { + struct ctp_expr expr1; + char *LocalName; + char Buffer[ 40 ]; + long left; + long right; + long left_bnd; + long right_bnd; + long in_bound; + long out_bound; + int mode; + int flag; + + flag = $1.FLAG; + + if ( ( flag != 0 ) && + ( flag != CTP_EVENT ) && + ( flag != CTP_STABLE ) ) + { + if ( ( flag != CTP_RANGE ) && + ( flag != CTP_REV_RANGE ) ) + { + { + sprintf( Buffer, "%ld", $1.LEFT ); + + expr1.IDENT = Buffer; + expr1.VEX = (vexexpr *)0; + expr1.TYPE = -1; + + $$ = ctp_crtvex( NOPS, expr1, CTP_EMPSTR, -1, -1); + } + } + else + { + autexit( 1 ); + } + } + else + if ( ( $1.NAME[0] == '"' ) || + ( $1.NAME[0] == '\'') ) + { + expr1.IDENT = $1.NAME; + expr1.VEX = (vexexpr *)0; + expr1.TYPE = -1; + + $$ = ctp_crtvex( NOPS ,expr1, CTP_EMPSTR, -1, -1); /* as for literal */ + } + else + { + LocalName = CTP_MODNAM; + mode = chktab (hshtab,$1.NAME,LocalName,CTP_SYMDFN); + + if( mode == 0 ) + { + my_ctp_error (17,$1.NAME); + } + + left_bnd = chktab (hshtab,$1.NAME,LocalName,CTP_WMNDFN); + right_bnd = chktab (hshtab,$1.NAME,LocalName,CTP_WMXDFN); + + left = $1.LEFT; + right = $1.RIGHT; + + { + int type; + + expr1.IDENT = $1.NAME; + type = chktab(hshtab,$1.NAME,LocalName,CTP_TYPDFN); + expr1.TYPE = type; + expr1.SIGNED = chktab (hshtab,$1.NAME,LocalName,CTP_SUNDFN); + + { + expr1 = ctp_crtvex (NOPI,expr1,CTP_EMPSTR,left,right); + } + + if( flag == CTP_EVENT ) + { + $$ = ctp_crtvex (VEX_EVENT,expr1,CTP_EMPSTR,left,right); + } + else + if( flag == CTP_STABLE ) + { + expr1 = ctp_crtvex(VEX_EVENT,expr1,CTP_EMPSTR,left,right); + $$ = ctp_crtvex (VEX_NOT,expr1,CTP_EMPSTR,-1,-1); + } + else + { + $$ = expr1; + } + } + } + } + | qualified_expression + { + struct ctp_expr expr1; + + expr1.IDENT = $1.NAME; + expr1.TYPE = $1.TYPE; + expr1.SIGNED = $1.SIGNED; + expr1.VEX = (vexexpr *)$1.LEFT; + + expr1 = ctp_crtvex(SUBVAR,expr1,CTP_EMPSTR,expr1.VEX->LEFT,expr1.VEX->RIGHT); + + $$ = expr1; + } + ; + +qualified_expression + : name + Apostrophe + aggregate + { + char *LocalName; + ctp_vexstr *VexStr; + chain_list *ScanChain; + vexexpr *VexExpr; + long Def; + + ScanChain = $3; + + if ( ( ScanChain == (chain_list *)0 ) || + ( ScanChain->NEXT != (chain_list *)0 ) ) + { + my_ctp_error(122,NULL); + } + + LocalName = CTP_MODNAM; + Def = chktab (hshtab,$1.NAME,LocalName,CTP_SYMDFN); + + if ( Def == CTP_TPEDFN ) + { + VexStr = (ctp_vexstr *)ScanChain->DATA; + + VexExpr = createvexfunc( $1.NAME, VexStr->VEX->WIDTH ); + addvexhexpr( VexExpr, VexStr->VEX ); + + autfreeheap( VexStr, sizeof( ctp_vexstr ) ); + + $$.NAME = $1.NAME; + $$.TYPE = chktab (hshtab,$1.NAME,LocalName,CTP_TYPDFN); + $$.SIGNED = chktab (hshtab,$1.NAME,LocalName,CTP_SUNDFN); + $$.FLAG = 0; + $$.LEFT = (long)VexExpr; + $$.RIGHT = 0; + + freechain( $3 ); + } + else + { + my_ctp_error(122, $1.NAME); + } + } + ; + +relational_operator + : _EQSym + { $$ = VEX_EQ; } + | _NESym + { $$ = VEX_NE; } + | _GESym + { $$ = VEX_GE; } + | _GTSym + { $$ = VEX_GT; } + | _LESym + { $$ = VEX_LE; } + | _LTSym + { $$ = VEX_LT; } + | Equiv + { $$ = VEX_EQUIV; } + | Imply + { $$ = VEX_IMPLY; } + ; + +literal + : AbstractLit + { $$ = $1; } + | CharacterLit + { + $$ = $1; } + | StringLit + { $$ = $1; } + | BitStringLit + { $$ = $1; } + | _TRUE + { $$ = namealloc( "'1'" ); } + | _FALSE + { $$ = namealloc( "'0'" ); } + ; + +aggregate + : LeftParen + element_association + ...element_association.. + RightParen_ERR + { + if ( $3 != (chain_list *)0 ) + { + $2->NEXT = reverse( $3 ); + } + + $$ = $2; + } + ; + +...element_association.. + : /* empty */ + { + $$ = (chain_list *)0; + } + | ...element_association.. + Comma + element_association + { + if ( $1 != (chain_list *)0 ) + { + $3->NEXT = $1; + } + + $$ = $3; + } + ; + +element_association + : expression + { + ctp_vexstr *VexStr; + + VexStr = (ctp_vexstr *)autallocheap( sizeof( ctp_vexstr ) ); + *VexStr = $1; + + $$ = addchain( (chain_list *)0, VexStr ); + } + | OTHERS + Arrow + expression + { + ctp_vexstr *VexStr; + + VexStr = (ctp_vexstr *)autallocheap( sizeof( ctp_vexstr ) ); + *VexStr = ctp_crtvex( VEX_OTHERS, $3,CTP_EMPSTR,-1,-1); + + $$ = addchain( (chain_list *)0, VexStr ); + } + ; + +name + : simple_name + { + authelem *valbitstr; + char *codedsigname; + char *LocalName; + char buffer[128]; + + LocalName = CTP_MODNAM; + + $$.NAME = $1; + $$.FLAG = 0; + + $$.TYPE = chktab (hshtab,$1,LocalName,CTP_TYPDFN); + $$.LEFT = chktab (hshtab,$1,LocalName,CTP_WMNDFN); + $$.RIGHT = chktab (hshtab,$1,LocalName,CTP_WMXDFN); + $$.SIGNED = chktab (hshtab,$1,LocalName,CTP_SUNDFN); + } + | indexed_name + { $$ = $1; } + | slice_name + { $$ = $1; } + | attribute_name + { $$ = $1; } + ; + +indexed_name + : simple_name + aggregate + { + char *LocalName; + ctp_vexstr *VexStr; + chain_list *ScanChain; + vexexpr *VexExpr; + vexexpr *VexRet; + long Index; + int Error; + long Def; + + ScanChain = $2; + + if ( ScanChain == (chain_list *)0 ) + { + my_ctp_error(114,NULL); + } + + LocalName = CTP_MODNAM; + Def = chktab (hshtab,$1,LocalName,CTP_SYMDFN); + + if ( ScanChain->NEXT != (chain_list *)0 ) + { + if ( ( ! Def ) || + ( ScanChain->NEXT->NEXT != (chain_list *)0 ) ) + { + my_ctp_error(118,$1); + } + + /* ICI */ + + $$.NAME = $1; + $$.TYPE = chktab (hshtab,$1,LocalName,CTP_TYPDFN); + $$.SIGNED = chktab (hshtab,$1,LocalName,CTP_SUNDFN); + $$.FLAG = 0; + + VexStr = (ctp_vexstr *)ScanChain->DATA; + $$.LEFT = (long)VexStr->VEX; + autfreeheap( VexStr, sizeof( ctp_vexstr ) ); + + ScanChain = ScanChain->NEXT; + VexStr = (ctp_vexstr *)ScanChain->DATA; + $$.RIGHT = (long)VexStr->VEX; + autfreeheap( VexStr, sizeof( ctp_vexstr ) ); + + freechain( $2 ); + } + else + { + VexStr = (ctp_vexstr *)ScanChain->DATA; + Error = ctp_vextonum( VexStr->VEX, &Index ); + + $$.NAME = $1; + $$.TYPE = chktab (hshtab,$1,LocalName,CTP_TYPDFN); + $$.SIGNED = chktab (hshtab,$1,LocalName,CTP_SUNDFN); + $$.FLAG = 0; + + if ( Error ) + { + my_ctp_error(36, $1); + } + else + { + $$.LEFT = Index; + $$.RIGHT = Index; + } + + autfreeheap( VexStr, sizeof( ctp_vexstr ) ); + freechain( ScanChain ); + } + } + ; + +slice_name + : simple_name + LeftParen + simple_expression + direction + simple_expression + RightParen_ERR + { + char *LocalName; + long Left; + long Right; + int ErrorL; + int ErrorR; + + LocalName = CTP_MODNAM; + + ErrorL = ctp_vextonum( $3.VEX, &Left ); + ErrorR = ctp_vextonum( $5.VEX, &Right ); + + $$.NAME = $1; + $$.TYPE = chktab (hshtab,$1,LocalName,CTP_TYPDFN); + $$.SIGNED = chktab (hshtab,$1,LocalName,CTP_SUNDFN); + $$.FLAG = 0; + + if ( ( ! ErrorL ) && ( ! ErrorR ) ) + { + if (((Left > Right) && ($4 == CTP_UPTDFN)) || + ((Left < Right) && ($4 == CTP_DWTDFN))) + my_ctp_error (32,$1); + + $$.LEFT = Left; + $$.RIGHT = Right; + } + else + { + my_ctp_error (36,$1); + } + } + ; + +attribute_name + : name + Apostrophe + attribute_designator + { + char *LocalName; + int type; + int flag; + int mode; + long AttrLeft; + long AttrRight; + long AttrLow; + long AttrHigh; + + LocalName = CTP_MODNAM; + mode = chktab (hshtab,$1.NAME,LocalName,CTP_SYMDFN); + type = chktab (hshtab,$1.NAME,LocalName,CTP_TYPDFN); + flag = $3; + + $$.NAME = $1.NAME; + $$.TYPE = type; + $$.LEFT = -1; + $$.RIGHT = -1; + $$.SIGNED = chktab (hshtab,$1.NAME,LocalName,CTP_SUNDFN); + $$.FLAG = $3; + + if ( ( flag == CTP_STABLE ) || + ( flag == CTP_EVENT ) ) + { + if ( LocalName != CTP_MODNAM ) + my_ctp_error (79,$1); + } + else + { + AttrLeft = chktab( hshtab,$1.NAME,LocalName,CTP_ATLDFN); + AttrRight = chktab( hshtab,$1.NAME,LocalName,CTP_ATRDFN); + + { + if ( AttrLeft > AttrRight ) + { + AttrLow = AttrRight; + AttrHigh = AttrLeft; + } + else + { + AttrHigh = AttrRight; + AttrLow = AttrLeft; + } + } + + switch ( flag ) + { + case CTP_LEFT : $$.LEFT = AttrLeft; + break; + + case CTP_RIGHT : $$.LEFT = AttrRight; + break; + + case CTP_LOW : $$.LEFT = AttrLow; + break; + + case CTP_HIGH : $$.LEFT = AttrHigh; + break; + + case CTP_LENGTH : $$.LEFT = 1 + (AttrHigh - AttrLow); + break; + + case CTP_RANGE : $$.LEFT = AttrLeft; + $$.RIGHT = AttrRight; + break; + + case CTP_REV_RANGE : $$.LEFT = AttrRight; + $$.RIGHT = AttrLeft; + break; + } + } + } + ; + +attribute_designator + : _STABLE { $$ = CTP_STABLE; } + | _EVENT { $$ = CTP_EVENT; } + | _LEFT { $$ = CTP_LEFT; } + | _RIGHT { $$ = CTP_RIGHT; } + | _LOW { $$ = CTP_LOW; } + | _HIGH { $$ = CTP_HIGH; } + | _LENGTH { $$ = CTP_LENGTH; } + | _RANGE { $$ = CTP_RANGE; } + | _REV_RANGE { $$ = CTP_REV_RANGE; } + ; + +identifier_list + : Identifier + { CTP_NM1LST = addchain (CTP_NM1LST,$1); } + ...identifier.. + ; + +...identifier.. + : /*empty*/ + | ...identifier.. + Comma + Identifier + { + CTP_NM1LST = addchain (CTP_NM1LST,$3); + } + ; + +simple_name + : Identifier + { $$ = $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 = NULL; + int i; + + if (CTP_DCEHED == NULL) + { + CTP_DCEHED = (struct dct_entry *) + autallocblock (sizeof(struct dct_entry) * CTP_ALODFN); + + entry = CTP_DCEHED; + for (i=1 ; inext = entry + 1; + entry++; + } + entry->next = NULL; + } + + entry = CTP_DCEHED; + CTP_DCEHED = CTP_DCEHED->next; + + entry->next = head; + entry->data = NULL; + entry->key = key; + + return (entry); +} + +static struct dct_recrd *addrcd (head , key) + +struct dct_recrd *head; +char *key; + +{ + struct dct_recrd *recrd = NULL; + int i; + + if (CTP_DCRHED == NULL) + { + CTP_DCRHED = (struct dct_recrd *) + autallocblock (sizeof(struct dct_recrd) * CTP_ALODFN); + + recrd = CTP_DCRHED; + for (i=1 ; inext = recrd + 1; + recrd++; + } + recrd->next = NULL; + } + + recrd = CTP_DCRHED; + CTP_DCRHED = CTP_DCRHED->next; + + recrd->next = head; + recrd->key = key; + + return (recrd); +} + +static struct dct_entry **initab () + +{ + struct dct_entry **head = NULL; + int i; + + head = (struct dct_entry **) + autallocblock (sizeof(struct dct_entry *) * CTP_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 != NULL) + { + 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 CTP_MODDFN : + recrd_pnt->fd0_val = valu; + break; + case CTP_SYMDFN : + recrd_pnt->fd1_val = valu; + break; + case CTP_TYPDFN : + recrd_pnt->fd2_val = valu; + break; + case CTP_SUNDFN : + recrd_pnt->fd3_val = valu; + break; + case CTP_LBLDFN : + recrd_pnt->fd4_val = valu; + break; + case CTP_WMXDFN : + recrd_pnt->fd5_val = valu; + break; + case CTP_WMNDFN : + recrd_pnt->fd6_val = valu; + break; + case CTP_ATLDFN : + recrd_pnt->fd7_val = valu; + break; + case CTP_ATRDFN : + recrd_pnt->fd8_val = valu; + break; + case CTP_PNTDFN : + recrd_pnt->pnt_val = valu; + break; + } +} + +static int chktab (head,key_str,ctx_str,field) + +struct dct_entry **head; +char *key_str; +char *ctx_str; +long field; + +{ + long found = 0; + long valu = 0; + struct dct_entry *entry_pnt; + struct dct_recrd *recrd_pnt; + + entry_pnt = head [((unsigned long)key_str) % CTP_HSZDFN]; + + while (entry_pnt != NULL) + { + 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 != NULL) + { + if (recrd_pnt->key == ctx_str) + { + found = 1; + break; + } + recrd_pnt = recrd_pnt->next; + } + if (found == 1) + { + switch (field) + { + case CTP_MODDFN : + valu = recrd_pnt->fd0_val; + break; + case CTP_SYMDFN : + valu = recrd_pnt->fd1_val; + break; + case CTP_TYPDFN : + valu = recrd_pnt->fd2_val; + break; + case CTP_SUNDFN : + valu = recrd_pnt->fd3_val; + break; + case CTP_LBLDFN : + valu = recrd_pnt->fd4_val; + break; + case CTP_WMXDFN : + valu = recrd_pnt->fd5_val; + break; + case CTP_WMNDFN : + valu = recrd_pnt->fd6_val; + break; + case CTP_ATLDFN : + valu = recrd_pnt->fd7_val; + break; + case CTP_ATRDFN : + valu = recrd_pnt->fd8_val; + break; + case CTP_PNTDFN : + 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; + long i; + + if (pt_hash != NULL) + { + for (i=0 ; idata; + + while (pt_record->next != NULL) + pt_record = pt_record->next; + + pt_record->next = CTP_DCRHED; + CTP_DCRHED = pt_entry->data; + + pt_nxtentry = pt_entry->next; + pt_entry->next = CTP_DCEHED; + CTP_DCEHED = pt_entry; + pt_entry = pt_nxtentry; + } + } + } + autfreeblock(pt_hash); + } +} + +static void *ctp_addstr(object,mode,prtype,type,flag,name,left,right,exp) + +char object; +int mode; +ctltype_list *prtype; +unsigned char type; +char flag; +char *name; +long left; +long right; +vexexpr *exp; + +{ + ctlform_list *CtlForm; + ctldecl_list *CtlDeclar; + void *pnt = NULL; + vexexpr *vex_pnt; + int bitsize; + + if ( object == 'F' ) + { + CtlForm = addctlform( CTP_HEADFIG, name, exp ); + addctlline( CTP_HEADFIG, &CtlForm->LINE, CTP_LINNUM ); + + return( (void *)CtlForm ); + } + + + if ( (flag == 'A') || + (flag == 'U') ) + { + /* ###------------------------------------------------------### */ + /* if object is an array ... */ + /* ###------------------------------------------------------### */ + + if ( flag == 'A' ) + { + vex_pnt = createvexatomvec( name, prtype->LEFT, prtype->RIGHT ); + } + else + { + vex_pnt = createvexatomvec( name, left, right ); + } + + if ( prtype->INDEX == VEX_TYPE_SIGNED ) + { + SetVexNodeSigned( vex_pnt ); + } + + } + else + if ( (flag == 'I') ) + { + /* ###------------------------------------------------------### */ + /* if object is an integer ... */ + /* ###------------------------------------------------------### */ + + if ((left == -1 ) && (right == -1)) + { + left = prtype->LEFT; + right = prtype->RIGHT; + } + + bitsize = ctp_intSize( left, right ); + + vex_pnt = createvexatomvec( name, bitsize - 1, 0 ); + + if ( ( left < 0 ) || + ( right < 0 ) ) + { + SetVexNodeSigned( vex_pnt ); + } + } + else + { + /* ###------------------------------------------------------### */ + /* if object is a scalar ... */ + /* ###------------------------------------------------------### */ + vex_pnt = createvexatombit( name ); + } + + if ( object == 'C' ) + { + CtlDeclar = addctldeclcst( CTP_HEADFIG, vex_pnt ); + CtlDeclar->TYPE = prtype; + CtlDeclar->VEX_INIT = exp; + addctlline( CTP_HEADFIG, &CtlDeclar->LINE, CTP_LINNUM ); + + pnt = (void *)CtlDeclar; + } + else + if ( object == 'V' ) + { + CtlDeclar = addctldeclvar( CTP_HEADFIG, vex_pnt ); + CtlDeclar->TYPE = prtype; + addctlline( CTP_HEADFIG, &CtlDeclar->LINE, CTP_LINNUM ); + + pnt = (void *)CtlDeclar; + } + + return (pnt); +} + +static ctltype_list *val_type(name) + + char *name; +{ + return( searchctltype( CTP_HEADFIG, name ) ); +} + +static ctltype_list *get_type(val) + + long val; +{ + ctltype_list *Type; + + for ( Type = CTP_HEADFIG->TYPE; + Type != (ctltype_list *)0; + Type = Type->NEXT ) + { + if ( Type->INDEX == val ) break; + } + + return( Type ); +} + +int ctp_y_wrap () +{ + return (1); +} + diff --git a/alliance/src/ctp/src/main.c b/alliance/src/ctp/src/main.c new file mode 100644 index 00000000..a7fdc52b --- /dev/null +++ b/alliance/src/ctp/src/main.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 : CTP | +| | +| File : main.c | +| | +| Date : 04.24.02 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include +# include + +# include "mut.h" +# include "aut.h" +# include "vex.h" +# include "ctl.h" +# include "ctp.h" + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Usage | +| | +\------------------------------------------------------------*/ + +void CtpUsage() +{ + fprintf( stderr, "\t\tctptest [Options] Input_name\n\n" ); + fprintf( stdout, "\t\tOptions : -V Sets Verbose mode on\n" ); + fprintf( stdout, "\n" ); + + exit( 1 ); +} + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +int main( argc, argv ) + + int argc; + char *argv[]; +{ + ctlfig_list *CtlFigure; + char *InputFileName; + int Number; + int Index; + char Option; + + int FlagVerbose = 0; + int FlagSave = 0; + + mbkenv(); + autenv(); + vexenv(); + ctlenv(); + + InputFileName = (char *)0; + + if ( argc < 2 ) CtpUsage(); + + for ( Number = 1; Number < argc; Number++ ) + { + if ( argv[ Number ][ 0 ] == '-' ) + { + for ( Index = 1; argv[ Number ][ Index ] != '\0'; Index++ ) + { + Option = argv[ Number ][ Index ]; + + switch ( Option ) + { + case 'V' : FlagVerbose = 1; + break; + default : CtpUsage(); + } + } + } + else + if ( InputFileName == (char *)0 ) InputFileName = argv[ Number ]; + else + CtpUsage(); + } + + if ( InputFileName == (char *)0 ) CtpUsage(); + + fprintf( stdout, "InputFileName %s\n", InputFileName ); + + CtlFigure = loadctlfig( InputFileName ); + + if ( FlagVerbose ) viewctlfig( CtlFigure ); + + delctlfig( CtlFigure->NAME ); + + return( 0 ); +}