diff --git a/alliance/src/vbl/Makefile.am b/alliance/src/vbl/Makefile.am new file mode 100644 index 00000000..af437a64 --- /dev/null +++ b/alliance/src/vbl/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/alliance/src/vbl/configure.in b/alliance/src/vbl/configure.in new file mode 100644 index 00000000..d0a1ced6 --- /dev/null +++ b/alliance/src/vbl/configure.in @@ -0,0 +1,47 @@ +dnl +/* +dnl This file is part of the Alliance CAD System +dnl Copyright (C) Laboratoire LIP6 - Département ASIM +dnl Universite Pierre et Marie Curie +dnl +dnl Home page : http://www-asim.lip6.fr/alliance/ +dnl E-mail support : mailto:alliance-support@asim.lip6.fr +dnl +dnl This library is free software; you can redistribute it and/or modify it +dnl under the terms of the GNU Library General Public License as published +dnl by the Free Software Foundation; either version 2 of the License, or (at +dnl your option) any later version. +dnl +dnl Alliance VLSI CAD System is distributed in the hope that it will be +dnl useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +dnl Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License along +dnl with the GNU C Library; see the file COPYING. If not, write to the Free +dnl Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +dnl +dnl Purpose : Auto stuffing Alliance +dnl Almost ten years since I wrote this stuff, I just can't +dnl believe it +dnl Date : 01/02/2002 +dnl Author : Frederic Petrot +dnl $Id: configure.in,v 1.1 2002/03/21 13:41:35 ludo Exp $ +dnl +dnl +AC_INIT(src/vbl.h) +AM_INIT_AUTOMAKE(vbl, 1.4) +AC_PROG_INSTALL +AC_PROG_CC +AC_PROG_YACC +AM_PROG_LEX +AC_HEADER_STDC +AC_C_CONST +AC_PROG_RANLIB + +AM_ALLIANCE + +AC_OUTPUT([ +Makefile +src/Makefile +]) diff --git a/alliance/src/vbl/src/Makefile.am b/alliance/src/vbl/src/Makefile.am new file mode 100644 index 00000000..29ffafe4 --- /dev/null +++ b/alliance/src/vbl/src/Makefile.am @@ -0,0 +1,11 @@ +lib_LIBRARIES = libVbl.a +libVbl_a_SOURCES = vbl_bcomp_y.y vbl_bcomp_l.l \ +vbl_bedef.h vbl_bspec.c vbl_byacc.h vbl_util.c vbl_utype.h \ +vbl.h vbl_blex.h vbl_bspec.h vbl_parse.c vbl_util.h + +CLEANFILES = vbl_bcompyac.c vbl_bcompyac.h vbl_bcomplex.c + +vbl_bcompyac.c vbl_bcompyac.h : $(srcdir)/vbl_bcomp_y.y + $(YACC) -d $(YFLAGS) $(srcdir)/vbl_bcomp_y.y && sed -e "s/yy/vbl_y_/g" -e "s/YY/VBL_Y_/g" y.tab.c > vbl_bcompyac.c && sed -e "s/yy/vbl_y_/g" -e "s/YY/VBL_Y_/g" y.tab.h > vbl_bcompyac.h +vbl_bcomplex.c : $(srcdir)/vbl_bcomp_l.l vbl_bcompyac.h + $(LEX) -t $(srcdir)/vbl_bcomp_l.l | sed -e "s/yy/vbl_y_/g" -e "s/YY/VBL_Y_/g" > vbl_bcomplex.c diff --git a/alliance/src/vbl/src/main.c b/alliance/src/vbl/src/main.c new file mode 100644 index 00000000..2e2e0e5b --- /dev/null +++ b/alliance/src/vbl/src/main.c @@ -0,0 +1,197 @@ +/*------------------------------------------------------------\ +| | +| 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 MUT_H +# include AUT_H +# include VEX_H +# include VBH_H +# include VBL_H + +# ifdef VBL_DEBUG + extern int vbl_y_debug; +# endif + +/*------------------------------------------------------------\ +| | +| Usage | +| | +\------------------------------------------------------------*/ + +void VblUsage() +{ + fprintf( stderr, "\t\tvbltest [Options] Input_name\n\n" ); + fprintf( stdout, "\t\tOptions : -V Sets Verbose mode on\n" ); +# ifdef VBL_DEBUG + fprintf( stdout, "\t\t -D Sets Debug mode on\n" ); +# endif + fprintf( stdout, "\t\t -G Load generic instances\n" ); + fprintf( stdout, "\t\t -S Simplify Vex\n" ); + fprintf( stdout, "\t\t -P File packages list file name\n" ); + fprintf( stdout, "\n" ); + + exit( 1 ); +} + +/*------------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------------*/ + +int main( argc, argv ) + + int argc; + char **argv; +{ + char *InputFileName; + char *PackageFileName; + int Number; + int Index; + char Option; + vbfig_list *VbhFigure; + vbfig_list *VbhGenFigure; + vbins_list *VbhInstance; + char *Extention; + + int FlagVerbose = 0; + int FlagGeneric = 0; +# ifdef VBL_DEBUG + int FlagDebug = 0; +# endif + int FlagSimplif = 0; + + mbkenv(); + autenv(); + vexenv(); + + InputFileName = (char *)0; + PackageFileName = (char *)0; + Extention = "vhdl"; + + if ( argc < 2 ) VblUsage(); + + InputFileName = (char *)0; + + for ( Number = 1; Number < argc; Number++ ) + { + if ( argv[ Number ][ 0 ] == '-' ) + { + for ( Index = 1; argv[ Number ][ Index ] != '\0'; Index++ ) + { + Option = argv[ Number ][ Index ]; + + if ( Option == 'I' ) + { + Number++; + + if ( Number < argc ) Extention = argv[ Number ]; + else VblUsage(); + + break; + } + else + if ( Option == 'P' ) + { + Number++; + + if ( Number < argc ) PackageFileName = argv[ Number ]; + else VblUsage(); + + break; + } + + switch ( Option ) + { + case 'V' : FlagVerbose = 1; + break; +# ifdef VBL_DEBUG + case 'D' : FlagDebug = 1; + break; +# endif + case 'S' : FlagSimplif = 1; + break; + case 'G' : FlagGeneric = 1; + break; + default : VblUsage(); + } + } + } + else + if ( InputFileName == (char *)0 ) InputFileName = argv[ Number ]; + else + VblUsage(); + } + + if ( InputFileName == (char *)0 ) VblUsage(); + + if ( PackageFileName != (char *)0 ) + { + getvbpkg( PackageFileName, Extention ); + } + +# ifdef VBL_DEBUG + if ( FlagDebug ) vbl_y_debug = 1; +# endif + + VbhFigure = getvbfig( InputFileName, Extention ); + + if ( ! FlagGeneric ) + { + if ( FlagSimplif ) vbh_simpvbfig( VbhFigure ); + if ( FlagVerbose ) vbh_viewvbfig( VbhFigure ); + + vbh_frevbfig( VbhFigure ); + } + else + { + for ( VbhInstance = VbhFigure->BEINS; + VbhInstance != (vbins_list *)0; + VbhInstance = VbhInstance->NEXT ) + { + if ( VbhInstance->GEN_MAP != (vbmap_list *)0 ) + { + VbhGenFigure = getvbfiggenmap( VbhInstance->MODEL, Extention, VbhInstance->GEN_MAP ); + } + } + + for ( VbhFigure = VBL_HEADFIG; + VbhFigure != (vbfig_list *)0; + VbhFigure = VbhFigure->NEXT ) + { + if ( FlagSimplif ) vbh_simpvbfig( VbhFigure ); + if ( FlagVerbose ) vbh_viewvbfig( VbhFigure ); + + } + + vbh_frevbfig( VBL_HEADFIG ); + } + + + return( 0 ); +} diff --git a/alliance/src/vbl/src/vbl.h b/alliance/src/vbl/src/vbl.h new file mode 100644 index 00000000..7f1bc1c9 --- /dev/null +++ b/alliance/src/vbl/src/vbl.h @@ -0,0 +1,68 @@ +/*------------------------------------------------------------\ +| | +| 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. | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------\ +| | +| Title : Structures and fonctions for VBL | +| | +| Date : 07.04.96 | +| | +| Author : Jacomme Ludovic | +| | +\------------------------------------------------------*/ + +# ifndef VBL_104_H +# define VBL_104_H + +/*------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------*/ +/*------------------------------------------------------\ +| | +| Structures | +| | +\------------------------------------------------------*/ +/*------------------------------------------------------\ +| | +| Global Variables | +| | +\------------------------------------------------------*/ + + extern vbfig_list *VBL_HEADFIG; + +/*------------------------------------------------------\ +| | +| Functions | +| | +\------------------------------------------------------*/ + + extern vbfig_list *getvbfig(); + extern vbfig_list *getvbfiggenmap(); + extern void getvbpkg(); + +# endif diff --git a/alliance/src/vbl/src/vbl_bcomp_l.l b/alliance/src/vbl/src/vbl_bcomp_l.l new file mode 100644 index 00000000..851dd3d4 --- /dev/null +++ b/alliance/src/vbl/src/vbl_bcomp_l.l @@ -0,0 +1,284 @@ +/*------------------------------------------------------------\ +| | +| 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 VBH_H + +typedef struct vbl_expr +{ + vexexpr *IDENT; /* identifier or constant name */ + vexexpr *VEX; /* pointer on bvl_abllst list */ + short WIDTH; + short TYPE; +} +vbl_vexstr; + +typedef struct + { + char *NAME; /* identifier name */ + long LEFT; /* vector's left index */ + long RIGHT; /* vector's right index */ + short WIDTH; + char FLAG; + } +vbl_name; + +struct g_type +{ + int VALU; + char FLAG; +}; + +#include "vbl_bcompyac.h" +#include "vbl_bedef.h" +#include "vbl_blex.h" + +static el_mc tab_mc []= + { + {"abs" ,ABS}, + {"access" ,ACCESS}, + {"after" ,AFTER}, + {"alias" ,ALIAS}, + {"all" ,ALL}, + {"and" ,_AND}, + {"architecture" ,ARCHITECTURE}, + {"array" ,ARRAY}, + {"assert" ,ASSERT}, + {"attribute" ,ATTRIBUTE}, + {"begin" ,_BEGIN}, + {"block" ,BLOCK}, + {"body" ,BODY}, + {"buffer" ,_BUFFER}, + {"bus" ,BUS}, + {"case" ,CASE}, + {"component" ,COMPONENT}, + {"configuration" ,CONFIGURATION}, + {"constant" ,CONSTANT}, + {"disconnect" ,DISCONNECT}, + {"downto" ,DOWNTO}, + {"else" ,ELSE}, + {"elsif" ,ELSIF}, + {"end" ,_END}, + {"entity" ,_ENTITY}, + {"error" ,ERROR}, + {"event" ,_EVENT}, + {"exit" ,_EXIT}, + {"false" ,_FALSE}, + {"file" ,_FILE}, + {"for" ,FOR}, + {"fs" ,_FS}, + {"function" ,FUNCTION}, + {"generate" ,GENERATE}, + {"generic" ,GENERIC}, + {"guarded" ,GUARDED}, + {"high" ,_HIGH}, + {"if" ,IF}, + {"ift" ,_IFT}, + {"in" ,_IN}, + {"inout" ,_INOUT}, + {"is" ,IS}, + {"label" ,_LABEL}, + {"left" ,_LEFT}, + {"length" ,_LENGTH}, + {"library" ,_LIBRARY}, + {"linkage" ,_LINKAGE}, + {"loop" ,LOOP}, + {"low" ,_LOW}, + {"map" ,MAP}, + {"mod" ,MOD}, + {"ms" ,_MS}, + {"nand" ,_NAND}, + {"new" ,NEW}, + {"next" ,_NEXT}, + {"nor" ,_NOR}, + {"not" ,_NOT}, + {"ns" ,_NS}, + {"null" ,_NULL}, + {"nxor" ,_NXOR}, + {"of" ,OF}, + {"on" ,ON}, + {"open" ,OPEN}, + {"or" ,_OR}, + {"others" ,OTHERS}, + {"out" ,_OUT}, + {"package" ,_PACKAGE}, + {"port" ,PORT}, + {"procedure" ,PROCEDURE}, + {"process" ,PROCESS}, + {"ps" ,_PS}, + {"range" ,_RANGE}, + {"record" ,RECORD}, + {"register" ,REGISTER}, + {"rem" ,REM}, + {"report" ,REPORT}, + {"return" ,_RETURN}, + {"reverse_range" ,_REV_RANGE}, + {"right" ,_RIGHT}, + {"select" ,SELECT}, + {"severity" ,SEVERITY}, + {"signal" ,SIGNAL}, + {"stable" ,_STABLE}, + {"subtype" ,SUBTYPE}, + {"then" ,THEN}, + {"to" ,TO}, + {"transport" ,TRANSPORT}, + {"true" ,_TRUE }, + {"type" ,_TYPE}, + {"units" ,UNITS}, + {"until" ,UNTIL}, + {"use" ,USE}, + {"variable" ,_VARIABLE}, + {"wait" ,WAIT}, + {"warning" ,WARNING}, + {"when" ,WHEN}, + {"while" ,WHILE}, + {"with" ,WITH}, + {"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,VBL_NB_MC,sizeof(el_mc), strcmp); + if (pt==NULL) return(-1); + + return(pt->kval); +} + + +int vbl_y_wrap () +{ + return (1); +} + +%} + +upper_case_letter [A-Z] +digit [0-9] +special_character [\#\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\_\|] +space_character [ \t] +format_effector [\t\v\r\l\f] +end_of_line \n +lower_case_letter [a-z] +other_special_character [\!\$\@\?\[\\\]\^\`\{\}\~] + +graphic_character ({basic_graphic_character}|{lower_case_letter}|{other_special_character}) +basic_graphic_character ({upper_case_letter}|{digit}|{special_character}|{space_character}) +letter ({upper_case_letter}|{lower_case_letter}) +letter_or_digit ({letter}|{digit}) +decimal_literal {integer}(\.{integer})?({exponent})? +integer {digit}(_?{digit})* +exponent ([eE][-+]?{integer}) +base {integer} +based_integer {extended_digit}(_?{extended_digit})* +extended_digit ({digit}|[a-fA-F]) +base_specifier (B|b|O|o|X|x) + +%% +[ \t] ; +\& { return(Ampersand); } +\' { return(Apostrophe); } +\( { return(LeftParen); } +\) { return(RightParen); } +"**" { return(DoubleStar); } +\* { return(Star); } +\+ { return(Plus); } +\, { return(Comma); } +\- { return(Minus); } +":=" { return(VarAsgn); } +\: { return(Colon); } +\; { return(Semicolon); } +"<=" { return(_LESym); } +">=" { return(_GESym); } +\< { return(_LTSym); } +\> { return(_GTSym); } += { return(_EQSym); } +\/= { return(_NESym); } +"=>" { return(Arrow); } +"<>" { return(Box); } +\| { return(Bar); } +! { return(Bar); } +\. { return(Dot); } +\/ { 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 { + VBL_LINNUM++; + } +\-\-.*$ { + /* comment */ + /* nothing */ + } +. { + return (*yytext); + } +%% diff --git a/alliance/src/vbl/src/vbl_bcomp_y.y b/alliance/src/vbl/src/vbl_bcomp_y.y new file mode 100644 index 00000000..0730af18 --- /dev/null +++ b/alliance/src/vbl/src/vbl_bcomp_y.y @@ -0,0 +1,8306 @@ +/*------------------------------------------------------------\ +| | +| 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 : vbl_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 VBH_H + +#include "vbl_utype.h" +#include "vbl_bedef.h" +#include "vbl_bspec.h" +#include "vbl_byacc.h" + +#if 1 +# define my_fprintf fprintf( stdout, "%s %d : ", __FILE__, __LINE__ ); fprintf +# define my_vbl_error(N,V) \ + do { fprintf( stderr, "%s %d : ", __FILE__, __LINE__); vbl_error(N,V); } while(0) +#else +# define my_fprintf fprintf +# define my_vbl_error vbl_error +#endif + +#ifdef VBL_DEBUG +#define YYDEBUG 1 +#endif + +%} + +%union { + int valu; + char *text; + chain_list *pcha; + vbl_name name; + vbl_vexstr list; + struct vbtyp type; + }; + +%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 .SEVERITY__expression. +%type severity__message +%type .REPORT__expression. +%type report__message + +%type .WHEN__condition. +%type .GUARDED. + +%type .VarAsgn__expression. +%type waveform +%type waveform_element +%type condition +%type expression +%type .expression. +%type guard_expression +%type .guard_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 choice +%type aggregate +%type element_association +%type ...element_association.. + +%type .condition_clause. +%type condition_clause +%type .iteration_scheme. +%type iteration_scheme +%type loop_parameter_specification + +%type type_definition +%type scalar_type_definition +%type composite_type_definition +%type enumeration_type_definition +%type subtype_indication +%type unconstrained_array_definition +%type constrained_array_definition +%type array_type_definition + +%type library_clause +%type use_clause +%type selected_name +%type ...selected_name.. + +%type index_subtype_definition +%type index_constraint +%type discrete_range +%type qualified_expression + +%type .label. +%type label +%type time_label +%type a_label +%type target +%type simple_name +%type prefix +%type suffix +%type type_or_function_name +%type name +%type attribute_name +%type indexed_name +%type slice_name +%type .simple_name. +%type .constraint. +%type constraint +%type .timeout_clause. +%type timeout_clause +%type range +%type range_constraint +%type direction +%type .mode. +%type .local_port_mode. +%type .procedure_parameter_mode. +%type .procedure_parameter_object_class. +%type .function_parameter_mode. +%type .function_parameter_object_class. +%type type_mark +%type .signal_kind. +%type attribute_designator +%type designator + +%type generation_scheme +%type generate_parameter_specification + +%type entity_class + +%type constant_VarAsgn__expression + +%start design_file + +%% + +design_file + : { + /* ###----------------------------------------------### */ + /* Initializations */ + /* ###----------------------------------------------### */ + + VBL_NM1LST = NULL; + VBL_NM2LST = NULL; + VBL_LOOPLBLLST = NULL; + VBL_LOOPLBL = NULL; + VBL_INSLST = NULL; + VBL_GRDLST = NULL; + VBL_CNDLST = NULL; + VBL_LINLST = NULL; + VBL_VALLST = NULL; + VBL_ENUMVAL = createauthtable( 100 ); + hshtab = initab (); + + VBL_ERRFLG = 0; + VBL_LINNUM = 1; + VBL_NUMPTP = 0; + VBL_NUMCHOICE = 0; + + VBL_MODNAM = namealloc( "undefined" ); + VBL_PROCNAM = (char *)0; + VBL_GNRNAM = (char *)0; + VBL_FUNCNAM = (char *)0; + VBL_COMPNAM = (char *)0; + VBL_BEFUN = (vbfun_list *)0; + + VBL_HEADFIG = vbh_addvbfig( VBL_HEADFIG, 0); + VBL_BEFPNT = VBL_HEADFIG; + + VBL_BEPCS = (vbpcs_list *)0; + VBL_BEINS = (vbins_list *)0; + VBL_BEGNR = (vbgnr_list *)0; + VBL_BEMAP = (vbmap_list *)0; + + VBL_GNR_BEPCS = (chain_list *)0; + VBL_GNR_BEINS = (chain_list *)0; + VBL_GNR_BEGNR = (chain_list *)0; + } + design_unit + ..design_unit.. + { + VBL_BEFPNT->BEPCS = VBL_BEPCS; + VBL_BEFPNT->BEINS = VBL_BEINS; + VBL_BEFPNT->BEGNR = VBL_BEGNR; + + fretab( hshtab ); + destroyauthtable( VBL_ENUMVAL ); + } + ; + +..design_unit.. + : /*empty*/ + | design_unit + ..design_unit.. + ; + +design_unit + : context_clause + library_unit + {} + ; + +library_unit + : primary_unit + {} + | secondary_unit + {} + | error + {} + ; + +primary_unit + : entity_declaration + {} + | configuration_declaration + {} + | package_declaration + {} + ; + +secondary_unit + : architecture_body + {} + | package_body + {} + ; + +library_clause + : _LIBRARY + logical_name_list + Semicolon_ERR + { } + ; + +logical_name_list + : Identifier + ...logical_name.. + { } + ; + +...logical_name.. + : /*empty*/ + | ...logical_name.. + Comma + Identifier + { } + ; + +/* 11.3 */ +context_clause + : ..context_item.. + { } + ; + +..context_item.. + : /*empty*/ + | ..context_item.. + context_item + { } + ; + +context_item + : library_clause + { } + | use_clause + { } + ; + +use_clause + : USE + selected_name /* package simple name */ + ...selected_name.. + Semicolon_ERR + { + } + ; + +/* 1.3 */ +configuration_declaration + : CONFIGURATION + Identifier + OF + Identifier + IS + block_configuration + END_ERR + .simple_name. + Semicolon_ERR + {} + | CONFIGURATION error + {} + ; + +/* block configuration */ +block_configuration + : FOR + label + END_ERR + FOR + Semicolon_ERR + {} + ; + + +/* Packages */ + +/* 2.5 */ +package_declaration + : _PACKAGE + Identifier + IS + { + vbfig_list *ScanPkgFig; + chain_list *ScanChain; + char *Name; + char **FuncArray; + int Index; + long Left; + long Right; + long AttrLeft; + long AttrRight; + long Dir; + int Signed; + vbcst_list *VbhCst; + vbaux_list *VbhAux; + vbmod_list *VbhMod; + vbpor_list *VbhPor; + vbgen_list *VbhGen; + vbtyp_list *VbhType; + vbpcs_list *VbhPcs; + vexexpr *VexAtom; + long Dynamic; + long Oper; + chain_list *PackList; + + extern char *vbl_func_std_logic_1164[]; + extern char *vbl_func_std_logic_arith[]; + extern char *vbl_func_std_numeric_std[]; + + int size=0; + struct vbtyp *vbtyp_pnt; + VBL_BEFPNT->NAME = $2; + VBL_BEFPNT->PACKAGE = 1; + VBL_MODNAM = $2; + + vbtyp_pnt = VBL_BEFPNT->BETYP; + while(vbtyp_pnt) + { + size++; + vbtyp_pnt = vbtyp_pnt->NEXT; + } + + vbtyp_pnt = VBL_BEFPNT->BETYP; + VBL_NUMTYP = 0; + while(vbtyp_pnt) + { + addtab(hshtab,vbtyp_pnt->NAME,VBL_MODNAM,VBL_SYMDFN,VBL_TPEDFN); + addtab(hshtab,vbtyp_pnt->NAME,VBL_MODNAM,VBL_LBLDFN,vbtyp_pnt->CLASS); + addtab(hshtab,vbtyp_pnt->NAME,VBL_MODNAM,VBL_TYPDFN,vbtyp_pnt->INDEX); + addtab(hshtab,vbtyp_pnt->NAME,VBL_MODNAM,VBL_WMNDFN,vbtyp_pnt->LEFT); + addtab(hshtab,vbtyp_pnt->NAME,VBL_MODNAM,VBL_WMXDFN,vbtyp_pnt->RIGHT); + addtab(hshtab,vbtyp_pnt->NAME,VBL_MODNAM,VBL_PNTDFN,(long)vbtyp_pnt); + vbtyp_pnt = vbtyp_pnt->NEXT; + VBL_NUMTYP++; + } + + for ( ScanChain = VBL_NM2LST; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + FuncArray = (char **)0; + + if ( ! strcmp( ScanChain->DATA, "ieee.std_logic_1164.all" ) ) + { + FuncArray = vbl_func_std_logic_1164; + } + else + if ( ( ! strcmp( ScanChain->DATA, "ieee.std_logic_arith.all" ) ) || + ( ! strcmp( ScanChain->DATA, "ieee.std_logic_signed.all" ) ) || + ( ! strcmp( ScanChain->DATA, "ieee.std_logic_unsigned.all" ) ) ) + { + FuncArray = vbl_func_std_logic_arith; + } + else + if ( ( ! strcmp( ScanChain->DATA, "ieee.numeric_std.all" ) ) || + ( ! strcmp( ScanChain->DATA, "ieee.numeric_bit.all" ) ) ) + { + FuncArray = vbl_func_std_numeric_std; + } + else + { + for ( ScanPkgFig = VBL_HEADFIG; + ScanPkgFig != (vbfig_list *)0; + ScanPkgFig = ScanPkgFig->NEXT ) + { + if ( ( ScanPkgFig->PACKAGE ) && + ( ScanPkgFig->NAME == (char *)ScanChain->DATA ) ) + { + for ( PackList = VBL_BEFPNT->PACK_LIST; + PackList != (chain_list *)0; + PackList = PackList->NEXT ) + { + if ( PackList->DATA == ScanChain->DATA ) break; /* already included */ + } + + if ( PackList == (chain_list *)0 ) + { + vbh_dupvbfig( VBL_BEFPNT, ScanPkgFig ); + } + + /* BECST */ + + for ( VbhCst = ScanPkgFig->BECST; + VbhCst != (vbcst_list *)0; + VbhCst = VbhCst->NEXT ) + { + VbhType = vbh_getvbtyp( VBL_BEFPNT, VbhCst->TYPE->NAME ); + VexAtom = VbhCst->TARGET; + + if ( ! IsVexNodeAtom( VexAtom ) ) + { + my_fprintf( stdout, "dynamic declaration not supported !\n" ); + autexit( 1 ); + } + + Name = GetVexAtomValue( VexAtom ); + + /* + if ( chktab( hshtab, Name, VBL_MODNAM, VBL_SYMDFN ) ) + { + my_vbl_error( 10, Name ); + } + */ + + if ( IsVexAtomBit( VexAtom ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VexAtom->LEFT; + Right = VexAtom->RIGHT; + } + + Signed = ( IsVexNodeSigned( VexAtom ) != 0 ); + AttrLeft = Left; + AttrRight = Right; + + addtab( hshtab, Name, VBL_MODNAM, VBL_SYMDFN, VBL_CSTDFN ); + addtab( hshtab, Name, VBL_MODNAM, VBL_TYPDFN, VbhType->INDEX ); + addtab( hshtab, Name, VBL_MODNAM, VBL_WMNDFN, Left ); + addtab( hshtab, Name, VBL_MODNAM, VBL_WMXDFN, Right ); + addtab( hshtab, Name, VBL_MODNAM, VBL_ATLDFN, AttrLeft ); + addtab( hshtab, Name, VBL_MODNAM, VBL_ATRDFN, AttrRight ); + addtab( hshtab, Name, VBL_MODNAM, VBL_LBLDFN, 0 ); + addtab( hshtab, Name, VBL_MODNAM, VBL_PNTDFN, (long)VbhCst->VEX ); + addtab( hshtab, Name, VBL_MODNAM, VBL_SUNDFN, Signed ); + addtab( hshtab, Name, VBL_MODNAM, VBL_DYNDFN, 0 ); + } + + /* BEAUX */ + + for ( VbhAux = ScanPkgFig->BEAUX; + VbhAux != (vbaux_list *)0; + VbhAux = VbhAux->NEXT ) + { + VbhType = vbh_getvbtyp( VBL_BEFPNT, VbhAux->TYPE->NAME ); + VexAtom = VbhAux->TARGET; + + if ( ! IsVexNodeAtom( VexAtom ) ) + { + my_fprintf( stdout, "dynamic declaration not supported !\n" ); + autexit( 1 ); + } + + Name = GetVexAtomValue( VexAtom ); + + /* + if ( chktab( hshtab, Name, VBL_MODNAM, VBL_SYMDFN ) ) + { + my_vbl_error( 10, Name ); + } + */ + + Signed = (IsVexNodeSigned( VexAtom ) != 0); + Left = VexAtom->LEFT; + Right = VexAtom->RIGHT; + AttrLeft = Left; + AttrRight = Right; + + addtab( hshtab, Name, VBL_MODNAM, VBL_SYMDFN, VBL_SGNDFN ); + addtab( hshtab, Name, VBL_MODNAM, VBL_TYPDFN, VbhType->INDEX ); + addtab( hshtab, Name, VBL_MODNAM, VBL_WMNDFN, Left ); + addtab( hshtab, Name, VBL_MODNAM, VBL_WMXDFN, Right ); + addtab( hshtab, Name, VBL_MODNAM, VBL_ATLDFN, AttrLeft ); + addtab( hshtab, Name, VBL_MODNAM, VBL_ATRDFN, AttrRight ); + addtab( hshtab, Name, VBL_MODNAM, VBL_LBLDFN, VbhAux->KIND ); + addtab( hshtab, Name, VBL_MODNAM, VBL_PNTDFN, (long)VexAtom ); + addtab( hshtab, Name, VBL_MODNAM, VBL_SUNDFN, Signed ); + addtab( hshtab, Name, VBL_MODNAM, VBL_DYNDFN, 0 ); + } + + /* BEPCS */ + + for ( VbhPcs = ScanPkgFig->BEPCS; + VbhPcs != (vbpcs_list *)0; + VbhPcs = VbhPcs->NEXT ) + { + addtab( hshtab, VbhPcs->LABEL, VBL_MODNAM, VBL_SYMDFN, VBL_LBLDFN ); + } + + /* BEFUN TO BE DONE */ + + if ( ScanPkgFig->BEFUN != (vbfun_list *)0 ) + { + my_fprintf( stdout, "function in package not supported !\n" ); + autexit( 1 ); + } + + /* BEATR TO BE DONE */ + + if ( ScanPkgFig->BEATR != (vbatr_list *)0 ) + { + my_fprintf( stdout, "attribute in package not supported !\n" ); + autexit( 1 ); + } + + /* BEGNR TO BE DONE ??? */ + + if ( ScanPkgFig->BEGNR != (vbgnr_list *)0 ) + { + my_fprintf( stdout, "generate in package not supported !\n" ); + autexit( 1 ); + } + + /* BEMOD */ + + for ( VbhMod = ScanPkgFig->BEMOD; + VbhMod != (vbmod_list *)0; + VbhMod = VbhMod->NEXT ) + { + addtab(hshtab,VbhMod->NAME,VBL_MODNAM,VBL_SYMDFN,VBL_COMDFN); + addtab(hshtab,VbhMod->NAME,VBL_MODNAM,VBL_PNTDFN,(long)VbhMod); + + for ( VbhGen = VbhMod->BEGEN; + VbhGen != (vbgen_list *)0; + VbhGen = VbhGen->NEXT ) + { + VbhType = vbh_getvbtyp( VBL_BEFPNT, VbhGen->TYPE->NAME ); + VexAtom = VbhGen->TARGET; + + if ( ! IsVexNodeAtom( VexAtom ) ) + { + my_fprintf( stdout, "dynamic declaration not supported !\n" ); + autexit( 1 ); + } + + Name = GetVexAtomValue( VexAtom ); + + /* + if ( chktab( hshtab, Name, VBL_MODNAM, VBL_SYMDFN ) ) + { + my_vbl_error( 10, Name ); + } + */ + + Signed = (IsVexNodeSigned( VexAtom ) != 0); + Left = VexAtom->LEFT; + Right = VexAtom->RIGHT; + AttrLeft = Left; + AttrRight = Right; + + addtab( hshtab, Name, VbhMod->NAME, VBL_SYMDFN, VBL_GENDFN ); + addtab( hshtab, Name, VbhMod->NAME, VBL_TYPDFN, VbhType->INDEX ); + addtab( hshtab, Name, VbhMod->NAME, VBL_WMNDFN, Left ); + addtab( hshtab, Name, VbhMod->NAME, VBL_WMXDFN, Right ); + addtab( hshtab, Name, VbhMod->NAME, VBL_ATLDFN, AttrLeft ); + addtab( hshtab, Name, VbhMod->NAME, VBL_ATRDFN, AttrRight ); + addtab( hshtab, Name, VbhMod->NAME, VBL_LBLDFN, VBH_KIND_NONE ); + addtab( hshtab, Name, VbhMod->NAME, VBL_PNTDFN, (long)VexAtom ); + addtab( hshtab, Name, VbhMod->NAME, VBL_SUNDFN, Signed ); + addtab( hshtab, Name, VbhMod->NAME, VBL_DYNDFN, 0 ); + } + + for ( VbhPor = VbhMod->BEPOR; + VbhPor != (vbpor_list *)0; + VbhPor = VbhPor->NEXT ) + { + VbhType = vbh_getvbtyp( VBL_BEFPNT, VbhPor->TYPE->NAME ); + VexAtom = VbhPor->TARGET; + + if ( ! IsVexNodeAtom( VexAtom ) ) + { + Name = getvexatomname( VexAtom ); + Dynamic = 0; + + if ( IsVexNodeOper( VexAtom ) ) + { + Oper = GetVexOperValue( VexAtom ); + + if ( Oper == VEX_DOWNTO ) Dynamic = VBL_DWTDFN; + else + if ( Oper == VEX_TO ) Dynamic = VBL_UPTDFN; + + Signed = (IsVexNodeSigned( VexAtom ) != 0); + Left = (long)GetVexOperand( VexAtom->OPERAND ); + Right = (long)GetVexOperand( VexAtom->OPERAND->NEXT ); + AttrLeft = Left; + AttrRight = Right; + } + + if ( ! Dynamic ) + { + my_fprintf( stdout, "such dynamic declaration not supported !\n" ); + autexit( 1 ); + } + } + else + { + Name = GetVexAtomValue( VexAtom ); + + Signed = (IsVexNodeSigned( VexAtom ) != 0); + Left = VexAtom->LEFT; + Right = VexAtom->RIGHT; + AttrLeft = Left; + AttrRight = Right; + Dynamic = 0; + } + + /* + if ( chktab( hshtab, Name, VBL_MODNAM, VBL_SYMDFN ) ) + { + my_vbl_error( 10, Name ); + } + */ + + if ( VbhPor->DIR == 'I' ) Dir = VBL_ICNDFN; + else + if ( VbhPor->DIR == 'O' ) Dir = VBL_OCNDFN; + else Dir = VBL_BCNDFN; + + addtab( hshtab, Name, VbhMod->NAME, VBL_SYMDFN, Dir ); + addtab( hshtab, Name, VbhMod->NAME, VBL_TYPDFN, VbhType->INDEX ); + addtab( hshtab, Name, VbhMod->NAME, VBL_WMNDFN, Left ); + addtab( hshtab, Name, VbhMod->NAME, VBL_WMXDFN, Right ); + addtab( hshtab, Name, VbhMod->NAME, VBL_ATLDFN, AttrLeft ); + addtab( hshtab, Name, VbhMod->NAME, VBL_ATRDFN, AttrRight ); + addtab( hshtab, Name, VbhMod->NAME, VBL_LBLDFN, VbhPor->KIND ); + addtab( hshtab, Name, VbhMod->NAME, VBL_PNTDFN, (long)VexAtom ); + addtab( hshtab, Name, VbhMod->NAME, VBL_SUNDFN, Signed ); + addtab( hshtab, Name, VbhMod->NAME, VBL_DYNDFN, Dynamic ); + } + } + + /* BEINS */ + + if ( ScanPkgFig->BEINS != (vbins_list *)0 ) + { + my_fprintf( stdout, "instance in package not supported !\n" ); + autexit( 1 ); + } + + break; + } + } + + if ( ScanPkgFig == (vbfig_list *)0 ) + { + my_vbl_error(127,(char *)ScanChain->DATA); + } + } + + if ( FuncArray != (char **)0 ) + { + Index = 0; + + while ( FuncArray[ Index ] != NULL ) + { + Name = namealloc( FuncArray[ Index ] ); + addtab ( hshtab, Name, VBL_MODNAM, VBL_SYMDFN, VBL_FUNDFN ); + Index++; + } + } + } + + freechain( VBL_NM2LST ); + VBL_NM2LST = NULL; + } + package_declarative_part + END_ERR + .simple_name. + Semicolon_ERR + { + if (($7 != NULL) && ($7 != $2)) my_vbl_error (128,$7); + } + | _PACKAGE + error + { } + ; + +package_declarative_part + : ..package_declarative_item.. + { } + ; + +..package_declarative_item.. + : /*empty*/ + | ..package_declarative_item.. + package_declarative_item + { } + ; + +package_declarative_item + : type_declaration + | subtype_declaration + | attribute_declaration + | constant_declaration + | subprogram_declaration + | component_declaration + | attribute_specification + | signal_declaration + | error END_ERR + Semicolon_ERR + ; + +/* 2.6 */ +/* package bodies */ + +package_body + : _PACKAGE + BODY + Identifier + IS + { + if ($3 != VBL_MODNAM) my_vbl_error (128,$3); + } + package_body_declarative_part + END_ERR + .simple_name. + Semicolon_ERR + { + if (($8 != NULL) && ($8 != $3)) my_vbl_error (128,$8); + } + | _PACKAGE + BODY + error + { my_vbl_error ( 129,NULL); } + ; + +package_body_declarative_part + : ..package_body_declarative_item.. + ; + +..package_body_declarative_item.. + : /*empty*/ + | ..package_body_declarative_item.. + package_body_declarative_item + ; + +package_body_declarative_item + : subprogram_declaration + | subprogram_body + | type_declaration + | subtype_declaration + | constant_declaration + ; + + + +/* 9.6 */ +component_instantiation_statement + : a_label + /* Identifier */ + name + { + if (chktab (hshtab,$1,VBL_MODNAM,VBL_SYMDFN) != 0) + { + my_vbl_error (19,$1); + } + + addtab (hshtab,$1,VBL_MODNAM,VBL_SYMDFN,VBL_LBLDFN); + + if (chktab (hshtab,$2.NAME,VBL_MODNAM,VBL_SYMDFN) != VBL_COMDFN) + { + my_vbl_error (125,$2.NAME); + } + + VBL_BEINS = vbh_addvbins( VBL_BEINS, $1, $2.NAME, VBL_LINNUM ); + VBL_COMPNAM = $2.NAME; + VBL_BEMAP = (vbmap_list *)0; + } + .generic_map_aspect. + { + VBL_BEINS->GEN_MAP = VBL_BEMAP; + VBL_BEMAP = (vbmap_list *)0; + } + .port_map_aspect. + { + VBL_BEINS->PORT_MAP = VBL_BEMAP; + VBL_BEMAP = (vbmap_list *)0; + } + Semicolon_ERR + { + vbmod_list *VbMod; + vbgen_list *VbGen; + vbpor_list *VbPor; + vbins_list *VbIns; + vbmap_list *VbMap; + int Explicit; + + VbMod = (vbmod_list *)chktab(hshtab,$2.NAME,VBL_MODNAM,VBL_PNTDFN); + VbIns = VBL_BEINS; + + VbIns->PORT_MAP = (vbmap_list *)reverse( (chain_list *)VbIns->PORT_MAP ); + + VbPor = VbMod->BEPOR; + VbMap = VbIns->PORT_MAP; + Explicit = 0; + + while ( ( VbMap != (vbmap_list *)0 ) && + ( VbPor != (vbpor_list *)0 ) ) + { + if ( VbMap->FORMAL == (vexexpr *)0 ) + { + if ( Explicit ) + { + my_vbl_error (125, VbIns->NAME); + } + + VbMap->FORMAL = dupvexexpr( VbPor->TARGET ); + VbPor = VbPor->NEXT; + } + else + { + Explicit = 1; + } + + VbMap = VbMap->NEXT; + } + + if ( VbMap != (vbmap_list *)0 ) + { + my_vbl_error (125, VbIns->NAME); + } + + VbIns->GEN_MAP = (vbmap_list *)reverse( (chain_list *)VbIns->GEN_MAP ); + + VbGen = VbMod->BEGEN; + VbMap = VbIns->GEN_MAP; + Explicit = 0; + + while ( ( VbMap != (vbmap_list *)0 ) && + ( VbGen != (vbgen_list *)0 ) ) + { + if ( VbMap->FORMAL == (vexexpr *)0 ) + { + if ( Explicit ) + { + my_vbl_error (125, VbIns->NAME); + } + + VbMap->FORMAL = dupvexexpr( VbGen->TARGET ); + VbGen = VbGen->NEXT; + } + else + { + Explicit = 1; + } + + VbMap = VbMap->NEXT; + } + + if ( VbMap != (vbmap_list *)0 ) + { + my_vbl_error (125, VbIns->NAME); + } + + VBL_COMPNAM = (char *)0; + } + ; + +.port_map_aspect. + : /*empty*/ + {} + | port_map_aspect + {} + ; +port_map_aspect + : + PORT + MAP + LeftParen /* was: PORT aggregate */ + association_list + RightParen_ERR + {} + ; + + +.generic_map_aspect. + : /*empty*/ + {} + | generic_map_aspect + {} + ; +generic_map_aspect + : + GENERIC + MAP + LeftParen + association_list + RightParen_ERR + {} + ; + +/* 9.7 */ +/* +** To avoid shift/reduce conflicts, define labeled/unlabeled generate +** statements. +*/ +generate_statement + : a_label + { + if ( chktab (hshtab,$1,VBL_MODNAM,VBL_SYMDFN) != 0) + my_vbl_error (19,$1); + + addtab( hshtab,$1,VBL_MODNAM,VBL_SYMDFN,VBL_LBLDFN); + + VBL_GNRNAM = $1; + } + unlabeled_generate_statement + { + } + ; + +unlabeled_generate_statement + : generation_scheme + GENERATE + { + vbl_name *Range; + vbvar_list *VbVar; + vexexpr *Target; + short Signed; + long Left; + long Right; + long AttrLeft; + long AttrRight; + char ForUp; + + VBL_BEGNR = vbh_addvbgnr( VBL_BEGNR, VBL_GNRNAM, VBL_LINNUM ); + + if ( $1.IDENT != (char *)0 ) + { + if ( chktab( hshtab,$1.IDENT,VBL_MODNAM,VBL_SYMDFN ) != 0 ) + { + my_vbl_error (80,$1.IDENT); + } + + Range = (vbl_name *)$1.VEX; + + if ( Range->DYNAMIC ) + { + if ( Range->DYNAMIC == VBL_UPTDFN ) ForUp = 1; + else ForUp = 0; + + AttrLeft = -1; + AttrRight = -1; + } + else + { + AttrLeft = Range->LEFT; + AttrRight = Range->RIGHT; + + if ( AttrLeft <= AttrRight ) ForUp = 1; + else ForUp = 0; + } + + VbVar = (vbvar_list *)vbl_addstr( 'f',0, + get_type(VBH_TYPE_INTEGER),VBH_TYPE_INTEGER, + 'I',$1.IDENT, -1, -1, NULL, 0, 0 ); + Target = VbVar->TARGET; + Signed = ( IsVexNodeSigned( VbVar->TARGET ) != 0 ); + + if ( IsVexAtomBit( VbVar->TARGET ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VbVar->TARGET->LEFT; + Right = VbVar->TARGET->RIGHT; + } + + addtab( hshtab,$1.IDENT,VBL_MODNAM,VBL_SYMDFN,VBL_VARDFN); + addtab( hshtab,$1.IDENT,VBL_MODNAM,VBL_TYPDFN,VBH_TYPE_INTEGER); + addtab( hshtab,$1.IDENT,VBL_MODNAM,VBL_WMNDFN,Left); + addtab( hshtab,$1.IDENT,VBL_MODNAM,VBL_WMXDFN,Right); + addtab( hshtab,$1.IDENT,VBL_MODNAM,VBL_ATLDFN,AttrLeft); + addtab( hshtab,$1.IDENT,VBL_MODNAM,VBL_ATRDFN,AttrRight); + addtab( hshtab,$1.IDENT,VBL_MODNAM,VBL_LBLDFN,0); + addtab( hshtab,$1.IDENT,VBL_MODNAM,VBL_PNTDFN,(long)VbVar->TARGET); + addtab( hshtab,$1.IDENT,VBL_MODNAM,VBL_SUNDFN,Signed); + + if ( ! Range->DYNAMIC ) + { + Range->LEFT = (long)createvexatomlong( AttrLeft , 0, Signed ); + Range->RIGHT = (long)createvexatomlong( AttrRight, 0, Signed ); + } + + VBL_BEGNR->TYPE = VBH_GENERATE_FOR; + VBL_BEGNR->FOR_VARIABLE = VbVar->TARGET; + VBL_BEGNR->FOR_LEFT = (vexexpr *)Range->LEFT; + VBL_BEGNR->FOR_RIGHT = (vexexpr *)Range->RIGHT; + VBL_BEGNR->FOR_UP = ForUp; + + autfreeheap( Range, sizeof( vbl_name ) ); + } + else + { + VBL_BEGNR->TYPE = VBH_GENERATE_IF; + VBL_BEGNR->IF_COND = $1.VEX; + } + + VBL_GNR_BEINS = addchain( VBL_GNR_BEINS, (void *)VBL_BEINS ); + VBL_GNR_BEPCS = addchain( VBL_GNR_BEPCS, (void *)VBL_BEPCS ); + VBL_GNR_BEGNR = addchain( VBL_GNR_BEGNR, (void *)VBL_BEGNR ); + + VBL_BEINS = (vbins_list *)0; + VBL_BEPCS = (vbpcs_list *)0; + VBL_BEGNR = (vbgnr_list *)0; + + } + set_of_statements + END_ERR + GENERATE + .label. + Semicolon_ERR + { + vbgnr_list *BeGnr; + + if ( $1.IDENT != (char *)0 ) + { + addtab( hshtab,$1.IDENT,VBL_MODNAM,VBL_SYMDFN,0); + addtab( hshtab,$1.IDENT,VBL_MODNAM,VBL_TYPDFN,0); + addtab( hshtab,$1.IDENT,VBL_MODNAM,VBL_WMNDFN,0); + addtab( hshtab,$1.IDENT,VBL_MODNAM,VBL_WMXDFN,0); + addtab( hshtab,$1.IDENT,VBL_MODNAM,VBL_ATLDFN,0); + addtab( hshtab,$1.IDENT,VBL_MODNAM,VBL_ATRDFN,0); + addtab( hshtab,$1.IDENT,VBL_MODNAM,VBL_LBLDFN,0); + addtab( hshtab,$1.IDENT,VBL_MODNAM,VBL_PNTDFN,0); + addtab( hshtab,$1.IDENT,VBL_MODNAM,VBL_SUNDFN,0); + } + + BeGnr = (vbgnr_list *)VBL_GNR_BEGNR->DATA; + + BeGnr->BEINS = VBL_BEINS; + BeGnr->BEPCS = VBL_BEPCS; + BeGnr->BEGNR = VBL_BEGNR; + + VBL_BEINS = (vbins_list *)VBL_GNR_BEINS->DATA; + VBL_BEPCS = (vbpcs_list *)VBL_GNR_BEPCS->DATA; + VBL_BEGNR = (vbgnr_list *)VBL_GNR_BEGNR->DATA; + + VBL_GNR_BEINS = delchain( VBL_GNR_BEINS, VBL_GNR_BEINS ); + VBL_GNR_BEPCS = delchain( VBL_GNR_BEPCS, VBL_GNR_BEPCS ); + VBL_GNR_BEGNR = delchain( VBL_GNR_BEGNR, VBL_GNR_BEGNR ); + } + ; + +generation_scheme + : FOR + generate_parameter_specification + { + $$ = $2; + } + | IF + condition + { + $$ = $2; + } + ; + +generate_parameter_specification + : Identifier + _IN + discrete_range + { + vbl_name *Range; + + Range = (vbl_name *)autallocheap( sizeof( vbl_name ) ); + *Range = $3; + + $$.IDENT = $1; + $$.VEX = (vexexpr *)Range; + } + ; + +association_list + : association_element + ...association_element.. + {} + ; + +...association_element.. + : /*empty*/ + {} + | Comma + association_element + ...association_element.. + { + yyerrok; + } + ; + +association_element + : name + Arrow + { + VBL_SAVCOMPNAM = VBL_COMPNAM; + VBL_COMPNAM = (char *)0; + } + expression + { + vexexpr *Formal; + vexexpr *Actual; + + struct vbl_expr expr1; + struct vbl_expr expr_name; + char *LocalName; + char Buffer[ 40 ]; + long left; + long right; + long left_bnd; + long right_bnd; + long in_bound; + long out_bound; + unsigned char dynamic; + int mode; + int flag; + + VBL_COMPNAM = VBL_SAVCOMPNAM; + VBL_SAVCOMPNAM = (char *)0; + + flag = $1.FLAG; + + if ( ( flag != 0 ) && + ( flag != VBL_EVENT ) && + ( flag != VBL_STABLE ) ) + { + if ( ( flag != VBL_RANGE ) && + ( flag != VBL_REV_RANGE ) ) + { + sprintf( Buffer, "%ld", $1.LEFT ); + + expr1.IDENT = Buffer; + expr1.VEX = (vexexpr *)0; + expr1.TYPE = -1; + + expr_name = vbl_crtvex( NOPS, expr1, VBL_EMPSTR, -1, -1, 0); + } + else + { + my_vbl_error(124,$1.NAME); + } + } + else + if ( ( $1.NAME[0] == '"' ) || + ( $1.NAME[0] == '\'') ) + { + my_vbl_error(124,$1.NAME); + } + else + { + LocalName = VBL_COMPNAM; + mode = chktab (hshtab,$1.NAME,LocalName,VBL_SYMDFN); + + if( mode == 0 || mode == VBL_PRODFN ) + { + my_vbl_error (17,$1.NAME); + } + + /* LUDO_DYNAMIC */ + dynamic = chktab (hshtab,$1.NAME,LocalName,VBL_DYNDFN); + left_bnd = chktab (hshtab,$1.NAME,LocalName,VBL_WMNDFN); + right_bnd = chktab (hshtab,$1.NAME,LocalName,VBL_WMXDFN); + + if ( ( ! $1.DYNAMIC ) && + ( ! dynamic ) ) + { + left = $1.LEFT; + right = $1.RIGHT; + + if ( left_bnd <= right_bnd ) + { + if (left <= right) + { + in_bound = left - left_bnd; + out_bound = right - left_bnd; + if ((left < left_bnd) || (right > right_bnd)) + { + my_vbl_error (36,$1.NAME); + } + } + else + { + in_bound = right - left_bnd; + out_bound = left - left_bnd; + if ((left > right_bnd) || (right < left_bnd)) + { + my_vbl_error (36,$1.NAME); + } + } + } + else + { + if (left <= right) + { + in_bound = left - right_bnd; + out_bound = right - right_bnd; + if ((left < right_bnd) || (right > left_bnd)) + { + my_vbl_error (36,$1.NAME); + } + } + else + { + in_bound = right - right_bnd; + out_bound = left - right_bnd; + if ((left > left_bnd) || (right < right_bnd)) + { + my_vbl_error (36,$1.NAME); + } + } + } + } + else + { + left = $1.LEFT; + right = $1.RIGHT; + } + + { + int type; + + expr1.IDENT = $1.NAME; + type = chktab(hshtab,$1.NAME,LocalName,VBL_TYPDFN); + expr1.TYPE = type; + expr1.SIGNED = chktab (hshtab,$1.NAME,LocalName,VBL_SUNDFN); + + if ( $1.DYNAMIC ) + { + if ( ( mode == VBL_FUNDFN ) || + ( mode == VBL_TPEDFN ) || + ( mode == VBL_PRODFN ) ) + { + expr1.VEX = (vexexpr *)left; + expr1 = + vbl_crtvex(SUBVAR,expr1,VBL_EMPSTR,expr1.VEX->LEFT,expr1.VEX->RIGHT,0); + } + else + { + expr1 = vbl_crtvex (NOPI,expr1,VBL_EMPSTR,left_bnd,right_bnd,dynamic); + + if ( $1.DYNAMIC == VBL_UPTDFN ) + { + if ( ( ! dynamic ) || + ( ! isvexequalexpr( (vexexpr *)left_bnd, (vexexpr *)left ) ) || + ( ! isvexequalexpr( (vexexpr *)right_bnd, (vexexpr *)right ) ) ) + { + expr1 = vbl_crtvex( VEX_TO, expr1,VBL_EMPSTR,left,right,0); + } + } + else + if ( $1.DYNAMIC == VBL_DWTDFN ) + { + if ( ( ! dynamic ) || + ( ! isvexequalexpr( (vexexpr *)left_bnd, (vexexpr *)left ) ) || + ( ! isvexequalexpr( (vexexpr *)right_bnd, (vexexpr *)right ) ) ) + { + expr1 = vbl_crtvex( VEX_DOWNTO, expr1,VBL_EMPSTR,left,right,0); + } + } + else + { + expr1.VEX = + createvexbinexpr( VEX_INDEX_N, 1, expr1.VEX, (vexexpr *)left ); + expr1.VEX = + createvexbinexpr( VEX_INDEX_N, 1, expr1.VEX, (vexexpr *)right ); + } + } + } + else + { + expr1 = vbl_crtvex (NOPI,expr1,VBL_EMPSTR,left,right,0); + } + + if( flag == VBL_EVENT ) + { + expr_name = vbl_crtvex (VEX_EVENT,expr1,VBL_EMPSTR,left,right,0); + } + else + if( flag == VBL_STABLE ) + { + expr1 = vbl_crtvex(VEX_EVENT,expr1,VBL_EMPSTR,left,right,0); + expr_name = vbl_crtvex (VEX_NOT,expr1,VBL_EMPSTR,-1,-1,0); + } + else + { + expr_name = expr1; + } + } + } + + Formal = expr_name.VEX; + Actual = $4.VEX; + + VBL_BEMAP = vbh_addvbmap( VBL_BEMAP, Formal, Actual, VBL_LINNUM); + } + | /* actual_part */ + expression /* can be name also */ + { + vexexpr *Actual; + + Actual = $1.VEX; + + VBL_BEMAP = vbh_addvbmap( VBL_BEMAP, (vexexpr *)0, Actual, VBL_LINNUM); + } + ; + +...selected_name.. + : /*empty*/ + { } + | ...selected_name.. + Comma + selected_name + { } + ; + +/* 4.5 */ +component_declaration + : COMPONENT + Identifier + { + VBL_COMPNAM = $2; + VBL_BEFPNT->BEMOD = vbh_addvbmod( VBL_BEFPNT->BEMOD, VBL_COMPNAM, VBL_LINNUM ); + addtab(hshtab,$2,VBL_MODNAM,VBL_SYMDFN,VBL_COMDFN); + addtab(hshtab,$2,VBL_MODNAM,VBL_PNTDFN,(long)VBL_BEFPNT->BEMOD); + } + .GENERIC__local_generic_list. + .PORT__local_port_list. + END_ERR + COMPONENT + Semicolon_ERR + { VBL_COMPNAM = (char *)0; + VBL_BEFPNT->BEMOD->BEPOR = + (vbpor_list *)reverse( (chain_list *)VBL_BEFPNT->BEMOD->BEPOR ); + VBL_BEFPNT->BEMOD->BEGEN = + (vbgen_list *)reverse( (chain_list *)VBL_BEFPNT->BEMOD->BEGEN ); + } + + ; + +.PORT__local_port_list. + : /*empty*/ + | PORT + LeftParen + local_port_list + RightParen_ERR + Semicolon_ERR + { } + ; + +local_port_list + : local_port_element + ...local_port_element.. + { } + | error RightParen_ERR + { } + ; + + +...local_port_element.. + : /*empty*/ + | ...local_port_element.. + Semicolon_ERR + local_port_element + { } + ; + + +local_port_element + : .SIGNAL. + identifier_list + Colon + .local_port_mode. + type_mark + .constraint. + .signal_kind. + { + char *signame; + vbpor_list *VbPort; + vbtyp_list *VbType; + short Signed; + long Left; + long Right; + long AttrLeft; + long AttrRight; + + VbType = val_type( $5.NAME ); + + if ( $6.DYNAMIC ) /* LUDO_DYNAMIC */ + { + AttrLeft = $6.LEFT; + AttrRight = $6.RIGHT; + Left = AttrLeft; + Right = AttrRight; + } + else + if ( ( $6.LEFT == -1 ) && + ( $6.RIGHT == -1 ) ) + { + AttrLeft = VbType->LEFT; + AttrRight = VbType->RIGHT; + } + else + { + AttrLeft = $6.LEFT; + AttrRight = $6.RIGHT; + } + + VBL_NM1LST = reverse( VBL_NM1LST ); + + while (VBL_NM1LST != NULL) + { + signame = (char *)VBL_NM1LST->DATA; + if (chktab (hshtab,signame,VBL_COMPNAM,VBL_SYMDFN) != 0) + my_vbl_error (4,signame); + + VbPort = (vbpor_list *)vbl_addstr( 'M',$4, VbType, + $5.TYPE,$5.FLAG,signame, + AttrLeft, AttrRight, + (vexexpr *)0,VBH_KIND_NONE, $6.DYNAMIC); + + addtab (hshtab,signame,VBL_COMPNAM,VBL_SYMDFN,$4); + + Signed = ( IsVexNodeSigned( VbPort->TARGET ) != 0 ); + + if ( ( $5.FLAG == 'I' ) && ( $6.DYNAMIC ) ) + { + $6.DYNAMIC = VBL_DWTDFN; + } + + if ( ! $6.DYNAMIC ) /* LUDO_DYNAMIC */ + { + if ( IsVexAtomBit( VbPort->TARGET ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VbPort->TARGET->LEFT; + Right = VbPort->TARGET->RIGHT; + } + } + + addtab( hshtab,signame,VBL_COMPNAM,VBL_TYPDFN,$5.TYPE); + addtab( hshtab,signame,VBL_COMPNAM,VBL_WMNDFN,Left ); + addtab( hshtab,signame,VBL_COMPNAM,VBL_WMXDFN,Right ); + addtab( hshtab,signame,VBL_COMPNAM,VBL_ATLDFN,AttrLeft ); + addtab( hshtab,signame,VBL_COMPNAM,VBL_ATRDFN,AttrRight ); + addtab( hshtab,signame,VBL_COMPNAM,VBL_LBLDFN,VBH_KIND_NONE); + addtab( hshtab,signame,VBL_COMPNAM,VBL_PNTDFN,(long)VbPort->TARGET); + addtab( hshtab,signame,VBL_COMPNAM,VBL_SUNDFN,Signed); + addtab( hshtab,signame,VBL_COMPNAM,VBL_DYNDFN,$6.DYNAMIC); + + VBL_NM1LST = delchain (VBL_NM1LST, VBL_NM1LST); + } + } + ; + +.local_port_mode. + : /*empty*/ + { $$ = VBL_ICNDFN; } + | _IN + { $$ = VBL_ICNDFN; } + | _OUT + { $$ = VBL_OCNDFN; } + | _INOUT + { $$ = VBL_BCNDFN; } + | _BUFFER + { $$ = VBL_BCNDFN; } + | _LINKAGE + { $$ = VBL_BCNDFN; } + ; + +.GENERIC__local_generic_list. + : /*empty*/ + | GENERIC + LeftParen + local_generic_list + RightParen_ERR + Semicolon_ERR + { } + ; + +local_generic_list + : local_generic_element + ...local_generic_element.. + { } + | error RightParen_ERR + { } + ; + + +...local_generic_element.. + : /*empty*/ + { } + | ...local_generic_element.. + Semicolon_ERR + local_generic_element + { } + ; + + +local_generic_element + : .CONSTANT. + identifier_list + Colon + .IN. + type_mark + .constraint. + .VarAsgn__expression. + { + char *signame; + vbgen_list *VbGen; + vbtyp_list *VbType; + vexexpr *VexInit; + short Signed; + long Left; + long Right; + long AttrLeft; + long AttrRight; + + if ( $6.DYNAMIC ) + { + my_vbl_error (6,NULL); + } + + VbType = val_type( $5.NAME ); + + if ( ( $6.LEFT == -1 ) && + ( $6.RIGHT == -1 ) ) + { + AttrLeft = VbType->LEFT; + AttrRight = VbType->RIGHT; + } + else + { + AttrLeft = $6.LEFT; + AttrRight = $6.RIGHT; + } + + VBL_NM1LST = reverse( VBL_NM1LST ); + + while (VBL_NM1LST != NULL) + { + VexInit = $7.VEX; + + if ( ( VexInit != (vexexpr *)0 ) && + ( VBL_NM1LST->NEXT != (chain_list *)0 ) ) + { + VexInit = dupvexexpr( $7.VEX ); + } + + signame = (char *)VBL_NM1LST->DATA; + if (chktab (hshtab,signame,VBL_COMPNAM,VBL_SYMDFN) != 0) + my_vbl_error (4,signame); + + VexInit = simpvexexpr( VexInit ); + + VbGen = (vbgen_list *)vbl_addstr( 'g',0, VbType, + $5.TYPE,$5.FLAG,signame, + AttrLeft, AttrRight,VexInit,VBH_KIND_NONE, 0); + + addtab (hshtab,signame,VBL_COMPNAM,VBL_SYMDFN,VBL_GENDFN); + + Signed = ( IsVexNodeSigned( VbGen->TARGET ) != 0 ); + + if ( IsVexAtomBit( VbGen->TARGET ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VbGen->TARGET->LEFT; + Right = VbGen->TARGET->RIGHT; + } + + addtab( hshtab,signame,VBL_COMPNAM,VBL_TYPDFN,$5.TYPE); + addtab( hshtab,signame,VBL_COMPNAM,VBL_WMNDFN,Left ); + addtab( hshtab,signame,VBL_COMPNAM,VBL_WMXDFN,Right ); + addtab( hshtab,signame,VBL_COMPNAM,VBL_ATLDFN,AttrLeft ); + addtab( hshtab,signame,VBL_COMPNAM,VBL_ATRDFN,AttrRight ); + addtab( hshtab,signame,VBL_COMPNAM,VBL_LBLDFN,VBH_KIND_NONE); + addtab( hshtab,signame,VBL_COMPNAM,VBL_PNTDFN,(long)VbGen->TARGET); + addtab( hshtab,signame,VBL_COMPNAM,VBL_SUNDFN,Signed); + + VBL_NM1LST = delchain (VBL_NM1LST, VBL_NM1LST); + } + } + ; + +/* 4.4 */ +attribute_declaration + : ATTRIBUTE + Identifier + Colon + simple_name + Semicolon_ERR + { + if ( strcmp( $4, "string" ) ) + { + my_vbl_error(9, $2 ); + } + + addtab(hshtab,$2,VBL_MODNAM,VBL_SYMDFN,VBL_ATTDFN); + } + ; + +attribute_specification + : ATTRIBUTE + simple_name + { + if ( ! chktab(hshtab,$2,VBL_MODNAM,VBL_SYMDFN ) ) + { + my_vbl_error(9,$2); + } + } + OF + simple_name + Colon + entity_class + IS + StringLit + Semicolon_ERR + { + char Buffer[ 512 ]; + int length; + + length = strlen( $9 ); + + strcpy( Buffer, $9 + 1); + Buffer[ length -2 ] = '\0'; + + $9 = namealloc( Buffer ); + + VBL_BEFPNT->BEATR = vbh_addvbatr( VBL_BEFPNT->BEATR, $2, $5, $7, $9, VBL_LINNUM ); + } + ; + +entity_class + : _ENTITY + { $$ = VBH_ATTR_ENTITY; } + | ARCHITECTURE + { $$ = VBH_ATTR_ARCHITECTURE; } + | _PACKAGE + { $$ = VBH_ATTR_PACKAGE; } + | FUNCTION + { $$ = VBH_ATTR_FUNCTION; } + | PROCEDURE + { $$ = VBH_ATTR_PROCEDURE; } + | SUBTYPE + { $$ = VBH_ATTR_SUBTYPE; } + | CONSTANT + { $$ = VBH_ATTR_CONSTANT; } + | _VARIABLE + { $$ = VBH_ATTR_VARIABLE; } + | SIGNAL + { $$ = VBH_ATTR_SIGNAL; } + | _LABEL + { $$ = VBH_ATTR_LABEL; } + | _TYPE + { $$ = VBH_ATTR_TYPE; } + | CONFIGURATION + { $$ = VBH_ATTR_CONFIGURATION; } + | COMPONENT + { $$ = VBH_ATTR_COMPONENT; } + ; + +selected_name + : prefix + Dot + suffix + { char buffer[ 128 ]; sprintf( buffer, "%s.%s", $1, $3 ); + $$ = namealloc( buffer ); + VBL_NM2LST = addchain( VBL_NM2LST, $$ ); + } + ; + +suffix + : simple_name + { $$ = $1; } + | ALL + { $$ = namealloc( "all" ); } + ; +prefix + : simple_name + { $$ = $1; } + | prefix + Dot + simple_name + { char buffer[ 128 ]; sprintf( buffer, "%s.%s", $1, $3 ); + $$ = namealloc( buffer ); } + ; + +entity_declaration + : _ENTITY + simple_name + IS + { + vbfig_list *ScanPkgFig; + chain_list *ScanChain; + char *Name; + char **FuncArray; + int Index; + long Left; + long Right; + long AttrLeft; + long AttrRight; + long Dir; + int Signed; + vbcst_list *VbhCst; + vbaux_list *VbhAux; + vbmod_list *VbhMod; + vbpor_list *VbhPor; + vbgen_list *VbhGen; + vbtyp_list *VbhType; + vbpcs_list *VbhPcs; + vexexpr *VexAtom; + chain_list *PackList; + long Dynamic; + long Oper; + + extern char *vbl_func_std_logic_1164[]; + extern char *vbl_func_std_logic_arith[]; + extern char *vbl_func_std_numeric_std[]; + + int size=0; + struct vbtyp *vbtyp_pnt; + VBL_BEFPNT->NAME = $2; + VBL_MODNAM = $2; + + for ( ScanChain = VBL_NM2LST; + ScanChain != (chain_list *)0; + ScanChain = ScanChain->NEXT ) + { + FuncArray = (char **)0; + + if ( ! strcmp( ScanChain->DATA, "ieee.std_logic_1164.all" ) ) + { + FuncArray = vbl_func_std_logic_1164; + } + else + if ( ( ! strcmp( ScanChain->DATA, "ieee.std_logic_arith.all" ) ) || + ( ! strcmp( ScanChain->DATA, "ieee.std_logic_signed.all" ) ) || + ( ! strcmp( ScanChain->DATA, "ieee.std_logic_unsigned.all" ) ) ) + { + FuncArray = vbl_func_std_logic_arith; + } + else + if ( ( ! strcmp( ScanChain->DATA, "ieee.numeric_std.all" ) ) || + ( ! strcmp( ScanChain->DATA, "ieee.numeric_bit.all" ) ) ) + { + FuncArray = vbl_func_std_numeric_std; + } + else + { + for ( ScanPkgFig = VBL_HEADFIG; + ScanPkgFig != (vbfig_list *)0; + ScanPkgFig = ScanPkgFig->NEXT ) + { + if ( ( ScanPkgFig->PACKAGE ) && + ( ScanPkgFig->NAME == (char *)ScanChain->DATA ) ) + { + for ( PackList = VBL_BEFPNT->PACK_LIST; + PackList != (chain_list *)0; + PackList = PackList->NEXT ) + { + if ( PackList->DATA == ScanChain->DATA ) break; /* already included */ + } + + if ( PackList == (chain_list *)0 ) + { + vbh_dupvbfig( VBL_BEFPNT, ScanPkgFig ); + } + + /* BECST */ + + for ( VbhCst = ScanPkgFig->BECST; + VbhCst != (vbcst_list *)0; + VbhCst = VbhCst->NEXT ) + { + VbhType = vbh_getvbtyp( VBL_BEFPNT, VbhCst->TYPE->NAME ); + VexAtom = VbhCst->TARGET; + + if ( ! IsVexNodeAtom( VexAtom ) ) + { + my_fprintf( stdout, "dynamic declaration not supported !\n" ); + autexit( 1 ); + } + + Name = GetVexAtomValue( VexAtom ); + + /* + if ( chktab( hshtab, Name, VBL_MODNAM, VBL_SYMDFN ) ) + { + my_vbl_error( 10, Name ); + } + */ + + if ( IsVexAtomBit( VexAtom ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VexAtom->LEFT; + Right = VexAtom->RIGHT; + } + + Signed = ( IsVexNodeSigned( VexAtom ) != 0 ); + AttrLeft = Left; + AttrRight = Right; + + addtab( hshtab, Name, VBL_MODNAM, VBL_SYMDFN, VBL_CSTDFN ); + addtab( hshtab, Name, VBL_MODNAM, VBL_TYPDFN, VbhType->INDEX ); + addtab( hshtab, Name, VBL_MODNAM, VBL_WMNDFN, Left ); + addtab( hshtab, Name, VBL_MODNAM, VBL_WMXDFN, Right ); + addtab( hshtab, Name, VBL_MODNAM, VBL_ATLDFN, AttrLeft ); + addtab( hshtab, Name, VBL_MODNAM, VBL_ATRDFN, AttrRight ); + addtab( hshtab, Name, VBL_MODNAM, VBL_LBLDFN, 0 ); + addtab( hshtab, Name, VBL_MODNAM, VBL_PNTDFN, (long)VbhCst->VEX ); + addtab( hshtab, Name, VBL_MODNAM, VBL_SUNDFN, Signed ); + addtab( hshtab, Name, VBL_MODNAM, VBL_DYNDFN, 0 ); + } + + /* BEAUX */ + + for ( VbhAux = ScanPkgFig->BEAUX; + VbhAux != (vbaux_list *)0; + VbhAux = VbhAux->NEXT ) + { + VbhType = vbh_getvbtyp( VBL_BEFPNT, VbhAux->TYPE->NAME ); + VexAtom = VbhAux->TARGET; + + if ( ! IsVexNodeAtom( VexAtom ) ) + { + my_fprintf( stdout, "dynamic declaration not supported !\n" ); + autexit( 1 ); + } + + Name = GetVexAtomValue( VexAtom ); + + /* + if ( chktab( hshtab, Name, VBL_MODNAM, VBL_SYMDFN ) ) + { + my_vbl_error( 10, Name ); + } + */ + + Signed = (IsVexNodeSigned( VexAtom ) != 0); + Left = VexAtom->LEFT; + Right = VexAtom->RIGHT; + AttrLeft = Left; + AttrRight = Right; + + addtab( hshtab, Name, VBL_MODNAM, VBL_SYMDFN, VBL_SGNDFN ); + addtab( hshtab, Name, VBL_MODNAM, VBL_TYPDFN, VbhType->INDEX ); + addtab( hshtab, Name, VBL_MODNAM, VBL_WMNDFN, Left ); + addtab( hshtab, Name, VBL_MODNAM, VBL_WMXDFN, Right ); + addtab( hshtab, Name, VBL_MODNAM, VBL_ATLDFN, AttrLeft ); + addtab( hshtab, Name, VBL_MODNAM, VBL_ATRDFN, AttrRight ); + addtab( hshtab, Name, VBL_MODNAM, VBL_LBLDFN, VbhAux->KIND ); + addtab( hshtab, Name, VBL_MODNAM, VBL_PNTDFN, (long)VexAtom ); + addtab( hshtab, Name, VBL_MODNAM, VBL_SUNDFN, Signed ); + addtab( hshtab, Name, VBL_MODNAM, VBL_DYNDFN, 0 ); + } + + /* BEPCS */ + + for ( VbhPcs = ScanPkgFig->BEPCS; + VbhPcs != (vbpcs_list *)0; + VbhPcs = VbhPcs->NEXT ) + { + addtab( hshtab, VbhPcs->LABEL, VBL_MODNAM, VBL_SYMDFN, VBL_LBLDFN ); + } + + /* BEFUN TO BE DONE */ + + if ( ScanPkgFig->BEFUN != (vbfun_list *)0 ) + { + my_fprintf( stdout, "function in package not supported !\n" ); + autexit( 1 ); + } + + /* BEATR TO BE DONE */ + + if ( ScanPkgFig->BEATR != (vbatr_list *)0 ) + { + my_fprintf( stdout, "attribute in package not supported !\n" ); + autexit( 1 ); + } + + /* BEGNR TO BE DONE ??? */ + + if ( ScanPkgFig->BEGNR != (vbgnr_list *)0 ) + { + my_fprintf( stdout, "generate in package not supported !\n" ); + autexit( 1 ); + } + + /* BEMOD */ + + for ( VbhMod = ScanPkgFig->BEMOD; + VbhMod != (vbmod_list *)0; + VbhMod = VbhMod->NEXT ) + { + addtab(hshtab,VbhMod->NAME,VBL_MODNAM,VBL_SYMDFN,VBL_COMDFN); + addtab(hshtab,VbhMod->NAME,VBL_MODNAM,VBL_PNTDFN,(long)VbhMod); + + for ( VbhGen = VbhMod->BEGEN; + VbhGen != (vbgen_list *)0; + VbhGen = VbhGen->NEXT ) + { + VbhType = vbh_getvbtyp( VBL_BEFPNT, VbhGen->TYPE->NAME ); + VexAtom = VbhGen->TARGET; + + if ( ! IsVexNodeAtom( VexAtom ) ) + { + my_fprintf( stdout, "dynamic declaration not supported !\n" ); + autexit( 1 ); + } + + Name = GetVexAtomValue( VexAtom ); + + /* + if ( chktab( hshtab, Name, VBL_MODNAM, VBL_SYMDFN ) ) + { + my_vbl_error( 10, Name ); + } + */ + + Signed = (IsVexNodeSigned( VexAtom ) != 0); + Left = VexAtom->LEFT; + Right = VexAtom->RIGHT; + AttrLeft = Left; + AttrRight = Right; + + addtab( hshtab, Name, VbhMod->NAME, VBL_SYMDFN, VBL_GENDFN ); + addtab( hshtab, Name, VbhMod->NAME, VBL_TYPDFN, VbhType->INDEX ); + addtab( hshtab, Name, VbhMod->NAME, VBL_WMNDFN, Left ); + addtab( hshtab, Name, VbhMod->NAME, VBL_WMXDFN, Right ); + addtab( hshtab, Name, VbhMod->NAME, VBL_ATLDFN, AttrLeft ); + addtab( hshtab, Name, VbhMod->NAME, VBL_ATRDFN, AttrRight ); + addtab( hshtab, Name, VbhMod->NAME, VBL_LBLDFN, VBH_KIND_NONE ); + addtab( hshtab, Name, VbhMod->NAME, VBL_PNTDFN, (long)VexAtom ); + addtab( hshtab, Name, VbhMod->NAME, VBL_SUNDFN, Signed ); + addtab( hshtab, Name, VbhMod->NAME, VBL_DYNDFN, 0 ); + } + + for ( VbhPor = VbhMod->BEPOR; + VbhPor != (vbpor_list *)0; + VbhPor = VbhPor->NEXT ) + { + VbhType = vbh_getvbtyp( VBL_BEFPNT, VbhPor->TYPE->NAME ); + VexAtom = VbhPor->TARGET; + + if ( ! IsVexNodeAtom( VexAtom ) ) + { + Name = getvexatomname( VexAtom ); + Dynamic = 0; + + if ( IsVexNodeOper( VexAtom ) ) + { + Oper = GetVexOperValue( VexAtom ); + + if ( Oper == VEX_DOWNTO ) Dynamic = VBL_DWTDFN; + else + if ( Oper == VEX_TO ) Dynamic = VBL_UPTDFN; + + Signed = (IsVexNodeSigned( VexAtom ) != 0); + Left = (long)GetVexOperand( VexAtom->OPERAND->NEXT ); + Right = (long)GetVexOperand( VexAtom->OPERAND->NEXT->NEXT ); + AttrLeft = Left; + AttrRight = Right; + } + + if ( ! Dynamic ) + { + my_fprintf( stdout, "such dynamic declaration not supported !\n" ); + autexit( 1 ); + } + } + else + { + Name = GetVexAtomValue( VexAtom ); + + Signed = (IsVexNodeSigned( VexAtom ) != 0); + Left = VexAtom->LEFT; + Right = VexAtom->RIGHT; + AttrLeft = Left; + AttrRight = Right; + Dynamic = 0; + } + + /* + if ( chktab( hshtab, Name, VBL_MODNAM, VBL_SYMDFN ) ) + { + my_vbl_error( 10, Name ); + } + */ + + if ( VbhPor->DIR == 'I' ) Dir = VBL_ICNDFN; + else + if ( VbhPor->DIR == 'O' ) Dir = VBL_OCNDFN; + else Dir = VBL_BCNDFN; + + addtab( hshtab, Name, VbhMod->NAME, VBL_SYMDFN, Dir ); + addtab( hshtab, Name, VbhMod->NAME, VBL_TYPDFN, VbhType->INDEX ); + addtab( hshtab, Name, VbhMod->NAME, VBL_WMNDFN, Left ); + addtab( hshtab, Name, VbhMod->NAME, VBL_WMXDFN, Right ); + addtab( hshtab, Name, VbhMod->NAME, VBL_ATLDFN, AttrLeft ); + addtab( hshtab, Name, VbhMod->NAME, VBL_ATRDFN, AttrRight ); + addtab( hshtab, Name, VbhMod->NAME, VBL_LBLDFN, VbhPor->KIND ); + addtab( hshtab, Name, VbhMod->NAME, VBL_PNTDFN, (long)VexAtom ); + addtab( hshtab, Name, VbhMod->NAME, VBL_SUNDFN, Signed ); + addtab( hshtab, Name, VbhMod->NAME, VBL_DYNDFN, Dynamic ); + } + } + + /* BEINS */ + + if ( ScanPkgFig->BEINS != (vbins_list *)0 ) + { + my_fprintf( stdout, "instance in package not supported !\n" ); + autexit( 1 ); + } + + break; + } + } + + if ( ScanPkgFig == (vbfig_list *)0 ) + { + my_vbl_error(127,(char *)ScanChain->DATA); + } + } + + if ( FuncArray != (char **)0 ) + { + Index = 0; + + while ( FuncArray[ Index ] != NULL ) + { + Name = namealloc( FuncArray[ Index ] ); + addtab ( hshtab, Name, VBL_MODNAM, VBL_SYMDFN, VBL_FUNDFN ); + Index++; + } + } + } + + freechain( VBL_NM2LST ); + VBL_NM2LST = NULL; + + vbtyp_pnt = VBL_BEFPNT->BETYP; + while(vbtyp_pnt) + { + size++; + vbtyp_pnt = vbtyp_pnt->NEXT; + } + + vbtyp_pnt = VBL_BEFPNT->BETYP; + VBL_NUMTYP = 0; + while(vbtyp_pnt) + { + addtab(hshtab,vbtyp_pnt->NAME,VBL_MODNAM,VBL_SYMDFN,VBL_TPEDFN); + addtab(hshtab,vbtyp_pnt->NAME,VBL_MODNAM,VBL_LBLDFN,vbtyp_pnt->CLASS); + addtab(hshtab,vbtyp_pnt->NAME,VBL_MODNAM,VBL_TYPDFN,vbtyp_pnt->INDEX); + addtab(hshtab,vbtyp_pnt->NAME,VBL_MODNAM,VBL_WMNDFN,vbtyp_pnt->LEFT); + addtab(hshtab,vbtyp_pnt->NAME,VBL_MODNAM,VBL_WMXDFN,vbtyp_pnt->RIGHT); + addtab(hshtab,vbtyp_pnt->NAME,VBL_MODNAM,VBL_PNTDFN,(long)vbtyp_pnt); + vbtyp_pnt = vbtyp_pnt->NEXT; + VBL_NUMTYP++; + } + + } + .generic_clause. + .port_clause. + END_ERR + .simple_name. + Semicolon_ERR + { + if (($8 != NULL) && ($8 != $2)) my_vbl_error (1,$8); + } + | _ENTITY + error + { my_vbl_error (2,NULL); } + ; + +.constraint. + : /*empty*/ + { + $$.FLAG = 'U'; + $$.LEFT = -1; + $$.RIGHT = -1; + $$.DYNAMIC = 0; + $$.AGGREG = 0; + } + | constraint + { + $$ = $1; + } + ; + +constraint + : range_constraint + { + $$ = $1; + } + | + LeftParen + range + RightParen_ERR + { + $$ = $2; + } + ; + +range_constraint + : _RANGE + range + { $$ = $2; } + ; + +range + : attribute_name + { + if ( ( $1.FLAG != VBL_RANGE ) && + ( $1.FLAG != VBL_REV_RANGE ) ) + { + my_vbl_error (32,NULL); + } + + $$ = $1; + } + | simple_expression + direction + simple_expression + { + long Left; + long Right; + int ErrorL; + int ErrorR; + + ErrorL = vbl_vextonum( $1.VEX, &Left ); + ErrorR = vbl_vextonum( $3.VEX, &Right ); + + $$.NAME = NULL; + $$.TYPE = $1.TYPE; + $$.SIGNED = 0; + $$.FLAG = 'A'; + + if ( ( ! ErrorL ) && ( ! ErrorR ) ) + { + if (((Left > Right) && ($2 == VBL_UPTDFN)) || + ((Left < Right) && ($2 == VBL_DWTDFN))) + { + my_vbl_error (32,NULL); + } + + $$.LEFT = Left; + $$.RIGHT = Right; + $$.DYNAMIC = 0; + $$.AGGREG = 0; + } + else + { + $$.LEFT = (long)$1.VEX; + $$.RIGHT = (long)$3.VEX; + $$.DYNAMIC = $2; + $$.AGGREG = 0; + } + } + ; + +direction + : TO + { $$ = VBL_UPTDFN; } + | DOWNTO + { $$ = VBL_DWTDFN; } + ; + +.generic_clause. + : /*empty*/ + | generic_clause + {} + ; + +generic_clause + : GENERIC + LeftParen + formal_generic_list + RightParen_ERR + Semicolon_ERR + {} + ; + +.port_clause. + : /*empty*/ + | port_clause + ; + +port_clause + : PORT + LeftParen + formal_port_list + RightParen_ERR + Semicolon_ERR {} + | PORT + error + Semicolon_ERR + { my_vbl_error (3,NULL); } + ; + +formal_port_list + : formal_port_element + ...formal_port_element.. + {} + ; + +...formal_port_element.. + : /*empty*/ + | ...formal_port_element.. + Semicolon_ERR + formal_port_element + {} + ; + +formal_port_element + : .SIGNAL. + identifier_list + Colon + .mode. + type_mark + .constraint. + .signal_kind. + .VarAsgn__expression. + { + char *signame; + vbpor_list *VbPort; + vbtyp_list *VbType; + vexexpr *VexInit; + char buffer[ 40 ]; + short Signed; + long Left; + long Right; + long AttrLeft; + long AttrRight; + struct vbl_expr expr1; + + /* ###----------------------------------------------### */ + /* First, check the validity of the declaration. */ + /* Then, for each port, create the apropriate set of */ + /* structures (vbrin, vbpor, vbout, vbbus) */ + /* ###----------------------------------------------### */ + + VbType = val_type( $5.NAME ); + + if ( $6.DYNAMIC ) /* LUDO_DYNAMIC */ + { + AttrLeft = $6.LEFT; + AttrRight = $6.RIGHT; + Left = AttrLeft; + Right = AttrRight; + } + else + if ( ( $6.LEFT == -1 ) && + ( $6.RIGHT == -1 ) ) + { + AttrLeft = VbType->LEFT; + AttrRight = VbType->RIGHT; + } + else + { + AttrLeft = $6.LEFT; + AttrRight = $6.RIGHT; + } + + VBL_NM1LST = reverse (VBL_NM1LST); + + if ( ! $6.DYNAMIC ) /* LUDO_DYNAMIC */ + { + if ( $8.VEX == (vexexpr *)0 ) + { + if ( VbType->CLASS == 'I' ) + { + sprintf( buffer, "%ld", AttrLeft ); + expr1.IDENT = buffer; + expr1.TYPE = -1; + expr1.VEX = (vexexpr *)0; + expr1 = vbl_crtvex( NOPS, expr1,VBL_EMPSTR,-1,-1,0); + + $8.VEX = expr1.VEX; + } + } + } + + while (VBL_NM1LST != NULL) + { + VexInit = $8.VEX; + + if ( ( VexInit != (vexexpr *)0 ) && + ( VBL_NM1LST->NEXT != (chain_list *)0 ) ) + { + VexInit = dupvexexpr( $8.VEX ); + } + + signame = (char *)VBL_NM1LST->DATA; + if (chktab (hshtab,signame,VBL_MODNAM,VBL_SYMDFN) != 0) + my_vbl_error (4,signame); + + VbPort = (vbpor_list *)vbl_addstr( 'P',$4, VbType, + $5.TYPE,$5.FLAG,signame, + AttrLeft, AttrRight,VexInit,$7, $6.DYNAMIC); + + addtab (hshtab,signame,VBL_MODNAM,VBL_SYMDFN,$4); + + Signed = ( IsVexNodeSigned( VbPort->TARGET ) != 0 ); + + if ( ! $6.DYNAMIC ) /* LUDO_DYNAMIC */ + { + if ( IsVexAtomBit( VbPort->TARGET ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VbPort->TARGET->LEFT; + Right = VbPort->TARGET->RIGHT; + } + } + + addtab( hshtab,signame,VBL_MODNAM,VBL_TYPDFN,$5.TYPE); + addtab( hshtab,signame,VBL_MODNAM,VBL_WMNDFN,Left ); + addtab( hshtab,signame,VBL_MODNAM,VBL_WMXDFN,Right ); + addtab( hshtab,signame,VBL_MODNAM,VBL_ATLDFN,AttrLeft ); + addtab( hshtab,signame,VBL_MODNAM,VBL_ATRDFN,AttrRight ); + addtab( hshtab,signame,VBL_MODNAM,VBL_LBLDFN,$7); + addtab( hshtab,signame,VBL_MODNAM,VBL_PNTDFN,(long)VbPort->TARGET); + addtab( hshtab,signame,VBL_MODNAM,VBL_SUNDFN,Signed); + addtab( hshtab,signame,VBL_MODNAM,VBL_DYNDFN,$6.DYNAMIC); + + VBL_NM1LST = delchain (VBL_NM1LST, VBL_NM1LST); + } + } + | error + { + my_vbl_error (6,NULL); + } + ; + +/* 1.1.1.1 */ +formal_generic_list + : formal_generic_element + ...formal_generic_element.. + {} + | error RightParen_ERR + {} + ; + + +...formal_generic_element.. + : /*empty*/ + | ...formal_generic_element.. + Semicolon_ERR + formal_generic_element + { + } + ; + +formal_generic_element + : .CONSTANT. + identifier_list + Colon + .IN. + type_mark + .constraint. + .VarAsgn__expression. + { + char *signame; + char *Value; + vbgen_list *VbGen; + vbmap_list *VbMap; + vbtyp_list *VbType; + vexexpr *VexInit; + char buffer[ 40 ]; + short Signed; + long Left; + long Right; + long AttrLeft; + long AttrRight; + struct vbl_expr expr1; + + /* ###----------------------------------------------### */ + /* First, check the validity of the declaration. */ + /* Then, for each port, create the apropriate set of */ + /* structures (vbrin, vbgen, vbout, vbbus) */ + /* ###----------------------------------------------### */ + + if ( $6.DYNAMIC ) + { + my_vbl_error (126,NULL); + } + + VbType = val_type( $5.NAME ); + + if ( ( $6.LEFT == -1 ) && + ( $6.RIGHT == -1 ) ) + { + AttrLeft = VbType->LEFT; + AttrRight = VbType->RIGHT; + } + else + { + AttrLeft = $6.LEFT; + AttrRight = $6.RIGHT; + } + + VBL_NM1LST = reverse (VBL_NM1LST); + + if ( $7.VEX == (vexexpr *)0 ) + { + if ( VbType->CLASS == 'I' ) + { + sprintf( buffer, "%ld", AttrLeft ); + expr1.IDENT = buffer; + expr1.TYPE = -1; + expr1.VEX = (vexexpr *)0; + expr1 = vbl_crtvex( NOPS, expr1,VBL_EMPSTR,-1,-1,0); + + $7.VEX = expr1.VEX; + } + } + + while (VBL_NM1LST != NULL) + { + VexInit = $7.VEX; + + if ( ( VexInit != (vexexpr *)0 ) && + ( VBL_NM1LST->NEXT != (chain_list *)0 ) ) + { + VexInit = dupvexexpr( $7.VEX ); + } + + signame = (char *)VBL_NM1LST->DATA; + if (chktab (hshtab,signame,VBL_MODNAM,VBL_SYMDFN) != 0) + my_vbl_error (4,signame); + + for ( VbMap = VBL_GENMAP; + VbMap != (vbmap_list *)0; + VbMap = VbMap->NEXT ) + { + Value = GetVexAtomValue( VbMap->FORMAL ); + + if ( Value == signame ) + { + VexInit = dupvexexpr( VbMap->ACTUAL ); + + break; + } + } + + VbGen = (vbgen_list *)vbl_addstr( 'G',0, VbType, + $5.TYPE,$5.FLAG,signame, + AttrLeft, + AttrRight,VexInit,VBH_KIND_NONE, 0); + + addtab (hshtab,signame,VBL_MODNAM,VBL_SYMDFN,VBL_GENDFN); + + Signed = ( IsVexNodeSigned( VbGen->TARGET ) != 0 ); + + if ( IsVexAtomBit( VbGen->TARGET ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VbGen->TARGET->LEFT; + Right = VbGen->TARGET->RIGHT; + } + + addtab( hshtab,signame,VBL_MODNAM,VBL_TYPDFN,$5.TYPE); + addtab( hshtab,signame,VBL_MODNAM,VBL_WMNDFN,Left ); + addtab( hshtab,signame,VBL_MODNAM,VBL_WMXDFN,Right ); + addtab( hshtab,signame,VBL_MODNAM,VBL_ATLDFN,AttrLeft ); + addtab( hshtab,signame,VBL_MODNAM,VBL_LBLDFN,VBH_KIND_NONE); + addtab( hshtab,signame,VBL_MODNAM,VBL_ATRDFN,AttrRight ); + addtab( hshtab,signame,VBL_MODNAM,VBL_PNTDFN,(long)VbGen->TARGET); + addtab( hshtab,signame,VBL_MODNAM,VBL_SUNDFN,Signed); + + VBL_NM1LST = delchain (VBL_NM1LST, VBL_NM1LST); + } + } + ; + + +.SIGNAL. + : /*empty*/ + | SIGNAL + {} + ; + +.CONSTANT. + : /*empty*/ + | CONSTANT + {} + ; + +.IN. + : /*empty*/ + | _IN + {} + ; + +.mode. + : /*empty*/ + { $$ = VBL_ICNDFN; } + | _IN + { $$ = VBL_ICNDFN; } + | _OUT + { $$ = VBL_OCNDFN; } + | _INOUT + { $$ = VBL_BCNDFN; } + ; + +architecture_body + : ARCHITECTURE + Identifier + OF + simple_name + IS + { + if ($4 != VBL_MODNAM) my_vbl_error (1,$4); + } + architecture_declarative_part + _BEGIN + architecture_statement_part + END_ERR + .simple_name. + Semicolon_ERR + { + if (($11 != NULL) && ($11 != $2)) my_vbl_error (7,$11); + } + | ARCHITECTURE + error + { my_vbl_error (8,NULL); } + ; + +architecture_declarative_part + : ..block_declarative_item.. + ; + +..block_declarative_item.. + : /*empty*/ + | ..block_declarative_item.. + block_declarative_item + ; + +block_declarative_item + : constant_declaration + | signal_declaration + | type_declaration + | variable_declaration + | subtype_declaration + | attribute_declaration + | attribute_specification + | component_declaration + | subprogram_declaration + | subprogram_body + | error + Semicolon_ERR + { my_vbl_error (9,NULL); } + ; + +designator + : Identifier + { $$ = $1; } + ; + +.procedure_parameter_list. + : /*empty*/ + | LeftParen + procedure_parameter_element + ...procedure_parameter_element.. + RightParen_ERR + { } + | LeftParen + error + RightParen_ERR + { } + ; + + +...procedure_parameter_element.. + : /*empty*/ + | ...procedure_parameter_element.. + Semicolon_ERR + procedure_parameter_element + ; + +procedure_parameter_element + : .procedure_parameter_object_class. + identifier_list + Colon + .procedure_parameter_mode. + type_mark + .constraint. + { + char *signame; + char *codedsigname; + char buffer[ 128 ]; + vbtyp_list *TypeEnum; + int EnumSize; + vbarg_list *VbPar; + short Signed; + long Left; + long Right; + long AttrLeft; + long AttrRight; + + if ( $6.DYNAMIC ) + { + my_vbl_error(86,0); + } + + if ( $1 == VBH_CLASS_NONE ) + { + if ( $4 == VBL_ICNDFN ) $1 = VBH_CLASS_CONSTANT; + else $1 = VBH_CLASS_VARIABLE; + } + + TypeEnum = val_type( $5.NAME ); + EnumSize = vbl_codeSize( TypeEnum->SIZE - 1 ); + + if ( ( $6.LEFT == -1 ) && + ( $6.RIGHT == -1 ) ) + { + AttrLeft = TypeEnum->LEFT; + AttrRight = TypeEnum->RIGHT; + } + else + { + AttrLeft = $6.LEFT; + AttrRight = $6.RIGHT; + } + + if (chktab( hshtab,VBL_FUNCNAM,VBL_MODNAM,VBL_SYMDFN ) == 0) + { + VBL_NM1LST = reverse( VBL_NM1LST ); + while (VBL_NM1LST != NULL) + { + if ( ( TypeEnum->CLASS == 'E' ) && + ( TypeEnum->INDEX >= VBH_MAX_TYPE ) ) + { + signame = (char *)VBL_NM1LST->DATA; + + if (chktab (hshtab,signame,VBL_FUNCNAM,VBL_SYMDFN) != 0) + my_vbl_error (80,signame); + + sprintf (buffer, "%s.cod.%s", VBL_FUNCNAM, signame); + codedsigname = namealloc ( buffer ); + + if (chktab (hshtab,codedsigname,VBL_FUNCNAM,VBL_SYMDFN) != 0) + my_vbl_error (80,codedsigname); +/*\ + VbPar = (vbarg_list *)vbl_addstr( 'p',$4,val_type($5.NAME),$5.TYPE, + $5.FLAG,codedsigname, AttrLeft,AttrRight,NULL,$1, 0); + + Signed = ( IsVexNodeSigned( VbPar->TARGET ) != 0 ); + + if ( IsVexAtomBit( VbPar->TARGET ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VbPar->TARGET->LEFT; + Right = VbPar->TARGET->RIGHT; + } +\*/ + addtab(hshtab,codedsigname,VBL_FUNCNAM,VBL_SYMDFN,VBL_PARDFN); + addtab(hshtab,codedsigname,VBL_FUNCNAM,VBL_TYPDFN,$5.TYPE); + addtab(hshtab,codedsigname,VBL_FUNCNAM,VBL_WMNDFN,-1); + addtab(hshtab,codedsigname,VBL_FUNCNAM,VBL_WMXDFN,-1); + addtab(hshtab,codedsigname,VBL_FUNCNAM,VBL_LBLDFN,0); + addtab(hshtab,codedsigname,VBL_FUNCNAM,VBL_PNTDFN,0); + addtab(hshtab,codedsigname,VBL_FUNCNAM,VBL_SUNDFN,0 ); + + if ( EnumSize > 1 ) + { + VbPar = (vbarg_list *)vbl_addstr( 'p',$4, + get_type(VBH_TYPE_BIT_VECTOR), VBH_TYPE_BIT_VECTOR, + 'U',signame, 0,EnumSize-1,NULL,$1, 0); + + Signed = ( IsVexNodeSigned( VbPar->TARGET ) != 0 ); + + addtab (hshtab,signame,VBL_FUNCNAM,VBL_SYMDFN,VBL_PARDFN); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_TYPDFN,VBH_TYPE_BIT_VECTOR); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_WMNDFN,0); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_WMXDFN,EnumSize-1); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_ATLDFN,0); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_ATRDFN,EnumSize-1); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_LBLDFN,0); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_PNTDFN,(long)VbPar->TARGET); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_SUNDFN,Signed); + } + else + { + VbPar = (vbarg_list *)vbl_addstr( 'p',$4, + get_type(VBH_TYPE_BIT),VBH_TYPE_BIT, + 'S',signame, -1,-1 ,NULL,$1, 0); + + Signed = ( IsVexNodeSigned( VbPar->TARGET ) != 0 ); + + addtab (hshtab,signame,VBL_FUNCNAM,VBL_SYMDFN,VBL_PARDFN); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_TYPDFN,VBH_TYPE_BIT); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_WMNDFN,-1); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_WMXDFN,-1); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_ATLDFN,0); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_ATRDFN,1); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_LBLDFN,0); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_PNTDFN,(long)VbPar->TARGET); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_SUNDFN,Signed); + } + } + else + { + signame = (char *)VBL_NM1LST->DATA; + + if (chktab (hshtab,signame,VBL_FUNCNAM,VBL_SYMDFN) != 0) + my_vbl_error (80,signame); + + VbPar = (vbarg_list *)vbl_addstr( 'p',$4, + val_type($5.NAME),$5.TYPE, $5.FLAG,signame, + AttrLeft,AttrRight,NULL,$1, 0); + + Signed = ( IsVexNodeSigned( VbPar->TARGET ) != 0 ); + + if ( IsVexAtomVarWidth( VbPar->TARGET ) ) + { + Left = -2; + Right = -2; + } + else + if ( IsVexAtomBit( VbPar->TARGET ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VbPar->TARGET->LEFT; + Right = VbPar->TARGET->RIGHT; + } + + addtab (hshtab,signame,VBL_FUNCNAM,VBL_SYMDFN,VBL_PARDFN); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_TYPDFN,$5.TYPE); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_WMNDFN,Left); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_WMXDFN,Right); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_ATLDFN,AttrLeft); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_ATRDFN,AttrRight); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_LBLDFN,0); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_PNTDFN,(long)VbPar->TARGET); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_SUNDFN,Signed); + } + + VBL_NM1LST = delchain (VBL_NM1LST,VBL_NM1LST); + } + } + else + { + freechain( VBL_NM1LST ); + VBL_NM1LST = (chain_list *)0; + } + } + ; + +.procedure_parameter_object_class. + : /*empty*/ + { $$ = VBH_CLASS_NONE; } + | _VARIABLE + { $$ = VBH_CLASS_VARIABLE; } + | CONSTANT + { $$ = VBH_CLASS_CONSTANT; } + | SIGNAL + { $$ = VBH_CLASS_SIGNAL; } + ; + +.procedure_parameter_mode. + : /*empty*/ + { $$ = VBL_ICNDFN; } + | _IN + { $$ = VBL_ICNDFN; } + | _OUT + { $$ = VBL_OCNDFN; } + | _INOUT + { $$ = VBL_BCNDFN; } + ; + +.function_parameter_list. + : /*empty*/ + | LeftParen + function_parameter_element + ...function_parameter_element.. + RightParen_ERR + { } + | LeftParen + error + RightParen_ERR + { } + ; + + +...function_parameter_element.. + : /*empty*/ + | ...function_parameter_element.. + Semicolon_ERR + function_parameter_element + ; + +function_parameter_element + : .function_parameter_object_class. + identifier_list + Colon + .function_parameter_mode. + type_mark + .constraint. + { + char *signame; + char *codedsigname; + char buffer[ 128 ]; + vbtyp_list *TypeEnum; + int EnumSize; + vbarg_list *VbPar; + short Signed; + long Left; + long Right; + long AttrLeft; + long AttrRight; + + if ( $6.DYNAMIC ) + { + my_vbl_error(86,0); + } + + if ( $1 == VBH_CLASS_NONE ) $1 = VBH_CLASS_CONSTANT; + + TypeEnum = val_type( $5.NAME ); + EnumSize = vbl_codeSize( TypeEnum->SIZE - 1 ); + + if ( ( $6.LEFT == -1 ) && + ( $6.RIGHT == -1 ) ) + { + AttrLeft = TypeEnum->LEFT; + AttrRight = TypeEnum->RIGHT; + } + else + { + AttrLeft = $6.LEFT; + AttrRight = $6.RIGHT; + } + + if (chktab( hshtab,VBL_FUNCNAM,VBL_MODNAM,VBL_SYMDFN ) == 0) + { + VBL_NM1LST = reverse( VBL_NM1LST ); + while (VBL_NM1LST != NULL) + { + if ( ( TypeEnum->CLASS == 'E' ) && + ( TypeEnum->INDEX >= VBH_MAX_TYPE ) ) + { + signame = (char *)VBL_NM1LST->DATA; + + if (chktab (hshtab,signame,VBL_FUNCNAM,VBL_SYMDFN) != 0) + my_vbl_error (80,signame); + + sprintf (buffer, "%s.cod.%s", VBL_FUNCNAM, signame); + codedsigname = namealloc ( buffer ); + + if (chktab (hshtab,codedsigname,VBL_FUNCNAM,VBL_SYMDFN) != 0) + my_vbl_error (80,codedsigname); +/*\ + VbPar = (vbarg_list *)vbl_addstr('p',$4, + val_type($5.NAME),$5.TYPE, + $5.FLAG,codedsigname, AttrLeft,AttrRight, NULL,$1, 0); + + Signed = ( IsVexNodeSigned( VbPar->TARGET ) != 0 ); + + if ( IsVexAtomBit( VbPar->TARGET ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VbPar->TARGET->LEFT; + Right = VbPar->TARGET->RIGHT; + } +\*/ + addtab(hshtab,codedsigname,VBL_FUNCNAM,VBL_SYMDFN,VBL_PARDFN); + addtab(hshtab,codedsigname,VBL_FUNCNAM,VBL_TYPDFN,$5.TYPE); + addtab(hshtab,codedsigname,VBL_FUNCNAM,VBL_WMNDFN,-1); + addtab(hshtab,codedsigname,VBL_FUNCNAM,VBL_WMXDFN,-1); + addtab(hshtab,codedsigname,VBL_FUNCNAM,VBL_LBLDFN,0); + addtab(hshtab,codedsigname,VBL_FUNCNAM,VBL_PNTDFN,0); + addtab(hshtab,codedsigname,VBL_FUNCNAM,VBL_SUNDFN,0); + + if ( EnumSize > 1 ) + { + VbPar = (vbarg_list *)vbl_addstr( 'p',$4, + get_type(VBH_TYPE_BIT_VECTOR), VBH_TYPE_BIT_VECTOR, + 'U',signame, 0,EnumSize-1,NULL,$1, 0); + + Signed = ( IsVexNodeSigned( VbPar->TARGET ) != 0 ); + + addtab (hshtab,signame,VBL_FUNCNAM,VBL_SYMDFN,VBL_PARDFN); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_TYPDFN,VBH_TYPE_BIT_VECTOR); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_WMNDFN,0); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_WMXDFN,EnumSize-1); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_ATLDFN,0); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_ATRDFN,EnumSize-1); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_LBLDFN,0); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_PNTDFN,(long)VbPar->TARGET); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_SUNDFN,Signed); + } + else + { + VbPar = (vbarg_list *)vbl_addstr( 'p',$4, + get_type(VBH_TYPE_BIT),VBH_TYPE_BIT, + 'S',signame, -1,-1 ,NULL,$1, 0); + + Signed = ( IsVexNodeSigned( VbPar->TARGET ) != 0 ); + + addtab (hshtab,signame,VBL_FUNCNAM,VBL_SYMDFN,VBL_PARDFN); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_TYPDFN,VBH_TYPE_BIT); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_WMNDFN,-1); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_WMXDFN,-1); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_ATLDFN,0); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_ATRDFN,1); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_LBLDFN,0); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_PNTDFN,(long)VbPar->TARGET); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_SUNDFN,Signed); + } + } + else + { + signame = (char *)VBL_NM1LST->DATA; + if (chktab (hshtab,signame,VBL_FUNCNAM,VBL_SYMDFN) != 0) + my_vbl_error (80,signame); + + VbPar = (vbarg_list *)vbl_addstr ('p',$4, + val_type($5.NAME),$5.TYPE, $5.FLAG, + signame, AttrLeft,AttrRight,NULL,$1, 0); + + Signed = ( IsVexNodeSigned( VbPar->TARGET ) != 0 ); + + if ( IsVexAtomBit( VbPar->TARGET ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VbPar->TARGET->LEFT; + Right = VbPar->TARGET->RIGHT; + } + + addtab (hshtab,signame,VBL_FUNCNAM,VBL_SYMDFN,VBL_PARDFN); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_TYPDFN,$5.TYPE); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_WMNDFN,Left); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_WMXDFN,Right); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_ATLDFN,AttrLeft); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_ATRDFN,AttrRight); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_LBLDFN,0); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_PNTDFN,(long)VbPar->TARGET); + addtab (hshtab,signame,VBL_FUNCNAM,VBL_SUNDFN,Signed); + } + + VBL_NM1LST = delchain (VBL_NM1LST,VBL_NM1LST); + } + } + else + { + freechain( VBL_NM1LST ); + VBL_NM1LST = (chain_list *)0; + } + } + ; + +.function_parameter_object_class. + : /*empty*/ + { $$ = VBH_CLASS_NONE; } + | CONSTANT + { $$ = VBH_CLASS_CONSTANT; } + | SIGNAL + { $$ = VBH_CLASS_SIGNAL; } + ; + +.function_parameter_mode. + : /*empty*/ + { $$ = VBL_ICNDFN; } + | _IN + { $$ = VBL_ICNDFN; } + ; + +subprogram_declarative_part + : /*empty*/ + | + subprogram_declarative_part + subprogram_declarative_item + ; + +subprogram_declarative_item + : constant_declaration + | variable_declaration + | type_declaration + | subtype_declaration + | attribute_declaration + | attribute_specification + ; + +subprogram_declaration + : subprogram_specification + { + VBL_FUNCNAM = (char *)0; + } + Semicolon_ERR + ; + +subprogram_specification + : PROCEDURE + designator + { + int Mode; + + VBL_FUNCNAM = $2; + + Mode = chktab(hshtab,VBL_FUNCNAM,VBL_MODNAM,VBL_SYMDFN); + + if ( Mode == 0 ) + { + VBL_BEFPNT->BEFUN = vbh_addvbfun( VBL_BEFPNT->BEFUN, + VBL_FUNCNAM, NULL, NULL, NULL, VBL_LINNUM ); + VBL_BEFUN = VBL_BEFPNT->BEFUN; + } + else + if ( Mode != VBL_PRODFN ) + { + my_vbl_error (117,VBL_FUNCNAM); + } + else + { + VBL_BEFUN = (vbfun_list *)chktab( hshtab, VBL_FUNCNAM, VBL_MODNAM, VBL_PNTDFN ); + } + } + .procedure_parameter_list. + { + if ( chktab(hshtab,VBL_FUNCNAM,VBL_MODNAM,VBL_SYMDFN) == 0 ) + { + VBL_BEFUN->ARGUMENT = + (vbarg_list *)reverse( (chain_list *)VBL_BEFUN->ARGUMENT ); + + addtab (hshtab,VBL_FUNCNAM,VBL_MODNAM,VBL_SYMDFN,VBL_PRODFN); + addtab (hshtab,VBL_FUNCNAM,VBL_MODNAM,VBL_PNTDFN,(long)VBL_BEFUN); + } + } + | FUNCTION + designator + { + int Mode; + + VBL_FUNCNAM = $2; + + Mode = chktab(hshtab,VBL_FUNCNAM,VBL_MODNAM,VBL_SYMDFN); + + if ( Mode == 0 ) + { + VBL_BEFPNT->BEFUN = vbh_addvbfun( VBL_BEFPNT->BEFUN, + VBL_FUNCNAM, NULL, NULL, NULL, VBL_LINNUM ); + VBL_BEFUN = VBL_BEFPNT->BEFUN; + } + else + if ( Mode != VBL_FUNDFN ) + { + my_vbl_error (116,VBL_FUNCNAM); + } + else + { + VBL_BEFUN = (vbfun_list *)chktab(hshtab,VBL_FUNCNAM,VBL_MODNAM,VBL_PNTDFN); + } + } + .function_parameter_list. + _RETURN + type_mark + { + char *signame; + char buffer[ 128 ]; + char *codedsigname; + vbtyp_list *TypeEnum; + short Signed; + long Left; + long Right; + long AttrLeft; + long AttrRight; + int EnumSize; + vbtyp_list *VbType; + vexexpr *VexRet; + + if ( $6.DYNAMIC ) + { + my_vbl_error(115,0); + } + + signame = VBL_FUNCNAM; + + TypeEnum = val_type( $6.NAME ); + EnumSize = vbl_codeSize( TypeEnum->SIZE - 1 ); + + AttrLeft = TypeEnum->LEFT; + AttrRight = TypeEnum->RIGHT; + + if ( chktab(hshtab,VBL_FUNCNAM,VBL_MODNAM,VBL_SYMDFN) == 0 ) + { + if ( ( TypeEnum->CLASS == 'E' ) && + ( TypeEnum->INDEX >= VBH_MAX_TYPE ) ) + { + sprintf (buffer, "%s.cod.%s", VBL_MODNAM, signame); + codedsigname = namealloc ( buffer ); + + if (chktab (hshtab,codedsigname,VBL_MODNAM,VBL_SYMDFN) != 0) + my_vbl_error (116,codedsigname); +/*\ + VexRet = (vexexpr *)vbl_addstr( 'F',0,val_type($6.NAME),$6.TYPE, + $6.FLAG,codedsigname,AttrLeft,AttrRight,NULL,0, 0); + + Signed = ( IsVexNodeSigned( VexRet ) != 0 ); + + if ( IsVexAtomBit( VexRet ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VexRet->LEFT; + Right = VexRet->RIGHT; + } +\*/ + addtab (hshtab,codedsigname,VBL_MODNAM,VBL_SYMDFN,VBL_FUNDFN); + addtab (hshtab,codedsigname,VBL_MODNAM,VBL_TYPDFN,$6.TYPE); + addtab (hshtab,codedsigname,VBL_MODNAM,VBL_WMNDFN,-1); + addtab (hshtab,codedsigname,VBL_MODNAM,VBL_WMXDFN,-1); + addtab (hshtab,codedsigname,VBL_MODNAM,VBL_SUNDFN,0); + + if ( EnumSize > 1 ) + { + VbType = get_type( VBH_TYPE_BIT_VECTOR ); + VexRet = (vexexpr *)vbl_addstr('F',0, + VbType,VBH_TYPE_BIT_VECTOR,'U',signame, 0,EnumSize-1,NULL,0, 0); + + Signed = ( IsVexNodeSigned( VexRet ) != 0 ); + + addtab (hshtab,signame,VBL_MODNAM,VBL_SYMDFN,VBL_FUNDFN); + addtab (hshtab,signame,VBL_MODNAM,VBL_TYPDFN,VBH_TYPE_BIT_VECTOR); + addtab (hshtab,signame,VBL_MODNAM,VBL_WMNDFN,0); + addtab (hshtab,signame,VBL_MODNAM,VBL_WMXDFN,EnumSize-1); + addtab (hshtab,signame,VBL_MODNAM,VBL_ATLDFN,0); + addtab (hshtab,signame,VBL_MODNAM,VBL_ATRDFN,TypeEnum->SIZE-1); + addtab (hshtab,signame,VBL_MODNAM,VBL_SUNDFN,Signed); + } + else + { + VbType = get_type(VBH_TYPE_BIT); + VexRet = (vexexpr *)vbl_addstr ('F',0, + VbType,VBH_TYPE_BIT,'S',signame, -1,-1 ,NULL,0, 0); + + Signed = ( IsVexNodeSigned( VexRet ) != 0 ); + + addtab (hshtab,signame,VBL_MODNAM,VBL_SYMDFN,VBL_FUNDFN); + addtab (hshtab,signame,VBL_MODNAM,VBL_TYPDFN,VBH_TYPE_BIT); + addtab (hshtab,signame,VBL_MODNAM,VBL_WMNDFN,-1); + addtab (hshtab,signame,VBL_MODNAM,VBL_WMXDFN,-1); + addtab (hshtab,signame,VBL_MODNAM,VBL_ATLDFN,0); + addtab (hshtab,signame,VBL_MODNAM,VBL_ATRDFN,TypeEnum->SIZE-1); + addtab (hshtab,signame,VBL_MODNAM,VBL_SUNDFN,Signed); + } + } + else + { + VbType = val_type($6.NAME); + VexRet = (vexexpr *)vbl_addstr( 'F',0,VbType,$6.TYPE, + $6.FLAG,signame,-1,-1,NULL,0, 0); + + Signed = ( IsVexNodeSigned( VexRet ) != 0 ); + + if ( IsVexAtomBit( VexRet ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VexRet->LEFT; + Right = VexRet->RIGHT; + } + + addtab (hshtab,signame,VBL_MODNAM,VBL_SYMDFN,VBL_FUNDFN); + addtab (hshtab,signame,VBL_MODNAM,VBL_TYPDFN,$6.TYPE); + addtab (hshtab,signame,VBL_MODNAM,VBL_WMNDFN,Left); + addtab (hshtab,signame,VBL_MODNAM,VBL_WMXDFN,Right); + addtab (hshtab,signame,VBL_MODNAM,VBL_ATLDFN,AttrLeft); + addtab (hshtab,signame,VBL_MODNAM,VBL_ATRDFN,AttrRight); + addtab (hshtab,signame,VBL_MODNAM,VBL_SUNDFN,Signed); + } + + VBL_BEFUN->RETURN = vbh_addvbarg( (vbarg_list *)0, VexRet, 'O', + VBH_CLASS_NONE, VbType, VBL_LINNUM ); + VBL_BEFUN->ARGUMENT = + (vbarg_list *)reverse( (chain_list *)VBL_BEFUN->ARGUMENT ); + + addtab (hshtab,VBL_FUNCNAM,VBL_MODNAM,VBL_SYMDFN,VBL_FUNDFN); + addtab (hshtab,VBL_FUNCNAM,VBL_MODNAM,VBL_PNTDFN,(long)VBL_BEFUN); + } + } + ; + +subprogram_body + : subprogram_specification + IS + subprogram_declarative_part + _BEGIN + { + void *pnt; + pnt = &(VBL_BEFUN->INSTRUCTION); + VBL_INSLST = addchain(NULL,pnt); + } + sequence_of_statements + { + struct ptype **pnt; + struct ptype *ptype; + pnt = (struct ptype**)VBL_INSLST->DATA; + ptype = reversetype(*pnt); + *pnt = ptype; + VBL_INSLST = delchain (VBL_INSLST, VBL_INSLST); + } + END_ERR + .designator. + { + VBL_FUNCNAM = (char *)0; + } + Semicolon_ERR + ; + +.designator. + : /*empty*/ + | designator + { } + ; + +constant_declaration + : CONSTANT + Identifier + Colon + type_mark + .constraint. + constant_VarAsgn__expression + Semicolon_ERR + { + vbtyp_list *Type; + vbcst_list *VbCst; + vexexpr *VexValue; + chain_list *HeadChain; + chain_list *ScanChain; + vbl_vexstr *VexStr; + short Signed; + long Left; + long Right; + short Width; + long AttrLeft; + long AttrRight; + + if ( $6.AGGREG ) + { + HeadChain = reverse( (chain_list *)$6.IDENT ); + ScanChain = HeadChain; + + if ( HeadChain->NEXT != (chain_list *)0 ) + { + Width = 0; + VexValue = createvexoper( VEX_ARRAY, 1 ); + + while ( ScanChain != (chain_list *)0 ) + { + VexStr = (vbl_vexstr *)ScanChain->DATA; + Width += VexStr->VEX->WIDTH; + addvexhexpr( VexValue, VexStr->VEX ); + + autfreeheap( VexStr, sizeof( vbl_vexstr ) ); + + ScanChain = ScanChain->NEXT; + } + + VexValue->WIDTH = Width; + } + else + { + VexStr = (vbl_vexstr *)HeadChain->DATA; + VexValue = VexStr->VEX; + + autfreeheap( VexStr, sizeof( vbl_vexstr ) ); + } + + freechain( HeadChain ); + } + else + { + VexValue = simpvexexpr( $6.VEX ); + } + + Type = val_type( $4.NAME ); + + + if ( $5.DYNAMIC ) + { + AttrLeft = $5.LEFT; + AttrRight = $5.RIGHT; + Left = AttrLeft; + Right = AttrRight; + } + else + if ( ( $5.LEFT == -1 ) && + ( $5.RIGHT == -1 ) ) + { + AttrLeft = Type->LEFT; + AttrRight = Type->RIGHT; + } + else + { + AttrLeft = $5.LEFT; + AttrRight = $5.RIGHT; + } + + VbCst = (vbcst_list *)vbl_addstr( 'C',0,val_type($4.NAME), + $4.TYPE,$4.FLAG,$2,AttrLeft,AttrRight,VexValue,0, $5.DYNAMIC); + + Signed = ( IsVexNodeSigned( VbCst->TARGET ) != 0 ); + + if ( ! $5.DYNAMIC ) + { + if ( IsVexAtomBit( VbCst->TARGET ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VbCst->TARGET->LEFT; + Right = VbCst->TARGET->RIGHT; + } + } + + addtab(hshtab,$2,VBL_MODNAM,VBL_SYMDFN,VBL_CSTDFN); + addtab(hshtab,$2,VBL_MODNAM,VBL_TYPDFN,$4.TYPE); + addtab(hshtab,$2,VBL_MODNAM,VBL_WMNDFN,Left); + addtab(hshtab,$2,VBL_MODNAM,VBL_WMXDFN,Right); + addtab(hshtab,$2,VBL_MODNAM,VBL_ATLDFN,AttrLeft); + addtab(hshtab,$2,VBL_MODNAM,VBL_ATRDFN,AttrRight); + addtab(hshtab,$2,VBL_MODNAM,VBL_LBLDFN,0); + addtab(hshtab,$2,VBL_MODNAM,VBL_PNTDFN,(long)VbCst->VEX); + addtab(hshtab,$2,VBL_MODNAM,VBL_SUNDFN,Signed ); + addtab(hshtab,$2,VBL_MODNAM,VBL_DYNDFN,$5.DYNAMIC ); + } + ; + +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 ]; + vbtyp_list *TypeEnum; + int EnumSize; + vbvar_list *VbVar; + short Signed; + long Left; + long Right; + long AttrLeft; + long AttrRight; + char StrFlag; + vexexpr *VexInit; + struct vbl_expr expr1; + + if ( VBL_FUNCNAM != (char *)0 ) + { + LocalName = VBL_FUNCNAM; + StrFlag = 'v'; + } + else + { + LocalName = VBL_PROCNAM; + StrFlag = 'V'; + } + + TypeEnum = val_type( $4.NAME ); + EnumSize = vbl_codeSize( TypeEnum->SIZE - 1 ); + + if ( $5.DYNAMIC ) /* LUDO_DYNAMIC */ + { + AttrLeft = $5.LEFT; + AttrRight = $5.RIGHT; + Left = AttrLeft; + Right = AttrRight; + } + else + if ( ( $5.LEFT == -1 ) && + ( $5.RIGHT == -1 ) ) + { + AttrLeft = TypeEnum->LEFT; + AttrRight = TypeEnum->RIGHT; + } + else + { + AttrLeft = $5.LEFT; + AttrRight = $5.RIGHT; + } + + VBL_NM1LST = reverse (VBL_NM1LST); + + if ( ! $5.DYNAMIC ) /* LUDO_DYNAMIC */ + { + if ( $6.VEX == (vexexpr *)0 ) + { + if ( TypeEnum->CLASS == 'I' ) + { + sprintf( buffer, "%ld", AttrLeft ); + expr1.IDENT = buffer; + expr1.TYPE = -1; + expr1.VEX = (vexexpr *)0; + expr1 = vbl_crtvex( NOPS, expr1,VBL_EMPSTR,-1,-1,0); + + $6.VEX = expr1.VEX; + } + } + } + + while (VBL_NM1LST != NULL) + { + VexInit = $6.VEX; + + if ( ( VexInit != (vexexpr *)0 ) && + ( VBL_NM1LST->NEXT != (chain_list *)0 ) ) + { + VexInit = dupvexexpr( $6.VEX ); + } + + if ( ( TypeEnum->CLASS == 'E' ) && + ( TypeEnum->INDEX >= VBH_MAX_TYPE ) ) + { + signame = (char *)VBL_NM1LST->DATA; + + if (chktab (hshtab,signame,LocalName,VBL_SYMDFN) != 0) + my_vbl_error (80,signame); + + sprintf (buffer, "%s.cod.%s", LocalName, signame); + codedsigname = namealloc ( buffer ); + + if (chktab (hshtab,codedsigname,LocalName,VBL_SYMDFN) != 0) + my_vbl_error (80,codedsigname); +/*\ + VbVar = (vbvar_list *)vbl_addstr(StrFlag,0,val_type($4.NAME),$4.TYPE, + $4.FLAG,codedsigname, AttrLeft,AttrRight, VexInit, 0 , 0); + + Signed = ( IsVexNodeSigned( VbVar->TARGET ) != 0 ); + + if ( IsVexAtomBit( VbVar->TARGET ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VbVar->TARGET->LEFT; + Right = VbVar->TARGET->RIGHT; + } +\*/ + addtab(hshtab,codedsigname,LocalName,VBL_SYMDFN,VBL_VARDFN); + addtab(hshtab,codedsigname,LocalName,VBL_TYPDFN,$4.TYPE); + addtab(hshtab,codedsigname,LocalName,VBL_WMNDFN,-1); + addtab(hshtab,codedsigname,LocalName,VBL_WMXDFN,-1); + addtab(hshtab,codedsigname,LocalName,VBL_LBLDFN,0); + addtab(hshtab,codedsigname,LocalName,VBL_PNTDFN,0); + addtab(hshtab,codedsigname,LocalName,VBL_SUNDFN,0); + addtab(hshtab,codedsigname,LocalName,VBL_DYNDFN,0); + + if ( VexInit != (vexexpr *)0 ) VexInit = dupvexexpr( VexInit ); + + if ( EnumSize > 1 ) + { + VbVar = (vbvar_list *)vbl_addstr( StrFlag,0, + get_type(VBH_TYPE_BIT_VECTOR),VBH_TYPE_BIT_VECTOR, + 'U',signame, 0,EnumSize-1 , VexInit, 0, 0 ); + + Signed = ( IsVexNodeSigned( VbVar->TARGET ) != 0 ); + + addtab (hshtab,signame,LocalName,VBL_SYMDFN,VBL_VARDFN); + addtab (hshtab,signame,LocalName,VBL_TYPDFN,VBH_TYPE_BIT_VECTOR); + addtab (hshtab,signame,LocalName,VBL_WMNDFN,0); + addtab (hshtab,signame,LocalName,VBL_WMXDFN,EnumSize-1); + addtab (hshtab,signame,LocalName,VBL_ATLDFN,0); + addtab (hshtab,signame,LocalName,VBL_ATRDFN,EnumSize-1); + addtab (hshtab,signame,LocalName,VBL_LBLDFN,0); + addtab (hshtab,signame,LocalName,VBL_PNTDFN,(long)VbVar->TARGET); + addtab (hshtab,signame,LocalName,VBL_SUNDFN,Signed); + addtab (hshtab,signame,LocalName,VBL_DYNDFN,0); + } + else + { + VbVar = (vbvar_list *)vbl_addstr( StrFlag,0, + get_type(VBH_TYPE_BIT),VBH_TYPE_BIT, + 'S',signame, -1,-1 , VexInit, 0, 0 ); + + Signed = ( IsVexNodeSigned( VbVar->TARGET ) != 0 ); + + addtab (hshtab,signame,LocalName,VBL_SYMDFN,VBL_VARDFN); + addtab (hshtab,signame,LocalName,VBL_TYPDFN,VBH_TYPE_BIT); + addtab (hshtab,signame,LocalName,VBL_WMNDFN,-1); + addtab (hshtab,signame,LocalName,VBL_WMXDFN,-1); + addtab (hshtab,signame,LocalName,VBL_ATLDFN,0); + addtab (hshtab,signame,LocalName,VBL_ATRDFN,1); + addtab (hshtab,signame,LocalName,VBL_LBLDFN,0); + addtab (hshtab,signame,LocalName,VBL_PNTDFN,(long)VbVar->TARGET); + addtab (hshtab,signame,LocalName,VBL_SUNDFN,Signed); + addtab (hshtab,signame,LocalName,VBL_DYNDFN,0); + } + } + else + { + signame = (char *)VBL_NM1LST->DATA; + if (chktab (hshtab,signame,LocalName,VBL_SYMDFN) != 0) + my_vbl_error (80,signame); + + VbVar = (vbvar_list *)vbl_addstr( StrFlag,0, + val_type($4.NAME),$4.TYPE, + $4.FLAG,signame, AttrLeft, AttrRight, VexInit, 0, $5.DYNAMIC); + + Signed = ( IsVexNodeSigned( VbVar->TARGET ) != 0 ); + + if ( ( $4.FLAG == 'I' ) && ( $5.DYNAMIC ) ) + { + $5.DYNAMIC = VBL_DWTDFN; + } + + + if ( ! $5.DYNAMIC ) /* LUDO_DYNAMIC */ + { + if ( IsVexAtomBit( VbVar->TARGET ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VbVar->TARGET->LEFT; + Right = VbVar->TARGET->RIGHT; + } + } + + addtab (hshtab,signame,LocalName,VBL_SYMDFN,VBL_VARDFN); + addtab (hshtab,signame,LocalName,VBL_TYPDFN,$4.TYPE); + addtab (hshtab,signame,LocalName,VBL_WMNDFN,Left); + addtab (hshtab,signame,LocalName,VBL_WMXDFN,Right); + addtab (hshtab,signame,LocalName,VBL_ATLDFN,AttrLeft); + addtab (hshtab,signame,LocalName,VBL_ATRDFN,AttrRight); + addtab (hshtab,signame,LocalName,VBL_LBLDFN,0); + addtab (hshtab,signame,LocalName,VBL_PNTDFN,(long)VbVar->TARGET); + addtab (hshtab,signame,LocalName,VBL_SUNDFN,Signed); + addtab (hshtab,signame,LocalName,VBL_DYNDFN,$5.DYNAMIC); + } + + VBL_NM1LST = delchain (VBL_NM1LST,VBL_NM1LST); + } + } + ; + +signal_declaration + : SIGNAL + identifier_list + Colon + type_mark + .constraint. + .signal_kind. + .VarAsgn__expression. + Semicolon_ERR + { + char *signame; + char buffer[ 128 ]; + char *codedsigname; + vbtyp_list *TypeEnum; + short Signed; + long Left; + long Right; + long AttrLeft; + long AttrRight; + int EnumSize; + vbaux_list *VbAux; + vexexpr *VexInit; + struct vbl_expr expr1; + + TypeEnum = val_type( $4.NAME ); + EnumSize = vbl_codeSize( TypeEnum->SIZE - 1 ); + + if ( ( $4.DYNAMIC ) && + ( ! $5.DYNAMIC ) ) + { + $5.DYNAMIC = $4.DYNAMIC; + $5.LEFT = $4.LEFT; + $5.RIGHT = $4.RIGHT; + } + + if ( $5.DYNAMIC ) /* LUDO_DYNAMIC */ + { + AttrLeft = $5.LEFT; + AttrRight = $5.RIGHT; + Left = AttrLeft; + Right = AttrRight; + } + else + if ( ( $5.LEFT == -1 ) && + ( $5.RIGHT == -1 ) ) + { + AttrLeft = TypeEnum->LEFT; + AttrRight = TypeEnum->RIGHT; + } + else + { + AttrLeft = $5.LEFT; + AttrRight = $5.RIGHT; + } + + VBL_NM1LST = reverse (VBL_NM1LST); + + if ( ! $5.DYNAMIC ) /* LUDO_DYNAMIC */ + { + if ( $7.VEX == (vexexpr *)0 ) + { + if ( TypeEnum->CLASS == 'I' ) + { + sprintf( buffer, "%ld", AttrLeft ); + expr1.IDENT = buffer; + expr1.TYPE = -1; + expr1.VEX = (vexexpr *)0; + expr1 = vbl_crtvex( NOPS, expr1,VBL_EMPSTR,-1,-1,0); + + $7.VEX = expr1.VEX; + } + } + } + + while (VBL_NM1LST != NULL) + { + VexInit = $7.VEX; + + if ( ( VexInit != (vexexpr *)0 ) && + ( VBL_NM1LST->NEXT != (chain_list *)0 ) ) + { + VexInit = dupvexexpr( $7.VEX ); + } + + if ( ( TypeEnum->CLASS == 'E' ) && + ( TypeEnum->INDEX >= VBH_MAX_TYPE ) ) + { + signame = (char *)VBL_NM1LST->DATA; + + if (chktab (hshtab,signame,VBL_MODNAM,VBL_SYMDFN) != 0) + my_vbl_error (10,signame); + + sprintf (buffer, "%s.cod.%s", VBL_MODNAM, signame); + codedsigname = namealloc ( buffer ); + + if (chktab (hshtab,codedsigname,VBL_MODNAM,VBL_SYMDFN) != 0) + my_vbl_error (10,codedsigname); +/*\ + VbAux = (vbaux_list *)vbl_addstr( 'S',0, + val_type($4.NAME),$4.TYPE, + $4.FLAG,codedsigname, AttrLeft, AttrRight,VexInit, $6, 0); + + Signed = ( IsVexNodeSigned( VbAux->TARGET ) != 0 ); + + if ( IsVexAtomBit( VbAux->TARGET ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VbAux->TARGET->LEFT; + Right = VbAux->TARGET->RIGHT; + } +\*/ + addtab (hshtab,codedsigname,VBL_MODNAM,VBL_SYMDFN,VBL_SGNDFN); + addtab (hshtab,codedsigname,VBL_MODNAM,VBL_TYPDFN,$4.TYPE); + addtab (hshtab,codedsigname,VBL_MODNAM,VBL_WMNDFN,-1); + addtab (hshtab,codedsigname,VBL_MODNAM,VBL_WMXDFN,-1); + addtab (hshtab,codedsigname,VBL_MODNAM,VBL_LBLDFN,$6); + addtab (hshtab,codedsigname,VBL_MODNAM,VBL_PNTDFN,0); + addtab (hshtab,codedsigname,VBL_MODNAM,VBL_PNTDFN,0); + addtab (hshtab,codedsigname,VBL_MODNAM,VBL_DYNDFN,0); + + if ( VexInit != (vexexpr *)0 ) VexInit = dupvexexpr( VexInit ); + + if ( EnumSize > 1 ) + { + VbAux = (vbaux_list *)vbl_addstr ('S',0, + get_type(VBH_TYPE_BIT_VECTOR), VBH_TYPE_BIT_VECTOR, + 'U',signame, 0,EnumSize-1 , VexInit, $6, 0); + + Signed = ( IsVexNodeSigned( VbAux->TARGET ) != 0 ); + + addtab (hshtab,signame,VBL_MODNAM,VBL_SYMDFN,VBL_SGNDFN); + addtab (hshtab,signame,VBL_MODNAM,VBL_TYPDFN,VBH_TYPE_BIT_VECTOR); + addtab (hshtab,signame,VBL_MODNAM,VBL_WMNDFN,0); + addtab (hshtab,signame,VBL_MODNAM,VBL_WMXDFN,EnumSize-1); + addtab (hshtab,signame,VBL_MODNAM,VBL_ATLDFN,0); + addtab (hshtab,signame,VBL_MODNAM,VBL_ATRDFN,EnumSize-1); + addtab (hshtab,signame,VBL_MODNAM,VBL_LBLDFN,$6); + addtab (hshtab,signame,VBL_MODNAM,VBL_PNTDFN,(long)VbAux->TARGET); + addtab (hshtab,signame,VBL_MODNAM,VBL_SUNDFN,Signed); + addtab (hshtab,signame,VBL_MODNAM,VBL_DYNDFN,0); + } + else + { + VbAux = (vbaux_list *)vbl_addstr ('S',0, + get_type(VBH_TYPE_BIT),VBH_TYPE_BIT, + 'S',signame, -1,-1 , VexInit, $6, 0); + + Signed = ( IsVexNodeSigned( VbAux->TARGET ) != 0 ); + + addtab (hshtab,signame,VBL_MODNAM,VBL_SYMDFN,VBL_SGNDFN); + addtab (hshtab,signame,VBL_MODNAM,VBL_TYPDFN,VBH_TYPE_BIT); + addtab (hshtab,signame,VBL_MODNAM,VBL_WMNDFN,-1); + addtab (hshtab,signame,VBL_MODNAM,VBL_WMXDFN,-1); + addtab (hshtab,signame,VBL_MODNAM,VBL_ATLDFN,0); + addtab (hshtab,signame,VBL_MODNAM,VBL_ATRDFN,1); + addtab (hshtab,signame,VBL_MODNAM,VBL_LBLDFN,$6); + addtab (hshtab,signame,VBL_MODNAM,VBL_PNTDFN,(long)VbAux->TARGET); + addtab (hshtab,signame,VBL_MODNAM,VBL_SUNDFN,Signed); + addtab (hshtab,signame,VBL_MODNAM,VBL_DYNDFN,0); + } + } + else + { + signame = (char *)VBL_NM1LST->DATA; + if (chktab (hshtab,signame,VBL_MODNAM,VBL_SYMDFN) != 0) + my_vbl_error (10,signame); + + VbAux = (vbaux_list *)vbl_addstr( 'S',0, + val_type($4.NAME),$4.TYPE, + $4.FLAG,signame, AttrLeft,AttrRight,VexInit, $6, + $5.DYNAMIC); + + if ( ( $4.FLAG == 'I' ) && ( $5.DYNAMIC ) ) + { + $5.DYNAMIC = VBL_DWTDFN; + } + + Signed = ( IsVexNodeSigned( VbAux->TARGET ) != 0 ); + + if ( ! $5.DYNAMIC ) /* LUDO_DYNAMIC */ + { + if ( IsVexAtomBit( VbAux->TARGET ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VbAux->TARGET->LEFT; + Right = VbAux->TARGET->RIGHT; + } + } + + addtab (hshtab,signame,VBL_MODNAM,VBL_SYMDFN,VBL_SGNDFN); + addtab (hshtab,signame,VBL_MODNAM,VBL_TYPDFN,$4.TYPE); + addtab (hshtab,signame,VBL_MODNAM,VBL_WMNDFN,Left); + addtab (hshtab,signame,VBL_MODNAM,VBL_WMXDFN,Right); + addtab (hshtab,signame,VBL_MODNAM,VBL_ATLDFN,AttrLeft); + addtab (hshtab,signame,VBL_MODNAM,VBL_ATRDFN,AttrRight); + addtab (hshtab,signame,VBL_MODNAM,VBL_LBLDFN,$6); + addtab (hshtab,signame,VBL_MODNAM,VBL_PNTDFN,(long)VbAux->TARGET); + addtab (hshtab,signame,VBL_MODNAM,VBL_SUNDFN,Signed); + addtab (hshtab,signame,VBL_MODNAM,VBL_DYNDFN,$5.DYNAMIC); + } + + VBL_NM1LST = delchain (VBL_NM1LST,VBL_NM1LST); + } + } + ; + +type_declaration + : full_type_declaration + ; + +full_type_declaration + : _TYPE + Identifier + IS + type_definition + Semicolon_ERR + { + vbtyp_list *VbType; + VbType = vbh_addvbtyp(VBL_BEFPNT,$2,$4.LEFT, + $4.RIGHT,$4.VALUE,$4.SIZE,$4.BYTE,$4.BASE,VBL_NUMTYP,$4.RESOLV,$4.CLASS, + VBL_LINNUM); + if ( $4.DYNAMIC ) + { + VbType->DYNAMIC = $4.DYNAMIC; + VbType->DYNAMIC_LEFT = $4.DYNAMIC_LEFT; + VbType->DYNAMIC_RIGHT = $4.DYNAMIC_RIGHT; + } + addtab(hshtab,$2,VBL_MODNAM,VBL_SYMDFN,VBL_TPEDFN); + addtab(hshtab,$2,VBL_MODNAM,VBL_LBLDFN,$4.CLASS); + addtab(hshtab,$2,VBL_MODNAM,VBL_TYPDFN,VBL_NUMTYP); + addtab(hshtab,$2,VBL_MODNAM,VBL_WMNDFN,$4.LEFT); + addtab(hshtab,$2,VBL_MODNAM,VBL_WMXDFN,$4.RIGHT); + addtab(hshtab,$2,VBL_MODNAM,VBL_DYNDFN,$4.DYNAMIC); + addtab(hshtab,$2,VBL_MODNAM,VBL_PNTDFN,(long)VBL_BEFPNT->BETYP); + VBL_NUMTYP++; + } + ; + +type_definition + : scalar_type_definition + { $$ = $1; } + | composite_type_definition + { $$ = $1; } + | error Semicolon_ERR + { yyerrok; } + ; + +subtype_declaration + : SUBTYPE + Identifier + IS + subtype_indication + Semicolon_ERR + { + vbtyp_list *VbType; + VbType = vbh_addvbtyp(VBL_BEFPNT,$2,$4.LEFT, + $4.RIGHT,$4.VALUE,$4.SIZE,$4.BYTE,$4.BASE,$4.INDEX,$4.RESOLV,$4.CLASS, + VBL_LINNUM); + if ( $4.DYNAMIC ) + { + VbType->DYNAMIC = $4.DYNAMIC; + VbType->DYNAMIC_LEFT = $4.DYNAMIC_LEFT; + VbType->DYNAMIC_RIGHT = $4.DYNAMIC_RIGHT; + } + addtab(hshtab,$2,VBL_MODNAM,VBL_SYMDFN,VBL_TPEDFN); + addtab(hshtab,$2,VBL_MODNAM,VBL_LBLDFN,$4.CLASS); + addtab(hshtab,$2,VBL_MODNAM,VBL_TYPDFN,$4.INDEX); + addtab(hshtab,$2,VBL_MODNAM,VBL_WMNDFN,$4.LEFT); + addtab(hshtab,$2,VBL_MODNAM,VBL_WMXDFN,$4.RIGHT); + addtab(hshtab,$2,VBL_MODNAM,VBL_DYNDFN,$4.DYNAMIC); + addtab(hshtab,$2,VBL_MODNAM,VBL_PNTDFN,(long)VBL_BEFPNT->BETYP); + VBL_NUMTYP++; + } + ; + +subtype_indication + : type_or_function_name + type_mark + .constraint. + { + struct vbtyp *vbtyp_pnt; + struct vbfun *vbfun_pnt; + int mode; + + mode = chktab(hshtab,$1,VBL_MODNAM,VBL_SYMDFN); + + vbfun_pnt = (vbfun_list *)chktab(hshtab,$1,VBL_MODNAM,VBL_PNTDFN); + vbtyp_pnt = (vbtyp_list *)chktab(hshtab,$2.NAME,VBL_MODNAM,VBL_PNTDFN); + + if ( ( mode != VBL_FUNDFN ) || ( $3.DYNAMIC ) ) + { + my_vbl_error(87,0); + } + + $$.NAME = NULL; + $$.BASE = vbtyp_pnt; + $$.VALUE = NULL ; + $$.SIZE = 0 ; + $$.INDEX = VBL_NUMTYP; + $$.BYTE = vbtyp_pnt->BYTE; + $$.LEFT = $3.LEFT ; + $$.RIGHT = $3.RIGHT ; + $$.CLASS = $3.FLAG ; + $$.RESOLV = vbfun_pnt; + $$.DYNAMIC = 0; + $$.DYNAMIC_LEFT = (vexexpr *)0; + $$.DYNAMIC_RIGHT = (vexexpr *)0; + } + | type_mark + .constraint. + { + struct vbtyp *vbtyp_pnt; + + vbtyp_pnt = (vbtyp_list *)chktab(hshtab,$1.NAME,VBL_MODNAM,VBL_PNTDFN); + + $$.NAME = NULL; + $$.BASE = vbtyp_pnt; + $$.VALUE = NULL ; + $$.SIZE = 0 ; + $$.INDEX = VBL_NUMTYP; + $$.BYTE = vbtyp_pnt->BYTE; + $$.RESOLV = NULL ; + $$.CLASS = $2.FLAG; + + if ( ! $2.DYNAMIC ) + { + $$.LEFT = $2.LEFT ; + $$.RIGHT = $2.RIGHT ; + $$.DYNAMIC = 0; + $$.DYNAMIC_LEFT = (vexexpr *)0; + $$.DYNAMIC_RIGHT = (vexexpr *)0; + } + else + { + $$.LEFT = -2; + $$.RIGHT = -2; + $$.DYNAMIC = $2.DYNAMIC; + $$.DYNAMIC_LEFT = (vexexpr *)$2.LEFT; + $$.DYNAMIC_RIGHT = (vexexpr *)$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 buffer[ 128 ]; + char *enumname; + char *enumval; + int size; + int indice; + int numbit; + char **pnt; + chain_list *nm1lst; + + VBL_NM1LST = reverse (VBL_NM1LST); + + nm1lst = VBL_NM1LST; + size = 0; + + while (nm1lst != NULL) + { + size++; + nm1lst = nm1lst->NEXT; + } + + if( size != 0) + pnt = (char **) autallocblock(size * sizeof(char*)); + + numbit = vbl_codeSize( size - 1 ); + indice = 0; + + while (VBL_NM1LST != NULL) + { + sprintf ( buffer, "%s.cod.%s", VBL_MODNAM, (char *)VBL_NM1LST->DATA); + enumname = namealloc ( buffer ); + + if (chktab (hshtab,enumname,VBL_MODNAM,VBL_SYMDFN) != 0) + my_vbl_error (82,enumname); + + enumval = vbl_enumbitstring(indice,size,numbit); + + addtab (hshtab,enumname,VBL_MODNAM,VBL_SYMDFN,VBL_CSTDFN); + addtab (hshtab,enumname,VBL_MODNAM,VBL_TYPDFN,VBL_NUMTYP); + addtab (hshtab,enumname,VBL_MODNAM,VBL_WMNDFN,-1); + addtab (hshtab,enumname,VBL_MODNAM,VBL_WMXDFN,-1); + addtab (hshtab,enumname,VBL_MODNAM,VBL_LBLDFN,indice); + addtab (hshtab,enumname,VBL_MODNAM,VBL_PNTDFN,(long)pnt); + addauthelem(VBL_ENUMVAL, enumname, (long)enumval ); + + pnt[indice++] = enumname; + VBL_NM1LST = delchain (VBL_NM1LST, VBL_NM1LST); + } + $$.VALUE = pnt ; + $$.SIZE = size ; + $$.LEFT = 0 ; + $$.RIGHT = 0 ; + $$.BYTE = size/256 +1; + $$.INDEX = VBL_NUMTYP; + $$.CLASS = 'E' ; + $$.BASE = 0 ; + $$.RESOLV = NULL ; + $$.DYNAMIC = 0; + $$.DYNAMIC_LEFT = NULL; + $$.DYNAMIC_RIGHT = NULL; + } + ; + + +...enumeration_literal.. + : /*empty*/ + | ...enumeration_literal.. + Comma + enumeration_literal + { yyerrok; } + ; + +enumeration_literal + : Identifier + { VBL_NM1LST = addchain (VBL_NM1LST,$1); } + | CharacterLit + { VBL_NM1LST = addchain (VBL_NM1LST,$1); } + ; + +composite_type_definition + : array_type_definition + { + $$ = $1; + } + ; + +array_type_definition + : unconstrained_array_definition + { + my_vbl_error(123,NULL); + $$ = $1; + } + | constrained_array_definition + { $$ = $1; } + ; + +unconstrained_array_definition + : ARRAY + LeftParen + index_subtype_definition + RightParen_ERR + OF + subtype_indication + { + $$ = $6; + $$.CLASS = 'U'; + $$.INDEX = $3.TYPE; + } + ; + +constrained_array_definition + : ARRAY + index_constraint + OF + subtype_indication + { + vbtyp_list *NewType; + char *name; + char buffer[ 32 ]; + + $$ = $4; + + if ( $4.CLASS == 'U' ) + { + if ( $4.BASE->CLASS != 'A' ) + { + my_vbl_error(123,NULL); + } + } + else + if ( $4.CLASS == 'A' ) + { + if ( $4.BASE->CLASS != 'U' ) + { + my_vbl_error(123,NULL); + } + + sprintf( buffer, "_subtype_%d", VBL_NUMTYP ); + name = namealloc( buffer ); + + NewType = vbh_addvbtyp(VBL_BEFPNT,name,$4.LEFT, + $4.RIGHT,$4.VALUE,$4.SIZE,$4.BYTE,$4.BASE,$4.INDEX,$4.RESOLV,$4.CLASS, + VBL_LINNUM); + addtab(hshtab,name,VBL_MODNAM,VBL_SYMDFN,VBL_TPEDFN); + addtab(hshtab,name,VBL_MODNAM,VBL_LBLDFN,$4.CLASS); + addtab(hshtab,name,VBL_MODNAM,VBL_TYPDFN,$4.INDEX); + addtab(hshtab,name,VBL_MODNAM,VBL_WMNDFN,$4.LEFT); + addtab(hshtab,name,VBL_MODNAM,VBL_WMXDFN,$4.RIGHT); + addtab(hshtab,name,VBL_MODNAM,VBL_PNTDFN,(long)VBL_BEFPNT->BETYP); + VBL_NUMTYP++; + + $$.BASE = NewType; + } + else + { + my_vbl_error(123,NULL); + } + + $$.CLASS = 'A'; + $$.INDEX = $2.TYPE; + $$.DYNAMIC = $2.DYNAMIC; + + if ( ! $2.DYNAMIC ) + { + $$.LEFT = $2.LEFT; + $$.RIGHT = $2.RIGHT; + + $$.DYNAMIC_LEFT = (vexexpr *)0; + $$.DYNAMIC_RIGHT = (vexexpr *)0; + } + else + { + $$.LEFT = -2; + $$.RIGHT = -2; + + $$.DYNAMIC_LEFT = (vexexpr *)$2.LEFT; + $$.DYNAMIC_RIGHT = (vexexpr *)$2.RIGHT; + } + + } + ; + +index_subtype_definition + : name /* type_mark - causes conflict */ + _RANGE + Box + { + $$.NAME = $1.NAME; + $$.LEFT = $1.LEFT; + $$.RIGHT = $1.RIGHT; + $$.DYNAMIC = $1.DYNAMIC; + $$.AGGREG = 0; + $$.TYPE = chktab(hshtab,$1.NAME,VBL_MODNAM,VBL_TYPDFN); + $$.FLAG = chktab(hshtab,$1.NAME,VBL_MODNAM,VBL_LBLDFN); + + if ( ( $$.TYPE == 0 ) || ( $$.FLAG == 0 ) ) + { + my_vbl_error(83,$1); + } + } + ; + +index_constraint + : LeftParen + discrete_range + RightParen_ERR + { $$ = $2;} + ; + +discrete_range + : range /* includes attribute_name */ + { $$ = $1;} + | name + range_constraint /* subtype_indication - causes conflict */ + { $$ = $2; + $$.NAME = $1.NAME; + } + | type_mark /* type_mark causes 2 r/r conflicts - required for + louie's code */ + { $$ = $1;} + ; + +type_mark + : + simple_name + { + vbtyp_list *VbType; + int type; + $$.NAME = $1; + $$.LEFT = -1; + $$.RIGHT = -1; + $$.DYNAMIC = 0; + $$.AGGREG = 0; + $$.TYPE = chktab(hshtab,$1,VBL_MODNAM,VBL_TYPDFN); + $$.FLAG = chktab(hshtab,$1,VBL_MODNAM,VBL_LBLDFN); + type = chktab(hshtab,$1,VBL_MODNAM,VBL_SYMDFN); + + if (type != VBL_TPEDFN || $$.TYPE ==0) + { + my_vbl_error(84,$1); + } + + VbType = (vbtyp_list *)chktab( hshtab,$1,VBL_MODNAM,VBL_PNTDFN); + if ( ( VbType != (vbtyp_list *)0 ) && + ( VbType->DYNAMIC ) ) + { + $$.DYNAMIC = VbType->DYNAMIC; + $$.LEFT = (long)VbType->DYNAMIC_LEFT; + $$.RIGHT = (long)VbType->DYNAMIC_RIGHT; + } + } + ; + +.signal_kind. + : /*empty*/ + { $$ = VBH_KIND_NONE; } + | BUS + { $$ = VBH_KIND_BUS; } + | REGISTER + { $$ = VBH_KIND_REGISTER; } + ; + +architecture_statement_part + : ..concurrent_statement.. + ; + +..concurrent_statement.. + : /*empty*/ + | ..concurrent_statement.. + concurrent_statement + ; + +concurrent_statement + : block_statement + | concurrent_assertion_statement + | process_statement + | concurrent_signal_assignment_statement + | component_instantiation_statement + | generate_statement + | error + Semicolon_ERR + { my_vbl_error (18,NULL); } + ; + +concurrent_assertion_statement + : a_label + unlabeled_concurrent_assertion_statement + { + if (chktab (hshtab,$1,VBL_MODNAM,VBL_SYMDFN) != 0) + my_vbl_error (19,$1); + + addtab (hshtab,$1,VBL_MODNAM,VBL_SYMDFN,VBL_LABDFN); + } + | unlabeled_concurrent_assertion_statement + ; + +unlabeled_concurrent_assertion_statement + : assertion_statement + ; + +block_statement + : a_label + BLOCK + .guard_expression. + _BEGIN + { + if (chktab( hshtab, $1,VBL_MODNAM,VBL_SYMDFN) != 0) + my_vbl_error (19,$1); + + addtab( hshtab,$1,VBL_MODNAM,VBL_SYMDFN,VBL_LABDFN); + + if ($3.VEX != (vexexpr *)0) + { + VBL_GRDLST = addchain( VBL_GRDLST, (char *)$3.VEX ); + } + + } + set_of_statements + END_ERR + BLOCK + .label. + Semicolon_ERR + { + if ( $3.VEX != (vexexpr *)0 ) + { + VBL_GRDLST = delchain( VBL_GRDLST,VBL_GRDLST ); + } + + if ( ($9 != NULL) && + ($9 != $1 ) ) my_vbl_error (20,$9); + } + ; + +set_of_statements + : ..concurrent_statement.. + ; + +concurrent_signal_assignment_statement + : a_label + unlabeled_conditional_signal_assignment + { + if (chktab( hshtab,$1,VBL_MODNAM,VBL_SYMDFN) != 0) + my_vbl_error (19,$1); + addtab( hshtab,$1,VBL_MODNAM,VBL_SYMDFN, VBL_LABDFN ); + } + | unlabeled_conditional_signal_assignment + | a_label + unlabeled_selected_signal_assignment + { + if (chktab (hshtab,$1,VBL_MODNAM,VBL_SYMDFN) != 0) + my_vbl_error (19,$1); + addtab( hshtab,$1,VBL_MODNAM,VBL_SYMDFN,VBL_LABDFN); + } + | unlabeled_selected_signal_assignment + ; + +unlabeled_conditional_signal_assignment + : target + _LESym + .GUARDED. + ..waveform__WHEN__condition__ELSE.. + waveform + Semicolon_ERR + { + vbl_vexstr *VexStr; + char Buffer[ 128 ]; + char *CodedSigName; + char *Name; + long Index; + vbl_vexstr *ExprCnd; + vbl_vexstr *ExprVal; + int ProcessType; + int Type; + int Mode; + int Width; + long Left; + long Right; + long Left_bnd; + long Right_bnd; + chain_list *SensList; + chain_list *HeadChain; + chain_list *ScanChain; + chain_list *DelChain; + chain_list **PrevChain; + ptype_list **PrevInst; + ptype_list *Inst; + ptype_list *InstIfs; + ptype_list *InstAsg; + vbtyp_list *TypeTarget; + vexexpr *VexTarget; + vexexpr *VexValue; + vexexpr *VexGuard; + long Line; + unsigned char Dynamic; + + if ( $1.AGGREG ) + { + my_vbl_error(114,NULL); + } + + if ( $5.AGGREG ) + { + HeadChain = reverse( (chain_list *)$5.IDENT ); + ScanChain = HeadChain; + + if ( HeadChain->NEXT != (chain_list *)0 ) + { + Width = 0; + VexValue = createvexoper( VEX_CONCAT, 1 ); + + while ( ScanChain != (chain_list *)0 ) + { + VexStr = (vbl_vexstr *)ScanChain->DATA; + Width += VexStr->VEX->WIDTH; + addvexhexpr( VexValue, VexStr->VEX ); + + autfreeheap( VexStr, sizeof( vbl_vexstr ) ); + + ScanChain = ScanChain->NEXT; + } + + VexValue->WIDTH = Width; + } + else + { + VexStr = (vbl_vexstr *)HeadChain->DATA; + VexValue = VexStr->VEX; + + autfreeheap( VexStr, sizeof( vbl_vexstr ) ); + } + + freechain( HeadChain ); + + $5.AGGREG = 0; + $5.VEX = VexValue; + } + + sprintf( Buffer, "%s.cod.%s", VBL_MODNAM, $1.NAME ); + CodedSigName = namealloc( Buffer ); + + Type = chktab( hshtab, CodedSigName, VBL_MODNAM, VBL_TYPDFN ); + ProcessType = 0; + + if ( Type >= VBH_MAX_TYPE ) + { + Mode = chktab( hshtab, $1.NAME, VBL_MODNAM, VBL_SYMDFN ); + Dynamic = chktab( hshtab, $1.NAME, VBL_MODNAM, VBL_DYNDFN ); + + Left = $1.LEFT; + Right = $1.RIGHT; + } + else + { + Type = chktab( hshtab, $1.NAME, VBL_MODNAM, VBL_TYPDFN ); + Mode = chktab( hshtab, $1.NAME, VBL_MODNAM, VBL_SYMDFN ); + Dynamic = chktab( hshtab, $1.NAME, VBL_MODNAM, VBL_DYNDFN ); + + Left = $1.LEFT; + Right = $1.RIGHT; + } + + if( Mode == VBL_ICNDFN ) my_vbl_error( 21, $1.NAME ); + if( Mode == 0 ) my_vbl_error( 17, $1.NAME ); + + if ( ! $1.DYNAMIC ) + { + VexTarget = vbl_dynamicvexatom( $1.NAME, $1.LEFT, $1.RIGHT, Dynamic ); + } + else + { + Left_bnd = chktab (hshtab,$1.NAME,VBL_MODNAM,VBL_WMNDFN); + Right_bnd = chktab (hshtab,$1.NAME,VBL_MODNAM,VBL_WMXDFN); + + VexTarget = vbl_dynamicvexatom( $1.NAME, Left_bnd, Right_bnd, Dynamic ); + + if ( Right == 0 ) + { + VexTarget = createvexbinexpr( VEX_INDEX, 1, VexTarget, (vexexpr *)Left ); + } + else + { + if ( ( Mode == VBL_FUNDFN ) || + ( Mode == VBL_PRODFN ) || + ( Mode == VBL_TPEDFN ) ) + { + freevexexpr( VexTarget ); + VexTarget = (vexexpr *)Left; + } + else + if ( $1.DYNAMIC == VBL_UPTDFN ) + { + if ( ( ! Dynamic ) || + ( ! isvexequalexpr( (vexexpr *)Left_bnd, (vexexpr *)Left ) ) || + ( ! isvexequalexpr( (vexexpr *)Right_bnd, (vexexpr *)Right ) ) ) + { + VexTarget = createvexternaryexpr( VEX_TO, 1, VexTarget, + (vexexpr *)Left, (vexexpr *)Right ); + } + } + else + if ( $1.DYNAMIC == VBL_DWTDFN ) + { + if ( ( ! Dynamic ) || + ( ! isvexequalexpr( (vexexpr *)Left_bnd, (vexexpr *)Left ) ) || + ( ! isvexequalexpr( (vexexpr *)Right_bnd, (vexexpr *)Right ) ) ) + { + VexTarget = createvexternaryexpr( VEX_DOWNTO, 1, VexTarget, + (vexexpr *)Left, (vexexpr *)Right ); + } + } + else + { + VexTarget = createvexbinexpr( VEX_INDEX_N, 1, VexTarget, (vexexpr *)Left ); + VexTarget = createvexbinexpr( VEX_INDEX_N, 1, VexTarget, (vexexpr *)Right ); + } + } + } + + if ( $1.SIGNED ) + { + SetVexNodeSigned( VexTarget ); + } + + TypeTarget = get_type( Type ); + + Inst = (ptype_list *)0; + PrevInst = &Inst; + SensList = (chain_list *)0; + + if ( VBL_CNDLST != (chain_list *)0 ) + { + VBL_CNDLST = reverse( VBL_CNDLST ); + VBL_VALLST = reverse( VBL_VALLST ); + VBL_LINLST = reverse( VBL_LINLST ); + } + + while ( VBL_CNDLST != (chain_list *)0 ) + { + ProcessType |= VBH_PROCESS_CONDITIONNAL_MASK; + + ExprVal = (vbl_vexstr *)VBL_VALLST->DATA; + ExprCnd = (vbl_vexstr *)VBL_CNDLST->DATA; + Line = (long )VBL_LINLST->DATA; + + SensList = unionvexexprsupport( SensList, ExprCnd->VEX ); + SensList = unionvexexprsupport( SensList, ExprVal->VEX ); + + InstAsg = vbh_addvbasg( (ptype_list *)0, dupvexexpr( VexTarget ), + simpvexexprothers( ExprVal->VEX, VexTarget->WIDTH ), + TypeTarget, Line ); + + InstIfs = vbh_addvbifs( (ptype_list *)0, ExprCnd->VEX, Line ); + ((vbifs_list *)InstIfs->DATA)->CNDTRUE = InstAsg; + + *PrevInst = InstIfs; + PrevInst = &((vbifs_list *)InstIfs->DATA)->CNDFALSE; + + autfreeheap( ExprCnd, sizeof( vbl_vexstr ) ); + autfreeheap( ExprVal, sizeof( vbl_vexstr ) ); + + VBL_CNDLST = delchain( VBL_CNDLST, VBL_CNDLST ); + VBL_VALLST = delchain( VBL_VALLST, VBL_VALLST ); + VBL_LINLST = delchain( VBL_LINLST, VBL_LINLST ); + } + + SensList = unionvexexprsupport( SensList, $5.VEX ); + *PrevInst = vbh_addvbasg( (ptype_list *)0, VexTarget, + simpvexexprothers( $5.VEX, VexTarget->WIDTH ), + TypeTarget, VBL_LINNUM ); + if ( $3 == VBL_GRDDFN ) + { + ProcessType |= VBH_PROCESS_GUARDED_MASK; + + VexGuard = dupvexexpr( (vexexpr *)VBL_GRDLST->DATA ); + SensList = unionvexexprsupport( SensList, VexGuard ); + + InstIfs = vbh_addvbifs( (ptype_list *)0, VexGuard, VBL_LINNUM ); + ((vbifs_list *)InstIfs->DATA)->CNDTRUE = Inst; + + Inst = InstIfs; + } + + PrevChain = &SensList; + ScanChain = SensList; + + while ( ScanChain != (chain_list *)0 ) + { + Name = getvexvectorname( ScanChain->DATA, &Index ); + Mode = chktab( hshtab, Name, VBL_MODNAM, VBL_SYMDFN ); + + if ( ( Mode == VBL_CSTDFN ) || + ( Mode == VBL_GENDFN ) || + ( Mode == VBL_VARDFN ) ) + { + DelChain = ScanChain; + *PrevChain = DelChain->NEXT; + ScanChain = ScanChain->NEXT; + + DelChain->NEXT = (chain_list *)0; + freechain( DelChain ); + } + else + { + PrevChain = &ScanChain->NEXT; + ScanChain = ScanChain->NEXT; + } + } + + Inst = addptype( Inst, VBH_BEWAS, + vbh_addvbwas( SensList, NULL, 0, NULL, VBL_LINNUM ) ); + Inst = reversetype( Inst ); + + sprintf( Buffer, "p%ld", VBL_LINNUM ); + VBL_PROCNAM = namealloc( Buffer ); + VBL_BEPCS = vbh_addvbpcs( VBL_BEPCS, VBL_PROCNAM, NULL, Inst, VBL_LINNUM ); + VBL_BEPCS->TYPE = ProcessType; + VBL_PROCNAM = (char *)0; + } + ; + +..waveform__WHEN__condition__ELSE.. + : /*empty*/ + | ..waveform__WHEN__condition__ELSE.. + waveform + WHEN + expression + ELSE + { + vbl_vexstr *Expr; + + Expr = (vbl_vexstr *)autallocheap( sizeof( vbl_vexstr ) ); + Expr->WIDTH = $4.WIDTH; + Expr->VEX = $4.VEX; + VBL_CNDLST = addchain( VBL_CNDLST, (char *)Expr ); + + Expr = (vbl_vexstr *)autallocheap( sizeof( vbl_vexstr ) ); + Expr->WIDTH = $2.WIDTH; + Expr->VEX = $2.VEX; + VBL_VALLST = addchain( VBL_VALLST, (char *)Expr ); + + VBL_LINLST = addchain( VBL_LINLST, (char *)VBL_LINNUM ); + } + ; + +unlabeled_selected_signal_assignment + : WITH + expression + { + VBL_CASSIZE = $2.WIDTH - 1; + } + SELECT + target + _LESym + .GUARDED. + waveform__WHEN__choices + ...waveform__WHEN__choices.. + Semicolon_ERR + { + char *CodedSigName; + char *Name; + long Index; + char Buffer[ 128 ]; + ptype_list *InstCase; + ptype_list *InstAsg; + ptype_list *InstIfs; + ptype_list *Inst; + chain_list *SensList; + vbl_vexstr *ExprVal; + vbcho_list *VbChoice; + vbcas_list *VbCase; + chain_list *ScanCond; + chain_list *ScanChain; + chain_list **PrevChain; + chain_list *DelChain; + vbtyp_list *TypeTarget; + vexexpr *VexTarget; + vexexpr *VexGuard; + char *Value; + int SizeValue; + int NumberChoice; + int Type; + int Mode; + long Left; + long Right; + long Left_bnd; + long Right_bnd; + long Line; + int ProcessType; + unsigned char Dynamic; + + if ( $5.AGGREG ) + { + my_vbl_error(114,NULL); + } + + sprintf( Buffer, "%s.cod.%s", VBL_MODNAM, $5.NAME ); + CodedSigName = namealloc( Buffer ); + ProcessType = VBH_PROCESS_WITHSELECT_MASK; + + Type = chktab( hshtab, CodedSigName, VBL_MODNAM, VBL_TYPDFN ); + + if ( Type >= VBH_MAX_TYPE ) + { + Mode = chktab( hshtab, $5.NAME, VBL_MODNAM, VBL_SYMDFN ); + Dynamic = chktab( hshtab, $5.NAME, VBL_MODNAM, VBL_DYNDFN ); + Left = $5.LEFT; + Right = $5.RIGHT; + } + else + { + Type = chktab( hshtab, $5.NAME, VBL_MODNAM, VBL_TYPDFN ); + Mode = chktab( hshtab, $5.NAME, VBL_MODNAM, VBL_SYMDFN ); + Dynamic = chktab( hshtab, $5.NAME, VBL_MODNAM, VBL_DYNDFN ); + + Left = $5.LEFT; + Right = $5.RIGHT; + } + + if( Mode == VBL_ICNDFN ) my_vbl_error( 21, $5.NAME ); + if( Mode == 0 ) my_vbl_error( 17, $5.NAME ); + + if ( ! $5.DYNAMIC ) + { + VexTarget = vbl_dynamicvexatom( $5.NAME, $5.LEFT, $5.RIGHT, Dynamic ); + } + else + { + Left_bnd = chktab (hshtab,$5.NAME,VBL_MODNAM,VBL_WMNDFN); + Right_bnd = chktab (hshtab,$5.NAME,VBL_MODNAM,VBL_WMXDFN); + + VexTarget = vbl_dynamicvexatom( $5.NAME, Left_bnd, Right_bnd, Dynamic ); + + if ( Right == 0 ) + { + VexTarget = createvexbinexpr( VEX_INDEX, 1, VexTarget, + (vexexpr *)Left ); + } + else + { + if ( ( Mode == VBL_FUNDFN ) || + ( Mode == VBL_TPEDFN ) || + ( Mode == VBL_PRODFN ) ) + { + VexTarget = (vexexpr *)Left; + } + else + if ( $5.DYNAMIC == VBL_UPTDFN ) + { + if ( ( ! Dynamic ) || + ( ! isvexequalexpr( (vexexpr *)Left_bnd, (vexexpr *)Left ) ) || + ( ! isvexequalexpr( (vexexpr *)Right_bnd, (vexexpr *)Right ) ) ) + { + VexTarget = createvexternaryexpr( VEX_TO, 1, VexTarget, + (vexexpr *)Left, (vexexpr *)Right ); + } + } + else + if ( $5.DYNAMIC == VBL_DWTDFN ) + { + if ( ( ! Dynamic ) || + ( ! isvexequalexpr( (vexexpr *)Left_bnd, (vexexpr *)Left ) ) || + ( ! isvexequalexpr( (vexexpr *)Right_bnd, (vexexpr *)Right ) ) ) + { + VexTarget = createvexternaryexpr( VEX_DOWNTO, 1, VexTarget, + (vexexpr *)Left, (vexexpr *)Right ); + } + } + else + { + VexTarget = createvexbinexpr( VEX_INDEX_N, 1, VexTarget, (vexexpr *)Left ); + VexTarget = createvexbinexpr( VEX_INDEX_N, 1, VexTarget, (vexexpr *)Right ); + } + } + } + + if ( $5.SIGNED ) + { + SetVexNodeSigned( VexTarget ); + } + + TypeTarget = get_type( Type ); + SensList = getvexexprsupport( $2.VEX ); + + InstCase = vbh_addvbcas( (ptype_list *)0, $2.VEX, get_type( $2.TYPE ), VBL_LINNUM ); + VbCase = (vbcas_list *)InstCase->DATA; + + SizeValue = $2.WIDTH + 1; + NumberChoice = 0; + + for ( ScanCond = VBL_CNDLST; + ScanCond != (chain_list *)0; + ScanCond = ScanCond->NEXT ) + { + NumberChoice++; + } + + VbChoice = (vbcho_list *)autallocblock( sizeof( vbcho_list ) * NumberChoice ); + + VbCase->CHOICE = VbChoice; + VbCase->SIZE = NumberChoice; + + while ( VBL_CNDLST != (chain_list *)0 ) + { + NumberChoice = NumberChoice - 1; + + ExprVal = (vbl_vexstr *)VBL_VALLST->DATA; + Line = (long )VBL_LINLST->DATA; + + ExprVal->VEX = simpvexexprothers( ExprVal->VEX, VexTarget->WIDTH ), + + InstAsg = vbh_addvbasg( (ptype_list *)0, dupvexexpr( VexTarget ), + ExprVal->VEX, TypeTarget, Line ); + + SensList = unionvexexprsupport( SensList, ExprVal->VEX ); + + Value = (char *)VBL_CNDLST->DATA; + if ( Value == (char *)0 ) Value = namealloc( "others" ); + + VbChoice[ NumberChoice ].INSTRUCTION = InstAsg; + VbChoice[ NumberChoice ].SIZE = SizeValue; + VbChoice[ NumberChoice ].VALUES = addchain( NULL, Value ); + + autfreeheap( ExprVal, sizeof( vbl_vexstr ) ); + + VBL_CNDLST = delchain( VBL_CNDLST, VBL_CNDLST ); + VBL_VALLST = delchain( VBL_VALLST, VBL_VALLST ); + VBL_LINLST = delchain( VBL_LINLST, VBL_LINLST ); + } + + if ( $7 == VBL_GRDDFN ) + { + ProcessType |= VBH_PROCESS_GUARDED_MASK; + + VexGuard = dupvexexpr( (vexexpr *)VBL_GRDLST->DATA ); + SensList = unionvexexprsupport( SensList, VexGuard ); + + InstIfs = vbh_addvbifs( (ptype_list *)0, VexGuard, VBL_LINNUM ); + ((vbifs_list *)InstIfs->DATA)->CNDTRUE = InstCase; + + Inst = InstIfs; + } + else + { + Inst = InstCase; + } + + PrevChain = &SensList; + ScanChain = SensList; + + while ( ScanChain != (chain_list *)0 ) + { + Name = getvexvectorname( ScanChain->DATA, &Index ); + Mode = chktab( hshtab, Name, VBL_MODNAM, VBL_SYMDFN ); + + if ( ( Mode == VBL_CSTDFN ) || + ( Mode == VBL_GENDFN ) || + ( Mode == VBL_VARDFN ) ) + { + DelChain = ScanChain; + *PrevChain = DelChain->NEXT; + ScanChain = ScanChain->NEXT; + + DelChain->NEXT = (chain_list *)0; + freechain( DelChain ); + } + else + { + PrevChain = &ScanChain->NEXT; + ScanChain = ScanChain->NEXT; + } + } + + Inst->NEXT = addptype( (ptype_list *)0, VBH_BEWAS, + vbh_addvbwas( SensList, NULL, 0, NULL, VBL_LINNUM ) ); + + sprintf( Buffer, "p%ld", VBL_LINNUM ); + VBL_PROCNAM = namealloc( Buffer ); + VBL_BEPCS = vbh_addvbpcs( VBL_BEPCS, VBL_PROCNAM, NULL, Inst, VBL_LINNUM ); + VBL_BEPCS->TYPE = ProcessType; + VBL_PROCNAM = (char *)0; + } + ; + +...waveform__WHEN__choices.. + : /*empty*/ + | ...waveform__WHEN__choices.. + Comma + waveform__WHEN__choices + +waveform__WHEN__choices + : waveform + WHEN + choices + { + vbl_vexstr *Expr; + + while ( VBL_NUMCHOICE > 0 ) + { + Expr = (vbl_vexstr *)autallocheap( sizeof( vbl_vexstr ) ); + Expr->WIDTH = $1.WIDTH; + Expr->VEX = dupvexexpr( $1.VEX ); + + VBL_VALLST = addchain( VBL_VALLST, (char *)Expr ); + VBL_NUMCHOICE--; + } + + freevexexpr( $1.VEX ); + } + ; + +process_statement + : a_label + { + if ( chktab (hshtab,$1,VBL_MODNAM,VBL_SYMDFN) != 0) + my_vbl_error (19,$1); + + addtab( hshtab,$1,VBL_MODNAM,VBL_SYMDFN, VBL_LABDFN); + + VBL_PROCNAM = $1; + } + unlabeled_process_statement + | { + char buffer[ 20 ]; + sprintf( buffer, "p%ld", VBL_LINNUM ); + VBL_PROCNAM = namealloc( buffer ); + } + unlabeled_process_statement + ; + +unlabeled_process_statement + : PROCESS + { VBL_NM1LST = NULL;} + .sensitivity_list. + { + VBL_BEPCS = vbh_addvbpcs( VBL_BEPCS, VBL_PROCNAM,VBL_NM1LST,NULL,VBL_LINNUM ); + VBL_BEPCS->TYPE = VBH_PROCESS_SEQUENTIAL_MASK; + VBL_NM1LST = NULL; + } + process_declarative_part + _BEGIN + { + void *pnt; + pnt = &(VBL_BEPCS->INSTRUCTION); + VBL_INSLST = addchain(NULL,pnt); + } + sequence_of_statements + { + struct ptype **pnt; + struct ptype *ptype; + pnt = (struct ptype**)VBL_INSLST->DATA; + ptype = reversetype(*pnt); + *pnt = ptype; + VBL_INSLST = delchain (VBL_INSLST, VBL_INSLST); + } + END_ERR + PROCESS + .label. + Semicolon_ERR + { + VBL_PROCNAM = (char *)0; + yyerrok; + } + ; + +process_declarative_part + : ..process_declarative_item.. + ; + + +..process_declarative_item.. + : /*empty*/ + | ..process_declarative_item.. + process_declarative_item + { + yyerrok; + } + ; + +process_declarative_item + : constant_declaration + | variable_declaration + | type_declaration + | subtype_declaration + | attribute_declaration + | attribute_specification + | subprogram_declaration + | subprogram_body + ; + +.sensitivity_list. + : /*empty*/ + | sensitivity_list + ; + +sensitivity_list + : LeftParen + signal_list + RightParen {} + ; + +signal_list + : name + ...name.. + { + vexexpr *Vex; + chain_list *Chain; + char *LocalName; + + if ( chktab(hshtab,$1.NAME,VBL_FUNCNAM,VBL_SYMDFN ) ) + { + LocalName = VBL_FUNCNAM; + } + else + if ( chktab(hshtab,$1.NAME,VBL_MODNAM,VBL_SYMDFN ) ) + { + LocalName = VBL_MODNAM; + } + else + { + my_vbl_error(17,$1.NAME); + } + + if ( ! $1.DYNAMIC ) + { + if ( ( $1.LEFT == -1 ) && + ( $1.RIGHT == -1 ) ) + { + Vex = createvexatombit( $1.NAME ); + } + else + { + Vex = createvexatomvec( $1.NAME, $1.LEFT, $1.RIGHT ); + } + } + else + { + Vex = createvexatomvec( $1.NAME, -1, -1 ); + } + + Chain = getvexatombitname( Vex ); + VBL_NM1LST = append( VBL_NM1LST, Chain ); + freevexexpr( Vex ); + } + ; + +...name.. + : /*empty*/ + | Comma + name + ...name.. + { + vexexpr *Vex; + chain_list *Chain; + char *LocalName; + + if ( chktab(hshtab,$2.NAME,VBL_FUNCNAM,VBL_SYMDFN ) ) + { + LocalName = VBL_FUNCNAM; + } + else + if ( chktab(hshtab,$2.NAME,VBL_MODNAM,VBL_SYMDFN ) ) + { + LocalName = VBL_MODNAM; + } + else + { + my_vbl_error(17,$2.NAME); + } + + if ( ! $2.DYNAMIC ) + { + if ( ( $2.LEFT == -1 ) && + ( $2.RIGHT == -1 ) ) + { + Vex = createvexatombit( $2.NAME ); + } + else + { + Vex = createvexatomvec( $2.NAME, $2.LEFT, $2.RIGHT ); + } + } + else + { + Vex = createvexatomvec( $2.NAME, -1, -1 ); + } + + Chain = getvexatombitname( Vex ); + VBL_NM1LST = append( VBL_NM1LST, Chain ); + freevexexpr( Vex ); + } + ; + +sequence_of_statements + : + | sequence_of_statements + sequential_statement + ; + +sequential_statement + : assertion_statement + | variable_assignment_statement + | signal_assignment_statement + | if_statement + | case_statement + | loop_statement + | next_statement + | exit_statement + | return_statement + | null_statement + | procedure_call_statement + | wait_statement + ; + +loop_statement + : a_label + { + if ( chktab (hshtab,$1,VBL_MODNAM,VBL_SYMDFN) != 0) + my_vbl_error (19,$1); + + VBL_LOOPLBLLST = addchain(VBL_LOOPLBLLST,$1 ); + } + + unlabeled_loop_statement + | + { + char buffer[ 20 ]; + + sprintf( buffer, "loop_%ld", VBL_LINNUM ); + VBL_LOOPLBLLST = addchain ( VBL_LOOPLBLLST, namealloc( buffer ) ); + } + unlabeled_loop_statement + ; + +unlabeled_loop_statement + : .iteration_scheme. + LOOP + { + struct ptype **pnt; + vbl_name *Range; + vbvar_list *VbVar; + char *LocalName; + vexexpr *Target; + short Signed; + long Left; + long Right; + long AttrLeft; + long AttrRight; + char StrFlag; + char ForUp; + + pnt = (struct ptype**)VBL_INSLST->DATA; + VBL_LOOPLBL = (char *)VBL_LOOPLBLLST->DATA; + + if ( $1.IDENT != (char *)0 ) + { + if ( VBL_FUNCNAM != (char *)0 ) + { + LocalName = VBL_FUNCNAM; + StrFlag = 'v'; + } + else + { + LocalName = VBL_PROCNAM; + StrFlag = 'V'; + } + + Range = (vbl_name *)$1.VEX; + + if ( Range->DYNAMIC ) + { + if ( Range->DYNAMIC == VBL_UPTDFN ) ForUp = 1; + else ForUp = 0; + + AttrLeft = -1; + AttrRight = -1; + } + else + { + AttrLeft = Range->LEFT; + AttrRight = Range->RIGHT; + + if ( AttrLeft <= AttrRight ) ForUp = 1; + else ForUp = 0; + } + + if ( chktab( hshtab,$1.IDENT,LocalName,VBL_SYMDFN ) != 0 ) + { + Target = (vexexpr *)chktab( hshtab, $1.IDENT, LocalName, VBL_PNTDFN ); + Signed = ( IsVexNodeSigned( Target ) != 0 ); + } + else + { + VbVar = (vbvar_list *)vbl_addstr( StrFlag,0, + get_type(VBH_TYPE_INTEGER),VBH_TYPE_INTEGER, + 'I',$1.IDENT, -1, -1, NULL, 0 ,0); + Target = VbVar->TARGET; + Signed = ( IsVexNodeSigned( VbVar->TARGET ) != 0 ); + + if ( IsVexAtomBit( VbVar->TARGET ) ) + { + Left = -1; + Right = -1; + } + else + { + Left = VbVar->TARGET->LEFT; + Right = VbVar->TARGET->RIGHT; + } + + addtab( hshtab,$1.IDENT,LocalName,VBL_SYMDFN,VBL_VARDFN); + addtab( hshtab,$1.IDENT,LocalName,VBL_TYPDFN,VBH_TYPE_INTEGER); + addtab( hshtab,$1.IDENT,LocalName,VBL_WMNDFN,Left); + addtab( hshtab,$1.IDENT,LocalName,VBL_WMXDFN,Right); + addtab( hshtab,$1.IDENT,LocalName,VBL_ATLDFN,AttrLeft); + addtab( hshtab,$1.IDENT,LocalName,VBL_ATRDFN,AttrRight); + addtab( hshtab,$1.IDENT,LocalName,VBL_LBLDFN,0); + addtab( hshtab,$1.IDENT,LocalName,VBL_PNTDFN,(long)VbVar->TARGET); + addtab( hshtab,$1.IDENT,LocalName,VBL_SUNDFN,Signed); + } + + if ( ! Range->DYNAMIC ) + { + Range->LEFT = (long)createvexatomlong( AttrLeft , 0, Signed ); + Range->RIGHT = (long)createvexatomlong( AttrRight, 0, Signed ); + } + + *pnt = vbh_addvbfor(*pnt,VBL_LOOPLBL,dupvexexpr(Target), + Range->LEFT,Range->RIGHT,ForUp, VBL_LINNUM ); + + VBL_INSLST = addchain( VBL_INSLST, + &(((struct vbfor*)(*pnt)->DATA)->INSTRUCTION)); + + autfreeheap( Range, sizeof( vbl_name ) ); + } + else + if ( $1.VEX != (vexexpr *)0 ) + { + *pnt = vbh_addvbwhi(*pnt,VBL_LOOPLBL,$1.VEX, VBL_LINNUM ); + VBL_INSLST = addchain( VBL_INSLST, + &(((struct vbwhi*)(*pnt)->DATA)->INSTRUCTION)); + } + else + { + *pnt = vbh_addvblop(*pnt,VBL_LOOPLBL, VBL_LINNUM ); + VBL_INSLST = addchain( VBL_INSLST, + &(((struct vblop *)(*pnt)->DATA)->INSTRUCTION)); + } + } + sequence_of_statements + END_ERR + LOOP + .label. + Semicolon_ERR + { + struct ptype **pnt; + struct ptype *ptype; + + pnt = (struct ptype**)VBL_INSLST->DATA; + ptype = reversetype(*pnt); + *pnt = ptype; + + if ( $7 != NULL ) + { + if ( VBL_LOOPLBLLST->DATA != $7 ) + { + my_vbl_error( 95, $7 ); + } + } + + VBL_INSLST = delchain( VBL_INSLST, VBL_INSLST); + VBL_LOOPLBLLST = delchain( VBL_LOOPLBLLST, VBL_LOOPLBLLST ); + VBL_LOOPLBL = (char *)NULL; + } + ; + +.iteration_scheme. + : /*empty*/ + { + $$ = vbl_crtvex( EMPTYOP,NULL ,NULL ,-1,-1,0); + } + | iteration_scheme + { + $$ = $1; + } + ; + +iteration_scheme + : WHILE + expression + { + $$ = $2; + } + | FOR + loop_parameter_specification + { + $$ = $2; + } + ; + +loop_parameter_specification + : Identifier + _IN + discrete_range + { + vbl_name *Range; + + Range = (vbl_name *)autallocheap( sizeof( vbl_name ) ); + *Range = $3; + + $$.IDENT = $1; + $$.VEX = (vexexpr *)Range; + } + ; + +wait_statement + : WAIT + { + if ( ( VBL_BEPCS != NULL ) && + ( VBL_BEPCS->SENSITIVITY != NULL ) ) + { + my_vbl_error(96,NULL); + } + } + .sensitivity_clause. + .condition_clause. + .timeout_clause. + Semicolon_ERR + { + struct ptype **pnt; + struct ptype *ptptyp; + struct vbwas *ptvbwas; + + ptvbwas = vbh_addvbwas( VBL_NM1LST, $4.VEX, $5.TYPE, + (vexexpr *)$5.NAME, VBL_LINNUM ); + + pnt = (struct ptype **) VBL_INSLST->DATA; + ptptyp = addptype(*pnt, VBH_BEWAS, ptvbwas); + *pnt = ptptyp; + VBL_NM1LST = NULL; + } + ; + +.sensitivity_clause. + : /*empty*/ + { VBL_NM1LST = NULL;} + | sensitivity_clause + ; + +sensitivity_clause + : ON + { VBL_NM1LST = NULL;} + signal_list + ; + +.condition_clause. + : /*empty*/ + { $$ = vbl_crtvex (EMPTYOP ,NULL ,NULL ,-1,-1,0); } + | condition_clause + { + $$ = $1; + } + ; + +condition_clause + : UNTIL + expression + { + $$ = $2; + } + ; + +.timeout_clause. + : /*empty*/ + { + $$.NAME = NULL; + $$.LEFT = 0; + $$.RIGHT = 0; + $$.FLAG = 0; + $$.TYPE = 0; + $$.DYNAMIC = 0; + $$.AGGREG = 0; + } + | timeout_clause + { + $$ = $1; + } + ; + +timeout_clause + : FOR + simple_expression + time_label + { + $$.NAME = (char *)$2.VEX; + $$.TYPE = $3; + $$.FLAG = 0; + $$.SIGNED = 0; + $$.LEFT = 0; + $$.RIGHT = 0; + $$.AGGREG = 0; + $$.DYNAMIC = 1; + + viewvexexprboundln( $2.VEX ); + fprintf( stdout, " %d\n", $3 ); + } + ; + +time_label + : _FS + { + $$ = VBH_TIME_UNIT_FS; + } + | _PS + { + $$ = VBH_TIME_UNIT_PS; + } + | _NS + { + $$ = VBH_TIME_UNIT_NS; + } + | _MS + { + $$ = VBH_TIME_UNIT_MS; + } + ; + +next_statement + : _NEXT + .label. + .WHEN__condition. + Semicolon_ERR + { + struct vbnxt *ptvbnxt; + struct ptype **pnt; + + pnt = (struct ptype**)VBL_INSLST->DATA; + ptvbnxt = vbh_addvbnxt($2, $3.VEX,VBL_LINNUM); + *pnt = addptype( *pnt, VBH_BENXT, ptvbnxt ); + } + ; + +exit_statement + : _EXIT + .label. + .WHEN__condition. + Semicolon_ERR + { + struct vbext *ptvbext; + struct ptype **pnt; + + pnt = (struct ptype**)VBL_INSLST->DATA; + ptvbext = vbh_addvbext($2, $3.VEX,VBL_LINNUM); + *pnt = addptype( *pnt, VBH_BEEXT, ptvbext ); + } + ; + +.WHEN__condition. + : /*empty*/ + { $$.VEX = (vexexpr *)0; } + | WHEN + condition + { $$ = $2; } + ; + +return_statement + : _RETURN + .expression. + Semicolon_ERR + { + struct vbret *ptvbret; + struct ptype **pnt; + + if ( VBL_FUNCNAM == (char *)0 ) + { + my_vbl_error(120,NULL); + } + + pnt = (struct ptype**)VBL_INSLST->DATA; + ptvbret = vbh_addvbret($2.VEX,VBL_LINNUM); + *pnt = addptype( *pnt, VBH_BERET, ptvbret ); + } + ; + +.expression. + : /*empty*/ + { $$.VEX = (vexexpr *)0; } + | expression + { $$ = $1; } + ; + +assertion_statement + : ASSERT + expression + .REPORT__expression. + .SEVERITY__expression. + Semicolon_ERR + { } + ; + +variable_assignment_statement + : target + VarAsgn + expression + Semicolon_ERR + { + unsigned int type; + char *codedsigname; + int mode; + long left ,right; + long left_bnd ,right_bnd; + char buffer[128]; + struct ptype **pnt; + vexexpr *vex; + char *LocalName; + vbl_vexstr *VexStr; + vbl_vexstr *VexStr2; + chain_list *ScanChain; + chain_list *ScanChain2; + ptype_list *AsgList; + unsigned char dynamic; + + if ( $1.AGGREG ) + { + if ( ! $3.AGGREG ) + { + my_vbl_error(114,NULL); + } + + ScanChain = (chain_list *)$1.NAME; + ScanChain2 = (chain_list *)$3.IDENT; + AsgList = (ptype_list *)0; + + while ( ( ScanChain != (chain_list *)0 ) && + ( ScanChain2 != (chain_list *)0 ) ) + { + VexStr = (vbl_vexstr *)ScanChain->DATA; + VexStr2 = (vbl_vexstr *)ScanChain2->DATA; + + AsgList = vbh_addvbvar( AsgList, VexStr->VEX, + simpvexexprothers( VexStr2->VEX, VexStr->VEX->WIDTH ), + get_type(VexStr->TYPE), VBL_LINNUM ); + + autfreeheap( VexStr , sizeof( vbl_vexstr ) ); + autfreeheap( VexStr2, sizeof( vbl_vexstr ) ); + + ScanChain = ScanChain ->NEXT; + ScanChain2 = ScanChain2->NEXT; + } + + if ( ( ScanChain != (chain_list *)0 ) || + ( ScanChain2 != (chain_list *)0 ) ) + { + my_vbl_error(114,NULL); + } + + freechain( (chain_list *)$1.NAME ); + freechain( (chain_list *)$3.IDENT ); + + pnt = (struct ptype**)(VBL_INSLST->DATA); + *pnt = (struct ptype *)vbh_addvbagr(*pnt, AsgList, VBL_LINNUM ); + } + else + { + if ( chktab(hshtab,$1.NAME,VBL_FUNCNAM,VBL_SYMDFN ) ) + { + LocalName = VBL_FUNCNAM; + } + else + if ( chktab(hshtab,$1.NAME,VBL_PROCNAM,VBL_SYMDFN ) ) + { + LocalName = VBL_PROCNAM; + } + else + { + my_vbl_error(27,$1.NAME); + } + + sprintf (buffer, "%s.cod.%s", LocalName, $1.NAME); + codedsigname = namealloc( buffer ); + + type = chktab(hshtab,codedsigname,LocalName,VBL_TYPDFN); + + if ( type >= VBH_MAX_TYPE ) + { + mode = chktab(hshtab,$1.NAME,LocalName,VBL_SYMDFN); + dynamic = chktab( hshtab, $1.NAME, LocalName, VBL_DYNDFN ); + left = $1.LEFT; + right = $1.RIGHT; + } + else + { + type = chktab(hshtab,$1.NAME,LocalName,VBL_TYPDFN); + mode = chktab(hshtab,$1.NAME,LocalName,VBL_SYMDFN); + dynamic = chktab( hshtab, $1.NAME, LocalName, VBL_DYNDFN ); + + left = $1.LEFT; + right = $1.RIGHT; + } + + if ( ! $1.DYNAMIC ) + { + if ( ( $1.LEFT == -1 ) && + ( $1.RIGHT == -1 ) ) + { + vex = createvexatombit( $1.NAME ); + } + else + { + vex = createvexatomvec( $1.NAME, $1.LEFT, $1.RIGHT ); + } + } + else + { + left_bnd = chktab (hshtab,$1.NAME,LocalName,VBL_WMNDFN); + right_bnd = chktab (hshtab,$1.NAME,LocalName,VBL_WMXDFN); + + vex = vbl_dynamicvexatom( $1.NAME, left_bnd, right_bnd, dynamic ); + + if ( right == 0 ) + { + vex = createvexbinexpr( VEX_INDEX, 1, vex, (vexexpr *)left ); + } + else + { + if ( ( mode == VBL_FUNDFN ) || + ( mode == VBL_TPEDFN ) || + ( mode == VBL_PRODFN ) ) + { + vex = (vexexpr *)left; + } + else + if ( $1.DYNAMIC == VBL_UPTDFN ) + { + if ( ( ! dynamic ) || + ( ! isvexequalexpr( (vexexpr *)left_bnd, (vexexpr *)left ) ) || + ( ! isvexequalexpr( (vexexpr *)right_bnd, (vexexpr *)right ) ) ) + { + vex = createvexternaryexpr( VEX_TO, 1, vex, + (vexexpr *)left, (vexexpr *)right ); + } + } + else + if ( $1.DYNAMIC == VBL_DWTDFN ) + { + if ( ( ! dynamic ) || + ( ! isvexequalexpr( (vexexpr *)left_bnd, (vexexpr *)left ) ) || + ( ! isvexequalexpr( (vexexpr *)right_bnd, (vexexpr *)right ) ) ) + { + vex = createvexternaryexpr( VEX_DOWNTO, 1, vex, + (vexexpr *)left, (vexexpr *)right ); + } + } + else + { + vex = createvexbinexpr( VEX_INDEX_N, 1, vex, (vexexpr *)left ); + vex = createvexbinexpr( VEX_INDEX_N, 1, vex, (vexexpr *)right ); + } + } + } + + pnt = (struct ptype**)(VBL_INSLST->DATA); + *pnt = (struct ptype *)vbh_addvbvar(*pnt,vex, + simpvexexprothers( $3.VEX, vex->WIDTH ),get_type(type),VBL_LINNUM); + } + } + ; + +procedure_call_statement + : name + Semicolon_ERR + { + struct vbcal *ptvbcal; + struct ptype **pnt; + vexexpr *VexFunc; + + pnt = (struct ptype**)VBL_INSLST->DATA; + + if ( chktab( hshtab,$1.NAME,VBL_MODNAM,VBL_SYMDFN) != VBL_PRODFN ) + { + my_vbl_error(119,$1.NAME); + } + + if ( ! $1.DYNAMIC ) VexFunc = createvexfunc( $1.NAME, 0 ); + else VexFunc = (vexexpr *)$1.LEFT; + + ptvbcal = vbh_addvbcal( VexFunc, VBL_LINNUM ); + *pnt = addptype( *pnt, VBH_BECAL, ptvbcal ); + } + +signal_assignment_statement + : target + _LESym + waveform + Semicolon_ERR + { + unsigned int type; + int mode; + char buffer[128]; + char *codedsigname; + char *LocalName; + long left ,right; + long left_bnd ,right_bnd; + struct ptype **pnt; + vexexpr *vex; + vbl_vexstr *VexStr; + vbl_vexstr *VexStr2; + chain_list *ScanChain; + chain_list *ScanChain2; + ptype_list *AsgList; + unsigned char dynamic; + + if ( $1.AGGREG ) + { + if ( ! $3.AGGREG ) + { + my_vbl_error(114,NULL); + } + + ScanChain = (chain_list *)$1.NAME; + ScanChain2 = (chain_list *)$3.IDENT; + AsgList = (ptype_list *)0; + + while ( ( ScanChain != (chain_list *)0 ) && + ( ScanChain2 != (chain_list *)0 ) ) + { + VexStr = (vbl_vexstr *)ScanChain->DATA; + VexStr2 = (vbl_vexstr *)ScanChain2->DATA; + + AsgList = vbh_addvbasg( AsgList, VexStr->VEX, + simpvexexprothers( VexStr2->VEX, VexStr->VEX->WIDTH ), + get_type(VexStr->TYPE), VBL_LINNUM ); + + autfreeheap( VexStr , sizeof( vbl_vexstr ) ); + autfreeheap( VexStr2, sizeof( vbl_vexstr ) ); + + ScanChain = ScanChain ->NEXT; + ScanChain2 = ScanChain2->NEXT; + } + + if ( ( ScanChain != (chain_list *)0 ) || + ( ScanChain2 != (chain_list *)0 ) ) + { + my_vbl_error(114,NULL); + } + + freechain( (chain_list *)$1.NAME ); + freechain( (chain_list *)$3.IDENT ); + + pnt = (struct ptype**)(VBL_INSLST->DATA); + *pnt = (struct ptype *)vbh_addvbagr(*pnt, AsgList, VBL_LINNUM ); + } + else + { + if ( chktab(hshtab,$1.NAME,VBL_FUNCNAM,VBL_SYMDFN ) ) + { + LocalName = VBL_FUNCNAM; + } + else + if ( chktab(hshtab,$1.NAME,VBL_MODNAM,VBL_SYMDFN ) ) + { + LocalName = VBL_MODNAM; + } + else + { + my_vbl_error(17,$1.NAME); + } + + sprintf (buffer, "%s.cod.%s", LocalName, $1.NAME); + codedsigname = namealloc( buffer ); + + type = chktab(hshtab,codedsigname,LocalName,VBL_TYPDFN); + + if ( type >= VBH_MAX_TYPE ) + { + mode = chktab(hshtab,$1.NAME,LocalName,VBL_SYMDFN); + dynamic = chktab(hshtab,$1.NAME,LocalName,VBL_DYNDFN); + left = $1.LEFT; + right = $1.RIGHT; + } + else + { + type = chktab(hshtab,$1.NAME,LocalName,VBL_TYPDFN); + mode = chktab(hshtab,$1.NAME,LocalName,VBL_SYMDFN); + dynamic = chktab(hshtab,$1.NAME,LocalName,VBL_DYNDFN); + + left = $1.LEFT; + right = $1.RIGHT; + } + + if( mode == VBL_ICNDFN) my_vbl_error(21,$1.NAME); + if( mode == 0 ) my_vbl_error(17,$1.NAME); + + if ( ! $1.DYNAMIC ) + { + if ( ( $1.LEFT == -1 ) && + ( $1.RIGHT == -1 ) ) + { + vex = createvexatombit( $1.NAME ); + } + else + { + vex = createvexatomvec( $1.NAME, $1.LEFT, $1.RIGHT ); + } + } + else + { + left_bnd = chktab (hshtab,$1.NAME,LocalName,VBL_WMNDFN); + right_bnd = chktab (hshtab,$1.NAME,LocalName,VBL_WMXDFN); + + vex = vbl_dynamicvexatom( $1.NAME, left_bnd, right_bnd, dynamic ); + + if ( right == 0 ) + { + vex = createvexbinexpr( VEX_INDEX, 1, vex, (vexexpr *)left ); + } + else + { + if ( ( mode == VBL_FUNDFN ) || + ( mode == VBL_TPEDFN ) || + ( mode == VBL_PRODFN ) ) + { + vex = (vexexpr *)left; + } + else + if ( $1.DYNAMIC == VBL_UPTDFN ) + { + if ( ( ! dynamic ) || + ( ! isvexequalexpr( (vexexpr *)left_bnd, (vexexpr *)left ) ) || + ( ! isvexequalexpr( (vexexpr *)right_bnd, (vexexpr *)right ) ) ) + { + vex = createvexternaryexpr( VEX_TO, 1, vex, + (vexexpr *)left, (vexexpr *)right ); + } + } + else + if ( $1.DYNAMIC == VBL_DWTDFN ) + { + if ( ( ! dynamic ) || + ( ! isvexequalexpr( (vexexpr *)left_bnd, (vexexpr *)left ) ) || + ( ! isvexequalexpr( (vexexpr *)right_bnd, (vexexpr *)right ) ) ) + { + vex = createvexternaryexpr( VEX_DOWNTO, 1, vex, + (vexexpr *)left, (vexexpr *)right ); + } + } + else + { + vex = createvexbinexpr( VEX_INDEX_N, 1, vex, (vexexpr *)left ); + vex = createvexbinexpr( VEX_INDEX_N, 1, vex, (vexexpr *)right ); + } + } + } + + pnt = (struct ptype**)(VBL_INSLST->DATA); + *pnt = (struct ptype *)vbh_addvbasg(*pnt,vex, + simpvexexprothers($3.VEX, vex->WIDTH ),get_type(type), VBL_LINNUM ); + } + } + ; + +waveform_element + : expression + { $$ = $1; } + ; + +if_statement + : IF + condition + THEN + { + struct ptype **pnt; + + pnt = (struct ptype**)VBL_INSLST->DATA; + *pnt = vbh_addvbifs( *pnt,$2.VEX, VBL_LINNUM ); + VBL_INSLST = addchain(VBL_INSLST,&(((struct vbifs*)(*pnt)->DATA)->CNDTRUE)); + } + sequence_of_statements + { + struct ptype **pnt; + struct ptype *ptype; + + pnt = (struct ptype**)VBL_INSLST->DATA; + ptype = reversetype(*pnt); + *pnt = ptype; + VBL_INSLST = delchain (VBL_INSLST, VBL_INSLST); + pnt = (struct ptype**)VBL_INSLST->DATA; + VBL_INSLST = addchain(VBL_INSLST,&(((struct vbifs*)(*pnt)->DATA)->CNDFALSE)); + } + ..ELSIF__THEN__seq_of_stmts.. + .ELSE__seq_of_stmts. + END_ERR + IF + Semicolon_ERR + ; + +..ELSIF__THEN__seq_of_stmts.. + : /*empty*/ + | ..ELSIF__THEN__seq_of_stmts.. + ELSIF + condition + THEN + { + struct ptype **pnt; + + pnt = (struct ptype**)VBL_INSLST->DATA; + *pnt = vbh_addvbifs(*pnt,$3.VEX, VBL_LINNUM ); + VBL_INSLST = addchain(VBL_INSLST,(void*)&((struct vbifs*)(*pnt)->DATA)->CNDTRUE); + } + sequence_of_statements + { + struct ptype **pnt; + struct ptype *ptype; + + pnt = (struct ptype**)VBL_INSLST->DATA; + ptype = reversetype(*pnt); + *pnt = ptype; + VBL_INSLST = delchain (VBL_INSLST, VBL_INSLST); + pnt = (struct ptype**)VBL_INSLST->DATA; + VBL_INSLST = delchain (VBL_INSLST, VBL_INSLST); + VBL_INSLST = addchain(VBL_INSLST,&((struct vbifs*)(*pnt)->DATA)->CNDFALSE); + } + ; + +.ELSE__seq_of_stmts. + : /*empty*/ + { + VBL_INSLST = delchain (VBL_INSLST, VBL_INSLST); + yyerrok; + } + | ELSE + sequence_of_statements + { + struct ptype *ptype; + struct ptype **pnt; + pnt = (struct ptype**)VBL_INSLST->DATA; + ptype = reversetype(*pnt); + *pnt = ptype; + VBL_INSLST = delchain (VBL_INSLST, VBL_INSLST); + yyerrok; + } + ; + +case_statement + : CASE + expression + { + struct ptype **pnt; + + pnt = (struct ptype**)VBL_INSLST->DATA; + + VBL_OTHPNT = NULL; + VBL_CASPNT = NULL; + VBL_CASSIZE = $2.WIDTH - 1; + + *pnt = vbh_addvbcas(*pnt,$2.VEX,get_type($2.TYPE), VBL_LINNUM ); + + VBL_INSLST = addchain( VBL_INSLST,(void*)&(((struct vbcas*)((*pnt)->DATA))->SIZE)); + VBL_INSLST = addchain( VBL_INSLST,(void*)&(((struct vbcas*)(*pnt)->DATA)->CHOICE)); + } + IS + case_statement_alternative + ..case_statement_alternative.. + END_ERR + CASE + Semicolon_ERR + { + unsigned int size=0; + unsigned int *size1; + int indice=0; + struct choice_chain *ch; + struct vbcho **pnt; + struct vbcho *tab; + struct choice_chain *nm1lst; + + + nm1lst = VBL_CASPNT; + while (nm1lst != NULL) + { + size++; + nm1lst = nm1lst->NEXT; + } + if ( VBL_OTHPNT != NULL ) size++; + + pnt = (struct vbcho**)VBL_INSLST->DATA; + VBL_INSLST = delchain(VBL_INSLST,VBL_INSLST); + + if( size != 0) + tab = (struct vbcho*)autallocblock(size*sizeof(struct vbcho)); + + while(VBL_CASPNT) + { + tab[indice].INSTRUCTION = reversetype(VBL_CASPNT->INSTRUCTION); + tab[indice].SIZE = VBL_CASPNT->SIZE; + tab[indice++].VALUES = VBL_CASPNT->VALUES; + ch = VBL_CASPNT; + VBL_CASPNT =VBL_CASPNT->NEXT; + autfreeblock( ch ); + /*free(ch);*/ + } + if ( VBL_OTHPNT != NULL ) + { + tab[indice].INSTRUCTION = reversetype(VBL_OTHPNT); + tab[indice].SIZE = -1; + tab[indice++].VALUES = addchain( NULL, namealloc("others") ); + } + (*pnt) = tab; + size1 = (unsigned int*) VBL_INSLST->DATA; + *size1 = size; + VBL_INSLST = delchain(VBL_INSLST,VBL_INSLST); + } + ; + +..case_statement_alternative.. + : /*empty*/ + | ..case_statement_alternative.. + case_statement_alternative + { yyerrok; } + ; + +case_statement_alternative + : WHEN + choices + Arrow + { + VBL_PTYPE = NULL; + VBL_INSLST = addchain(VBL_INSLST,(void*)&VBL_PTYPE); + } + sequence_of_statements + { + if( VBL_CNDLST == NULL) + my_vbl_error(85,"case"); + else + if ( VBL_CNDLST->DATA == NULL) + { + VBL_OTHPNT = VBL_PTYPE ; + VBL_CNDLST = delchain(VBL_CNDLST,VBL_CNDLST); + } + else + { + struct choice_chain *NewChoice; + char *Value; + int Length; + + NewChoice = (struct choice_chain*)autallocblock(sizeof(struct choice_chain)); + NewChoice->VALUES = (chain_list *)0; + NewChoice->SIZE = 0; + NewChoice->INSTRUCTION = VBL_PTYPE; + + NewChoice->NEXT = VBL_CASPNT; + VBL_CASPNT = NewChoice; + + while(VBL_CNDLST) + { + Value = (char *)VBL_CNDLST->DATA; + Length = strlen( Value ); + + NewChoice->VALUES = addchain( NewChoice->VALUES, (void *)Value ); + if ( NewChoice->SIZE < Length ) NewChoice->SIZE = Length; + + VBL_CNDLST = delchain(VBL_CNDLST,VBL_CNDLST); + } + } + VBL_INSLST = delchain(VBL_INSLST,VBL_INSLST); + } + ; + +waveform + : waveform_element + { $$ = $1; } + ; + +choices + : choice + { + VBL_LINLST = addchain (VBL_LINLST, (void *)VBL_LINNUM ); + + if ( ! strcmp($1.NAME , "others")) + { + VBL_CNDLST = addchain (VBL_CNDLST,NULL); + } + else + { + VBL_CNDLST = addchain (VBL_CNDLST,(void*)$1.NAME); + } + + VBL_NUMCHOICE = 1; + } + ..Bar__choice.. + { yyerrok; } + ; + +null_statement + : _NULL + Semicolon_ERR {} + ; + +..Bar__choice.. + : /*empty*/ + | ..Bar__choice.. + Bar + choice + { + VBL_NUMCHOICE++; + + if ((!strcmp($3.NAME , "others")) || (VBL_CNDLST->DATA == NULL)) + my_vbl_error (31,NULL); + + VBL_CNDLST = addchain (VBL_CNDLST ,(void*)$3.NAME); + VBL_LINLST = addchain (VBL_LINLST ,(void *)VBL_LINNUM ); + } + ; + +choice + : literal + { + char Buffer[ 512 ]; + + Buffer[ 0 ] = '"'; + vbl_tobin( &Buffer[1],$1,0,VBL_CASSIZE ); + Buffer[ VBL_CASSIZE + 2 ] = '"'; + Buffer[ VBL_CASSIZE + 3 ] = '\0'; + + $$.NAME = namealloc( Buffer ); + $$.RIGHT = -1; + $$.TYPE = -1; + $$.LEFT = -1; + $$.DYNAMIC = 0; + $$.AGGREG = 0; + } + + | OTHERS + { + $$.RIGHT = -1; + $$.TYPE = -1; + $$.LEFT = -1; + $$.DYNAMIC = 0; + $$.AGGREG = 0; + $$.NAME = namealloc("others"); + } + | name + { + vexexpr *VexCst; + int left; + int right; + int in_bound; + int out_bound; + int left_bnd; + int right_bnd; + int sig_conf; + + if ( ( $1.NAME[0] == '"' ) || ( $1.NAME[0] == '\'') ) + { + $$.NAME = $1.NAME; + $$.LEFT = -1; + $$.RIGHT = -1; + $$.TYPE = -1; + $$.DYNAMIC = 0; + $$.AGGREG = 0; + } + else + { + sig_conf = chktab (hshtab,$1.NAME,VBL_MODNAM,VBL_SYMDFN); + VexCst = (vexexpr *)chktab (hshtab,$1.NAME,VBL_MODNAM,VBL_PNTDFN); + + if (sig_conf == 0) + { + my_vbl_error (17,$1.NAME); + } + else + if (sig_conf != VBL_CSTDFN) + { + my_vbl_error (76,$1.NAME); + } + + left_bnd = chktab (hshtab,$1.NAME,VBL_MODNAM,VBL_WMNDFN); + right_bnd = chktab (hshtab,$1.NAME,VBL_MODNAM,VBL_WMXDFN); + + left = $1.LEFT; + right = $1.RIGHT; + + if (left_bnd <= right_bnd) + { + if (left <= right) + { + in_bound = left - left_bnd; + out_bound = right - left_bnd; + if ((left < left_bnd) || (right > right_bnd)) + { + my_vbl_error (36,$1.NAME); + } + } + else + { + in_bound = left - right_bnd; + out_bound = right - right_bnd; + if ((left > right_bnd) || (right < left_bnd)) + { + my_vbl_error (36,$1.NAME); + } + } + } + else + { + if (left <= right) + { + in_bound = right - left_bnd; + out_bound = left - left_bnd; + if ((left < right_bnd) || (right > left_bnd)) + { + my_vbl_error (36,$1.NAME); + } + } + else + { + in_bound = right - right_bnd; + out_bound = left - right_bnd; + if ((left > left_bnd) || (right < right_bnd)) + { + my_vbl_error (36,$1.NAME); + } + } + } + + $$.NAME = GetVexAtomValue( VexCst ); + $$.LEFT = -1; + $$.RIGHT = -1; + $$.TYPE = -1; + $$.DYNAMIC = 0; + $$.AGGREG = 0; + } + } + ; + +condition + : expression + { $$ = $1; } + ; + +.REPORT__expression. + : /*empty*/ + { $$ = NULL;} + | REPORT + report__message + { $$ = $2;} + ; + +.SEVERITY__expression. + : /*empty*/ + { $$ = 'E';} + | SEVERITY + severity__message + { $$ = $1;} + ; + +report__message + : StringLit + { $$ = $1; } + ; + +severity__message + : ERROR + { $$ = 'E';} + | WARNING + { $$ = 'W';} + ; + +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 + { $$ = vbl_crtvex (VEX_AND ,$1 ,$3 ,-1,-1,0); } + | relation..AND__relation.. + _AND + relation + { $$ = vbl_crtvex (VEX_AND ,$1 ,$3 ,-1,-1,0);} + ; + +relation..OR__relation.. + : relation + _OR + relation + { $$ = vbl_crtvex (VEX_OR ,$1 ,$3 ,-1,-1,0); } + | relation..OR__relation.. + _OR + relation + { $$ = vbl_crtvex (VEX_OR ,$1 ,$3 ,-1,-1,0); } + ; + +relation.NAND_NOR_NXOR_relation. + : relation + { $$ = $1; } + | relation + _NAND + relation + { $$ = vbl_crtvex (VEX_NAND ,$1 ,$3 ,-1,-1,0); } + | relation + _NOR + relation + { $$ = vbl_crtvex (VEX_NOR ,$1 ,$3 ,-1,-1,0); } + | relation + _NXOR + relation + { $$ = vbl_crtvex (VEX_NXOR ,$1 ,$3 ,-1,-1,0); } + | relation + _IFT + relation + { $$ = vbl_crtvex (VEX_IFT,$1 ,$3 ,-1,-1,0); } + ; + +relation..XOR__relation.. + : relation + _XOR + relation + { $$ = vbl_crtvex (VEX_XOR ,$1 ,$3 ,-1,-1,0); } + | relation..XOR__relation.. + _XOR + relation + { $$ = vbl_crtvex (VEX_XOR ,$1 ,$3 ,-1,-1,0); } + ; + +relation + : simple_expression + { $$ = $1; } + | simple_expression + relational_operator + simple_expression + { $$ = vbl_crtvex ($2 ,$1 ,$3 ,-1,-1,0); } + ; + +simple_expression + : .sign.term..add_op__term.. + { $$ = $1; } + ; + +.sign.term..add_op__term.. + : term + { $$ = $1; } + | sign + term + { if ( $1 == VEX_NEG ) + { + $$ = vbl_crtvex( VEX_NEG,$2,NULL,-1,-1,0); + } + else + { + $$ = $2; + } + } + | .sign.term..add_op__term.. + adding_operator + term + { $$ = vbl_crtvex($2,$1,$3,-1,-1,0); } + ; + +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 + { $$ = vbl_crtvex( $2, $1, $3,-1,-1,0); } + ; + +factor + : primary + { $$ = $1; } + | primary + DoubleStar + primary + { $$ = vbl_crtvex( VEX_EXP,$1,$3,-1,-1,0); } + | ABS + primary + { + $$ = vbl_crtvex( VEX_ABS,$2,VBL_EMPSTR,-1,-1,0); + } + | _NOT + primary + { $$ = vbl_crtvex( VEX_NOT,$2,VBL_EMPSTR,-1,-1,0); } + ; + +primary + : literal + { + struct vbl_expr expr1; + + expr1.IDENT = $1; + expr1.TYPE = -1; + expr1.VEX = (vexexpr *)0; + + $$ = vbl_crtvex( NOPS,expr1,VBL_EMPSTR,-1,-1,0); + } + | aggregate + { + vbl_vexstr *VexStr; + chain_list *ScanChain; + + ScanChain = $1; + + if ( ScanChain == (chain_list *)0 ) + { + my_vbl_error(114,NULL); + } + + if ( ScanChain->NEXT == (chain_list *)0 ) + { + VexStr = (vbl_vexstr *)ScanChain->DATA; + + $$ = *VexStr; + + autfreeheap( VexStr, sizeof( vbl_vexstr ) ); + freechain( ScanChain ); + } + else + { + $$.IDENT = (char *)$1; + $$.AGGREG = 1; + } + } + | name + { + struct vbl_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; + unsigned char dynamic; + + flag = $1.FLAG; + + if ( ( flag != 0 ) && + ( flag != VBL_EVENT ) && + ( flag != VBL_STABLE ) ) + { + if ( ( flag != VBL_RANGE ) && + ( flag != VBL_REV_RANGE ) ) + { + if ( ! $1.DYNAMIC ) + { + sprintf( Buffer, "%ld", $1.LEFT ); + + expr1.IDENT = Buffer; + expr1.VEX = (vexexpr *)0; + expr1.TYPE = -1; + + $$ = vbl_crtvex( NOPS, expr1, VBL_EMPSTR, -1, -1,0); + } + else + { + $$.IDENT = (char *)0; + $$.VEX = (vexexpr *)$1.LEFT; + $$.TYPE = -1; + $$.SIGNED = 0; + } + } + else + { + autexit( 1 ); + } + } + else + if ( ( $1.NAME[0] == '"' ) || + ( $1.NAME[0] == '\'') ) + { + expr1.IDENT = $1.NAME; + expr1.VEX = (vexexpr *)0; + expr1.TYPE = -1; + + $$ = vbl_crtvex( NOPS ,expr1, VBL_EMPSTR, -1, -1,0); /* as for literal */ + } + else + { + if ( ( mode = chktab(hshtab,$1.NAME,VBL_FUNCNAM,VBL_SYMDFN ) ) != 0 ) + { + LocalName = VBL_FUNCNAM; + } + else + if ( ( mode = chktab(hshtab,$1.NAME,VBL_PROCNAM,VBL_SYMDFN ) ) != 0 ) + { + LocalName = VBL_PROCNAM; + } + else + if ( ( VBL_COMPNAM != (char *)0 ) && + ( ( mode = chktab(hshtab,$1.NAME,VBL_COMPNAM,VBL_SYMDFN ) ) != 0 ) ) + { + LocalName = VBL_COMPNAM; + } + else + { + LocalName = VBL_MODNAM; + mode = chktab (hshtab,$1.NAME,LocalName,VBL_SYMDFN); + } + + /*\ Skipped for out argument parameter + if ( mode == VBL_OCNDFN ) + { + my_vbl_error (26,$1.NAME); + } + \*/ + + /* LUDO ICI + if( mode == 0 || mode == VBL_TPEDFN || mode == VBL_PRODFN ) + */ + if( mode == 0 || mode == VBL_PRODFN ) + { + my_vbl_error (17,$1.NAME); + } + + left_bnd = chktab (hshtab,$1.NAME,LocalName,VBL_WMNDFN); + right_bnd = chktab (hshtab,$1.NAME,LocalName,VBL_WMXDFN); + dynamic = chktab (hshtab,$1.NAME,LocalName,VBL_DYNDFN); + + if ( ( ! $1.DYNAMIC ) && + ( ! dynamic ) ) + { + left = $1.LEFT; + right = $1.RIGHT; + + if ( ! dynamic ) + { + if ( VBL_COMPNAM == (char *)0 ) + { + if ( left_bnd <= right_bnd ) + { + if (left <= right) + { + in_bound = left - left_bnd; + out_bound = right - left_bnd; + if ((left < left_bnd) || (right > right_bnd)) + { + my_vbl_error (36,$1.NAME); + } + } + else + { + in_bound = right - left_bnd; + out_bound = left - left_bnd; + if ((left > right_bnd) || (right < left_bnd)) + { + my_vbl_error (36,$1.NAME); + } + } + } + else + { + if (left <= right) + { + in_bound = left - right_bnd; + out_bound = right - right_bnd; + if ((left < right_bnd) || (right > left_bnd)) + { + my_vbl_error (36,$1.NAME); + } + } + else + { + in_bound = right - right_bnd; + out_bound = left - right_bnd; + if ((left > left_bnd) || (right < right_bnd)) + { + my_vbl_error (36,$1.NAME); + } + } + } + } + } + } + else + { + left = $1.LEFT; + right = $1.RIGHT; + } + +/*\ + if (mode == VBL_CSTDFN) + { + expr1.VEX = (vexexpr *)chktab(hshtab,$1.NAME,LocalName,VBL_PNTDFN); + expr1.IDENT = (char *)expr1.VEX->VALUE; + expr1.TYPE = chktab(hshtab,$1.NAME,LocalName,VBL_TYPDFN); + expr1.SIGNED = chktab (hshtab,$1.NAME,LocalName,VBL_SUNDFN); + + $$ = vbl_crtvex (NOPS,expr1,VBL_EMPSTR,in_bound,out_bound,0); + } + else +\*/ + { + int type; + + expr1.IDENT = $1.NAME; + type = chktab(hshtab,$1.NAME,LocalName,VBL_TYPDFN); + expr1.TYPE = type; + expr1.SIGNED = chktab (hshtab,$1.NAME,LocalName,VBL_SUNDFN); + + if ( $1.DYNAMIC ) + { + if ( ( mode == VBL_FUNDFN ) || + ( mode == VBL_TPEDFN ) || + ( mode == VBL_PRODFN ) ) + { + expr1.VEX = (vexexpr *)left; + expr1 = vbl_crtvex(SUBVAR,expr1,VBL_EMPSTR,expr1.VEX->LEFT,expr1.VEX->RIGHT,0); + } + else + { + expr1 = vbl_crtvex (NOPI,expr1,VBL_EMPSTR,left_bnd,right_bnd,dynamic); + + if ( $1.DYNAMIC == VBL_UPTDFN ) + { + if ( ( ! dynamic ) || + ( ! isvexequalexpr( (vexexpr *)left_bnd, (vexexpr *)left ) ) || + ( ! isvexequalexpr( (vexexpr *)right_bnd, (vexexpr *)right ) ) ) + { + expr1 = vbl_crtvex( VEX_TO, expr1,VBL_EMPSTR,left,right,0); + } + } + else + if ( $1.DYNAMIC == VBL_DWTDFN ) + { + if ( ( ! dynamic ) || + ( ! isvexequalexpr( (vexexpr *)left_bnd, (vexexpr *)left ) ) || + ( ! isvexequalexpr( (vexexpr *)right_bnd, (vexexpr *)right ) ) ) + { + expr1 = vbl_crtvex( VEX_DOWNTO, expr1,VBL_EMPSTR,left,right,0); + } + } + else + { + expr1.VEX = + createvexbinexpr( VEX_INDEX_N, 1, expr1.VEX, (vexexpr *)left ); + expr1.VEX = + createvexbinexpr( VEX_INDEX_N, 1, expr1.VEX, (vexexpr *)right ); + } + } + } + else + { + expr1 = vbl_crtvex (NOPI,expr1,VBL_EMPSTR,left,right,0); + } + + if( flag == VBL_EVENT ) + { + $$ = vbl_crtvex (VEX_EVENT,expr1,VBL_EMPSTR,left,right,0); + } + else + if( flag == VBL_STABLE ) + { + expr1 = vbl_crtvex(VEX_EVENT,expr1,VBL_EMPSTR,left,right,0); + $$ = vbl_crtvex (VEX_NOT,expr1,VBL_EMPSTR,-1,-1,0); + } + else + { + $$ = expr1; + } + } + } + } + | qualified_expression + { + struct vbl_expr expr1; + + expr1.IDENT = $1.NAME; + expr1.TYPE = $1.TYPE; + expr1.SIGNED = $1.SIGNED; + expr1.VEX = (vexexpr *)$1.LEFT; + + expr1 = vbl_crtvex(SUBVAR,expr1,VBL_EMPSTR,expr1.VEX->LEFT,expr1.VEX->RIGHT,0); + + $$ = expr1; + } + ; + +qualified_expression + : name + Apostrophe + aggregate + { + char *LocalName; + vbl_vexstr *VexStr; + chain_list *ScanChain; + vexexpr *VexExpr; + long Def; + + ScanChain = $3; + + if ( ( ScanChain == (chain_list *)0 ) || + ( ScanChain->NEXT != (chain_list *)0 ) ) + { + my_vbl_error(122,NULL); + } + + if ( ( Def = chktab(hshtab,$1.NAME,VBL_FUNCNAM,VBL_SYMDFN ) ) != 0 ) + { + LocalName = VBL_FUNCNAM; + } + else + if ( ( Def = chktab(hshtab,$1.NAME,VBL_PROCNAM,VBL_SYMDFN ) ) != 0 ) + { + LocalName = VBL_PROCNAM; + } + else + { + LocalName = VBL_MODNAM; + Def = chktab (hshtab,$1.NAME,LocalName,VBL_SYMDFN); + } + + if ( Def == VBL_TPEDFN ) + { + VexStr = (vbl_vexstr *)ScanChain->DATA; + + VexExpr = createvexfunc( $1.NAME, VexStr->VEX->WIDTH ); + addvexhexpr( VexExpr, VexStr->VEX ); + + autfreeheap( VexStr, sizeof( vbl_vexstr ) ); + + $$.NAME = $1.NAME; + $$.TYPE = chktab (hshtab,$1.NAME,LocalName,VBL_TYPDFN); + $$.SIGNED = chktab (hshtab,$1.NAME,LocalName,VBL_SUNDFN); + $$.FLAG = 0; + $$.LEFT = (long)VexExpr; + $$.RIGHT = 0; + $$.DYNAMIC = 1; + $$.AGGREG = 0; + + freechain( $3 ); + } + else + { + my_vbl_error(122, $1.NAME); + } + } + ; + +relational_operator + : _EQSym + { $$ = VEX_EQ; } + | _NESym + { $$ = VEX_NE; } + | _GESym + { $$ = VEX_GE; } + | _GTSym + { $$ = VEX_GT; } + | _LESym + { $$ = VEX_LE; } + | _LTSym + { $$ = VEX_LT; } + ; + +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 + { + vbl_vexstr *VexStr; + + VexStr = (vbl_vexstr *)autallocheap( sizeof( vbl_vexstr ) ); + *VexStr = $1; + + $$ = addchain( (chain_list *)0, VexStr ); + } + | OTHERS + Arrow + expression + { + vbl_vexstr *VexStr; + + VexStr = (vbl_vexstr *)autallocheap( sizeof( vbl_vexstr ) ); + *VexStr = vbl_crtvex( VEX_OTHERS, $3,VBL_EMPSTR,-1,-1,0); + + $$ = addchain( (chain_list *)0, VexStr ); + } + ; + +name + : simple_name + { + authelem *valbitstr; + char *codedsigname; + char *LocalName; + char buffer[128]; + + if ( chktab(hshtab,$1,VBL_FUNCNAM,VBL_SYMDFN ) ) + { + LocalName = VBL_FUNCNAM; + } + else + if ( chktab(hshtab,$1,VBL_PROCNAM,VBL_SYMDFN ) ) + { + LocalName = VBL_PROCNAM; + } + else + if ( ( VBL_COMPNAM != (char *)0 ) && + ( chktab(hshtab,$1,VBL_COMPNAM,VBL_SYMDFN ) ) ) + { + LocalName = VBL_COMPNAM; + } + else + { + LocalName = VBL_MODNAM; + } + + $$.NAME = $1; + $$.FLAG = 0; + + sprintf ( buffer, "%s.cod.%s", LocalName, $1); + codedsigname = namealloc( buffer ); + $$.TYPE = chktab (hshtab,codedsigname,LocalName,VBL_TYPDFN); + + if ( $$.TYPE >= VBH_MAX_TYPE ) + { + if ((valbitstr = searchauthelem(VBL_ENUMVAL, codedsigname )) != NULL) + { + $$.NAME = namealloc((char *)valbitstr->VALUE); + $$.TYPE = VBH_TYPE_BIT_VECTOR ; /* BIT_VECTOR intentionnel */ + $$.LEFT = -1; + $$.RIGHT = -1; + $$.DYNAMIC = 0; + $$.AGGREG = 0; + $$.SIGNED = 0; + } + else + { + $$.TYPE = VBH_TYPE_BIT_VECTOR ; /* BIT_VECTOR intentionnel */ + $$.LEFT = chktab (hshtab,$1,LocalName,VBL_WMNDFN); + $$.RIGHT = chktab (hshtab,$1,LocalName,VBL_WMXDFN); + $$.DYNAMIC = chktab(hshtab,$1,LocalName,VBL_DYNDFN); + $$.AGGREG = 0; + $$.SIGNED = 0; + } + } + else + { + $$.TYPE = chktab (hshtab,$1,LocalName,VBL_TYPDFN); + $$.LEFT = chktab (hshtab,$1,LocalName,VBL_WMNDFN); + $$.RIGHT = chktab (hshtab,$1,LocalName,VBL_WMXDFN); + $$.SIGNED = chktab (hshtab,$1,LocalName,VBL_SUNDFN); + $$.DYNAMIC = chktab(hshtab,$1,LocalName,VBL_DYNDFN); + $$.AGGREG = 0; + + } + } + | indexed_name + { $$ = $1; } + | slice_name + { $$ = $1; } + | attribute_name + { $$ = $1; } + ; + +indexed_name + : simple_name + aggregate + { + char *LocalName; + vbl_vexstr *VexStr; + vbfun_list *VbFunc; + chain_list *ScanChain; + vexexpr *VexExpr; + vexexpr *VexRet; + long Index; + int Error; + long Def; + + ScanChain = $2; + + if ( ScanChain == (chain_list *)0 ) + { + my_vbl_error(114,NULL); + } + + if ( ( Def = chktab(hshtab,$1,VBL_FUNCNAM,VBL_SYMDFN ) ) != 0 ) + { + LocalName = VBL_FUNCNAM; + } + else + if ( ( Def = chktab(hshtab,$1,VBL_PROCNAM,VBL_SYMDFN ) ) != 0 ) + { + LocalName = VBL_PROCNAM; + } + else + if ( ( VBL_COMPNAM != (char *)0 ) && + ( ( Def = chktab(hshtab,$1,VBL_COMPNAM,VBL_SYMDFN ) ) != 0 ) ) + { + LocalName = VBL_COMPNAM; + } + else + { + LocalName = VBL_MODNAM; + Def = chktab (hshtab,$1,LocalName,VBL_SYMDFN); + } + + if ( ( Def == VBL_FUNDFN ) || + ( Def == VBL_TPEDFN ) || + ( Def == VBL_PRODFN ) ) + { + if ( Def != VBL_TPEDFN ) + { + VexExpr = createvexfunc( $1, 0 ); + } + + if ( Def == VBL_FUNDFN ) + { + VbFunc = (vbfun_list *)chktab( hshtab,$1,LocalName,VBL_PNTDFN); + + if ( VbFunc != (vbfun_list *)0 ) + { + VexRet = VbFunc->RETURN->TARGET; + + VexExpr->LEFT = VexRet->LEFT; + VexExpr->RIGHT = VexRet->RIGHT; + VexExpr->WIDTH = VexRet->WIDTH; + + if ( ! IsVexNodeVarWidth( VexRet ) ) + { + ClearVexNodeVarWidth( VexExpr ); + } + } + } + + if ( Def == VBL_TPEDFN ) + { + if ( ScanChain->NEXT != (chain_list *)0 ) + { + my_vbl_error(114,NULL); + } + + VexStr = (vbl_vexstr *)ScanChain->DATA; + + VexExpr = createvexfunc( $1, VexStr->VEX->WIDTH ); + addvexhexpr( VexExpr, VexStr->VEX ); + + autfreeheap( VexStr, sizeof( vbl_vexstr ) ); + } + else + { + while ( ScanChain != (chain_list *)0 ) + { + VexStr = (vbl_vexstr *)ScanChain->DATA; + addvexqexpr( VexExpr, VexStr->VEX ); + + autfreeheap( VexStr, sizeof( vbl_vexstr ) ); + ScanChain = ScanChain->NEXT; + } + } + + $$.NAME = $1; + $$.TYPE = chktab (hshtab,$1,LocalName,VBL_TYPDFN); + $$.SIGNED = chktab (hshtab,$1,LocalName,VBL_SUNDFN); + $$.FLAG = 0; + $$.LEFT = (long)VexExpr; + $$.RIGHT = -1; + $$.DYNAMIC = 1; + $$.AGGREG = 0; + + freechain( $2 ); + } + else + if ( ScanChain->NEXT != (chain_list *)0 ) + { + if ( ( ! Def ) || + ( ScanChain->NEXT->NEXT != (chain_list *)0 ) ) + { + my_vbl_error(118,$1); + } + + /* ICI */ + + $$.NAME = $1; + $$.TYPE = chktab (hshtab,$1,LocalName,VBL_TYPDFN); + $$.SIGNED = chktab (hshtab,$1,LocalName,VBL_SUNDFN); + $$.FLAG = 0; + + $$.DYNAMIC = VBL_IDXDFN; + $$.AGGREG = 0; + + VexStr = (vbl_vexstr *)ScanChain->DATA; + $$.LEFT = (long)VexStr->VEX; + autfreeheap( VexStr, sizeof( vbl_vexstr ) ); + + ScanChain = ScanChain->NEXT; + VexStr = (vbl_vexstr *)ScanChain->DATA; + $$.RIGHT = (long)VexStr->VEX; + autfreeheap( VexStr, sizeof( vbl_vexstr ) ); + + freechain( $2 ); + } + else + { + VexStr = (vbl_vexstr *)ScanChain->DATA; + Error = vbl_vextonum( VexStr->VEX, &Index ); + + $$.NAME = $1; + $$.TYPE = chktab (hshtab,$1,LocalName,VBL_TYPDFN); + $$.SIGNED = chktab (hshtab,$1,LocalName,VBL_SUNDFN); + $$.FLAG = 0; + $$.AGGREG = 0; + + if ( Error ) + { + $$.LEFT = (long)VexStr->VEX; + $$.RIGHT = 0; + $$.DYNAMIC = VBL_UPTDFN; + } + else + { + $$.LEFT = Index; + $$.RIGHT = Index; + $$.DYNAMIC = 0; + } + + autfreeheap( VexStr, sizeof( vbl_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; + + if ( chktab(hshtab,$1,VBL_FUNCNAM,VBL_SYMDFN ) ) + { + LocalName = VBL_FUNCNAM; + } + else + if ( chktab(hshtab,$1,VBL_PROCNAM,VBL_SYMDFN ) ) + { + LocalName = VBL_PROCNAM; + } + else + if ( ( VBL_COMPNAM != (char *)0 ) && + ( chktab(hshtab,$1,VBL_COMPNAM,VBL_SYMDFN ) ) ) + { + LocalName = VBL_COMPNAM; + } + else + { + LocalName = VBL_MODNAM; + } + + ErrorL = vbl_vextonum( $3.VEX, &Left ); + ErrorR = vbl_vextonum( $5.VEX, &Right ); + + $$.NAME = $1; + $$.TYPE = chktab (hshtab,$1,LocalName,VBL_TYPDFN); + $$.SIGNED = chktab (hshtab,$1,LocalName,VBL_SUNDFN); + $$.FLAG = 0; + $$.AGGREG = 0; + + if ( ( ! ErrorL ) && ( ! ErrorR ) ) + { + if (((Left > Right) && ($4 == VBL_UPTDFN)) || + ((Left < Right) && ($4 == VBL_DWTDFN))) + my_vbl_error (32,$1); + + $$.LEFT = Left; + $$.RIGHT = Right; + $$.DYNAMIC = 0; + } + else + { + $$.LEFT = (long)$3.VEX; + $$.RIGHT = (long)$5.VEX; + $$.DYNAMIC = $4; + } + } + ; + +attribute_name + : name + Apostrophe + attribute_designator + { + char *LocalName; + int type; + int flag; + int mode; + long AttrLeft; + long AttrRight; + long AttrLow; + long AttrHigh; + unsigned char Dynamic; + + if ( ( mode = chktab(hshtab,$1.NAME,VBL_FUNCNAM,VBL_SYMDFN ) ) != 0 ) + { + LocalName = VBL_FUNCNAM; + } + else + if ( ( mode = chktab(hshtab,$1.NAME,VBL_PROCNAM,VBL_SYMDFN ) ) != 0 ) + { + LocalName = VBL_PROCNAM; + } + else + { + LocalName = VBL_MODNAM; + mode = chktab (hshtab,$1.NAME,LocalName,VBL_SYMDFN); + } + + type = chktab (hshtab,$1.NAME,LocalName,VBL_TYPDFN); + flag = $3; + + Dynamic = chktab(hshtab,$1.NAME,LocalName,VBL_DYNDFN); + + $$.NAME = $1.NAME; + $$.TYPE = type; + $$.LEFT = -1; + $$.RIGHT = -1; + $$.SIGNED = chktab (hshtab,$1.NAME,LocalName,VBL_SUNDFN); + $$.FLAG = $3; + $$.DYNAMIC = Dynamic; + + if ( ( flag == VBL_STABLE ) || + ( flag == VBL_EVENT ) ) + { + if ( LocalName != VBL_MODNAM ) + my_vbl_error (79,$1); + } + else + { + AttrLeft = chktab( hshtab,$1.NAME,LocalName,VBL_ATLDFN); + AttrRight = chktab( hshtab,$1.NAME,LocalName,VBL_ATRDFN); + + if ( ! Dynamic ) + { + if ( AttrLeft > AttrRight ) + { + AttrLow = AttrRight; + AttrHigh = AttrLeft; + } + else + { + AttrHigh = AttrRight; + AttrLow = AttrLeft; + } + } + else + { + if ( Dynamic == VBL_UPTDFN ) + { + AttrLow = AttrLeft; + AttrHigh = AttrRight; + } + else + { + AttrHigh = AttrLeft; + AttrLow = AttrRight; + } + } + + switch ( flag ) + { + case VBL_LEFT : $$.LEFT = AttrLeft; + break; + + case VBL_RIGHT : $$.LEFT = AttrRight; + break; + + case VBL_LOW : $$.LEFT = AttrLow; + break; + + case VBL_HIGH : $$.LEFT = AttrHigh; + break; + + case VBL_LENGTH : $$.LEFT = 1 + (AttrHigh - AttrLow); + break; + + case VBL_RANGE : $$.LEFT = AttrLeft; + $$.RIGHT = AttrRight; + break; + + case VBL_REV_RANGE : $$.LEFT = AttrRight; + $$.RIGHT = AttrLeft; + break; + } + } + } + ; + +attribute_designator + : _STABLE { $$ = VBL_STABLE; } + | _EVENT { $$ = VBL_EVENT; } + | _LEFT { $$ = VBL_LEFT; } + | _RIGHT { $$ = VBL_RIGHT; } + | _LOW { $$ = VBL_LOW; } + | _HIGH { $$ = VBL_HIGH; } + | _LENGTH { $$ = VBL_LENGTH; } + | _RANGE { $$ = VBL_RANGE; } + | _REV_RANGE { $$ = VBL_REV_RANGE; } + ; + +identifier_list + : Identifier + { VBL_NM1LST = addchain (VBL_NM1LST,$1); } + ...identifier.. + ; + +...identifier.. + : /*empty*/ + | ...identifier.. + Comma + Identifier + { VBL_NM1LST = addchain (VBL_NM1LST,$3); } + ; + +.label. + : /*empty*/ + { $$ = NULL; } + | label + { $$ = $1; } + ; + +.guard_expression. + : /*empty*/ + { $$.VEX = (vexexpr *)0; } + | guard_expression + { $$ = $1; } + ; + +guard_expression + : LeftParen + expression + RightParen_ERR + { $$ = $2; } + ; + +.GUARDED. + : /*empty*/ + { + $$ = VBL_UNGDFN; + } + | GUARDED + { + $$ = VBL_GRDDFN; + + if ( VBL_GRDLST == (chain_list *)0 ) + my_vbl_error(41,0 ); + } + ; + +.simple_name. + : /*empty*/ + { $$ = NULL; } + | simple_name + { $$ = $1; } + ; + +simple_name + : Identifier + { $$ = $1; } + ; + +target + : name + { $$ = $1; } + | aggregate + { + $$.NAME = (char *)$1; + $$.LEFT = 0; + $$.RIGHT = 0; + $$.FLAG = 0; + $$.TYPE = 0; + $$.DYNAMIC = 0; + $$.SIGNED = 0; + $$.AGGREG = 1; + } + ; + +a_label + : label + Colon + { + $$ = $1; + } + ; + +label + : 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; + int i; + + if (VBL_DCEHED == NULL) + { + VBL_DCEHED = (struct dct_entry *) + autallocblock (sizeof(struct dct_entry) * VBL_ALODFN); + + entry = VBL_DCEHED; + for (i=1 ; inext = entry + 1; + entry++; + } + entry->next = NULL; + } + + entry = VBL_DCEHED; + VBL_DCEHED = VBL_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; + int i; + + if (VBL_DCRHED == NULL) + { + VBL_DCRHED = (struct dct_recrd *) + autallocblock (sizeof(struct dct_recrd) * VBL_ALODFN); + + recrd = VBL_DCRHED; + for (i=1 ; inext = recrd + 1; + recrd++; + } + recrd->next = NULL; + } + + recrd = VBL_DCRHED; + VBL_DCRHED = VBL_DCRHED->next; + + recrd->next = head; + recrd->fd0_val = 0; + recrd->fd1_val = 0; + recrd->fd2_val = 0; + recrd->fd3_val = 0; + recrd->fd4_val = 0; + recrd->fd5_val = 0; + recrd->fd6_val = 0; + recrd->fd7_val = 0; + recrd->fd8_val = 0; + recrd->pnt_val = 0; + recrd->dyn_val = 0; + recrd->key = key; + + return (recrd); +} + +static struct dct_entry **initab () + +{ + struct dct_entry **head; + int i; + + head = (struct dct_entry **) + autallocblock (sizeof(struct dct_entry *) * VBL_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 VBL_MODDFN : + recrd_pnt->fd0_val = valu; + break; + case VBL_SYMDFN : + recrd_pnt->fd1_val = valu; + break; + case VBL_TYPDFN : + recrd_pnt->fd2_val = valu; + break; + case VBL_SUNDFN : + recrd_pnt->fd3_val = valu; + break; + case VBL_LBLDFN : + recrd_pnt->fd4_val = valu; + break; + case VBL_WMXDFN : + recrd_pnt->fd5_val = valu; + break; + case VBL_WMNDFN : + recrd_pnt->fd6_val = valu; + break; + case VBL_ATLDFN : + recrd_pnt->fd7_val = valu; + break; + case VBL_ATRDFN : + recrd_pnt->fd8_val = valu; + break; + case VBL_PNTDFN : + recrd_pnt->pnt_val = valu; + break; + case VBL_DYNDFN : + recrd_pnt->dyn_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) % VBL_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 VBL_MODDFN : + valu = recrd_pnt->fd0_val; + break; + case VBL_SYMDFN : + valu = recrd_pnt->fd1_val; + break; + case VBL_TYPDFN : + valu = recrd_pnt->fd2_val; + break; + case VBL_SUNDFN : + valu = recrd_pnt->fd3_val; + break; + case VBL_LBLDFN : + valu = recrd_pnt->fd4_val; + break; + case VBL_WMXDFN : + valu = recrd_pnt->fd5_val; + break; + case VBL_WMNDFN : + valu = recrd_pnt->fd6_val; + break; + case VBL_ATLDFN : + valu = recrd_pnt->fd7_val; + break; + case VBL_ATRDFN : + valu = recrd_pnt->fd8_val; + break; + case VBL_PNTDFN : + valu = recrd_pnt->pnt_val; + break; + case VBL_DYNDFN : + valu = recrd_pnt->dyn_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 = VBL_DCRHED; + VBL_DCRHED = pt_entry->data; + + pt_nxtentry = pt_entry->next; + pt_entry->next = VBL_DCEHED; + VBL_DCEHED = pt_entry; + pt_entry = pt_nxtentry; + } + } + } + autfreeblock(pt_hash); + } +} + +static void *vbl_addstr(object,mode,prtype,type,flag,name,left,right,exp,kind,dynamic) + +char object; +int mode; +vbtyp_list *prtype; +unsigned char type; +char flag; +char *name; +long left; +long right; +vexexpr *exp; +unsigned char kind; +unsigned char dynamic; + +{ + ptype_list *GenVar; + void *pnt = NULL; + char porflg = 0; + char modflg = 0; + char auxflg = 0; + char cstflg = 0; + char varflg = 0; + char funflg = 0; + char conflg = 0; + char parflg = 0; + char genflg = 0; + char gnrflg = 0; + char genmodflg = 0; + char lclmod = 'X'; + vexexpr *vex_pnt; + int bitsize; + + switch (object) + { + case 'M': + + /* ###------------------------------------------------------### */ + /* if object is a model port ... */ + /* ###------------------------------------------------------### */ + + modflg = 1; + switch (mode) + { + case VBL_ICNDFN: + lclmod = 'I'; break; + case VBL_OCNDFN: + lclmod = 'O'; break; + case VBL_BCNDFN: + lclmod = 'B'; break; + } + break; + + case 'P': + + /* ###------------------------------------------------------### */ + /* if object is a port ... */ + /* ###------------------------------------------------------### */ + + porflg = 1; + switch (mode) + { + case VBL_ICNDFN: + lclmod = 'I'; break; + case VBL_OCNDFN: + lclmod = 'O'; break; + case VBL_BCNDFN: + lclmod = 'B'; break; + } + break; + + case 'p': + + /* ###------------------------------------------------------### */ + /* if object is a parameter of a function / procedure */ + /* ###------------------------------------------------------### */ + + parflg = 1; + switch (mode) + { + case VBL_ICNDFN: + lclmod = 'I'; break; + case VBL_OCNDFN: + lclmod = 'O'; break; + case VBL_BCNDFN: + lclmod = 'B'; break; + } + break; + + case 'S': + + /* ###------------------------------------------------------### */ + /* if object is a signal ... */ + /* ###------------------------------------------------------### */ + + auxflg = 1; + + break; + + case 'v': + + /* ###------------------------------------------------------### */ + /* if object is a variable in function/procedure */ + /* ###------------------------------------------------------### */ + + funflg = 1; + + break; + + case 'V': + + /* ###------------------------------------------------------### */ + /* if object is a variable ... */ + /* ###------------------------------------------------------### */ + + varflg = 1; + + break; + + case 'C': + + /* ###------------------------------------------------------### */ + /* if object is a constant ... */ + /* ###------------------------------------------------------### */ + + cstflg = 1; + + break; + + case 'G': + + /* ###------------------------------------------------------### */ + /* if object is a generic ... */ + /* ###------------------------------------------------------### */ + + genflg = 1; + + break; + + case 'f': + + /* ###------------------------------------------------------### */ + /* if object is a for generate variable ... */ + /* ###------------------------------------------------------### */ + + gnrflg = 1; + + break; + + case 'g': + + /* ###------------------------------------------------------### */ + /* if object is a generic map ... */ + /* ###------------------------------------------------------### */ + + genmodflg = 1; + + break; + + case 'F': + + /* ###------------------------------------------------------### */ + /* if object is a function ... */ + /* ###------------------------------------------------------### */ + + conflg = 1; + + break; + } + + if ( (flag == 'A') || + (flag == 'U') ) + { + /* ###------------------------------------------------------### */ + /* if object is an array ... */ + /* ###------------------------------------------------------### */ + +/* Original + vex_pnt = createvexatomvec( name, left, right ); +*/ + +/* Correction */ + if ( ( flag == 'A' ) && ( ! dynamic ) ) + { + vex_pnt = createvexatomvec( name, prtype->LEFT, prtype->RIGHT ); + } + else + { + if ( dynamic ) + { + if ( dynamic == VBL_UPTDFN ) vex_pnt = createvexoper( VEX_TO , 0 ); + else vex_pnt = createvexoper( VEX_DOWNTO, 0 ); + + addvexqexpr( vex_pnt, createvexatomvec( name, -1, -1 ) ); + addvexqexpr( vex_pnt, dupvexexpr( (vexexpr *)left ) ); + addvexqexpr( vex_pnt, dupvexexpr( (vexexpr *)right ) ); + } + else + { + vex_pnt = createvexatomvec( name, left, right ); + } + } +/* Fin Correction */ + + if ( prtype->INDEX == VBH_TYPE_SIGNED ) + { + SetVexNodeSigned( vex_pnt ); + } + + if ( auxflg == 1 ) + VBL_BEFPNT->BEAUX = vbh_addvbaux(VBL_BEFPNT->BEAUX, vex_pnt,exp,kind,prtype, + VBL_LINNUM ); + if ( cstflg == 1 ) + VBL_BEFPNT->BECST = vbh_addvbcst(VBL_BEFPNT->BECST, vex_pnt,exp,prtype, + VBL_LINNUM ); + + if ( genflg == 1 ) + VBL_BEFPNT->BEGEN = vbh_addvbgen(VBL_BEFPNT->BEGEN, vex_pnt,exp,prtype, + VBL_LINNUM ); + if (porflg == 1) + VBL_BEFPNT->BEPOR = vbh_addvbpor(VBL_BEFPNT->BEPOR, vex_pnt,exp,lclmod,kind,prtype, + VBL_LINNUM ); + + if (modflg == 1) + VBL_BEFPNT->BEMOD->BEPOR = + vbh_addvbpor(VBL_BEFPNT->BEMOD->BEPOR, vex_pnt,exp,lclmod,kind,prtype, + VBL_LINNUM ); + if (genmodflg == 1) + VBL_BEFPNT->BEMOD->BEGEN = + vbh_addvbgen(VBL_BEFPNT->BEMOD->BEGEN, vex_pnt,exp,prtype, + VBL_LINNUM ); + if (parflg == 1) + VBL_BEFUN->ARGUMENT = vbh_addvbarg(VBL_BEFUN->ARGUMENT,vex_pnt,lclmod,kind,prtype, + VBL_LINNUM ); + if (varflg == 1) + VBL_BEPCS->VARIABLE = vbh_addvbvar(VBL_BEPCS->VARIABLE,vex_pnt,exp,prtype, + VBL_LINNUM ); + if (funflg == 1) + VBL_BEFUN->VARIABLE = vbh_addvbvar(VBL_BEFUN->VARIABLE,vex_pnt,exp,prtype, + VBL_LINNUM ); + if (gnrflg == 1) + GenVar = vbh_addvbvar( (vbvar_list *)0,vex_pnt,exp,prtype, VBL_LINNUM ); + } + else + if ( (flag == 'I') ) + { + /* ###------------------------------------------------------### */ + /* if object is an integer ... */ + /* ###------------------------------------------------------### */ + + if ( dynamic ) + { + vexexpr *new_left; + vexexpr *new_right; + + vex_pnt = createvexoper( VEX_NUM_BIT, 0 ); + addvexqexpr( vex_pnt, dupvexexpr( (vexexpr *)left ) ); + addvexqexpr( vex_pnt, dupvexexpr( (vexexpr *)right ) ); + + new_left = (vexexpr *)vex_pnt; + new_right = (vexexpr *)createvexatomlit( VEX_ATOM_ZERO ); + + vex_pnt = createvexternaryexpr( + VEX_DOWNTO, -1, createvexatomvec( name, -1, -1 ), + dupvexexpr( (vexexpr *)new_left ), dupvexexpr( (vexexpr *)new_right ) ); + + /* It's not clean but ... */ + copyvexnode( (vexexpr *)left, new_left ); + copyvexnode( (vexexpr *)right, new_right ); + } + else + { + if ((left == -1 ) && (right == -1)) + { + left = prtype->LEFT; + right = prtype->RIGHT; + } + + bitsize = vbl_intSize( left, right ); + + vex_pnt = createvexatomvec( name, bitsize - 1, 0 ); + + if ( ( left < 0 ) || + ( right < 0 ) ) + { + SetVexNodeSigned( vex_pnt ); + } + } + + if ( auxflg == 1 ) + VBL_BEFPNT->BEAUX = vbh_addvbaux(VBL_BEFPNT->BEAUX, vex_pnt,exp,kind,prtype, + VBL_LINNUM ); + if ( cstflg == 1 ) + VBL_BEFPNT->BECST = vbh_addvbcst(VBL_BEFPNT->BECST, vex_pnt,exp,prtype, + VBL_LINNUM ); + + if ( genflg == 1 ) + VBL_BEFPNT->BEGEN = vbh_addvbgen(VBL_BEFPNT->BEGEN, vex_pnt,exp,prtype, + VBL_LINNUM ); + if (porflg == 1) + VBL_BEFPNT->BEPOR = vbh_addvbpor(VBL_BEFPNT->BEPOR, vex_pnt,exp,lclmod,kind,prtype, + VBL_LINNUM ); + if (modflg == 1) + VBL_BEFPNT->BEMOD->BEPOR = + vbh_addvbpor(VBL_BEFPNT->BEMOD->BEPOR, vex_pnt,exp,lclmod,kind,prtype, + VBL_LINNUM ); + if (genmodflg == 1) + VBL_BEFPNT->BEMOD->BEGEN = + vbh_addvbgen(VBL_BEFPNT->BEMOD->BEGEN, vex_pnt,exp,prtype, + VBL_LINNUM ); + if (parflg == 1) + VBL_BEFUN->ARGUMENT = vbh_addvbarg(VBL_BEFUN->ARGUMENT, vex_pnt, lclmod,kind,prtype, + VBL_LINNUM ); + if (varflg == 1) + VBL_BEPCS->VARIABLE = vbh_addvbvar(VBL_BEPCS->VARIABLE,vex_pnt,exp,prtype, + VBL_LINNUM ); + if (funflg == 1) + VBL_BEFUN->VARIABLE = vbh_addvbvar(VBL_BEFUN->VARIABLE,vex_pnt,exp,prtype, + VBL_LINNUM ); + if (gnrflg == 1) + GenVar = vbh_addvbvar( (vbvar_list *)0,vex_pnt,exp,prtype, VBL_LINNUM ); + } + else + { + vex_pnt = createvexatombit( name ); + /* ###------------------------------------------------------### */ + /* if object is a scalar ... */ + /* ###------------------------------------------------------### */ + + if (porflg == 1) + VBL_BEFPNT->BEPOR = vbh_addvbpor (VBL_BEFPNT->BEPOR,vex_pnt,exp,lclmod,kind,prtype, + VBL_LINNUM ); + if (modflg == 1) + VBL_BEFPNT->BEMOD->BEPOR = + vbh_addvbpor (VBL_BEFPNT->BEMOD->BEPOR,vex_pnt,exp,lclmod,kind,prtype, + VBL_LINNUM ); + if (genmodflg == 1) + VBL_BEFPNT->BEMOD->BEGEN = + vbh_addvbgen(VBL_BEFPNT->BEMOD->BEGEN, vex_pnt,exp,prtype, + VBL_LINNUM ); + if (parflg == 1) + VBL_BEFUN->ARGUMENT = vbh_addvbarg(VBL_BEFUN->ARGUMENT,vex_pnt,lclmod,kind,prtype, + VBL_LINNUM ); + if (auxflg == 1) + VBL_BEFPNT->BEAUX = vbh_addvbaux (VBL_BEFPNT->BEAUX,vex_pnt,exp,kind,prtype, + VBL_LINNUM ); + if (cstflg == 1) + VBL_BEFPNT->BECST = vbh_addvbcst (VBL_BEFPNT->BECST,vex_pnt,exp,prtype, + VBL_LINNUM ); + if (genflg == 1) + VBL_BEFPNT->BEGEN = vbh_addvbgen (VBL_BEFPNT->BEGEN,vex_pnt,exp,prtype, + VBL_LINNUM ); + if (varflg == 1) + VBL_BEPCS->VARIABLE = vbh_addvbvar(VBL_BEPCS->VARIABLE,vex_pnt, exp, prtype, + VBL_LINNUM ); + if (funflg == 1) + VBL_BEFUN->VARIABLE = vbh_addvbvar(VBL_BEFUN->VARIABLE,vex_pnt, exp, prtype, + VBL_LINNUM ); + if (gnrflg == 1) + GenVar = vbh_addvbvar( (vbvar_list *)0,vex_pnt,exp,prtype, VBL_LINNUM ); + } + + if (auxflg == 1) + pnt = (void *) VBL_BEFPNT->BEAUX; + if (cstflg == 1) + pnt = (void *) VBL_BEFPNT->BECST; + if (genflg == 1) + pnt = (void *) VBL_BEFPNT->BEGEN; + if (varflg == 1) + pnt = (void *) VBL_BEPCS->VARIABLE->DATA; + if (gnrflg == 1) + { + pnt = (void *) GenVar->DATA; + freeptype( GenVar ); + } + if (funflg == 1) + pnt = (void *) VBL_BEFUN->VARIABLE->DATA; + if (porflg == 1) + pnt = (void *) VBL_BEFPNT->BEPOR; + if (modflg == 1) + pnt = (void *) VBL_BEFPNT->BEMOD->BEPOR; + if (genmodflg == 1) + pnt = (void *) VBL_BEFPNT->BEMOD->BEGEN; + if (parflg == 1) + pnt = (void *) VBL_BEFUN->ARGUMENT; + if (conflg == 1) + pnt = (void *) vex_pnt; + + return (pnt); +} + +static vbtyp_list *val_type(name) + + char *name; +{ + return( vbh_getvbtyp( VBL_HEADFIG, name ) ); +} + +static vbtyp_list *get_type(val) + + int val; +{ + vbtyp_list *Type; + + for ( Type = VBL_BEFPNT->BETYP; + Type != (vbtyp_list *)0; + Type = Type->NEXT ) + { + if ( Type->INDEX == val ) break; + } + + return( Type ); +} + +static struct ptype *reversetype(pnt) + struct ptype *pnt; +{ + return( (ptype_list *)reverse( (chain_list *)pnt ) ); +# if 0 + struct ptype* revtype; + struct ptype* aux2; + struct ptype* aux1; + + if(pnt == NULL || pnt->NEXT == NULL) + return(pnt); + revtype = pnt; + aux1 = pnt->NEXT; + revtype->NEXT = NULL; + while(aux1) + { + aux2 = revtype; + revtype = aux1; + aux1 = aux1->NEXT; + revtype->NEXT = aux2; + } + return(revtype); +# endif +} diff --git a/alliance/src/vbl/src/vbl_bedef.h b/alliance/src/vbl/src/vbl_bedef.h new file mode 100644 index 00000000..698b5fb6 --- /dev/null +++ b/alliance/src/vbl/src/vbl_bedef.h @@ -0,0 +1,106 @@ +/*------------------------------------------------------------\ +| | +| 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 VBL_LG_MC 15 +#define VBL_NB_MC ((tab_mc -1 + sizeof(tab_mc)/ (sizeof(tab_mc[0])) - tab_mc+1)) + +#define VBL_ICNDFN 1 /* input port */ +#define VBL_OCNDFN 2 /* output port */ +#define VBL_BCNDFN 3 /* inout port */ +#define VBL_CSTDFN 4 /* constant */ +#define VBL_TPEDFN 5 /* type */ +#define VBL_SGNDFN 6 /* signal */ +#define VBL_FUNDFN 7 /* function */ +#define VBL_VARDFN 8 /* variable */ +#define VBL_PARDFN 9 /* parameter */ +#define VBL_PRODFN 10 /* procedure */ +#define VBL_ATTDFN 11 /* attribute */ +#define VBL_COMDFN 12 /* component */ +#define VBL_GENDFN 13 /* generic */ +#define VBL_LABDFN 14 /* label */ + +#define VBL_MODDFN 0 /* mod_val field of dct_recrd */ +#define VBL_SYMDFN 1 /* sym_val field of dct_recrd */ +#define VBL_TYPDFN 2 /* type_val field of dct_recrd */ +#define VBL_SUNDFN 3 /* sign_val */ +#define VBL_LBLDFN 4 /* lbl_val field of dct_recrd */ +#define VBL_WMXDFN 5 /* wmx_val field of dct_recrd */ +#define VBL_WMNDFN 6 /* wmn_val field of dct_recrd */ +#define VBL_ATLDFN 7 /* attr_left_val */ +#define VBL_ATRDFN 8 /* attr_left_val */ +#define VBL_PNTDFN 9 /* pnt_val field of dct_recrd */ +#define VBL_DYNDFN 10 /* dynamic_val */ + +#define VBL_UPTDFN 1 /* direction is up */ +#define VBL_DWTDFN 2 /* direction is down */ +#define VBL_IDXDFN 3 + +#define VBL_EVENT 1 +#define VBL_STABLE 2 +#define VBL_LEFT 3 +#define VBL_RIGHT 4 +#define VBL_HIGH 5 +#define VBL_LOW 6 +#define VBL_LENGTH 7 +#define VBL_RANGE 8 +#define VBL_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 VBL_UNGDFN 0 +#define VBL_GRDDFN 1 + +/* ###---------------------------------------------------------------### */ + +#define VBL_INTDFN 0 /* int_val field of dtc_recrd */ + +#define VBL_ALODFN 60 /* nbr of allocations */ +#define VBL_HSZDFN 97 /* size of dictionnary: entries */ diff --git a/alliance/src/vbl/src/vbl_blex.h b/alliance/src/vbl/src/vbl_blex.h new file mode 100644 index 00000000..68f0f31e --- /dev/null +++ b/alliance/src/vbl/src/vbl_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 "vbl_bedef.h" + +extern long VBL_LINNUM; /* file's line number */ + +typedef struct +{ char nom[VBL_LG_MC]; + int kval; +} el_mc; + diff --git a/alliance/src/vbl/src/vbl_bspec.c b/alliance/src/vbl/src/vbl_bspec.c new file mode 100644 index 00000000..31b865bd --- /dev/null +++ b/alliance/src/vbl/src/vbl_bspec.c @@ -0,0 +1,1177 @@ +/*------------------------------------------------------------\ +| | +| 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 VBH_H + +#include "vbl_bedef.h" +#include "vbl_bspec.h" + +static int VblEvalError = 0; + +/* ###--------------------------------------------------------------### */ +/* function : vbl_stostr */ +/* description : purge double % (percent) or Quote (") from string */ +/* called func. : mbkalloc */ +/* ###--------------------------------------------------------------### */ + +char *vbl_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 : vbl_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 , vbl_toolbug, */ +/* vbl_error , addchain , freechain */ +/* ###--------------------------------------------------------------### */ + +vbtyp_list *vbl_getbasetype( type ) + + int type; +{ + vbtyp_list *ScanType; + + for ( ScanType = VBL_HEADFIG->BETYP; + ScanType != (vbtyp_list *)0; + ScanType = ScanType->NEXT ) + { + if ( ScanType->INDEX == type ) + { + if ( ScanType->BASE != (vbtyp_list *)0 ) + { + ScanType = ScanType->BASE; + } + + break; + } + } + + return( ScanType ); +} + +vexexpr *vbl_dynamicvexatom( Name, Left, Right, Dynamic ) + + char *Name; + long Left; + long Right; + unsigned char Dynamic; +{ + vexexpr *Result; + + if ( Dynamic ) + { + if ( Dynamic == VBL_UPTDFN ) Result = createvexoper( VEX_TO, 0 ); + else Result = createvexoper( VEX_DOWNTO, 0 ); + + addvexqexpr( Result, createvexatomvec( Name, -1, -1 ) ); + addvexqexpr( Result, dupvexexpr( (vexexpr *)Left ) ); + addvexqexpr( Result, dupvexexpr( (vexexpr *)Right ) ); + } + else + if ( ( Left == -1 ) && + ( Right == -1 ) ) + { + Result = createvexatombit( Name ); + } + else + { + Result = createvexatomvec( Name, Left, Right ); + } + + return( Result ); + +} + +vbl_vexstr vbl_crtvex( oper, expr1, expr2, left, right, dynamic ) + +short oper; +vbl_vexstr expr1; +vbl_vexstr expr2; +long left; +long right; +unsigned char dynamic; +{ + char name[128]; + vbl_vexstr result; + char lcl_buffer[128]; + int Length; + vbtyp_list *BaseType1; + vbtyp_list *BaseType2; + vbtyp_list *VbhType; + + result.IDENT = NULL; + result.VEX = NULL; + result.WIDTH = 0; + result.AGGREG = 0; + + switch (oper) + { + case VEX_CONCAT : + if ((expr1.VEX == NULL) || (expr2.VEX == NULL)) + vbl_toolbug (4,"vbl_crtvex","CONC",0); + else + { + if (expr1.VEX == expr2.VEX) + vbl_toolbug (16,"vbl_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 = VBH_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 ) + vbl_toolbug (2,"vbl_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 ) + vbl_toolbug (2,"vbl_crtvex","NOPI IDENT = ) ",0); + else + { + result.VEX = vbl_dynamicvexatom( expr1.IDENT, left, right, dynamic ); + + result.WIDTH = result.VEX->WIDTH; + result.TYPE = expr1.TYPE; + result.SIGNED = expr1.SIGNED; + + if ( result.SIGNED ) SetVexNodeSigned( result.VEX ); + + if ( result.TYPE >= VBH_MAX_TYPE ) + { + VbhType = vbl_getbasetype( result.TYPE ); + + if ( ( VbhType != (vbtyp_list *)0 ) && + ( VbhType->CLASS == 'A' ) ) + { + if ( VbhType->LEFT > VbhType->RIGHT ) + { + result.WIDTH = VbhType->LEFT - VbhType->RIGHT + 1; + } + else + { + result.WIDTH = VbhType->RIGHT - VbhType->LEFT + 1; + } + } + } + + expr1.IDENT = NULL; + } + break; + + case NOPS : + + if ( expr1.IDENT == NULL ) + vbl_toolbug (2,"vbl_crtvex","NOPS",0); + else + { + if ( expr1.VEX == (vexexpr *)0 ) + { + result.TYPE = vbl_tobin(lcl_buffer,expr1.IDENT,left,right); + Length = strlen( lcl_buffer ); + + if ( ( left == -1 ) && + ( right == -1 ) ) + { + if ( ( result.TYPE == VBH_TYPE_INTEGER ) || + ( result.TYPE == VBH_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 ) + { + vbl_error(97,NULL); + } + else + { + sprintf( name, "\"%s\"", lcl_buffer ); + result.VEX = createvexatomvec( name, left, right ); + } + + if ( result.TYPE == VBH_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) + vbl_toolbug (3,"vbl_crtvex","EVENT",0); + else + { + result.VEX = createvexunaryexpr( VEX_EVENT, 1, expr1.VEX ); + result.WIDTH = 1; + result.TYPE = VBH_TYPE_BIT; + result.SIGNED = expr1.SIGNED; + + if ( result.SIGNED ) SetVexNodeSigned( result.VEX ); + + expr1.VEX = NULL; + } + break; + + case VEX_NOT : + if (expr1.VEX == NULL) + vbl_toolbug (3,"vbl_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_OTHERS : + if ((expr1.VEX == NULL)|| + (! IsVexNodeAtom(expr1.VEX))|| + (! IsVexAtomLiteral( expr1.VEX ))) + vbl_toolbug (3,"vbl_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) + vbl_toolbug (3,"vbl_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) ) + vbl_toolbug (4,"vbl_crtvex","EQ or NE",0); + else + { + BaseType1 = vbl_getbasetype( expr1.TYPE ); + BaseType2 = vbl_getbasetype( expr2.TYPE ); + + if ( ( BaseType1->INDEX != VBH_TYPE_INTEGER ) && + ( BaseType2->INDEX != VBH_TYPE_INTEGER ) ) + { + if ( ( expr1.WIDTH != expr2.WIDTH ) && + ( ! IsVexNodeVarWidth( expr1.VEX ) ) && + ( ! IsVexNodeVarWidth( expr2.VEX ) ) ) + { + vbl_error(38,NULL); + } + } + + result.VEX = createvexbinexpr( oper, 1, expr1.VEX, expr2.VEX ); + result.WIDTH = 1; + result.TYPE = VBH_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)) + vbl_toolbug (4,"vbl_crtvex","LT, LE, GT or GE",0); + else + { + BaseType1 = vbl_getbasetype( expr1.TYPE ); + BaseType2 = vbl_getbasetype( expr2.TYPE ); + + if ( ( BaseType1->INDEX != VBH_TYPE_INTEGER ) && + ( BaseType2->INDEX != VBH_TYPE_INTEGER ) ) + { + if ( ( expr1.WIDTH != expr2.WIDTH ) && + ( ! IsVexNodeVarWidth( expr1.VEX ) ) && + ( ! IsVexNodeVarWidth( expr2.VEX ) ) ) + { + vbl_error (38,NULL); + } + } + + result.VEX = createvexbinexpr( oper, 1, expr1.VEX, expr2.VEX ); + result.WIDTH = 1; + result.TYPE = VBH_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)) + vbl_toolbug (4,"vbl_crtvex","logical operators",0); + else + { + if ( expr1.WIDTH != expr2.WIDTH ) + { + vbl_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)) + vbl_toolbug (4,"vbl_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)) + vbl_toolbug (4,"vbl_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 == VBH_TYPE_INTEGER ) || + ( expr1.TYPE == VBH_TYPE_NATURAL ) ) && + ( ( expr2.TYPE == VBH_TYPE_INTEGER ) || + ( expr2.TYPE == VBH_TYPE_NATURAL ) ) ) + { + if ( expr1.WIDTH > expr2.WIDTH ) Width = expr1.WIDTH; + else Width = expr2.WIDTH; + } + else + if ( ( expr1.TYPE == VBH_TYPE_INTEGER ) || + ( expr1.TYPE == VBH_TYPE_NATURAL ) ) + { + Width = expr2.WIDTH * 2; + } + else + if ( ( expr2.TYPE == VBH_TYPE_INTEGER ) || + ( expr2.TYPE == VBH_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) + vbl_toolbug (3,"vbl_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 : vbl_toolbug (1,"vbl_crtvex","Default",0); + } + + return (result); +} + +/* ###--------------------------------------------------------------### */ +/* function : vbl_numtobin */ +/* description : transform a ENUMERATE */ +/* in a string of '0' and '1's */ +/* ###--------------------------------------------------------------### */ +long vbl_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 : vbl_numtobin */ +/* description : transform a ENUMERATE */ +/* in a string of '0' and '1's */ +/* ###--------------------------------------------------------------### */ +char *vbl_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 : vbl_codeSize, compute the number of bits to */ +/* store a user-type value, given the scope width */ +/*------------------------------------------------------------*/ + +int vbl_codeSize( Size ) + + long Size; +{ + return( getvexintnumbit( Size ) ); +} + +/*------------------------------------------------------------*/ +/* function : vbl_intSize, compute the number of bits to */ +/* store an integer value, given the left and right */ +/*------------------------------------------------------------*/ + +int vbl_intSize( Left, Right ) + + long Left; + long Right; +{ + return( getvexintervalnumbit( Left, Right ) ); +} + + +/* ###--------------------------------------------------------------### */ +/* function : vbl_enumbitstring */ +/* description : transform a ENUMERATE */ +/* in a string of '0' and '1' and '-' */ +/* ###--------------------------------------------------------------### */ +char *vbl_enumbitstring(num,size,numbit) +int num; +int size; +int numbit; + +{ + char val[40]; + int i; + long shiftnum; + long sup_bound; /* (1 << (numbit-1)) */ + long inf_bound; /* size & ~(1 << (numbit-1)) */ + + if ( numbit == 1 ) + { + if ( num == 1 ) return ( "'1'" ); + else return ( "'0'" ); + } + + sup_bound = 1 << (numbit - 1); + inf_bound = size & ~sup_bound; + + val[0] = '"'; + val[numbit+1] = '"'; + val[numbit+2] = '\0'; + + shiftnum = num; + + for (i=1; i<=numbit; i++) + { + val[i] = (shiftnum & 1) + '0'; + shiftnum = shiftnum>>1 ; + } + + if ( ( num >= inf_bound ) && + ( num < sup_bound ) ) + { + /* ICI LUDO !! + val[numbit] = '-'; + */ + val[numbit] = '0'; + } + + return( namealloc( val ) ); +} + +/* ###--------------------------------------------------------------### */ +/* function : vbl_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 vbl_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 = VBH_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( VBH_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; vbl_error(73,src); + } + indx++; + } + + type = VBH_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; vbl_error(73,src); + } + indx++; + } + type = VBH_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 = VBH_TYPE_INTEGER; + } + else + { + /*\ + if ( src[ 0 ] == '-' ) lcl_trg[ 0 ] = '1'; + else lcl_trg[ 0 ] = '0'; + + j = 1; + \*/ + + type = VBH_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 = VBH_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; + vbl_toolbug (17,"vbl_tobin",NULL,base); + } + + strcpy (trg, lcl_trg); + } + } + + return (type); +} + +static long vbl_vexliteval( Vex ) + + vexexpr *Vex; +{ + long Value; + + if ( evalvexatomlong( Vex, &Value ) ) + { + VblEvalError = 1; + } + + return( Value ); +} + +static long vbl_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 = vbl_vexeval( Vex ); + + if ( Oper == VEX_NEG ) + { + Value = - Value; + } + else + if ( Oper == VEX_ABS ) + { + if ( Value < 0 ) Value = - Value; + } + else + if ( ScanOper == (chain_list *)0 ) + { + VblEvalError = 1; + } + + while ( ScanOper != (chain_list *)0 ) + { + Vex = GetVexOperand( ScanOper ); + Operand = vbl_vexeval( Vex ); + + if ( VblEvalError ) 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 ) VblEvalError = 1; + else Value /= Operand; + break; + + default : VblEvalError = 1; + break; + } + + ScanOper = ScanOper->NEXT; + } + } + else + if ( ( IsVexNodeAtom( Vex ) ) && + ( IsVexAtomLiteral( Vex ) ) ) + { + Value = vbl_vexliteval( Vex ); + } + else + { + VblEvalError = 1; + } + + return( Value ); +} + +int vbl_vextonum( Vex, PValue ) + + vexexpr *Vex; + long *PValue; +{ + VblEvalError = 0; + *PValue = vbl_vexeval( Vex ); + +# ifdef DEBUG +fprintf( stdout, "vbl_vextonum " ); +viewvexexprbound( Vex ); +fprintf( stdout, "\n%ld %d\n", *PValue, VblEvalError ); +# endif + + return( VblEvalError ); +} diff --git a/alliance/src/vbl/src/vbl_bspec.h b/alliance/src/vbl/src/vbl_bspec.h new file mode 100644 index 00000000..10efcb42 --- /dev/null +++ b/alliance/src/vbl/src/vbl_bspec.h @@ -0,0 +1,92 @@ +/*------------------------------------------------------------\ +| | +| This file is part of the Alliance CAD System Copyright | +| (C) Laboratoire LIP6 - Département ASIM Universite P&M Curie| +| | +| Home page : http://www-asim.lip6.fr/alliance/ | +| E-mail support : mailto:alliance-support@asim.lip6.fr | +| | +| This progam is free software; you can redistribute it | +| and/or modify it under the terms of the GNU Library General| +| Public License as published by the Free Software Foundation | +| either version 2 of the License, or (at your option) any | +| later version. | +| | +| Alliance VLSI CAD System is distributed in the hope that | +| it will be useful, but WITHOUT ANY WARRANTY; | +| without even the implied warranty of MERCHANTABILITY or | +| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | +| Public License for more details. | +| | +| You should have received a copy of the GNU General Public | +| License along with the GNU C Library; see the file COPYING. | +| If not, write to the Free Software Foundation, Inc., | +| 675 Mass Ave, Cambridge, MA 02139, USA. | +| | +\------------------------------------------------------------*/ + +/* ###--------------------------------------------------------------### */ +/* */ +/* 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 vbl_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; + } +vbl_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 DYNAMIC; /* Left and Right are static */ + char SIGNED; + char AGGREG; + } +vbl_name; + +struct g_type + { + int VALU; + char FLAG; + }; + +struct choice_chain + { + struct choice_chain* NEXT; + chain_list *VALUES; + unsigned int SIZE; + struct ptype *INSTRUCTION; + }; + + +extern vbl_vexstr VBL_EMPSTR; +extern struct vbfig *VBL_HEADFIG; +extern struct vbmap *VBL_GENMAP; + + +extern vbl_vexstr vbl_crtvex (); +extern char *vbl_numtobin (); +extern char *vbl_enumbitstring(); +extern int vbl_codeSize(); +extern vexexpr *vbl_dynamicvexatom(); +extern int vbl_intSize(); +extern int vbl_vextonum(); +extern vbtyp_list *vbl_getbasetype(); + extern void vbl_error(); + extern int vbl_tobin(); + diff --git a/alliance/src/vbl/src/vbl_byacc.h b/alliance/src/vbl/src/vbl_byacc.h new file mode 100644 index 00000000..994230d4 --- /dev/null +++ b/alliance/src/vbl/src/vbl_byacc.h @@ -0,0 +1,111 @@ +/*------------------------------------------------------------\ +| | +| 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_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 *vbl_addstr (); +static vbtyp_list *val_type(); +static vbtyp_list *get_type(); +static struct ptype *reversetype(); +static struct choice_chain *addchoice(); +static struct choice_chain *order_choice(); + +extern char VBL_ERRFLG; /* set to 1 in case of error */ +extern struct vbfig *VBL_HEADFIG; /* head of vbfigs */ +extern long VBL_LINNUM; +extern int VBL_NUMPTP; +extern int VBL_NUMCHOICE; + +/*\ +pNode VBL_BDDPNT; +\*/ + /* BDD pointer */ +char *VBL_MODNAM; /* curnennt model name */ +char *VBL_PROCNAM; /* current process name */ +char *VBL_FUNCNAM; /* current function/procedure name */ +char *VBL_COMPNAM; +char *VBL_SAVCOMPNAM; +char *VBL_GNRNAM; /* current generate name */ +vbl_vexstr VBL_SLCEXP; /* structure filled with the */ +vbl_vexstr VBL_EMPSTR; /* empty structure used with NOT*/ + +static int VBL_NUMTYP = 0; /* nombre de type */ +static struct chain *VBL_NM1LST = NULL; /* 1-st name liste */ +static struct chain *VBL_NM2LST = NULL; /* 2-st name liste */ +static struct chain *VBL_INSLST = NULL; /* 3-st name liste */ +static struct chain *VBL_LOOPLBLLST = NULL; +static struct chain *VBL_GRDLST = NULL; /* list of guard's ABL */ +static struct chain *VBL_CNDLST = NULL; /* list of conditions (ABL) */ +static struct chain *VBL_LINLST = NULL; /* list of line */ +static struct chain *VBL_VALLST = NULL; /* list of waveforms (ABL) */ +static struct vbfig *VBL_BEFPNT = NULL; /* current BEFIG pointer */ +static char *VBL_LOOPLBL = NULL; +static struct vbmap *VBL_BEMAP = NULL; + +static struct vbins *VBL_BEINS = NULL; +static struct vbgnr *VBL_BEGNR = NULL; +static vbpcs_list *VBL_BEPCS = (vbpcs_list *)0; +static vbfun_list *VBL_BEFUN = (vbfun_list *)0; + +static chain_list *VBL_GNR_BEPCS = (chain_list *)0; +static chain_list *VBL_GNR_BEINS = (chain_list *)0; +static chain_list *VBL_GNR_BEGNR = (chain_list *)0; + +static struct authtable *VBL_ENUMVAL = NULL; +static struct choice_chain *VBL_CASPNT = NULL; +static int VBL_CASSIZE = 0; +static struct ptype *VBL_OTHPNT = NULL; +static struct ptype *VBL_PTYPE = NULL; + +static struct dct_entry *VBL_DCEHED; /* free dct_entry's head */ +static struct dct_recrd *VBL_DCRHED; /* free dct_recrd's head */ + +static struct dct_entry **hshtab; + +extern struct vbgen *bvl_addgen(); + +extern vbl_vexstr vbl_crtvex(); +extern vbl_vexstr bvl_cpyvexstr(); +extern vbl_vexstr bvl_select(); +extern char *bvl_stostr(); +extern void bvl_error(); + diff --git a/alliance/src/vbl/src/vbl_parse.c b/alliance/src/vbl/src/vbl_parse.c new file mode 100644 index 00000000..41f8b6f2 --- /dev/null +++ b/alliance/src/vbl/src/vbl_parse.c @@ -0,0 +1,206 @@ +/*------------------------------------------------------------\ +| | +| 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 : VBL | +| | +| File : vbl_parse.c | +| | +| Author : Jacomme Ludovic | +| | +| Date : 01.01.95 | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Include Files | +| | +\------------------------------------------------------------*/ + +# include MUT_H +# include AUT_H +# include VEX_H +# include VBH_H +# include VBL_H + +# include +# include +# include + +/*------------------------------------------------------------\ +| | +| Constants | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Types | +| | +\------------------------------------------------------------*/ +/*------------------------------------------------------------\ +| | +| Variables | +| | +\------------------------------------------------------------*/ + + extern FILE *vbl_y_in; + extern int vbl_y_parse(); + extern char VBL_ERRFLG; + extern vbfig_list *VBL_HEADFIG; + extern vbmap_list *VBL_GENMAP; + extern char *VBL_FILENAME; + +/*------------------------------------------------------------\ +| | +| vpnloadvpnfig | +| | +\------------------------------------------------------------*/ + +vbfig_list *getvbfiggenmap( InputFileName, Extention, GenericMap ) + + char *InputFileName; + char *Extention; + vbmap_list *GenericMap; +{ + int Value; + int Index; + +static char *AllianceExtention[] = { "vst", "vbe", "fsm" }; + + if ( ! strcmp( Extention, "vst" ) ) + { + Index = 0; + + for ( Index = 0; Index < 3; Index++ ) + { + vbl_y_in = mbkfopen( InputFileName, AllianceExtention[ Index ], "r" ); + + if ( vbl_y_in != (FILE *)0 ) break; + } + } + else + { + vbl_y_in = mbkfopen( InputFileName, Extention, "r" ); + } + + if ( vbl_y_in == (FILE *)0 ) + { + fprintf( stdout, "Error opening file %s\n", InputFileName ); + autexit( 1 ); + } + + VBL_GENMAP = GenericMap; + VBL_FILENAME = InputFileName; + + Value = vbl_y_parse(); + + fclose( vbl_y_in ); + + if ( ( Value ) || + ( VBL_ERRFLG ) ) + { + fprintf( stdout, "Error parsing file %s\n", InputFileName ); + autexit( 1 ); + } + + VBL_HEADFIG->BEGEN = (vbgen_list *)reverse( (chain_list *)VBL_HEADFIG->BEGEN ); + VBL_HEADFIG->BECST = (vbcst_list *)reverse( (chain_list *)VBL_HEADFIG->BECST ); + + return( VBL_HEADFIG ); +} + +/*------------------------------------------------------------\ +| | +| getvbfig | +| | +\------------------------------------------------------------*/ + +vbfig_list *getvbfig( InputFileName, Extention ) + + char *InputFileName; + char *Extention; +{ + return( getvbfiggenmap( InputFileName, Extention, (vbmap_list *)0 ) ); +} + +/*------------------------------------------------------------\ +| | +| getvbpkg | +| | +\------------------------------------------------------------*/ + +void getvbpkg( FileName, Extention ) + + char *FileName; + char *Extention; +{ + vbfig_list *VbhFigure; + FILE *File; + char Buffer[ 512 ]; + char LogicalName[ 512 ]; + char PhysicalName[ 512 ]; + long LineNumber; + + if ( FileName == (char *)0 ) return; + + File = mbkfopen( FileName, "pkg", "r" ); + + if ( File != (FILE *)0 ) + { + LineNumber = 0; + + while ( fgets( Buffer, 512, File ) != (char *)0 ) + { + LineNumber++; + + if ( Buffer[ 0 ] == '#' ) continue; + + if ( sscanf( Buffer, "%s : %s\n", LogicalName, PhysicalName ) == 2 ) + { + VbhFigure = getvbfiggenmap( PhysicalName, Extention, (vbmap_list *)0 ); + + if ( ! VbhFigure->PACKAGE ) + { + fprintf( stdout, "ERROR file %s is not a package\n", PhysicalName ); + autexit( 1 ); + } + + VbhFigure->NAME = namealloc( LogicalName ); + } + else + { + fprintf( stdout, "ERROR syntax error line %ld, in file %s\n", LineNumber, FileName ); + autexit( 1 ); + } + } + } + else + { + fprintf( stdout, "Error opening package file list %s\n", FileName ); + autexit( 1 ); + } +} diff --git a/alliance/src/vbl/src/vbl_util.c b/alliance/src/vbl/src/vbl_util.c new file mode 100644 index 00000000..c67ac541 --- /dev/null +++ b/alliance/src/vbl/src/vbl_util.c @@ -0,0 +1,516 @@ +/*------------------------------------------------------------\ +| | +| 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 : vbl_util.c */ +/* date : Sep 14 1992 */ +/* version : v100 */ +/* author : Pirouz BAZARGAN SABET, M.HANAFI */ +/* description : This file contains some utility functions : */ +/* vbl_error , vbl_y_error, vbl_toolbug, vbl_message, */ +/* */ +/* ###--------------------------------------------------------------### */ + +#include +#include +#include +#include +#include + +#include MUT_H +#include AUT_H +#include VEX_H +#include VBH_H + +#include "vbl_utype.h" +#include "vbl_util.h" + +char VBL_ERRFLG = 0; /* if = 1 no structure is made */ +char *VBL_FILENAME = (char *)0; +long VBL_LINNUM = 1; /* file's line number */ +int VBL_NUMPTP = 0; /* file's line number */ +int VBL_NUMCHOICE = 0; +vbfig_list *VBL_HEADFIG = (vbfig_list *)0; +vbmap_list *VBL_GENMAP = (vbmap_list *)0; + + char *vbl_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 *vbl_func_std_logic_arith[] = + { + "abs", + "shl", + "shr", + "conv_integer", + "conv_unsigned", + "conv_signed", + "conv_std_logic_vector", + "ext", + "sxt", + NULL + }; + + char *vbl_func_std_numeric_std[] = + { + "shift_left", + "shift_right", + "rotate_left", + "rotate_right", + "resize", + "to_integer", + "to_unsigned", + "to_signed", + NULL + }; + + +/* ###--------------------------------------------------------------### */ +/* function : vbl_toolbug */ +/* ###--------------------------------------------------------------### */ +void vbl_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 : vbl_message */ +/* ###--------------------------------------------------------------### */ +void vbl_message (code,str1,nmb1) + +int code; +char *str1; +int nmb1; + +{ + switch (code) + { + case 1: + (void) fprintf(stderr,"USAGE is vbl [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,"vbl_message : code %d unknown.\n",code); + } +} + +/* ###--------------------------------------------------------------### */ +/* function : vbl_error */ +/* ###--------------------------------------------------------------### */ + +void vbl_error (code,str1) + +int code; +char *str1; + +{ + VBL_ERRFLG++; + if (code < 100) + (void)fprintf (stderr,"Error %d line %ld in file %s :",code,VBL_LINNUM, VBL_FILENAME); + else + { + if (code < 200) + (void)fprintf (stderr,"Error %d :",code); + } + + switch (code) + { + case 1: + (void) fprintf (stderr,"`%s` is incompatible with the entity name\n",str1); + break; + case 2: + (void) fprintf (stderr,"bad entity declaration\n"); + break; + case 3: + (void) fprintf (stderr,"bad port clause declaration\n"); + break; + case 4: + (void) fprintf (stderr,"port `%s` already declared\n",str1); + break; + case 5: + (void) fprintf (stderr,"illegal port declaration\n"); + break; + case 6: + (void) fprintf (stderr,"bad port declaration\n"); + break; + case 7: + (void) fprintf (stderr,"`%s` is incompatible with the architecture name\n",str1); + break; + case 8: + (void) fprintf (stderr,"bad architecture declaration\n"); + break; + case 9: + (void) fprintf (stderr,"illegal declaration\n"); + break; + case 10: + (void) fprintf (stderr,"symbol `%s` already declared\n",str1); + break; + case 11: + (void) fprintf (stderr,"illegal signal declaration\n"); + break; + case 17: + (void) fprintf (stderr,"`%s` unknown port or signal\n",str1); + break; + case 18: + (void) fprintf (stderr,"illegal concurrent statement\n"); + break; + case 19: + (void) fprintf (stderr,"label `%s` already used\n",str1); + break; + case 20: + (void) fprintf (stderr,"`%s` is incompatible with the block's label\n",str1); + break; + case 21: + (void) fprintf (stderr,"input port `%s` cannot be assigned\n",str1); + break; + case 22: + (void) fprintf (stderr,"unguarded signal `%s` assigned by guarded assignment\n",str1); + break; + case 23: + (void) fprintf (stderr,"guarded signal `%s` assigned by unguarded assignment\n",str1); + break; + case 25: + (void) fprintf (stderr,"some choices missing in the selected signal assignment\n"); + break; + case 26: + (void) fprintf (stderr,"output port `%s` cannot be read\n",str1); + break; + case 27: + (void) fprintf (stderr," '%s' only variable can be assigned with ':=' \n",str1); + break; + case 28: + (void) fprintf (stderr,"duplicate choice in selected signal assignment\n"); + break; + case 30: + (void) fprintf (stderr,"illegal use of OTHERS in selected signal assignment\n"); + break; + case 31: + (void) fprintf (stderr,"illegal use of OTHERS in case statement \n"); + break; + case 32: + (void) fprintf (stderr,"null array not supported\n"); + break; + case 33: + (void) fprintf (stderr,"incompatible constraint and type\n"); + break; + case 35: + (void) fprintf (stderr,"illegal assignment of `%s` (widths mismatch)\n",str1); + break; + case 36: + (void) fprintf (stderr,"signal `%s` used out of declared range\n",str1); + break; + case 38: + (void) fprintf (stderr,"width or/and type mismatch %s\n",str1); + break; + case 39: + (void) fprintf (stderr,"signal `%s` assigned more than once\n",str1); + break; + case 40: + (void) fprintf (stderr,"signal `%s` never assigned\n",str1); + break; + case 41: + (void) fprintf (stderr,"usage of GUARD statement outside a block not permitted\n"); + break; + case 68: + (void) fprintf (stderr,"BEPOR type is unknown\n"); + break; + case 73: + (void) fprintf (stderr,"`%s` is not a bit string litteral\n",str1); + break; + case 74: + (void) fprintf (stderr,"bad generic declaration\n"); + break; + case 75: + (void) fprintf (stderr,"bad generic element\n"); + break; + case 76: + (void) fprintf (stderr,"`%s`: when expression must be a constant\n",str1); + break; + case 77: + (void) fprintf (stderr,"illegal generic declaration\n"); + 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 81: + (void) fprintf (stderr,"internal signal not allowed `%s`\n",str1); + break; + case 82: + (void) fprintf (stderr,"enumerate valu `%s` already declared\n",str1); + break; + case 83: + (void) fprintf (stderr,"'%s' illegal index subtype definition \n",str1); + break; + case 84: + (void) fprintf (stderr,"'%s' illegal type mark definition \n",str1); + break; + case 85: + (void) fprintf (stderr,"when choice is empty in case statement \n"); + break; + case 86: + (void) fprintf (stderr,"illegal variable declaration\n"); + break; + case 87: + (void) fprintf (stderr,"illegal type declaration\n"); + break; + case 94: + (void) fprintf (stderr,"The %s instruction is not accepted in the VHDL SUBSET \n",str1); + break; + case 95: + (void) fprintf (stderr,"`%s` is incompatible with the loop's label\n",str1); + break; + case 96: + (void) fprintf (stderr,"A process with sensitivity list cannot have WAIT statements\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 112: + (void) fprintf (stderr,"multiple driver on guarded signal `%s`\n",str1); + break; + + case 113: + (void) fprintf (stderr,"bad subprogram declaration\n"); + break; + case 114: + (void) fprintf (stderr,"illegal aggregate\n"); + break; + case 115: + (void) fprintf (stderr,"illegal function declaration\n"); + break; + case 116: + (void) fprintf (stderr,"function `%s` already declared\n",str1); + break; + case 117: + (void) fprintf (stderr,"procedure `%s` already declared\n",str1); + break; + case 118: + (void) fprintf (stderr,"unknown procedure or function `%s`\n",str1); + break; + case 119: + (void) fprintf (stderr,"illegal procedure call `%s`\n",str1); + break; + case 120: + (void) fprintf (stderr,"illegal return statement\n"); + break; + case 121: + (void) fprintf (stderr,"illegal for statement\n"); + break; + case 122: + (void) fprintf (stderr,"illegal qualified expression\n"); + break; + case 123: + (void) fprintf (stderr,"such array type definition is not supported\n"); + break; + case 124: + (void) fprintf (stderr,"bad association list (%s)\n",str1); + break; + case 125: + (void) fprintf (stderr,"unknown model name (%s)\n",str1); + break; + case 126: + (void) fprintf (stderr,"bad generic declaration\n"); + break; + case 127: + (void) fprintf (stderr,"unknown package %s\n", str1 ); + break; + case 128: + (void) fprintf (stderr,"`%s` is incompatible with the package name\n",str1); + break; + case 129: + (void) fprintf (stderr,"bad package body declaration\n"); + break; + + default: + (void) fprintf (stderr,"syntax error\n"); + break; + } + + if (VBL_ERRFLG > VBL_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 : vbl_y_error */ +/* ###--------------------------------------------------------------### */ +void vbl_y_error (str) + +char *str; +{ + VBL_ERRFLG++; + (void)fprintf (stderr,"Error line %ld : %s\n",VBL_LINNUM,str); +} diff --git a/alliance/src/vbl/src/vbl_util.h b/alliance/src/vbl/src/vbl_util.h new file mode 100644 index 00000000..c3f8a64a --- /dev/null +++ b/alliance/src/vbl/src/vbl_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 : vbl_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 `vbl_util.c` */ +/* */ +/* ###--------------------------------------------------------------### */ + +#define VBL_MXRDFN 30 + + extern long VBL_LINNUM; /* file's line number */ + extern char VBL_ERRFLG; /* Error flag */ + extern char VBL_CURFIL[]; /* current file name */ diff --git a/alliance/src/vbl/src/vbl_utype.h b/alliance/src/vbl/src/vbl_utype.h new file mode 100644 index 00000000..6c59e480 --- /dev/null +++ b/alliance/src/vbl/src/vbl_utype.h @@ -0,0 +1,61 @@ +/*------------------------------------------------------------\ +| | +| 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 : vbl_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; + char dyn_val; + }; diff --git a/alliance/src/vbl/src/vhdl.yac b/alliance/src/vbl/src/vhdl.yac new file mode 100644 index 00000000..6ac73d42 --- /dev/null +++ b/alliance/src/vbl/src/vhdl.yac @@ -0,0 +1,2980 @@ +/**************************************************************************** +* +* Date: 19 Feb, 1990 S. Datta, Univ of Cincinnati +* +*This file currently contains 3 shift/reduce and 3 reduce/reduce conflicts: +* +*Shift/reduce conflicts: +* +* 1. name -> simple_name +*and .architecture_identifier. -> LeftParen simple_name RightParen_ERR +*cause 1 shift/reduce conflict. +* +* 2. attribute_name -> name Apostrophe attribute_designator .aggregate. +*causes 1 shift/reduce conflict (since .aggregate. -> | aggregate) +* +* 3. component_instantiation_statement -> a_label name +*.generic_map_aspect. .port_map_aspect. Semicolon_ERR +*causes 1 shift/reduce conflict (with .generic_map_aspect.). +* +*Reduce/reduce conflicts: +* +* 1. range -> attribute_name +*and name -> attribute_name causes 1 reduce/reduce conflict. +* +* 2. expanded_name -> simple_name +*and name -> simple_name causes 2 reduce/reduce conflicts. +* +*To avoid conflicts while implementing on an LALR(1) shift-reduce +*parser-generator such as YACC or BISON, the original IEEE-1076 VHDL grammar +*has been modified at appropriate places: +* +*The production for formal_port_element contains "type_mark .constraint." +*instead of ".name. type_mark .constraint." (ie instead of subtype_indication) +*(AFIT file contains only "type_mark") +* +*The production for formal_generic_element contains "type_mark .constraint." +*instead of ".name. type_mark .constraint." (ie instead of subtype_indication) +*(AFIT file contains only "type_mark") +* +*In the production for architecture_body, "simple_name" (AFIT) has been +*changed to "name" in accordance with the LRM +* +*The production for configuration_declaration contains "name" instead of +*"entity_name" (LRM), or "Identifier" (AFIT) +* +*Missing Semicolon_ERR at end of production for block_configuration (in AFIT +*file) has been set right. +* +*In production for block_specification, "name" causes conflict and has not +*been implemented. +* +*In production for component_configuration, "Identifier" (AFIT) has been +*replaced by "name" in accordance with the LRM definition. Besides, missing +*Semicolon_ERR (in AFIT file) has been set right. +* +*In production for operator_symbol, "sign" has not been implemented. Besides, +*"StringLit" (absent in AFIT file) has been added in accordance with the LRM +*definition. Also, "logical_operator" and "miscelaneous_operator", and +*productions for them have been added (these were commented out in the AFIT +*file). +* +*In production for procedure_parameter_element, ".name. type_mark +*.constraint." (or subtype_indication) has been replaced with "type_mark +*.constraint.". AFIT file contains only "type_mark". +* +*In production for function_parameter_element, ".name. type_mark +*.constraint." (or subtype_indication) has been replaced with "type_mark +*.constraint.". AFIT file contains only "type_mark". +* +*In production for scalar_type_definition, "range_type_definition" includes +*both integer and floating point types. +* +*In production for index_subtype_definition, "type_mark" (LRM) has been +*replaced by "name". +* +*In production for discrete_range, "subtype_indication" (ie ".name. +*type_mark .constraint." in LRM) has been replaced by "name range_constraint +*| type_mark". Note: "constraint" (LRM) implies "range_constraint" or +*"index_constraint", but "index_constraint" has been ommitted in the +*production for discrete_range. This is the same as the AFIT file, except that +*"type_mark" has also been ommitted in AFIT file, since it causes 2 +*reduce/reduce errors. +* +*Missing Semicolon_ERR in AFIT file for the production for +*incomplete_type_declaration has been set right here. +* +*This file as well as AFIT file contains "expanded_name" in production for +*"type_mark" to avoid conflict between "type_mark" and "constraint". +* +*In production for constraint, "index_constraint" has been replaced by +*"aggregate", both in this as well as the AFIT file. +* +*Missing Semicolon_ERR in AFIT file for the production for file_declaration +*has been set right. +* +*In production for association_element, ".formal_part_Arrow. actual_part" +*has been replaced by "name Arrow OPEN_or_expression | OPEN_or_expression". +* +*Productions for "formal_part" and "actual_part" have been replaced by their +*equivalents. (ie formal_part -> name | LeftParen name RightParen; +*actual_part -> OPEN_or_expression | LeftParen OPEN_or_expression RightParen;) +* +*In production for local_port_element, "subtype_indication .BUS. +*.VarAsgn_expression." has been replaced by "type_mark .constraint." in this +*file, and "type_mark" in the AFIT file. +* +*In production for local_generic_element, "subtype_indication +*.VarAsgn_expression." has been replaced by "type_mark .constraint." in this +*file, and "type_mark" in the AFIT file. +* +*In production for configuration_specification, "Identifier" (AFIT) has been +*replaced by "name" in this file in accordance with the LRM definition. +* +*In production for entity_aspect, "ENTITY Identifier" (AFIT) has been +*replaced by "ENTITY name" as per the LRM, but "CONFIGURATION name" (LRM) +*has been replaced by "CONFIGURATION Identifier", here, as well as in AFIT file. +* +*Missing Semicolon_ERR in production for disconnection_specification in AFIT +*file has been set right. +* +*In production for name, "indexed_name" includes "slice_name". Besides, +*name -> operator_symbol (operator overloading) has not been implemented. +*(causes 28 reduce/reduce conflicts). +* +*prefix -> function_call is not implemented. "function_call" is handled by +*"indexed_name". +* +*suffix -> operator_symbol is not implemented. +* +*indexed_name -> prefix ( expression ,{ expression } ) in LRM is implemented +*here as indexed_name -> name aggregate. +* +*In production for attribute_name, "prefix" (LRM) is replaced by "name", +*and optional '(' expression ')' in LRM is implemented as ".aggregate." +*here. +* +*"attribute_designator -> simple_name | RANGE" includes the keyword "RANGE" +*here. (used as an Identifier here). +* +*In production for primary, "function_call" is handled by "name", and '(' +*expression ')' is handled by aggregate. Besides primary -> type_conversion +*is not implemented. +* +*literal -> Identifier is not implemented. (causes 99 reduce/reduce conflicts). +* +*Production for element_association contains "simple_expression direction +*simple_expression | name range_constraint" to compensate for change in +*production for "choice". +* +*choice -> discrete_range has been replaced by "choice -> simple_expression +*direction simple_expression | name range_constraint", since "discrete_range +*-> subtype_indication | range" causes conflicts. Besides "choice -> +*simple_expression | simple_name" has been replaced by "choice -> +*simple_expression" since "simple_expression" contains "simple_name" in LRM +*definition. +* +*function_call is handled by "indexed_name" +* +*In production for qualified_expression, "type_mark" has been replaced by +*"name", and "aggregate" includes '(' expression ')'. +* +*"type_conversion" has been replaced everywhere by its appropriate +*production. +* +*allocator -> NEW subtype_indication | NEW qualified_expression has been +*replaced by "NEW qualified_expression" only, since "subtype_indication" +*causes conflicts. +* +*.AFTER__expression. -> | AFTER numeric_literal (AFIT) has been changed to +*".AFTER__expression. -> | AFTER expression" to reflect the LRM. +* +*In production for procedure_call_statement, "actual_parameter_part" has +*been ommitted. Its inclusion causes 1 shift/reduce, and 2 reduce/reduce +*conflicts. Here, procedure_call_statement has been implemented as "name +*Semicolon_ERR", since "name" includes "name aggregate". +* +*In production for component_instantiation_statement, "Identifier" (AFIT) +*has been replaced by "name" as per the LRM definition +* +*generate_statement is always labelled (LRM). So unlabelled_generate_statement +*(AFIT) is not implemented. +* +*Missing Semicolon_ERR in production for library_clause in AFIT file has +*been set right. +* +* +****************************************************************************/ +/* +** $Header: /dsk/l1/alliance/cvsroot/alliance/src/vbl/src/vhdl.yac,v 1.1 2002/03/21 13:41:36 ludo Exp $$$ +** +** $Log: vhdl.yac,v $ +** Revision 1.1 2002/03/21 13:41:36 ludo +** Initial revision +** $$ + * Revision 4.0 87/11/30 15:58:01 rbratton + * Check in of VHDL version 4.0 (version reported in thesis). + * + * Revision 3.2 87/11/04 16:10:48 rbratton + * Parser: corrected ranges and aggregate grammar. 1 shift/reduce + * conflict. + * Lex: Save before trying to implement alternate replacement + * characters (! for |, : for #, and % for "). + * + * Revision 3.1 87/11/01 11:28:31 rbratton + * Checkpoint save before trying to resolve "range" problems. + * + * Revision 3.0 87/10/15 06:23:49 rbratton + * Beta 3 Save. Implemented case/selected signal assignment and + * with/use (using improved symbol table). + * + * Revision 2.3 87/10/11 15:06:54 rbratton + * Because of problems with passing floating point parameters, floating + * point has been removed--replaced with integer long. Hopefully, at a + * later time, the problems will be resolved. + * This is also a configuration save before adding WITH/USE capabilities + * to the analyzer. + * + * Revision 2.2 87/09/06 20:05:55 rbratton + * Checkpoint save before implementing improved symbol table. + * + * Revision 2.1 87/09/01 11:26:46 rbratton + * Implemented floating point notation. Uses float (32 bits?) rather than + * double, but could possibly be changed later. + * +** Revision 2.0 87/08/29 09:43:08 rbratton +** Configuration save. For VHDL Release 2.0 +** +** Revision 1.8 87/08/24 18:30:11 rbratton +** 1 shift/reduce conflict (default acceptable). Creates 487 cases. +** Changed value of NULL_SYMBOL from (struct sym_entry *) 0 to +** NULL (= 0). Still creates a NULL pointer, but does not generate +** warnings while compiling the resulting code (vhdlyacc.c). +** +** Revision 1.7 87/08/18 19:35:46 rbratton +** Corrected problems with signal assignment statement. Added labels to +** block statement and label symbol table entry. +** +** Revision 1.6 87/08/09 19:34:47 rbratton +** This version will NOT compile. It causes a "switch table overflow". +** The next version may be a reduced grammar to try to avoid this +** problem. +** +** Revision 1.5 87/07/18 19:14:53 rbratton +** checkpoint save: no conflicts +** +** Revision 1.4 87/07/17 18:21:23 rbratton +** checkpoint save: 9 shift/reduce conflicts +** Plus/Minus LeftParen +** +** Revision 1.3 87/07/17 17:57:50 rbratton +** checkpoint save: 13 shift/reduce conflicts +** Plus/Minus; Identifier +** +** Revision 1.2 87/07/15 10:07:55 rbratton +** checkpoint save +** +** Revision 1.1 87/06/21 09:24:24 rbratton +** Added some error recovery. More to follow. +** +** Revision 1.0 87/04/24 17:28:14 rbratton +** Initial revision +** +** +*/ + +/************************************************************************* +** +** Portions of the following code was extracted from +** LALR(1) grammar for ANSI Ada (public domain) +** by Herman Fischer +** adapted by: Gerry Fisher & Philippe Charles +** +** VHDL source for yacc +** syntax analysis with error recovery +** symbol table +** memory allocation +** no code generation +** shift/reduce conflicts: 1 +** +** +** Symbol conventions used: +** [foo] is denoted .foo. +** {foo} is denoted ..foo.. +** {, foo } is denoted ...foo.. +** foo_bar is a single nonterminal +** FOO__bar is a nonterminal where the keyword FOO is +** followed by a nonterminal bar +** +************************************************************************/ + +%{ +#include + + +extern HASH_ENTRY hashtab[]; /* hash table of id indices and names */ +extern int ANY_NAME; /* generic hash table index for error recovery */ +extern SYM_PTR ANYPTR; /* generic symbol table ptr for error recovery */ +SYM_PTR sym1, sym2, sym3; /* temp variables for symbol table pointers */ +NODE_PTR nod1, nod2, nod3; /* temp variables for node list pointers */ +int op1, op2, op3; /* temporary variables for op indices */ + +int is_childless; /* attribute of architecture body */ +int is_structure; /* attribute of architecture body */ +%} + +%union { + int y_tok; /* token */ + int y_op; /* Index to op table entry */ + int y_hash; /* Index to hash table entry */ + int y_str; /* Index to string storage */ + SYM_PTR y_sym; /* Pointer to symbol table entry */ + long y_val; /* Floating point number (32 bits) */ + /* (also handles integer values) */ + } + +/* terminal symbols */ + +/* old terminal symbols - keep until removed from yacc code */ + + +%token Ampersand +%token Apostrophe +%token LeftParen +%token RightParen +%token DoubleStar +%token Star +%token Plus +%token Comma +%token Minus +%token VarAsgn +%token Colon +%token Semicolon +%token LESym +%token Box +%token LTSym +%token Arrow +%token EQSym +%token GESym +%token GTSym +%token Bar +%token NESym +%token Dot +%token Slash +%token Identifier +%token DecimalInt +%token DecimalReal +%token BasedInt +%token BasedReal +%token CharacterLit +%token StringLit +%token BitStringLit +%token ABS +%token ACCESS +%token AFTER +%token ALIAS +%token ALL +%token AND +%token ARCHITECTURE +%token ARRAY +%token ASSERT +%token ATTRIBUTE +%token BEGIN_ +%token BLOCK +%token BODY +%token BUFFER +%token BUS +%token CASE +%token COMPONENT +%token CONFIGURATION +%token CONSTANT +%token DISCONNECT +%token DOWNTO +%token ELSE +%token ELSIF +%token END_ +%token ENTITY +%token EXIT +%token FILE_ +%token FOR +%token FUNCTION +%token GENERATE +%token GENERIC +%token GUARDED +%token IF +%token INOUT +%token IN +%token IS +%token LABEL +%token LIBRARY +%token LINKAGE +%token LOOP +%token MAP +%token MOD +%token NAND +%token NEW +%token NEXT +%token NOR +%token NOT +%token NULL_ +%token OF +%token ON +%token OPEN +%token OR +%token OTHERS +%token OUT +%token PACKAGE +%token PORT +%token PROCEDURE +%token PROCESS +%token RANGE +%token RECORD +%token REGISTER +%token REM +%token REPORT +%token RETURN +%token SELECT +%token SEVERITY +%token SIGNAL +%token SUBTYPE +%token THEN +%token TO +%token TRANSPORT +%token TYPE +%token UNITS +%token UNTIL +%token USE +%token VARIABLE +%token WAIT +%token WHEN +%token WHILE +%token WITH +%token XOR + + /**************************************************************************** + ** + ** operator precedences and associativities listed in + ** increasing precedence. + ** + ** Note: ABS and NOT have the same precedence as DoubleStar; + ** yet, they associate to the right. The (non)token UNARY_SIGN is used + ** only to establish precedence for unary plus/minus signs. It does not + ** have to be a declared token or have any other value other than its + ** relative precedence value. + ** + ****************************************************************************/ + +%left AND OR NAND NOR XOR +%left EQSym NESym LTSym LESym GTSym GESym +%left Plus Minus Ampersand +%left Star Slash MOD REM +%right UNARY_SIGN +%left DoubleStar +%right ABS NOT + +%{ +#ifndef NDEBUG +#define TRACE(x,z) {if(yaccdebug)printf("#RULE %s ::= %s\n",x,z);} +#else +#define TRACE(x,z) ; +#endif +%} + +/* + * Start symbol = "design_file" + */ +%start design_file + +/* + * Rules + */ +%% + + +/* +** Chapter 1: Design Entities +*/ + +/* 1.1 */ +entity_declaration + : ENTITY + Identifier + IS + .generic_clause. + .port_clause. + entity_declarative_part + .BEGIN__entity_statement_part. + END_ERR + .simple_name. + Semicolon_ERR + | ENTITY error + ; + +/* 1.1.1 */ +.port_clause. + : /*empty*/ + | port_clause + ; + + +.generic_clause. + : /*empty*/ + | generic_clause + ; + +port_clause + : PORT + LeftParen + formal_port_list + RightParen_ERR + Semicolon_ERR + ; + +generic_clause + : GENERIC + LeftParen + formal_generic_list + RightParen_ERR + Semicolon_ERR + ; + + + +/* 1.1.1.2 */ +formal_port_list + : formal_port_element + ...formal_port_element.. + | error RightParen_ERR + ; + + +...formal_port_element.. + : /*empty*/ + | ...formal_port_element.. + Semicolon_ERR + formal_port_element + { + yyerrok; + } + ; + +formal_port_element + : .SIGNAL. + identifier_list + Colon + .mode. + /* .name. causes conflict */ + type_mark + .constraint. + .BUS. + .VarAsgn__expression. + ; + +.SIGNAL. + : /*empty*/ + | SIGNAL + ; + +.mode. + :/*empty*/ + | IN + | OUT + | INOUT + | BUFFER + | LINKAGE + ; + +.BUS. + : /*empty*/ + | BUS + ; + + + +.VarAsgn__expression. + : /*empty*/ + | VarAsgn + expression + ; + +/* 1.1.1.1 */ +formal_generic_list + : formal_generic_element + ...formal_generic_element.. + | error RightParen_ERR + ; + + +...formal_generic_element.. + : /*empty*/ + | ...formal_generic_element.. + Semicolon_ERR + formal_generic_element + { + yyerrok; + } + ; + +formal_generic_element + : .CONSTANT. + identifier_list + Colon + .IN. + /* .name. causes conflict */ + type_mark + .constraint. + .VarAsgn__expression. + ; + + +.CONSTANT. + : /*empty*/ + | CONSTANT + ; + +.IN. + : /*empty*/ + | IN + ; + +/* 1.1.2 */ +entity_declarative_part + : ..entity_declarative_item.. + ; + + +..entity_declarative_item.. + : /*empty*/ + | ..entity_declarative_item.. + entity_declarative_item + ; + + +entity_declarative_item + : alias_declaration + | constant_declaration + | type_declaration + | subtype_declaration + | attribute_declaration + | attribute_specification + | subprogram_declaration + | subprogram_body + | signal_declaration + | file_declaration + | disconnection_specification + | use_clause + ; + + +/* 1.1.3 */ + +.BEGIN__entity_statement_part. + : /* empty */ + | BEGIN_ + entity_statement_part + ; + + +entity_statement_part + : ..entity_statement.. + ; + +..entity_statement.. + : /*empty*/ + | ..entity_statement.. + entity_statement + ; + + +entity_statement + : concurrent_assertion_statement + | concurrent_procedure_call + | process_statement /* NOT IN 7.2 */ + ; + + +/* 1.2 */ +/* architecture bodies */ + +architecture_body + : ARCHITECTURE + Identifier + OF + name /* entity name */ + IS + architecture_declarative_part + BEGIN_ + architecture_statement_part + END_ERR + .simple_name. /* architecture simple name */ + Semicolon_ERR + | ARCHITECTURE error + ; + +/* 1.2.1 */ +/* Architecture Declarative Part */ +architecture_declarative_part + : ..block_declarative_item.. + ; + +..block_declarative_item.. + : /*empty*/ + | ..block_declarative_item.. + block_declarative_item + ; + +block_declarative_item + : constant_declaration + | signal_declaration + | type_declaration + | subtype_declaration + | attribute_declaration + | component_declaration + | alias_declaration + | attribute_specification + | configuration_specification + | subprogram_declaration + | subprogram_body + | file_declaration + | disconnection_specification + | use_clause + ; + +/* 1.2.2 */ +/* Architecture Statement Part */ +architecture_statement_part + : ..concurrent_statement.. + ; + + +/* 1.3 */ +configuration_declaration + : CONFIGURATION + Identifier + OF + name /* Identifier */ /* entity_name */ + IS + configuration_declarative_part + block_configuration + END_ERR + .simple_name. + Semicolon_ERR + | CONFIGURATION error + ; + +configuration_declarative_part + : ..configuration_declarative_item.. + ; + +..configuration_declarative_item.. + : /*empty*/ + | ..configuration_declarative_item.. + configuration_declarative_item + ; + +configuration_declarative_item + : use_clause + | attribute_specification + ; + +/* 1.3.1 */ +/* block configuration */ +block_configuration + : FOR + block_specification + ..use_clause.. + ..configuration_item.. + END_ERR + FOR + Semicolon_ERR + ; + + +..use_clause.. + : /*empty*/ + | use_clause + ..use_clause.. + ; + +..configuration_item.. + : /*empty*/ + | ..configuration_item.. + configuration_item + ; + +block_specification + : label /* arch, block, generate */ + .opt_index_spec. + /* | name causes conflict */ + ; + +.opt_index_spec. + : /*empty*/ + | LeftParen + index_specification + RightParen_ERR + ; + + +index_specification + : discrete_range + | expression + ; + +configuration_item + : block_configuration + | component_configuration + ; + +/* 1.3.2 */ + +component_configuration + : FOR + instantiation_list + Colon + name /* Identifier */ + .USE__binding_indication. + .block_configuration. + END_ERR + FOR + Semicolon_ERR + ; + +.USE__binding_indication. + : /*empty*/ + | USE + binding_indication + Semicolon_ERR + ; + +.block_configuration. + : /*empty*/ + | block_configuration + ; + + +/* +** Chapter 2: Subprograms +*/ + +/* 2.1 */ +subprogram_declaration + : subprogram_specification + Semicolon_ERR + ; + +subprogram_specification + : PROCEDURE + designator + .procedure_parameter_list. + | FUNCTION + designator + .function_parameter_list. + RETURN + type_mark + ; + +designator + : Identifier + | operator_symbol + ; + +operator_symbol /* defined in LRM 2.1 */ + : relational_operator + | adding_operator +/* | sign */ + | multiplying_operator + | logical_operator + | miscellaneous_operator + | StringLit + ; +logical_operator : AND | OR | NAND | NOR | XOR + ; +miscellaneous_operator : DoubleStar | ABS | NOT + ; + +.procedure_parameter_list. + : /*empty*/ + | LeftParen + procedure_parameter_element + ...procedure_parameter_element.. + RightParen_ERR + | LeftParen + error + RightParen_ERR + ; + + +...procedure_parameter_element.. + : /*empty*/ + | ...procedure_parameter_element.. + Semicolon_ERR + procedure_parameter_element + { + yyerrok; + } + ; + + +procedure_parameter_element + : .procedure_parameter_object_class. + identifier_list + Colon + .procedure_parameter_mode. + /* .name. causes conflict */ + type_mark + .constraint. + .VarAsgn__expression. + ; + +.procedure_parameter_object_class. + : /*empty*/ + | VARIABLE + | CONSTANT + ; + +.procedure_parameter_mode. + : /*empty*/ + | IN + | OUT + | INOUT + ; + +.function_parameter_list. + : /*empty*/ + | LeftParen + function_parameter_element + ...function_parameter_element.. + RightParen_ERR + | LeftParen + error + RightParen_ERR + ; + + +...function_parameter_element.. + : /*empty*/ + | ...function_parameter_element.. + Semicolon_ERR + function_parameter_element + ; + +function_parameter_element + : .function_parameter_object_class. + identifier_list + Colon + .function_parameter_mode. + type_mark + .constraint. + .VarAsgn__expression. + ; + + +.function_parameter_object_class. + : /*empty*/ + | CONSTANT + | SIGNAL + ; + +.function_parameter_mode. + : /*empty*/ + | IN + ; + + +/* 2.2 */ +subprogram_declarative_part + : /*empty*/ + | subprogram_declarative_part + subprogram_declarative_item + { + yyerrok; + } + ; + +subprogram_declarative_item + : constant_declaration + | variable_declaration + | alias_declaration + | type_declaration + | subtype_declaration + | attribute_declaration + | attribute_specification + | subprogram_declaration + | subprogram_body + | file_declaration + | use_clause + ; + + +/* 2.2 */ +/* subprogram bodies */ + +subprogram_body + : subprogram_specification + IS + subprogram_declarative_part + BEGIN_ + sequence_of_statements + END_ERR + .designator. + Semicolon_ERR + ; + +.designator. + : /*empty*/ + | designator + ; + + + +/* Packages */ + +/* 2.5 */ +package_declaration + : PACKAGE + Identifier + IS + package_declarative_part + END_ERR + .simple_name. + Semicolon_ERR + | PACKAGE + error + ; + +package_declarative_part + : ..package_declarative_item.. + ; + +..package_declarative_item.. + : /*empty*/ + | ..package_declarative_item.. + package_declarative_item + ; + +package_declarative_item + : type_declaration + | subtype_declaration + | attribute_declaration + | constant_declaration + | alias_declaration + | subprogram_declaration + | component_declaration + | attribute_specification + | signal_declaration + | file_declaration + | disconnection_specification + | use_clause + | error END_ERR + Semicolon_ERR + ; + +/* 2.6 */ +/* package bodies */ + +package_body + : PACKAGE + BODY + Identifier + IS + package_body_declarative_part + END_ERR + .simple_name. + Semicolon_ERR + | PACKAGE + BODY + error + ; + +package_body_declarative_part + : ..package_body_declarative_item.. + ; + +..package_body_declarative_item.. + : /*empty*/ + | ..package_body_declarative_item.. + package_body_declarative_item + ; + +package_body_declarative_item + : subprogram_declaration + | subprogram_body + | type_declaration + | subtype_declaration + | constant_declaration + | file_declaration + | alias_declaration + | use_clause + ; + + +/* +** Chapter 3: Types +*/ + + +/* 3.1 */ +scalar_type_definition + : enumeration_type_definition + | range_type_definition /* includes integer and floating point */ + | physical_type_definition + ; + +range_constraint + : RANGE + range + ; + +range + : attribute_name /* simple_expression simple_expression -> (attribute) name */ + | simple_expression + direction + simple_expression + ; + +direction + : TO + | DOWNTO + ; + +/* 3.1.1. */ +enumeration_type_definition + : LeftParen + enumeration_literal + ...enumeration_literal.. + RightParen_ERR + ; + + +...enumeration_literal.. + : /*empty*/ + | ...enumeration_literal.. + Comma + enumeration_literal + { + yyerrok; + } + ; + +enumeration_literal + : Identifier + | CharacterLit + ; + +/* 3.1.2 & 3.1.4 */ +/* Integer and Floating Point types */ + +range_type_definition + : range_constraint + ; + +/* 3.1.3 */ +physical_type_definition + : range_constraint + UNITS + base_unit_declaration + ..secondary_unit_declaration.. + END_ERR + UNITS + ; + + +..secondary_unit_declaration.. + : /*empty*/ + | ..secondary_unit_declaration.. + secondary_unit_declaration + { + yyerrok; + } + ; + +base_unit_declaration + : Identifier + Semicolon_ERR + ; + +secondary_unit_declaration + : Identifier + EQSym + physical_literal + Semicolon_ERR + ; + +physical_literal + : .abstract_literal. + name /* in LRM: UNIT_name */ + ; + + +.abstract_literal. + : /*empty*/ + | abstract_literal + ; + +/* 3.2 */ +composite_type_definition + : array_type_definition + | record_type_definition + ; + +/* 3.2.1 */ +array_type_definition + : unconstrained_array_definition + | constrained_array_definition + ; + +unconstrained_array_definition + : ARRAY + LeftParen + index_subtype_definition + ...index_subtype_definition.. + RightParen_ERR + OF + subtype_indication + ; + + +...index_subtype_definition.. + : /*empty*/ + | ...index_subtype_definition.. + Comma + index_subtype_definition + ; + +constrained_array_definition + : ARRAY + index_constraint + OF + subtype_indication + ; + +index_subtype_definition + : name /* type_mark - causes conflict */ + RANGE + Box + ; + +index_constraint + : LeftParen + discrete_range + ...discrete_range.. + RightParen_ERR + ; + +...discrete_range.. + : /*empty*/ + | ...discrete_range.. + Comma + discrete_range + { + yyerrok; + } + ; + +discrete_range + : range /* includes attribute_name */ + | name + range_constraint /* subtype_indication - causes conflict */ + | type_mark /* type_mark causes 2 r/r conflicts - required for + louie's code */ + ; + +/* 3.2.2 */ +record_type_definition + : RECORD + element_declaration + ..element_declaration.. + END_ERR + RECORD + | RECORD + error + END_ERR + RECORD + ; + + +..element_declaration.. + : /*empty*/ + | ..element_declaration.. + element_declaration + { + yyerrok; + } + ; + +element_declaration + : identifier_list + Colon + element_subtype_definition + Semicolon_ERR + ; + +/* +** identifier_list is used consistantly in definitions of new Identifiers, +** with one exception--IMPORT_DIRECTIVE. The IMPORT_DIRECTIVE expects to +** find all Identifiers declared at the local scope and it is an error if +** they are not. In all other cases, it is an error to have two Identifiers +** with the same name at the same level. (Overloading not implemented.) +** Therefore, identifier_list checks to see if the previous token was +** IMPORT. +** returns pointer to symbol table which has a list of identifier +** definitions connected by the "next" pointers. +*/ +identifier_list + : Identifier + ...identifier.. + ; + + +...identifier.. + : /*empty*/ + | Comma + Identifier + ...identifier.. + ; + + +element_subtype_definition + : subtype_indication + ; + +/* 3.3 */ +/* Access Types */ +access_type_definition + : ACCESS + subtype_indication + ; + +/* 3.3.1 */ +/* Incomplete Type Declarations */ +incomplete_type_declaration + : TYPE + Identifier + Semicolon_ERR + ; + + +/* 3.4 */ +/* File Types */ +file_type_definition + : FILE_ + OF + type_mark + ; + + + +/* +** Chapter 4: Declarations +*/ +/* 4.1.1 */ +type_declaration + : full_type_declaration + | incomplete_type_declaration + ; + +full_type_declaration + : TYPE + Identifier + IS + type_definition + Semicolon_ERR + ; + +type_definition + : scalar_type_definition + | composite_type_definition + | access_type_definition + | file_type_definition + | error Semicolon_ERR + ; + +/* 4.2 */ +subtype_declaration + : SUBTYPE + Identifier + IS + subtype_indication + Semicolon_ERR + ; + +subtype_indication + : type_or_function_name + type_mark + .constraint. + | type_mark + .constraint. + ; + + +.constraint. + : /*empty*/ + | constraint + ; + +type_or_function_name + : expanded_name + ; + + +expanded_name + : simple_name /* Identifier */ +/* | STANDARD + */ + | expanded_name /* was Identifier */ + Dot + simple_name /* Identifier */ + { + yyerrok; + } + ; + +type_mark + : expanded_name /* move to production.c !!! */ + + /* type_mark and constraint + will otherwise cause conflict */ + ; + +constraint + : range_constraint + | aggregate /* was: ( discrete_range ...discrete_range.. ) */ + /* index_constraint */ + ; + +/* 4.3.1.1 */ +constant_declaration + : CONSTANT + identifier_list + Colon + subtype_indication + .VarAsgn__expression. + Semicolon_ERR + ; + +/* 4.3.1.2 */ +signal_declaration + : SIGNAL + identifier_list + Colon + subtype_indication + .signal_kind. + .VarAsgn__expression. + Semicolon_ERR + ; + +.signal_kind. + : /*empty*/ + | signal_kind + ; + +signal_kind + : REGISTER + | BUS + ; + +/* 4.3.1.3 */ +variable_declaration + : VARIABLE + identifier_list + Colon + subtype_indication + .VarAsgn__expression. + Semicolon_ERR + ; + +/* 4.3.2 */ +/* File Declarations */ +file_declaration + : FILE_ + Identifier + Colon + subtype_indication + IS + .mode. + expression + Semicolon_ERR + ; + +/* 4.3.3 and 4.3.3.1 */ +/* Interface Declaration and lists are interspersed + where they are actually used port, generic and parameter */ + +/* 4.3.3.2 */ +/* Association lists */ + +association_list + : association_element + ...association_element.. + ; + +...association_element.. + : /*empty*/ + | Comma + association_element + ...association_element.. + { + yyerrok; + } + ; + +/* +** ( expression ) is defined by aggregate as: +** ( general_element_association ) => +** ( OPEN_or_expression ) => +** ( expression ) +*/ + +association_element + : /* formal_part */ /* causes conflict */ + name + Arrow + /* actual_part */ + OPEN_or_expression /* can be name also */ + | /* actual_part */ + OPEN_or_expression /* can be name also */ + ; +/* causes conflict +formal_part : name | name LeftParen name RightParen + ; +actual_part : OPEN_or_expression | name LeftParen OPEN_or_expression + RightParen + ; +*/ +OPEN_or_expression + : OPEN + | expression + ; + +/* 4.3.4 */ +alias_declaration + : ALIAS + Identifier + Colon + subtype_indication + IS + name + Semicolon_ERR + ; + + +/* 4.4 */ +attribute_declaration + : ATTRIBUTE + Identifier + Colon + type_mark + Semicolon_ERR + ; + + +/* 4.5 */ +component_declaration + : COMPONENT + Identifier + .GENERIC__local_generic_list. + .PORT__local_port_list. + END_ERR + COMPONENT + Semicolon_ERR + ; + +.PORT__local_port_list. + : /*empty*/ + | PORT + LeftParen + local_port_list + RightParen_ERR + Semicolon_ERR + ; + +local_port_list + : local_port_element + ...local_port_element.. + | error RightParen_ERR + ; + + +...local_port_element.. + : /*empty*/ + | ...local_port_element.. + Semicolon_ERR + local_port_element + ; + + +local_port_element + : .SIGNAL. + identifier_list + Colon + .local_port_mode. + type_mark + .constraint. + ; + +.local_port_mode. + : /*empty*/ + | IN + | OUT + | INOUT + | BUFFER + | LINKAGE + ; + +.GENERIC__local_generic_list. + : /*empty*/ + | GENERIC + LeftParen + local_generic_list + RightParen_ERR + Semicolon_ERR + ; + +local_generic_list + : local_generic_element + ...local_generic_element.. + | error RightParen_ERR + ; + + +...local_generic_element.. + : /*empty*/ + | ...local_generic_element.. + Semicolon_ERR + local_generic_element + ; + + +local_generic_element + : .CONSTANT. + identifier_list + Colon + .IN. + type_mark + .constraint. + ; + +/* +** Chapter 5: Specifications +*/ + +/* 5.1 */ +attribute_specification + : ATTRIBUTE + attribute_designator + OF + entity_specification + IS + expression + Semicolon_ERR + ; + +entity_specification + : entity_name_list + Colon + entity_class + ; + + +entity_class + : ENTITY + | ARCHITECTURE + | PACKAGE + | FUNCTION + | PROCEDURE + | SUBTYPE + | CONSTANT + | VARIABLE + | SIGNAL + | LABEL + | TYPE + | CONFIGURATION + | COMPONENT + ; + +entity_name_list + : entity_designator + ...entity_designator.. + | OTHERS + | ALL + ; + +...entity_designator.. + : /*empty*/ + | ...entity_designator.. + Comma + entity_designator + ; + +entity_designator + : simple_name + | operator_symbol + ; + + +/* 5.2 */ +configuration_specification + : FOR + instantiation_list + Colon + /* Identifier */ + name + USE + binding_indication + Semicolon_ERR + | FOR + error + Semicolon_ERR + ; + +instantiation_list + : identifier_list + | OTHERS + | ALL + | error Colon + { + yyerrok; + } + ; + +/* 5.2.1 */ +binding_indication + : entity_aspect + .generic_map_aspect. + .port_map_aspect. + ; + + +/* 5.2.1.1 */ +entity_aspect + : ENTITY + /* Identifier */ + name /* name causes 1 s/r conflict */ + .architecture_identifier. + | CONFIGURATION + Identifier + /* name causes conflict */ + | OPEN + ; + +.architecture_identifier. + : /*empty*/ + | LeftParen + simple_name + RightParen_ERR + ; + + +/* entity_indication + : library_name entity library_name + | OPEN + ; */ + +/* 5.2.1.2 */ +...element_association.. + : /*empty*/ + | ...element_association.. + Comma + element_association + { + yyerrok; + } + ; +/* 5.3 */ +/* Disconnection_specification */ +disconnection_specification + : DISCONNECT + guarded_signal_specification + AFTER + expression + Semicolon_ERR + ; + +guarded_signal_specification + : signal_list + Colon + type_mark + ; + + + +/* 6.2.3 */ +/* initialize_directive + : INITIALIZE + type_mark + TO + expression + ..waveform. + Semicolon_ERR + ; */ + +/* +** Chapter 6: Names +*/ + +/* 6.1 */ +/* +** According to the VHDL Test suite, library names are not used +** in expressions. Therefore, the choice "library_name" is removed. +** NEED TO CHECK THIS OUT!!! */ +name + : simple_name /* move to production.c */ + | indexed_name /* includes "slice_name" */ + | selected_name + | attribute_name /* not implemented: causes 2 reduce/reduce conflicts. + | operator_symbol overloading not implemented + causes reduce/reduce conflicts (28) */ + ; + +prefix + : name /*function call handled by indexed_name*/ +/* | function_call +*/ + ; + + +/* 6.2 */ +simple_name /* returns hash index */ + : Identifier + ; + + +.simple_name. + : /*empty*/ + | simple_name + ; + + +/* 6.3 */ +selected_name + : prefix + Dot + suffix + ; + +suffix + : simple_name + | CharacterLit +/* | operator_symbol */ /* handled by characterLit */ + | ALL + ; + +/* 6.4 */ +indexed_name /* also includes "slice_name" 6.5 */ + : name /* in LRM: prefix */ + aggregate /* in LRM: '(' expression { ',' expression } ')' */ + ; + +/* 6.6 */ +attribute_name + : name /* prefix causes 7 shift/reduce conflicts */ + Apostrophe + attribute_designator + .aggregate. /* in LRM: '(' static_expression ')' */ + ; + + +.aggregate. + : /*empty*/ + | aggregate + ; + +attribute_designator + : simple_name /* attribute simple_name */ + | RANGE /* somebody goofed! Keyword used as an identifier */ + ; + +/******** +** +** Chapter 7 Expressions +** +*********/ + +/* 7.1 */ +expression + : relation..AND__relation.. + | relation..OR__relation.. + | relation.NAND_NOR__relation. + | relation..XOR__relation.. + ; + + +relation..AND__relation.. + : relation + AND + relation + | relation..AND__relation.. + AND + relation + ; + +relation..OR__relation.. + : relation + OR + relation + | relation..OR__relation.. + OR + relation + ; + +relation.NAND_NOR__relation. + : relation + | relation + NAND + relation + | relation + NOR + relation + ; + + +relation..XOR__relation.. + : relation + XOR + relation + | relation..XOR__relation.. + XOR + relation + ; + +relation + : simple_expression + .relop__simple_expression. + ; + + +.relop__simple_expression. + : /*empty*/ + | relational_operator + simple_expression + ; + +/* +** simple_expression ::= [sign] term { adding_operator term } +*/ +simple_expression + : .sign.term..add_op__term.. + ; + +term + : factor + | term + multiplying_operator + factor + { + yyerrok; + } + ; + + +.sign.term..add_op__term.. + : term %prec UNARY_SIGN + | sign + term %prec UNARY_SIGN + | .sign.term..add_op__term.. + adding_operator + term + ; + +factor + : primary + .DoubleStar__primary. + | ABS + primary + | NOT + primary + ; + + +.DoubleStar__primary. + : /*empty*/ + | DoubleStar + primary + ; + +primary + : literal + | qualified_expression +/* | function_call +*/ + | name /* name = simple_name = Identifier = enumeration_literal */ + /* includes function_call */ + | aggregate /*(expression) is included under aggregate*/ + /* | type_conversion causes reduce/reduce conflicts + */ | allocator + ; + + /* 7.2.1 */ + /* logical operators embedded in expression */ + + /* 7.2.2 */ + relational_operator + : EQSym + | NESym + | LTSym + | LESym + | GTSym + | GESym + ; + + /* 7.2.3 */ + adding_operator + : Plus + | Minus + | Ampersand + ; + +sign + : Plus + | Minus + ; + +/* 7.2.4 */ +multiplying_operator + : Star + | Slash + | MOD + | REM + ; + +/* 7.3.1 */ +literal + : numeric_literal + | CharacterLit + /* + * | enumeration_literal + * Causes 99 reduce/reduce conflicts with Id and CharLit. + * Covered under 'name'. + */ /* Identifier causes conflict */ + | StringLit + | BitStringLit + | NULL_ + ; + +numeric_literal + : abstract_literal + | abstract_literal /* physical_literal */ + name /* Identifier */ /* in LRM: UNIT_name */ + + /* name in physical_literal causes conflict */ + ; + +/* 7.3.2 */ +aggregate + : LeftParen + element_association + ...element_association.. + RightParen_ERR + ; + +element_association + : expression + | choice + ..Bar__choice.. + Arrow + expression + | simple_expression + direction /* because of production for "choice" + to avoid conflict */ + simple_expression + | name + range_constraint + ; + +choices + : choice + ..Bar__choice.. + { + yyerrok; + } + ; + + +..Bar__choice.. + : /*empty*/ + | ..Bar__choice.. + Bar + choice + ; + +choice + : simple_expression /* includes simple_name */ + | simple_expression + direction + simple_expression /* because of production for "discrete_range" + to avoid conflict */ + | name + range_constraint + | OTHERS + ; + + +/* 7.3.3 */ +/* function_call + : Identifier + actual_parameter_part + ; + +actual_parameter_part + : + LeftParen + association_list + RightParen_ERR + ; function_call handled by selected name */ +/* .actual_parameter_part. + : + | LeftParen + association_list + RightParen_ERR + ; * function_call handled by selected name */ + +/* 7.3.4 */ +qualified_expression + : name + Apostrophe + aggregate + /* + ** type_mark ' aggregate | type_mark ' ( expression ) + */ + ; + +/* 7.3.5 */ +/* type_conversion causes reduce/reduce conflict + : Identifier type_mark + LeftParen aggregate + expression + RightParen_ERR + ; +*/ + +/* 7.3.6 */ +allocator + : NEW +/* subtype_indication + + | NEW causes numerous reduce/reduce conflicts */ + qualified_expression + ; + + +/* +** Chapter 8: Sequential Statements +*/ + +/* 8.0 */ +sequence_of_statements + : ..sequential_statement.. + | error END_ERR + { + yyerrok; + } + | error ELSIF + { + yyerrok; + } + | error ELSE + { + yyerrok; + } + | error WHEN + { + yyerrok; + } + ; + + +..sequential_statement.. + : /*empty*/ + | sequential_statement + ..sequential_statement.. + ; + +sequential_statement + : assertion_statement + | signal_assignment_statement + | variable_assignment_statement + | if_statement + | case_statement + | loop_statement + | next_statement + | exit_statement + | return_statement + | null_statement + | procedure_call_statement + | wait_statement + ; + +/* 8.1 */ +wait_statement + : WAIT + .sensitivity_clause. + .condition_clause. + .timeout_clause. + Semicolon_ERR + ; + +.sensitivity_clause. + : /*empty*/ + | sensitivity_clause + ; + +.condition_clause. + : /*empty*/ + | condition_clause + ; + +.timeout_clause. + : /*empty*/ + | timeout_clause + ; + +sensitivity_clause + : ON + /* sensitivity_list */ + signal_list + ; + +condition_clause + : UNTIL + expression + ; + +timeout_clause + : FOR + expression + ; + + +/* +** returns SYM_REF op tree indexes +*/ +signal_list + : name + ...name.. + | OTHERS + | ALL + ; + + +...name.. + : /*empty*/ + | ...name.. + Comma + name + ; + +/* 8.2 */ +assertion_statement + : ASSERT + expression + .REPORT__expression. + .SEVERITY__expression. + Semicolon_ERR + ; + + +.REPORT__expression. + : /*empty*/ + | REPORT + expression + ; + +.SEVERITY__expression. + : /*empty*/ + | SEVERITY + expression + ; + +/* 8.3 */ +signal_assignment_statement + : target + LESym + .TRANSPORT. + waveform + Semicolon_ERR + ; + +target + : name + | aggregate + ; + + +waveform + : waveform_element + ...waveform_element.. + ; + + +...waveform_element.. + : /*empty*/ + | Comma + waveform_element + ...waveform_element.. + ; + +/* 8.3.1 */ +waveform_element + : expression /* NULL can be arrived at through expression - literal */ + .AFTER__expression. + ; + + +.AFTER__expression. + : /*empty*/ + | AFTER + expression /* numeric_literal */ /* in LRM: expression */ + ; + +/* 8.4 */ +variable_assignment_statement + : target + VarAsgn + expression + Semicolon_ERR + ; + +/* 8.5 */ +procedure_call_statement + : name /* name includes "name ( association_list )" */ + Semicolon_ERR /* need to include actual_parameter_part + - causes conflict */ + ; + +/* 8.6 */ +if_statement + : IF + condition + THEN + sequence_of_statements + ..ELSIF__THEN__seq_of_stmts.. + .ELSE__seq_of_stmts. + END_ERR + IF + Semicolon_ERR + ; + + +..ELSIF__THEN__seq_of_stmts.. + : /*empty*/ + | ELSIF + condition + THEN + sequence_of_statements + ..ELSIF__THEN__seq_of_stmts.. + { + yyerrok; + } + ; + +.ELSE__seq_of_stmts. + : /*empty*/ + | ELSE + sequence_of_statements + { + yyerrok; + } + ; + +/* 8.7 */ +case_statement + : CASE + expression + IS + case_statement_alternative + ..case_statement_alternative.. + END_ERR + CASE + Semicolon_ERR + ; + + +..case_statement_alternative.. + : /*empty*/ + | ..case_statement_alternative.. + case_statement_alternative + { + yyerrok; + } + ; + +case_statement_alternative + : WHEN + choices + Arrow + sequence_of_statements + ; + +/* 8.8 */ +/* +** To avoid shift/reduce conflicts, define rules for labeled/unlabeled loop +** statement +*/ +loop_statement + : a_label + unlabeled_loop_statement + | unlabeled_loop_statement + ; + +unlabeled_loop_statement + : .iteration_scheme. + LOOP + sequence_of_statements + END_ERR + LOOP + .label. + Semicolon_ERR + ; + + +.iteration_scheme. + : /*empty*/ + | iteration_scheme + ; + +iteration_scheme + : WHILE + condition + | FOR + loop_parameter_specification + ; + +.label. + : /*empty*/ + | label + ; + + +loop_parameter_specification + : Identifier + IN + discrete_range + ; + +/* 8.9 */ +next_statement + : NEXT + .label. + .WHEN__condition. + Semicolon_ERR + ; + + +.WHEN__condition. + : /*empty*/ + | WHEN + condition + ; + +/* 8.10 */ +exit_statement + : EXIT + .label. + .WHEN__condition. + Semicolon_ERR + ; + +/* 8.11 */ +return_statement + : RETURN + .expression. + Semicolon_ERR + ; + + +.expression. + : /*empty*/ + | expression + ; + +/* 8.12 */ +null_statement + : NULL_ + Semicolon_ERR + ; + +/* +* chapter 9 - concurrent statements +*/ + +/* 9.0 */ +set_of_statements + : ..concurrent_statement.. + | error END_ERR + ; + + +..concurrent_statement.. + : /*empty*/ + | concurrent_statement + ..concurrent_statement.. + ; + +concurrent_statement + : block_statement + | process_statement + | concurrent_assertion_statement + | concurrent_signal_assignment_statement + | component_instantiation_statement + | generate_statement + | concurrent_procedure_call + ; + +/* 9.1 */ +block_statement /****** needs changing *******/ + : a_label + BLOCK + .guard_expression. + .generic_clause_map_aspect. + .port_clause_map_aspect. + block_declarative_part + BEGIN_ + set_of_statements + END_ERR + BLOCK + .label. + Semicolon_ERR + ; + + +.guard_expression. + : /*empty*/ + | guard_expression + ; + +guard_expression + : LeftParen + expression + RightParen_ERR + ; + +.generic_clause_map_aspect. + : /*empty*/ + | generic_clause + .generic_map_aspect_Semicolon. + ; +.generic_map_aspect_Semicolon. + : + | generic_map_aspect + Semicolon_ERR + ; + +.port_clause_map_aspect. + : /*empty*/ + | port_clause + .port_map_aspect_Semicolon. + ; +.port_map_aspect_Semicolon. + : + | port_map_aspect + Semicolon_ERR + ; + +block_declarative_part + : ..block_declarative_item.. + ; + + +/* 9.2 */ +/* +** To avoid shift/reduce conflicts, define rules for labeled/unlabeled process +** statements. +*/ +process_statement + : a_label + unlabeled_process_statement + | unlabeled_process_statement + ; + +unlabeled_process_statement + : PROCESS + .sensitivity_list. + process_declarative_part + BEGIN_ + sequence_of_statements + END_ERR + PROCESS + .label. + Semicolon_ERR + ; + + +.sensitivity_list. + : /*empty*/ + | sensitivity_list + ; + +sensitivity_list + : LeftParen + signal_list + RightParen_ERR + ; + +process_declarative_part + : ..process_declarative_item.. + ; + + +..process_declarative_item.. + : /*empty*/ + | ..process_declarative_item.. + process_declarative_item + { + yyerrok; + } + ; + +process_declarative_item + : constant_declaration + | variable_declaration + | type_declaration + | subtype_declaration + | attribute_declaration + | attribute_specification + | subprogram_declaration + | subprogram_body + | file_declaration + | alias_declaration + | use_clause + ; + +/* 9.3 */ +/* +** to avoid shift/reduce conflicts for concurrent_procedure_call +** define rules for labeled and unlabeled statements separately +*/ + +concurrent_procedure_call + : a_label + unlabeled_concurrent_procedure_call + | unlabeled_concurrent_procedure_call + ; + +unlabeled_concurrent_procedure_call + : procedure_call_statement + ; + + + +/* 9.4 */ +/* +** To avoid shift/reduce conflicts, define rules for labeled/unlabeled +** concurrent_assertion_statements. +** +** This creates an equivalent process statement which has a sensitivity +** list of the longest static prefix of each signal name appearing in +** the boolean expression of the assertion statement. +*/ +concurrent_assertion_statement + : a_label + unlabeled_concurrent_assertion_statement + | unlabeled_concurrent_assertion_statement + ; + +unlabeled_concurrent_assertion_statement + : assertion_statement + ; + +/* 9.5 */ +/* +** To avoid shift/reduce conflicts, define rules for labeled/unlabeled +** concurrent_signal_assignment_statements. +** +** This creates an equivalent process statement. See 8.2.4 of the LRM. +*/ +concurrent_signal_assignment_statement + : a_label + unlabeled_conditional_signal_assignment + | unlabeled_conditional_signal_assignment + | a_label + unlabeled_selected_signal_assignment + | unlabeled_selected_signal_assignment + ; + + +/* 9.5.1 */ +unlabeled_conditional_signal_assignment + : target + LESym + /* options */ + .GUARDED. + .TRANSPORT. + /* conditional_waveforms */ + ..waveform__WHEN__condition__ELSE.. + waveform + Semicolon_ERR + ; + + +..waveform__WHEN__condition__ELSE.. + : /*empty*/ + | ..waveform__WHEN__condition__ELSE.. + waveform + WHEN + expression + ELSE + ; + +/* 9.5.2 */ +unlabeled_selected_signal_assignment + : WITH + expression + SELECT + target + LESym + /* options */ + .GUARDED. + .TRANSPORT. + /* selected_waveforms */ + waveform + WHEN + choices + ...waveform__WHEN__choices.. /* changed from LRM for consistancy */ + Semicolon_ERR + ; + + +...waveform__WHEN__choices.. + : /*empty*/ + | ...waveform__WHEN__choices.. + Comma + waveform + WHEN + choices + ; + + +.GUARDED. + : /*empty*/ + | GUARDED + ; + +.TRANSPORT. + : /*empty*/ + | TRANSPORT + ; + +/* 9.6 */ +component_instantiation_statement + : a_label + /* Identifier */ + name + .generic_map_aspect. + .port_map_aspect. + Semicolon_ERR + ; + + +.port_map_aspect. + : /*empty*/ + | port_map_aspect + ; +port_map_aspect + : + PORT + MAP + LeftParen /* was: PORT aggregate */ + association_list + RightParen_ERR + ; + + +.generic_map_aspect. + : /*empty*/ + | generic_map_aspect + ; +generic_map_aspect + : + GENERIC + MAP + LeftParen + association_list + RightParen_ERR + ; + +/* 9.7 */ +/* +** To avoid shift/reduce conflicts, define labeled/unlabeled generate +** statements. +*/ +generate_statement + : a_label + unlabeled_generate_statement +/* | unlabeled_generate_statement +*/ ; + +unlabeled_generate_statement + : generation_scheme + GENERATE + set_of_statements + END_ERR + GENERATE + .label. + Semicolon_ERR + ; + +generation_scheme + : FOR + generate_parameter_specification + | IF + condition + ; + +generate_parameter_specification + : Identifier + IN + discrete_range + ; + +condition + : expression + ; + +/* +** label declaration +*/ +a_label + : label + Colon + ; + + +label + : Identifier + ; + +/* +** Chapter 10: Scope and Visibility +*/ + +/* 10.4 */ +use_clause + : USE + selected_name /* package simple name */ + ...selected_name.. + Semicolon_ERR + ; + + +...selected_name.. + : /*empty*/ + | ...selected_name.. + Comma + selected_name + ; + +/* +** Design Units and Their Analysis +*/ + +/* 11.1 */ +design_file + : design_unit + ..design_unit.. + ; + +..design_unit.. + : /*empty*/ + | design_unit + ..design_unit.. + ; + +design_unit + : context_clause + library_unit + ; + +library_unit + : primary_unit + | secondary_unit + | error + ; + +primary_unit + : entity_declaration + | configuration_declaration + | package_declaration + ; + +secondary_unit + : architecture_body + | package_body + ; + +/* Design Libraries */ +/* 11.2 */ + +library_clause + : LIBRARY + logical_name_list + Semicolon_ERR + ; + +logical_name_list + : Identifier + ...logical_name.. + ; + +...logical_name.. + : /*empty*/ + | ...logical_name.. + Comma + Identifier + ; + +/* 11.3 */ +context_clause + : ..context_item.. + ; + +..context_item.. + : /*empty*/ + | ..context_item.. + context_item + ; + +context_item + : library_clause + | use_clause + ; + +/* A.4 */ +/* abstract_literal */ +/* +** Normally, the grammar for abstract literal would be found here. It +** has been moved to the end of this file. There you will find an +** explanation. +*/ + + +/********************************* +** +** Error recovery non-terminals +** +*********************************/ + +/* + * Make ';', ')', and 'end' significant for error recovery. + */ + +RightParen_ERR + : RightParen + { + yyerrok; + } + ; + +Semicolon_ERR + : Semicolon + { + yyerrok; + } + ; + +END_ERR + : END_ + { + yyerrok; + } + ; + +/* +** In order to implement floating point notation, it was necessary to +** declare the types of the parameters for 'abstract_literal_real' and +** 'abstract_literal_int', as well as the return type for 'abstract_literal'. +** But if you do this, then yacc demands that all following grammar rules +** be similarily typed. Therefore, this special case was made the last +** rule in the grammar. This will cause the compiler to complain about +** "struct/union or struct/union pointer required", but the source code +** produced by yacc is correct. +*/ +abstract_literal + : DecimalInt + | DecimalReal + | BasedInt + | BasedReal + ; +%% + +