OpenCores
URL https://opencores.org/ocsvn/sc2v/sc2v/trunk

Subversion Repositories sc2v

[/] [sc2v/] [trunk/] [src/] [sc2v_step1.y] - Diff between revs 36 and 39

Only display areas with differences | Details | Blame | View Log

Rev 36 Rev 39
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
 *
 *
 *  SystemC to Verilog Translator v0.4
 *  SystemC to Verilog Translator v0.4
 *  Provided by Universidad Rey Juan Carlos
 *  Provided by Universidad Rey Juan Carlos
 *
 *
 * -----------------------------------------------------------------------------
 * -----------------------------------------------------------------------------
 *  This program is free software; you can redistribute it and/or modify
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *  (at your option) any later version.
 *
 *
 *  This program is distributed in the hope that it will be useful,
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *  GNU Library General Public License for more details.
 *
 *
 *  You should have received a copy of the GNU General Public License
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 */
%{
%{
#include 
#include 
#include 
#include 
#include "sglib.h"
#include "sglib.h"
#include "sc2v_step1.h"
#include "sc2v_step1.h"
  int lineno = 1;
  int lineno = 1;
  int processfound = 0;
  int processfound = 0;
  int switchfound = 0;
  int switchfound = 0;
  int lastswitch=0;
  int lastswitch=0;
  int switchparenthesis[256];
  int switchparenthesis[256];
  int ifdeffound = 0;
  int ifdeffound = 0;
  char *processname, *processname2;
  char *processname, *processname2;
  char *fileregs;
  char *fileregs;
  char *filename;
  char *filename;
  int openedkeys = 0;
  int openedkeys = 0;
  int newline = 0;
  int newline = 0;
  int reg_found = 0;
  int reg_found = 0;
  int sigreg_found = 0;
  int sigreg_found = 0;
  int reglenght = 0;
  int reglenght = 0;
  int writelenght = 0;
  int writelenght = 0;
  int array_size=0;
  int array_size=0;
  int integer_found=0;
  int integer_found=0;
  int regs_end;
  int regs_end;
  int i = 0;                    //for loops counter
  int i = 0;                    //for loops counter
  FILE *file;
  FILE *file;
  FILE *regs_file;
  FILE *regs_file;
  char *regname, *regname2;
  char *regname, *regname2;
  char *lastword;               // Stores last WORD for use it in WRITE
  char *lastword;               // Stores last WORD for use it in WRITE
  char *file_defines;
  char *file_defines;
  FILE *FILE_DEFINES;
  FILE *FILE_DEFINES;
  char *file_writes;
  char *file_writes;
  FILE *FILE_WRITES;            //FILE to store .write to know if it is a wire or reg
  FILE *FILE_WRITES;            //FILE to store .write to know if it is a wire or reg
  int definefound = 0;
  int definefound = 0;
  int defineinvocationfound = 0;
  int defineinvocationfound = 0;
  int opencorchfound = 0;
  int opencorchfound = 0;
  int defineparenthesis = 0;
  int defineparenthesis = 0;
  int openedcase = 0;
  int openedcase = 0;
  int writingvar=0;
  int writingvar=0;
  int default_break_found = 0;
  int default_break_found = 0;
  int default_found;
  int default_found;
  int struct_found=0;
  int struct_found=0;
  int end_struct=0;
  int end_struct=0;
  int ignore_semicolon=0;
  int ignore_semicolon=0;
  char *structname;
  char *structname;
//Directives variables
//Directives variables
  int translate;
  int translate;
  int verilog;
  int verilog;
  int writemethod;
  int writemethod;
  void yyerror (const char *str)
  void yyerror (const char *str)
  {
  {
    fprintf (stderr, "line: %d error: %s\n", lineno, str);
    fprintf (stderr, "line: %d error: %s\n", lineno, str);
  }
  }
  int yywrap ()
  int yywrap ()
  {
  {
    return 1;
    return 1;
  }
  }
  main ()
  main ()
  {
  {
    int i;
    int i;
    defineslist = NULL;
    defineslist = NULL;
    regslist = NULL;
    regslist = NULL;
    structslist = NULL;
    structslist = NULL;
    structsreglist = NULL;
    structsreglist = NULL;
    fprintf (stderr, "\nSystemC to Verilog Translator v0.6");
    fprintf (stderr, "\nSystemC to Verilog Translator v0.6");
    fprintf (stderr,
    fprintf (stderr,
             "\nProvided by URJC(Universidad Rey Juan Carlos)\nhttp://gdhwsw.escet.urjc.es\n\n");
             "\nProvided by URJC(Universidad Rey Juan Carlos)\nhttp://gdhwsw.escet.urjc.es\n\n");
    fprintf (stderr, "Parsing implementation file.......\n\n");
    fprintf (stderr, "Parsing implementation file.......\n\n");
    processname = (char *) malloc (256 * sizeof (char));
    processname = (char *) malloc (256 * sizeof (char));
    processname2 = (char *) malloc (256 * sizeof (char));
    processname2 = (char *) malloc (256 * sizeof (char));
    fileregs = (char *) malloc (256 * sizeof (char));
    fileregs = (char *) malloc (256 * sizeof (char));
    file_defines = (char *) malloc (256 * sizeof (char));
    file_defines = (char *) malloc (256 * sizeof (char));
    strcpy (file_defines, (char *) "file_defines.sc2v");
    strcpy (file_defines, (char *) "file_defines.sc2v");
    FILE_DEFINES = fopen (file_defines, (char *) "w");
    FILE_DEFINES = fopen (file_defines, (char *) "w");
    file_writes = (char *) malloc (256 * sizeof (char));
    file_writes = (char *) malloc (256 * sizeof (char));
    strcpy (file_writes, (char *) "file_writes.sc2v");
    strcpy (file_writes, (char *) "file_writes.sc2v");
    FILE_WRITES = fopen (file_writes, (char *) "w");
    FILE_WRITES = fopen (file_writes, (char *) "w");
    lastword = (char *) malloc (sizeof (char) * 256);
    lastword = (char *) malloc (sizeof (char) * 256);
    structname = (char *) malloc (sizeof (char) * 256);
    structname = (char *) malloc (sizeof (char) * 256);
    for (i = 0; i < 256; i++)
    for (i = 0; i < 256; i++)
      switchparenthesis[i] = 0;
      switchparenthesis[i] = 0;
    translate = 1;
    translate = 1;
    verilog = 0;
    verilog = 0;
    writemethod = 0;
    writemethod = 0;
    FILE *yyin = stdin;
    FILE *yyin = stdin;
    FILE *yyout = stdout;
    FILE *yyout = stdout;
    yyparse ();
    yyparse ();
    fclose (FILE_WRITES);
    fclose (FILE_WRITES);
    fclose (FILE_DEFINES);
    fclose (FILE_DEFINES);
    fprintf (stderr, "\nDone\n\n");
    fprintf (stderr, "\nDone\n\n");
  }
  }
%}
%}
%token NUMBER WORD SC_REG SC_SIGREG BOOL BIGGER LOWER OPENKEY CLOSEKEY WRITE SYMBOL NEWLINE ENUM INCLUDE
%token NUMBER WORD SC_REG SC_SIGREG BOOL BIGGER LOWER OPENKEY CLOSEKEY WRITE SYMBOL NEWLINE ENUM INCLUDE
%token COLON SEMICOLON RANGE OPENPAR CLOSEPAR TWODOUBLEPOINTS OPENCORCH CLOSECORCH SWITCH CASE DEFAULT BREAK
%token COLON SEMICOLON RANGE OPENPAR CLOSEPAR TWODOUBLEPOINTS OPENCORCH CLOSECORCH SWITCH CASE DEFAULT BREAK
%token HEXA DEFINE READ TRANSLATEOFF TRANSLATEON VERILOGBEGIN VERILOGEND TAB DOLLAR MINEQ
%token HEXA DEFINE READ TRANSLATEOFF TRANSLATEON VERILOGBEGIN VERILOGEND TAB DOLLAR MINEQ
%token VOID TTRUE TFALSE ENDFUNC INC DEC INTEGER EQUALS
%token VOID TTRUE TFALSE ENDFUNC INC DEC INTEGER EQUALS
%token PIFDEF PIFNDEF PENDDEF PELSE COMMENT STRUCT DOT
%token PIFDEF PIFNDEF PENDDEF PELSE COMMENT STRUCT DOT
%% commands:    /* empty */
%% commands:    /* empty */
|commands command;
|commands command;
command:
command:
  struct_dec
  struct_dec
  |
  |
  endfunc
  endfunc
  |
  |
  voidword
  voidword
  |
  |
  include
  include
  |
  |
  dollar
  dollar
  |
  |
  tab
  tab
  |
  |
  read
  read
  |
  |
  sc_reg
  sc_reg
  |
  |
  sc_sigreg
  sc_sigreg
  |
  |
  integer
  integer
  |
  |
  number
  number
  |
  |
  bool
  bool
  |
  |
  word
  word
  |
  |
  symbol
  symbol
  |
  |
  write
  write
  |
  |
  newline
  newline
  |
  |
  openkey
  openkey
  |
  |
  closekey
  closekey
  |
  |
  colon
  colon
  |
  |
  semicolon
  semicolon
  |
  |
  range
  range
  |
  |
  openpar
  openpar
  |
  |
  closepar
  closepar
  |
  |
  void
  void
  |
  |
  opencorch
  opencorch
  |
  |
  closecorch
  closecorch
  |
  |
  bigger
  bigger
  |
  |
  lower
  lower
  |
  |
  switch
  switch
  |
  |
  case_only
  case_only
  |
  |
  case_number
  case_number
  |
  |
  case_hexnumber
  case_hexnumber
  |
  |
  case_hexword
  case_hexword
  |
  |
  case_hexnumberword
  case_hexnumberword
  |
  |
  case_word
  case_word
  |
  |
  case_default
  case_default
  |
  |
  break
  break
  |
  |
  hexa
  hexa
  |
  |
  definemacro
  definemacro
  |
  |
  defineword
  defineword
  |
  |
 
  definewordsimple
 
  |
  definenumber
  definenumber
  |
  |
  translateoff
  translateoff
  |
  |
  translateon
  translateon
  |
  |
  verilogbegin
  verilogbegin
  |
  |
  verilogend
  verilogend
  |
  |
  ifdef
  ifdef
  |
  |
  ifndef
  ifndef
  |
  |
  endif
  endif
  |
  |
  pelse
  pelse
  |
  |
  ttrue
  ttrue
  |
  |
  tfalse
  tfalse
  |
  |
  increment
  increment
  |
  |
  decrement
  decrement
  |
  |
  equal
  equal
  |
  |
  minorequal
  minorequal
  |
  |
  comment
  comment
  |
  |
  struct_access
  struct_access
  ;
  ;
struct_access:
struct_access:
WORD DOT WORD
WORD DOT WORD
{
{
/*Struct access
/*Struct access
 Check if it is a var acess or a reg*/
 Check if it is a var acess or a reg*/
 if (newline){
 if (newline){
   for (i = 0; i < openedkeys; i++)
   for (i = 0; i < openedkeys; i++)
      fprintf (file, "   ");
      fprintf (file, "   ");
 }
 }
 strcpy(structname,(char *)$3);
 strcpy(structname,(char *)$3);
 strcat(structname,(char *)$1);
 strcat(structname,(char *)$1);
 regname2 = IsReg (regslist, structname);
 regname2 = IsReg (regslist, structname);
 if (regname2 == NULL){
 if (regname2 == NULL){
  fprintf (file, "%s ", structname);
  fprintf (file, "%s ", structname);
 }else{
 }else{
  fprintf (file, "%s", regname2);
  fprintf (file, "%s", regname2);
}
}
  newline = 0;
  newline = 0;
 /*printf("Access to struct %s.%s\n",(char *)$1,(char *)$3);*/
 /*printf("Access to struct %s.%s\n",(char *)$1,(char *)$3);*/
}
}
minorequal:
minorequal:
MINEQ
MINEQ
{
{
 //This rule is needed because <= in the step two could be confused with a non-blocking assignment
 //This rule is needed because <= in the step two could be confused with a non-blocking assignment
 defineparenthesis = 0;
 defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          fprintf (file, "<1+");
          fprintf (file, "<1+");
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "<=");
    fprintf (file, "<=");
};
};
endfunc:
endfunc:
ENDFUNC
ENDFUNC
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          for (i = 0; i < openedkeys; i++)
          for (i = 0; i < openedkeys; i++)
            fprintf (file, "   ");
            fprintf (file, "   ");
          fprintf (file, "%s = ", processname);
          fprintf (file, "%s = ", processname);
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "return ");
    fprintf (file, "return ");
};
};
voidword:
voidword:
VOID
VOID
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (verilog == 1)
  if (verilog == 1)
    fprintf (file, " void");
    fprintf (file, " void");
};
};
include:
include:
INCLUDE
INCLUDE
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (verilog == 1)
  if (verilog == 1)
    fprintf (file, " #include");
    fprintf (file, " #include");
};
};
dollar:
dollar:
DOLLAR
DOLLAR
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (verilog == 1)
  if (verilog == 1)
    fprintf (file, " $");
    fprintf (file, " $");
};
};
tab:
tab:
TAB
TAB
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (verilog == 1)
  if (verilog == 1)
    fprintf (file, " \t");
    fprintf (file, " \t");
};
};
read:
read:
READ OPENPAR CLOSEPAR
READ OPENPAR CLOSEPAR
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (verilog == 1)
  if (verilog == 1)
    fprintf (file, ".read()");
    fprintf (file, ".read()");
}
}
 
 
 
definewordsimple:
 
DEFINE WORD
 
{
 
 
 
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
 
      if (processfound)
 
        {
 
          fprintf (file, "`define %s\n", (char *) $2);
 
        }
 
      else
 
        {
 
          fprintf (FILE_DEFINES, "`define %s\n", (char *) $2);
 
        }
 
    }
 
  else if (verilog == 1)
 
    fprintf (file, "#define %s\n", (char *) $2);
 
 
 
};
 
 
defineword:
defineword:
DEFINE WORD WORD
DEFINE WORD WORD
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          fprintf (file, "`define %s %s\n", (char *) $2, (char *) $3);
          fprintf (file, "`define %s %s\n", (char *) $2, (char *) $3);
          defineslist = InsertDefine (defineslist, (char *) $2);
          defineslist = InsertDefine (defineslist, (char *) $2);
        }
        }
      else
      else
        {
        {
          fprintf (FILE_DEFINES, "`define %s %s\n", (char *) $2, (char *) $3);
          fprintf (FILE_DEFINES, "`define %s %s\n", (char *) $2, (char *) $3);
          defineslist = InsertDefine (defineslist, (char *) $2);
          defineslist = InsertDefine (defineslist, (char *) $2);
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "#define %s %s\n", (char *) $2, (char *) $3);
    fprintf (file, "#define %s %s\n", (char *) $2, (char *) $3);
};
};
definenumber:
definenumber:
DEFINE WORD NUMBER
DEFINE WORD NUMBER
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          fprintf (file, "`define %s %d\n", (char *) $2, (int) $3);
          fprintf (file, "`define %s %d\n", (char *) $2, (int) $3);
          defineslist = InsertDefine (defineslist, (char *) $2);
          defineslist = InsertDefine (defineslist, (char *) $2);
        }
        }
      else
      else
        {
        {
          fprintf (FILE_DEFINES, "`define %s %d\n", (char *) $2, (int) $3);
          fprintf (FILE_DEFINES, "`define %s %d\n", (char *) $2, (int) $3);
          defineslist = InsertDefine (defineslist, (char *) $2);
          defineslist = InsertDefine (defineslist, (char *) $2);
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "#define %s %d\n", (char *) $2, (int) $3);
    fprintf (file, "#define %s %d\n", (char *) $2, (int) $3);
};
};
definemacro:
definemacro:
DEFINE WORD OPENPAR CLOSEPAR
DEFINE WORD OPENPAR CLOSEPAR
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  //Macro found
  //Macro found
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      defineslist = InsertDefine (defineslist, (char *) $2);
      defineslist = InsertDefine (defineslist, (char *) $2);
      definefound = 1;
      definefound = 1;
      if (processfound)
      if (processfound)
        fprintf (file, "`define %s ", (char *) $2);
        fprintf (file, "`define %s ", (char *) $2);
      else
      else
        fprintf (FILE_DEFINES, "`define %s ", (char *) $2);
        fprintf (FILE_DEFINES, "`define %s ", (char *) $2);
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "#define %s ()", (char *) $2);
    fprintf (file, "#define %s ()", (char *) $2);
}
}
void:
void:
WORD TWODOUBLEPOINTS WORD OPENPAR
WORD TWODOUBLEPOINTS WORD OPENPAR
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      strcpy (processname, (char *) $4);
      strcpy (processname, (char *) $4);
      strcpy (processname2, (char *) $4);
      strcpy (processname2, (char *) $4);
      strcat (processname2, (char *) ".sc2v");
      strcat (processname2, (char *) ".sc2v");
      strcpy (fileregs, (char *) $4);
      strcpy (fileregs, (char *) $4);
      strcat (fileregs, (char *) "_regs.sc2v");
      strcat (fileregs, (char *) "_regs.sc2v");
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, " %s::%s()", (char *) $1, (char *) $3);
    fprintf (file, " %s::%s()", (char *) $1, (char *) $3);
}
}
sc_reg:
sc_reg:
SC_REG LOWER NUMBER BIGGER
SC_REG LOWER NUMBER BIGGER
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          writelenght=1;
          writelenght=1;
          reglenght = $3;
          reglenght = $3;
          reg_found = 1;
          reg_found = 1;
        }
        }
    }
    }
};
};
sc_sigreg:
sc_sigreg:
SC_SIGREG LOWER NUMBER BIGGER
SC_SIGREG LOWER NUMBER BIGGER
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          writelenght=1;
          writelenght=1;
          reglenght = $3;
          reglenght = $3;
          sigreg_found = 1;
          sigreg_found = 1;
        }
        }
    }
    }
};
};
integer:
integer:
INTEGER
INTEGER
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          fprintf (regs_file, "integer ");
          fprintf (regs_file, "integer ");
          integer_found = 1;
          integer_found = 1;
        }
        }
    }
    }
};
};
bool:
bool:
BOOL
BOOL
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          writelenght=1;
          writelenght=1;
          reglenght=0;
          reglenght=0;
          reg_found = 1;
          reg_found = 1;
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "bool");
    fprintf (file, "bool");
}
}
;
;
range:
range:
RANGE OPENPAR NUMBER COLON NUMBER CLOSEPAR
RANGE OPENPAR NUMBER COLON NUMBER CLOSEPAR
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        fprintf (file, "[%d:%d]", $3, $5);
        fprintf (file, "[%d:%d]", $3, $5);
      else if (definefound)
      else if (definefound)
        fprintf (FILE_DEFINES, "[%d:%d]", $3, $5);
        fprintf (FILE_DEFINES, "[%d:%d]", $3, $5);
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, ".range(%d,%d)", $3, $5);
    fprintf (file, ".range(%d,%d)", $3, $5);
}
}
;
;
number:
number:
NUMBER
NUMBER
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
       if(opencorchfound && (reg_found || sigreg_found))
       if(opencorchfound && (reg_found || sigreg_found))
        fprintf (regs_file, "%d:0",$1-1);
        fprintf (regs_file, "%d:0",$1-1);
       else
       else
        fprintf (file, "%d", $1);
        fprintf (file, "%d", $1);
      else if (definefound)
      else if (definefound)
        fprintf (FILE_DEFINES, "%d", $1);
        fprintf (FILE_DEFINES, "%d", $1);
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "%d", $1);
    fprintf (file, "%d", $1);
};
};
increment:
increment:
WORD INC
WORD INC
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
       if (processfound){
       if (processfound){
        regname2 = IsReg (regslist, (char *) $1);
        regname2 = IsReg (regslist, (char *) $1);
        if (regname2 == NULL){
        if (regname2 == NULL){
            fprintf (file, "%s=%s+1", (char *) $1,(char *)$1);
            fprintf (file, "%s=%s+1", (char *) $1,(char *)$1);
        }else
        }else
            fprintf (file, "%s=%s+1", regname2,regname2);
            fprintf (file, "%s=%s+1", regname2,regname2);
       }
       }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "%s++ ", (char *) $1);
    fprintf (file, "%s++ ", (char *) $1);
};
};
decrement:
decrement:
WORD DEC
WORD DEC
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
      if (processfound){
      if (processfound){
        regname2 = IsReg (regslist, (char *) $1);
        regname2 = IsReg (regslist, (char *) $1);
        if (regname2 == NULL){
        if (regname2 == NULL){
            fprintf (file, "%s=%s+1", (char *) $1,(char *)$1);
            fprintf (file, "%s=%s+1", (char *) $1,(char *)$1);
        }else
        }else
            fprintf (file, "%s=%s+1", regname2,regname2);
            fprintf (file, "%s=%s+1", regname2,regname2);
      }
      }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "%s-- ", (char *) $1);
    fprintf (file, "%s-- ", (char *) $1);
};
};
word:
word:
WORD
WORD
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
          if(opencorchfound==0){
          if(opencorchfound==0){
                strcpy (lastword, (char *) $1);
                strcpy (lastword, (char *) $1);
          }
          }
      if (processfound)
      if (processfound)
        {
        {
          if(lastswitch){
          if(lastswitch){
            openedcase=0;
            openedcase=0;
          }else if (openedcase){
          }else if (openedcase){
              fprintf (file, " :\n");
              fprintf (file, " :\n");
              for (i = 0; i < openedkeys; i++)
              for (i = 0; i < openedkeys; i++)
                fprintf (file, "   ");
                fprintf (file, "   ");
              fprintf(file,"begin\n");
              fprintf(file,"begin\n");
              openedcase=0;
              openedcase=0;
          }
          }
          if (end_struct){
          if (end_struct){
             end_struct=0;
             end_struct=0;
             struct_found=0;
             struct_found=0;
             ignore_semicolon=1;
             ignore_semicolon=1;
             structslist=InsertStruct(structslist,(char *)$1,structsreglist);
             structslist=InsertStruct(structslist,(char *)$1,structsreglist);
             //ShowStructs(structslist);
             //ShowStructs(structslist);
             /*Now we should convert all the elements of the struct into regs*/
             /*Now we should convert all the elements of the struct into regs*/
             StructRegNode *srll;
             StructRegNode *srll;
             SGLIB_LIST_MAP_ON_ELEMENTS (StructRegNode,structsreglist, srll,next,
             SGLIB_LIST_MAP_ON_ELEMENTS (StructRegNode,structsreglist, srll,next,
             {
             {
               if(srll->length==0)
               if(srll->length==0)
                 fprintf (regs_file, "reg ");
                 fprintf (regs_file, "reg ");
               else
               else
                 fprintf (regs_file, "reg[%d:0] ", (-1 +srll->length));
                 fprintf (regs_file, "reg[%d:0] ", (-1 +srll->length));
               regname =(char *) malloc (sizeof (char) * (strlen (srll->name) + 1));
               regname =(char *) malloc (sizeof (char) * (strlen (srll->name) + 1));
               regname2 = (char *) malloc (sizeof (char) * (strlen (srll->name) + strlen (processname)+strlen((char *)$1)) + 1);
               regname2 = (char *) malloc (sizeof (char) * (strlen (srll->name) + strlen (processname)+strlen((char *)$1)) + 1);
               strcpy (regname, srll->name);
               strcpy (regname, srll->name);
               strcpy (regname2, srll->name);
               strcpy (regname2, srll->name);
               strcat (regname, (char *)$1);
               strcat (regname, (char *)$1);
               strcat (regname2, (char *)$1);
               strcat (regname2, (char *)$1);
               strcat (regname2, processname);
               strcat (regname2, processname);
               fprintf (regs_file, "%s;\n", regname2); /*By the moment no arrays inside the struct supported*/
               fprintf (regs_file, "%s;\n", regname2); /*By the moment no arrays inside the struct supported*/
               regslist = InsertReg (regslist, regname, regname2);
               regslist = InsertReg (regslist, regname, regname2);
               free (regname);
               free (regname);
               free (regname2);
               free (regname2);
               structsreglist=NULL;
               structsreglist=NULL;
               reg_found=0; /*To avoid arrays in sructs the interpretation finish here*/
               reg_found=0; /*To avoid arrays in sructs the interpretation finish here*/
          sigreg_found = 0;
          sigreg_found = 0;
             );}
             );}
          }else if(struct_found && (reg_found || sigreg_found)){
          }else if(struct_found && (reg_found || sigreg_found)){
              structsreglist=InsertStructReg(structsreglist,(char *)$1,reglenght);
              structsreglist=InsertStructReg(structsreglist,(char *)$1,reglenght);
          }else if (reg_found || sigreg_found){
          }else if (reg_found || sigreg_found){
              if(writelenght){
              if(writelenght){
               writelenght=0;
               writelenght=0;
               if(reglenght==0)
               if(reglenght==0)
            if(sigreg_found)
            if(sigreg_found)
                    fprintf (regs_file, "reg signed");
                    fprintf (regs_file, "reg signed");
            else
            else
               fprintf (regs_file, "reg ");
               fprintf (regs_file, "reg ");
               else
               else
            if(sigreg_found)
            if(sigreg_found)
               fprintf (regs_file, "reg signed [%d:0] ", (-1 +reglenght));
               fprintf (regs_file, "reg signed [%d:0] ", (-1 +reglenght));
            else
            else
                fprintf (regs_file, "reg [%d:0] ", (-1 +reglenght));
                fprintf (regs_file, "reg [%d:0] ", (-1 +reglenght));
              }
              }
              regname = (char *) malloc (sizeof (char) * (strlen ((char *) $1) + 1));
              regname = (char *) malloc (sizeof (char) * (strlen ((char *) $1) + 1));
              regname2 = (char *) malloc (sizeof (char) * (strlen ((char *) $1) + strlen (processname)) + 1);
              regname2 = (char *) malloc (sizeof (char) * (strlen ((char *) $1) + strlen (processname)) + 1);
              strcpy (regname, (char *) $1);
              strcpy (regname, (char *) $1);
              strcpy (regname2, (char *) $1);
              strcpy (regname2, (char *) $1);
              strcat (regname2, processname);
              strcat (regname2, processname);
              fprintf (regs_file, "%s", regname2);
              fprintf (regs_file, "%s", regname2);
              regslist = InsertReg (regslist, regname, regname2);
              regslist = InsertReg (regslist, regname, regname2);
              free (regname);
              free (regname);
              free (regname2);
              free (regname2);
          }else if(integer_found){
          }else if(integer_found){
              regname = (char *) malloc (sizeof (char) * (strlen ((char *) $1) + 1));
              regname = (char *) malloc (sizeof (char) * (strlen ((char *) $1) + 1));
              regname2 = (char *) malloc (sizeof (char) * (strlen ((char *) $1) + strlen (processname)) + 1);
              regname2 = (char *) malloc (sizeof (char) * (strlen ((char *) $1) + strlen (processname)) + 1);
              strcpy (regname, (char *) $1);
              strcpy (regname, (char *) $1);
              strcpy (regname2, (char *) $1);
              strcpy (regname2, (char *) $1);
              strcat (regname2, processname);
              strcat (regname2, processname);
              fprintf (regs_file, "%s;\n", regname2);
              fprintf (regs_file, "%s;\n", regname2);
              regslist = InsertReg (regslist, regname, regname2);
              regslist = InsertReg (regslist, regname, regname2);
              //After adding to list print it
              //After adding to list print it
              fprintf (file, "%s ", regname2);
              fprintf (file, "%s ", regname2);
              integer_found=0;
              integer_found=0;
              free (regname);
              free (regname);
              free (regname2);
              free (regname2);
          }else{
          }else{
              if (newline){
              if (newline){
                for (i = 0; i < openedkeys; i++)
                for (i = 0; i < openedkeys; i++)
                  fprintf (file, "   ");
                  fprintf (file, "   ");
              }
              }
              regname2 = IsReg (regslist, (char *) $1);
              regname2 = IsReg (regslist, (char *) $1);
              if (regname2 == NULL){
              if (regname2 == NULL){
                if (IsDefine (defineslist, (char *) $1)){
                if (IsDefine (defineslist, (char *) $1)){
                   if (ifdeffound == 0){
                   if (ifdeffound == 0){
                      fprintf (file, "`%s", (char *) $1);
                      fprintf (file, "`%s", (char *) $1);
                      defineinvocationfound = 1;
                      defineinvocationfound = 1;
                   }else{
                   }else{
                      fprintf (file, "%s", (char *) $1);
                      fprintf (file, "%s", (char *) $1);
                      ifdeffound = 0;
                      ifdeffound = 0;
                   }
                   }
                }else{
                }else{
                   fprintf (file, "%s ", (char *) $1);
                   fprintf (file, "%s ", (char *) $1);
                }
                }
             }else
             }else
                fprintf (file, "%s", regname2);
                fprintf (file, "%s", regname2);
             newline = 0;
             newline = 0;
          }
          }
        }else if (definefound)
        }else if (definefound)
        {
        {
          if (IsDefine (defineslist, (char *) $1))
          if (IsDefine (defineslist, (char *) $1))
            {
            {
              fprintf (FILE_DEFINES, "`%s", (char *) $1);
              fprintf (FILE_DEFINES, "`%s", (char *) $1);
            }
            }
          else
          else
            {
            {
              fprintf (FILE_DEFINES, "%s ", (char *) $1);
              fprintf (FILE_DEFINES, "%s ", (char *) $1);
            }
            }
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "%s ", (char *) $1);
    fprintf (file, "%s ", (char *) $1);
  lastswitch=0;
  lastswitch=0;
};
};
symbol:
symbol:
SYMBOL
SYMBOL
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          if (reg_found || sigreg_found)
          if (reg_found || sigreg_found)
            fprintf (regs_file, "%s", (char *) $1);
            fprintf (regs_file, "%s", (char *) $1);
          else
          else
            fprintf (file, "%s", (char *) $1);
            fprintf (file, "%s", (char *) $1);
        }
        }
      else if (definefound)
      else if (definefound)
        {
        {
          fprintf (FILE_DEFINES, "%s", (char *) $1);
          fprintf (FILE_DEFINES, "%s", (char *) $1);
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "%s", (char *) $1);
    fprintf (file, "%s", (char *) $1);
};
};
equal:
equal:
EQUALS
EQUALS
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  reg_found=0;
  reg_found=0;
  sigreg_found=0;
  sigreg_found=0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
  {
  {
   if (processfound)
   if (processfound)
        fprintf (file, "=");
        fprintf (file, "=");
        writingvar=1;
        writingvar=1;
  }
  }
  else if (definefound)
  else if (definefound)
    fprintf (FILE_DEFINES, "=");
    fprintf (FILE_DEFINES, "=");
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "=");
    fprintf (file, "=");
}
}
write:
write:
WRITE
WRITE
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      writemethod = 1;
      writemethod = 1;
      if (processfound)
      if (processfound)
        {
        {
          fprintf (file, " <= ");
          fprintf (file, " <= ");
          fprintf (FILE_WRITES, "%s\n", lastword);
          fprintf (FILE_WRITES, "%s\n", lastword);
        }
        }
      else if (definefound)
      else if (definefound)
        {
        {
          fprintf (FILE_DEFINES, " <= ");
          fprintf (FILE_DEFINES, " <= ");
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    {
    {
      fprintf (file, ".write");
      fprintf (file, ".write");
    }
    }
};
};
newline:
newline:
NEWLINE
NEWLINE
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  writingvar=0;
  writingvar=0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound & !reg_found & !openedcase & !sigreg_found)
      if (processfound & !reg_found & !openedcase & !sigreg_found)
        {
        {
          fprintf (file, "\n");
          fprintf (file, "\n");
          newline = 1;
          newline = 1;
        }
        }
      else if (definefound)
      else if (definefound)
        {
        {
          fprintf (FILE_DEFINES, "\n");
          fprintf (FILE_DEFINES, "\n");
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "\n");
    fprintf (file, "\n");
};
};
colon:
colon:
COLON
COLON
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          if (reg_found || sigreg_found)
          if (reg_found || sigreg_found)
            {
            {
              fprintf (regs_file, ",");
              fprintf (regs_file, ",");
            }
            }
          else
          else
            fprintf (file, ",");
            fprintf (file, ",");
        }
        }
      else if (definefound)
      else if (definefound)
        {
        {
          fprintf (FILE_DEFINES, ",");
          fprintf (FILE_DEFINES, ",");
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, ",");
    fprintf (file, ",");
};
};
semicolon:
semicolon:
SEMICOLON
SEMICOLON
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound && !struct_found && !ignore_semicolon)
      if (processfound && !struct_found && !ignore_semicolon)
        {
        {
          if (reg_found || sigreg_found)
          if (reg_found || sigreg_found)
            {
            {
              fprintf (regs_file, ";\n");
              fprintf (regs_file, ";\n");
              reg_found = 0;
              reg_found = 0;
         sigreg_found = 0;
         sigreg_found = 0;
            }
            }
          else
          else
            {
            {
            if (defineinvocationfound == 0 || writingvar)
            if (defineinvocationfound == 0 || writingvar)
                  fprintf (file, ";");
                  fprintf (file, ";");
            }
            }
        }
        }
      else if (definefound)
      else if (definefound)
        {
        {
          fprintf (FILE_DEFINES, ";");
          fprintf (FILE_DEFINES, ";");
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, ";");
    fprintf (file, ";");
  writingvar=0;
  writingvar=0;
  defineinvocationfound = 0;
  defineinvocationfound = 0;
  ignore_semicolon=0;
  ignore_semicolon=0;
};
};
openpar:
openpar:
OPENPAR
OPENPAR
{
{
  defineparenthesis = 1;
  defineparenthesis = 1;
  if (translate == 1 && verilog == 0 && defineinvocationfound == 0)
  if (translate == 1 && verilog == 0 && defineinvocationfound == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          fprintf (file, "(");
          fprintf (file, "(");
        }
        }
      else if (definefound)
      else if (definefound)
        {
        {
          fprintf (FILE_DEFINES, "(");
          fprintf (FILE_DEFINES, "(");
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    {
    {
      fprintf (file, "(");
      fprintf (file, "(");
    }
    }
  //If par after a sc_reg declaration the declaration is a type cast
  //If par after a sc_reg declaration the declaration is a type cast
  reg_found=0;
  reg_found=0;
  sigreg_found=0;
  sigreg_found=0;
}
}
closepar:
closepar:
CLOSEPAR
CLOSEPAR
{
{
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          if (defineparenthesis == 0)
          if (defineparenthesis == 0)
            {
            {
              fprintf (file, ")");
              fprintf (file, ")");
              defineinvocationfound = 0;
              defineinvocationfound = 0;
            }
            }
        }
        }
      else if (definefound)
      else if (definefound)
        {
        {
          fprintf (FILE_DEFINES, ")");
          fprintf (FILE_DEFINES, ")");
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, ")");
    fprintf (file, ")");
};
};
opencorch:
opencorch:
OPENCORCH
OPENCORCH
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          opencorchfound = 1;
          opencorchfound = 1;
          if (reg_found || sigreg_found)
          if (reg_found || sigreg_found)
            {
            {
              fprintf (regs_file, "[");
              fprintf (regs_file, "[");
            }
            }
          else
          else
            fprintf (file, "[");
            fprintf (file, "[");
        }
        }
      else if (definefound)
      else if (definefound)
        {
        {
          fprintf (FILE_DEFINES, "[");
          fprintf (FILE_DEFINES, "[");
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "[");
    fprintf (file, "[");
};
};
closecorch:
closecorch:
CLOSECORCH
CLOSECORCH
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
          {
          {
          opencorchfound = 0;
          opencorchfound = 0;
          if (reg_found || sigreg_found)
          if (reg_found || sigreg_found)
            {
            {
              fprintf (regs_file, "]");
              fprintf (regs_file, "]");
            }
            }
          else
          else
            fprintf (file, "]");
            fprintf (file, "]");
        }
        }
      else if (definefound)
      else if (definefound)
        {
        {
          fprintf (FILE_DEFINES, "]");
          fprintf (FILE_DEFINES, "]");
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "]");
    fprintf (file, "]");
};
};
openkey:
openkey:
OPENKEY
OPENKEY
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      openedkeys++;
      openedkeys++;
      if (!definefound)
      if (!definefound)
        {
        {
          if (openedkeys == 1)
          if (openedkeys == 1)
            {
            {
              printf ("Found process %s\n", processname);
              printf ("Found process %s\n", processname);
              file = fopen (processname2, (char *) "w");
              file = fopen (processname2, (char *) "w");
              regs_file = fopen (fileregs, (char *) "w");
              regs_file = fopen (fileregs, (char *) "w");
              processfound = 1;
              processfound = 1;
            }
            }
          if (processfound)
          if (processfound)
            if (openedkeys != switchparenthesis[switchfound])
            if (openedkeys != switchparenthesis[switchfound])
              {
              {
                fprintf (file, "\n");
                fprintf (file, "\n");
                for (i = 0; i < openedkeys; i++)
                for (i = 0; i < openedkeys; i++)
                  fprintf (file, "   ");
                  fprintf (file, "   ");
                fprintf (file, "begin\n");
                fprintf (file, "begin\n");
                newline = 1;
                newline = 1;
              }
              }
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "{");
    fprintf (file, "{");
};
};
closekey:
closekey:
CLOSEKEY
CLOSEKEY
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if(struct_found){
  if(struct_found){
    end_struct=1;
    end_struct=1;
  }else if (translate == 1 && verilog == 0){
  }else if (translate == 1 && verilog == 0){
      if (processfound && !definefound){
      if (processfound && !definefound){
          if (openedkeys == switchparenthesis[switchfound] && switchfound > 0){
          if (openedkeys == switchparenthesis[switchfound] && switchfound > 0){
              fprintf (file, "\n");
              fprintf (file, "\n");
              if (default_found & !default_break_found){
              if (default_found & !default_break_found){
                  for (i = 0; i < openedkeys - 1; i++)
                  for (i = 0; i < openedkeys - 1; i++)
                    fprintf (file, "   ");
                    fprintf (file, "   ");
                  fprintf (file, "end\n");
                  fprintf (file, "end\n");
                  default_found = 0;
                  default_found = 0;
              }
              }
              for (i = 0; i < openedkeys - 1; i++)
              for (i = 0; i < openedkeys - 1; i++)
                fprintf (file, "   ");
                fprintf (file, "   ");
              fprintf (file, "endcase\n");
              fprintf (file, "endcase\n");
              newline = 1;
              newline = 1;
              switchparenthesis[switchfound] = 0;
              switchparenthesis[switchfound] = 0;
              switchfound--;
              switchfound--;
          }else{
          }else{
              fprintf (file, "\n");
              fprintf (file, "\n");
              for (i = 0; i < openedkeys; i++)
              for (i = 0; i < openedkeys; i++)
                fprintf (file, "   ");
                fprintf (file, "   ");
              fprintf (file, "end\n");
              fprintf (file, "end\n");
              newline = 1;
              newline = 1;
          }
          }
      }
      }
      openedkeys--;
      openedkeys--;
      if (definefound)
      if (definefound)
        {
        {
          definefound = 0;
          definefound = 0;
          if (processfound)
          if (processfound)
            fprintf (file, "\n//Dummy Comment\n");
            fprintf (file, "\n//Dummy Comment\n");
          else
          else
            fprintf (FILE_DEFINES, "\n//Dummy Comment\n");
            fprintf (FILE_DEFINES, "\n//Dummy Comment\n");
        }
        }
      else if (openedkeys == 0)
      else if (openedkeys == 0)
        {
        {
          fclose (file);
          fclose (file);
          fclose (regs_file);
          fclose (regs_file);
          processfound = 0;
          processfound = 0;
          /*Clear process struct list*/
          /*Clear process struct list*/
          structslist=NULL;
          structslist=NULL;
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "}");
    fprintf (file, "}");
};
};
bigger:
bigger:
BIGGER
BIGGER
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          fprintf (file, ">");
          fprintf (file, ">");
        }
        }
      else if (definefound)
      else if (definefound)
        {
        {
          fprintf (FILE_DEFINES, ">");
          fprintf (FILE_DEFINES, ">");
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, ">");
    fprintf (file, ">");
};
};
lower:
lower:
LOWER
LOWER
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          fprintf (file, "<");
          fprintf (file, "<");
        }
        }
      else if (definefound)
      else if (definefound)
        {
        {
          fprintf (FILE_DEFINES, "<");
          fprintf (FILE_DEFINES, "<");
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "<");
    fprintf (file, "<");
};
};
switch:
switch:
SWITCH
SWITCH
  {
  {
    defineparenthesis = 0;
    defineparenthesis = 0;
    lastswitch=1;
    lastswitch=1;
    if (translate == 1 && verilog == 0)
    if (translate == 1 && verilog == 0)
      {
      {
        if (processfound && !openedcase)
        if (processfound && !openedcase)
          {
          {
            fprintf (file, "\n");
            fprintf (file, "\n");
            for (i = 0; i < openedkeys; i++)
            for (i = 0; i < openedkeys; i++)
              fprintf (file, "   ");
              fprintf (file, "   ");
            fprintf (file, "case");
            fprintf (file, "case");
            switchfound++;
            switchfound++;
            switchparenthesis[switchfound] = openedkeys + 1;
            switchparenthesis[switchfound] = openedkeys + 1;
          }else if (processfound)
          }else if (processfound)
          {
          {
            fprintf (file, ":\n");
            fprintf (file, ":\n");
            for (i = 0; i < openedkeys; i++)
            for (i = 0; i < openedkeys; i++)
              fprintf (file, "   ");
              fprintf (file, "   ");
            fprintf(file,"begin\n");
            fprintf(file,"begin\n");
            for (i = 0; i < openedkeys; i++)
            for (i = 0; i < openedkeys; i++)
              fprintf (file, "   ");
              fprintf (file, "   ");
            fprintf (file, "case");
            fprintf (file, "case");
            switchfound++;
            switchfound++;
            switchparenthesis[switchfound] = openedkeys + 1;
            switchparenthesis[switchfound] = openedkeys + 1;
          }
          }
      }
      }
    else if (verilog == 1)
    else if (verilog == 1)
      fprintf (file, "switch");
      fprintf (file, "switch");
  };
  };
case_number:
case_number:
CASE NUMBER SYMBOL
CASE NUMBER SYMBOL
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
         if (!openedcase)
         if (!openedcase)
          for (i = 0; i < openedkeys; i++)
          for (i = 0; i < openedkeys; i++)
            fprintf (file, "   ");
            fprintf (file, "   ");
          if (openedcase)
          if (openedcase)
            fprintf (file, ", %d", $2);
            fprintf (file, ", %d", $2);
          else
          else
            fprintf (file, "%d", $2);
            fprintf (file, "%d", $2);
          newline = 1;
          newline = 1;
          openedcase = 1;
          openedcase = 1;
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "case %d %s", $2, (char *) $3);
    fprintf (file, "case %d %s", $2, (char *) $3);
};
};
case_hexnumber:
case_hexnumber:
CASE HEXA NUMBER SYMBOL
CASE HEXA NUMBER SYMBOL
{
{
  //Is a dec number
  //Is a dec number
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
         if (!openedcase)
         if (!openedcase)
          for (i = 0; i < openedkeys; i++)
          for (i = 0; i < openedkeys; i++)
            fprintf (file, "   ");
            fprintf (file, "   ");
          if (openedcase)
          if (openedcase)
            fprintf (file, ", 'h%d", $3);
            fprintf (file, ", 'h%d", $3);
          else
          else
            fprintf (file, "'h%d", $3);
            fprintf (file, "'h%d", $3);
          newline = 1;
          newline = 1;
          openedcase = 1;
          openedcase = 1;
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "case %d %s", $3, (char *) $4);
    fprintf (file, "case %d %s", $3, (char *) $4);
};
};
case_hexword:
case_hexword:
CASE HEXA WORD SYMBOL
CASE HEXA WORD SYMBOL
{
{
  //Begin with a-F
  //Begin with a-F
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
         if (!openedcase)
         if (!openedcase)
          for (i = 0; i < openedkeys; i++)
          for (i = 0; i < openedkeys; i++)
            fprintf (file, "   ");
            fprintf (file, "   ");
          if (openedcase)
          if (openedcase)
            fprintf (file, ", 'h%s", (char *)$3);
            fprintf (file, ", 'h%s", (char *)$3);
          else
          else
            fprintf (file, "'h%s", (char *)$3);
            fprintf (file, "'h%s", (char *)$3);
          newline = 1;
          newline = 1;
          openedcase = 1;
          openedcase = 1;
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "case 0x%s %s", (char *)$3, (char *) $4);
    fprintf (file, "case 0x%s %s", (char *)$3, (char *) $4);
};
};
case_hexnumberword:
case_hexnumberword:
CASE HEXA NUMBER WORD SYMBOL
CASE HEXA NUMBER WORD SYMBOL
{
{
  //Hex number beginning with dec number
  //Hex number beginning with dec number
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
         if (!openedcase)
         if (!openedcase)
          for (i = 0; i < openedkeys; i++)
          for (i = 0; i < openedkeys; i++)
            fprintf (file, "   ");
            fprintf (file, "   ");
          if (openedcase)
          if (openedcase)
            fprintf (file, ", 'h%d%s", $3,(char *)$4);
            fprintf (file, ", 'h%d%s", $3,(char *)$4);
          else
          else
            fprintf (file, "'h%d%s", $3,(char *)$4);
            fprintf (file, "'h%d%s", $3,(char *)$4);
          newline = 1;
          newline = 1;
          openedcase = 1;
          openedcase = 1;
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "case %d%s %s", $3, (char *) $4, (char *)$5);
    fprintf (file, "case %d%s %s", $3, (char *) $4, (char *)$5);
};
};
case_word:
case_word:
CASE WORD SYMBOL
CASE WORD SYMBOL
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
         if (!openedcase)
         if (!openedcase)
          for (i = 0; i < openedkeys; i++)
          for (i = 0; i < openedkeys; i++)
            fprintf (file, "   ");
            fprintf (file, "   ");
          if (openedcase){
          if (openedcase){
            if (IsDefine (defineslist, (char *) $2))
            if (IsDefine (defineslist, (char *) $2))
              fprintf (file, ", `%s", (char *) $2);
              fprintf (file, ", `%s", (char *) $2);
                else
                else
                  fprintf (file, ", %s", (char *) $2);
                  fprintf (file, ", %s", (char *) $2);
          }else{
          }else{
            if (IsDefine (defineslist, (char *) $2))
            if (IsDefine (defineslist, (char *) $2))
              fprintf (file, "`%s", (char *) $2);
              fprintf (file, "`%s", (char *) $2);
                else
                else
                  fprintf (file, "%s", (char *) $2);
                  fprintf (file, "%s", (char *) $2);
      }
      }
          newline = 1;
          newline = 1;
          openedcase = 1;
          openedcase = 1;
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "case %s %s", (char *) $2, (char *) $3);
    fprintf (file, "case %s %s", (char *) $2, (char *) $3);
};
};
case_default:
case_default:
DEFAULT SYMBOL
DEFAULT SYMBOL
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
         if (!openedcase)
         if (!openedcase)
          for (i = 0; i < openedkeys; i++)
          for (i = 0; i < openedkeys; i++)
            fprintf (file, "   ");
            fprintf (file, "   ");
          fprintf (file, "default:\n");
          fprintf (file, "default:\n");
          for (i = 0; i < openedkeys; i++)
          for (i = 0; i < openedkeys; i++)
            fprintf (file, "   ");
            fprintf (file, "   ");
          fprintf (file, "begin\n");
          fprintf (file, "begin\n");
          newline = 1;
          newline = 1;
          default_found = 1;
          default_found = 1;
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "default %s", (char *) $2);
    fprintf (file, "default %s", (char *) $2);
};
};
case_only:
case_only:
CASE OPENPAR
CASE OPENPAR
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  //This rule occurs when in Verilog mode a case appears
  //This rule occurs when in Verilog mode a case appears
  if (verilog == 1)
  if (verilog == 1)
    fprintf (file, "case(");
    fprintf (file, "case(");
};
};
break:
break:
BREAK SEMICOLON
BREAK SEMICOLON
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          if (newline == 0)
          if (newline == 0)
            fprintf (file, "\n");
            fprintf (file, "\n");
          for (i = 0; i < openedkeys; i++)
          for (i = 0; i < openedkeys; i++)
            fprintf (file, "   ");
            fprintf (file, "   ");
          fprintf (file, "end\n");
          fprintf (file, "end\n");
          if (default_found)
          if (default_found)
            {
            {
              default_break_found = 1;
              default_break_found = 1;
            }
            }
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "break;");
    fprintf (file, "break;");
};
};
hexa:
hexa:
HEXA
HEXA
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          fprintf (file, "'h");
          fprintf (file, "'h");
        }
        }
      else if (definefound)
      else if (definefound)
        {
        {
          fprintf (FILE_DEFINES, "'h");
          fprintf (FILE_DEFINES, "'h");
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "0x");
    fprintf (file, "0x");
};
};
translateoff:
translateoff:
TRANSLATEOFF
TRANSLATEOFF
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  translate = 0;
  translate = 0;
  fprintf (stderr, "line: %d Found Translate off directive \n", lineno);
  fprintf (stderr, "line: %d Found Translate off directive \n", lineno);
};
};
translateon:
translateon:
TRANSLATEON
TRANSLATEON
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  translate = 1;
  translate = 1;
  fprintf (stderr, "line: %d Found Translate on directive \n", lineno);
  fprintf (stderr, "line: %d Found Translate on directive \n", lineno);
};
};
verilogbegin:
verilogbegin:
VERILOGBEGIN
VERILOGBEGIN
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  verilog = 1;
  verilog = 1;
  fprintf (stderr, "line: %d Found Verilog Begin directive \n", lineno);
  fprintf (stderr, "line: %d Found Verilog Begin directive \n", lineno);
};
};
verilogend:
verilogend:
VERILOGEND
VERILOGEND
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  verilog = 0;
  verilog = 0;
  fprintf (stderr, "line: %d Found Verilog End directive \n", lineno);
  fprintf (stderr, "line: %d Found Verilog End directive \n", lineno);
};
};
ifdef:
ifdef:
PIFDEF
PIFDEF
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          ifdeffound = 1;
          ifdeffound = 1;
          fprintf (file, "`ifdef");
          fprintf (file, "`ifdef");
        }
        }
      else if (definefound)
      else if (definefound)
        {
        {
          fprintf (FILE_DEFINES, "`ifdef");
          fprintf (FILE_DEFINES, "`ifdef");
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "#ifdef");
    fprintf (file, "#ifdef");
};
};
ifndef:
ifndef:
PIFNDEF
PIFNDEF
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          ifdeffound = 1;
          ifdeffound = 1;
          fprintf (file, "`ifndef");
          fprintf (file, "`ifndef");
        }
        }
      else if (definefound)
      else if (definefound)
        {
        {
          fprintf (FILE_DEFINES, "`ifndef");
          fprintf (FILE_DEFINES, "`ifndef");
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "#ifndef");
    fprintf (file, "#ifndef");
};
};
endif:
endif:
PENDDEF
PENDDEF
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          fprintf (file, "`endif");
          fprintf (file, "`endif");
        }
        }
      else if (definefound)
      else if (definefound)
        {
        {
          fprintf (FILE_DEFINES, "`endif");
          fprintf (FILE_DEFINES, "`endif");
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "#endif");
    fprintf (file, "#endif");
};
};
pelse:
pelse:
PELSE
PELSE
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          fprintf (file, "`else");
          fprintf (file, "`else");
        }
        }
      else if (definefound)
      else if (definefound)
        {
        {
          fprintf (FILE_DEFINES, "`else");
          fprintf (FILE_DEFINES, "`else");
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "#else");
    fprintf (file, "#else");
};
};
ttrue:
ttrue:
TTRUE
TTRUE
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          fprintf (file, "1");
          fprintf (file, "1");
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "1");
    fprintf (file, "1");
};
};
tfalse:
tfalse:
TFALSE
TFALSE
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          fprintf (file, "0");
          fprintf (file, "0");
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "0");
    fprintf (file, "0");
};
};
comment:
comment:
COMMENT
COMMENT
{
{
if(processfound){
if(processfound){
  //To manage comments inside switch statements
  //To manage comments inside switch statements
  if(lastswitch){
  if(lastswitch){
        openedcase=0;
        openedcase=0;
  }else if (openedcase){
  }else if (openedcase){
        fprintf (file, " :\n");
        fprintf (file, " :\n");
      for (i = 0; i < openedkeys; i++)
      for (i = 0; i < openedkeys; i++)
                fprintf (file, "   ");
                fprintf (file, "   ");
        fprintf(file,"begin\n");
        fprintf(file,"begin\n");
        openedcase=0;
        openedcase=0;
  }
  }
  //indent
  //indent
  if(newline){
  if(newline){
    for (i = 0; i < openedkeys; i++)
    for (i = 0; i < openedkeys; i++)
          fprintf (file, "   ");
          fprintf (file, "   ");
        newline=0;
        newline=0;
  }
  }
  fprintf (file, " %s", (char *)$1);
  fprintf (file, " %s", (char *)$1);
 }
 }
}
}
struct_dec:
struct_dec:
STRUCT OPENKEY
STRUCT OPENKEY
{
{
  struct_found=1;
  struct_found=1;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.