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

Subversion Repositories sc2v

[/] [sc2v/] [trunk/] [src/] [sc2v_step1.y] - Diff between revs 11 and 12

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 11 Rev 12
Line 34... Line 34...
DefinesList *defineslist;
DefinesList *defineslist;
 
 
 
 
int processfound = 0;
int processfound = 0;
int switchfound = 0;
int switchfound = 0;
int switchparenthesis = 0;
  int switchparenthesis[256];
 
  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;
Line 54... Line 55...
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 openedcase = 0;
int openedcase = 0;
 
 
int default_break_found = 0;
int default_break_found = 0;
int default_found;
int default_found;
Line 77... Line 79...
        return 1;
        return 1;
}
}
 
 
main()
main()
{
{
 
    int i;
 
 
        regslist = (RegsList *)malloc(sizeof(RegsList));
        regslist = (RegsList *)malloc(sizeof(RegsList));
        InitializeRegsList(regslist);
        InitializeRegsList(regslist);
        defineslist = (DefinesList *)malloc(sizeof(DefinesList));
        defineslist = (DefinesList *)malloc(sizeof(DefinesList));
        InitializeDefinesList(defineslist);
        InitializeDefinesList(defineslist);
 
 
Line 98... Line 102...
                        if(FILE_WRITES!=NULL)
                        if(FILE_WRITES!=NULL)
                                printf("\nopening file => filename = %s\n",file_writes);
                                printf("\nopening file => filename = %s\n",file_writes);
 
 
        lastword=malloc(sizeof(char)*256);
        lastword=malloc(sizeof(char)*256);
 
 
 
    for (i = 0; i < 256; i++)
 
      switchparenthesis[i] = 0;
 
 
        translate=1;
        translate=1;
        verilog=0;
        verilog=0;
        writemethod=0;
        writemethod=0;
 
 
        yyparse();
        yyparse();
Line 115... Line 122...
%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 SC_BIGINT SC_BIGUINT HEXA DEFINE READ TRANSLATEOFF TRANSLATEON VERILOGBEGIN VERILOGEND TAB DOLLAR INTCONV
%token SC_BIGINT SC_BIGUINT HEXA DEFINE READ TRANSLATEOFF TRANSLATEON VERILOGBEGIN VERILOGEND TAB DOLLAR INTCONV
%token VOID TTRUE TFALSE
%token VOID TTRUE TFALSE
%token PIFDEF PENDDEF PELSE
%token PIFDEF PENDDEF PELSE
 
 
%%
%% commands:/* empty */
 
|commands command;
commands: /* empty */
 
        | commands command
 
        ;
 
 
 
 
 
command:
command:
    voidword
    voidword
        |
        |
Line 193... Line 197...
        |
        |
        break
        break
        |
        |
        hexa
        hexa
        |
        |
        define
  definemacro
 
  |
 
  defineword
 
  |
 
  definenumber
        |
        |
        translateoff
        translateoff
        |
        |
        translateon
        translateon
        |
        |
Line 211... Line 219...
        |
        |
        pelse
        pelse
        |
        |
        ttrue
        ttrue
        |
        |
        tfalse
  tfalse;
        ;
 
 
 
 
 
 
 
voidword:
voidword:
    VOID
    VOID
        {
        {
 
  defineparenthesis = 0;
        if(verilog==1)
        if(verilog==1)
          fprintf(file," void");
          fprintf(file," void");
        };
        };
 
 
 
 
include:
include:
    INCLUDE
    INCLUDE
        {
        {
 
  defineparenthesis = 0;
        if(verilog==1)
        if(verilog==1)
          fprintf(file," #include");
          fprintf(file," #include");
        };
        };
 
 
 
 
dollar:
dollar:
    DOLLAR
    DOLLAR
        {
        {
 
  defineparenthesis = 0;
        if(verilog==1)
        if(verilog==1)
          fprintf(file," $");
          fprintf(file," $");
        };
        };
 
 
intconv:
intconv:
    INTCONV
    INTCONV
        {
        {
 
  defineparenthesis = 0;
        if(verilog==1)
        if(verilog==1)
          fprintf(file," (int)");
          fprintf(file," (int)");
        };
        };
 
 
tab:
tab:
    TAB
    TAB
        {
        {
 
  defineparenthesis = 0;
        if(verilog==1)
        if(verilog==1)
          fprintf(file," \t");
          fprintf(file," \t");
        };
        };
 
 
read:
read:
        READ OPENPAR CLOSEPAR
        READ OPENPAR CLOSEPAR
                {
                {
 
  defineparenthesis = 0;
                if(verilog==1)
                if(verilog==1)
                  fprintf(file,".read()");
                  fprintf(file,".read()");
 
 
                }
                }
 
 
define:
defineword:
 
DEFINE WORD WORD
 
{
 
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
 
      if (processfound)
 
        {
 
          fprintf (file, "`define %s %s\n", (char *) $2, (char *) $3);
 
          InsertDefine (defineslist, (char *) $2);
 
        }
 
      else
 
        {
 
          fprintf (FILE_DEFINES, "`define %s %s\n", (char *) $2, (char *) $3);
 
          InsertDefine (defineslist, (char *) $2);
 
        }
 
    }
 
  else if (verilog == 1)
 
    fprintf (file, "#define %s %s\n", (char *) $2, (char *) $3);
 
 
 
};
 
 
 
definenumber:
 
DEFINE WORD NUMBER
 
{
 
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
 
      if (processfound)
 
        {
 
          fprintf (file, "`define %s %d\n", (char *) $2, (int) $3);
 
          InsertDefine (defineslist, (char *) $2);
 
        }
 
      else
 
        {
 
          fprintf (FILE_DEFINES, "`define %s %d\n", (char *) $2, (int) $3);
 
          InsertDefine (defineslist, (char *) $2);
 
        }
 
    }
 
  else if (verilog == 1)
 
    fprintf (file, "#define %s %d\n", (char *) $2, (int) $3);
 
 
 
};
 
 
 
 
 
definemacro:
        DEFINE WORD OPENPAR CLOSEPAR
        DEFINE WORD OPENPAR CLOSEPAR
                {
                {
                  if(translate==1 && verilog==0){
  defineparenthesis = 0;
 
  //Macro found
 
  if (translate == 1 && verilog == 0)
 
    {
                        InsertDefine(defineslist, (char *)$2);
                        InsertDefine(defineslist, (char *)$2);
                        definefound = 1;
                        definefound = 1;
 
      if (processfound)
 
        fprintf (file, "`define %s ", (char *) $2);
 
      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 CLOSEPAR
        WORD TWODOUBLEPOINTS WORD OPENPAR CLOSEPAR
                {
                {
                if(translate==1&& verilog==0){
  defineparenthesis = 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");
                        /*
    }
                        strcpy(file_writes, (char *)$4);
  else if (verilog == 1)
                        strcat(file_writes, (char *)"_writes.sc2v");
 
                        */
 
                }else if(verilog==1)
 
                  fprintf(file," %s::%s()",(char *)$1,(char *)$3);
                  fprintf(file," %s::%s()",(char *)$1,(char *)$3);
 
 
                }
                }
 
 
sc_int:
sc_int:
        SC_INT LOWER NUMBER BIGGER
        SC_INT LOWER NUMBER BIGGER
                {
                {
        if(translate==1&& verilog==0){
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
                        if(processfound)
                        if(processfound)
                        {
                        {
                                fprintf(regs_file,"reg[%d:0] ",(-1 + $3));
                                fprintf(regs_file,"reg[%d:0] ",(-1 + $3));
                                reg_found = 1;
                                reg_found = 1;
                        }
                        }
                }else if(verilog==1)
    }
 
  else if (verilog == 1)
                  fprintf(file,"sc_int<%d>",$3);
                  fprintf(file,"sc_int<%d>",$3);
 
 
                }
                }
 
 
                ;
                ;
 
 
sc_uint:
sc_uint:
        SC_UINT LOWER NUMBER BIGGER
        SC_UINT LOWER NUMBER BIGGER
                {
                {
                if(translate==1&& verilog==0){
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
                        if(processfound)
                        if(processfound)
                        {
                        {
                                fprintf(regs_file,"reg[%d:0] ",(-1 + $3));
                                fprintf(regs_file,"reg[%d:0] ",(-1 + $3));
                                reg_found = 1;
                                reg_found = 1;
                        }
                        }
                }else if(verilog==1)
    }
 
  else if (verilog == 1)
                  fprintf(file,"sc_uint<%d>",$3);
                  fprintf(file,"sc_uint<%d>",$3);
                }
                }
 
 
                ;
                ;
 
 
sc_bigint:
sc_bigint:
        SC_BIGINT LOWER NUMBER BIGGER
        SC_BIGINT LOWER NUMBER BIGGER
                {
                {
                if(translate==1&& verilog==0){
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
                        if(processfound)
                        if(processfound)
                        {
                        {
                                fprintf(regs_file,"reg[%d:0] ",(-1 + $3));
                                fprintf(regs_file,"reg[%d:0] ",(-1 + $3));
                                reg_found = 1;
                                reg_found = 1;
                        }
                        }
                }else if(verilog==1)
    }
 
  else if (verilog == 1)
                 fprintf(file,"sc_bigint<%d> ",$3);
                 fprintf(file,"sc_bigint<%d> ",$3);
                }
                }
 
 
                ;
                ;
 
 
sc_biguint:
sc_biguint:
        SC_BIGUINT LOWER NUMBER BIGGER
        SC_BIGUINT LOWER NUMBER BIGGER
                {
                {
                if(translate==1&& verilog==0){
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
                        if(processfound)
                        if(processfound)
                        {
                        {
                                fprintf(regs_file,"reg[%d:0] ",(-1 + $3));
                                fprintf(regs_file,"reg[%d:0] ",(-1 + $3));
                                reg_found = 1;
                                reg_found = 1;
                        }
                        }
                }else if(verilog==1)
    }
 
  else if (verilog == 1)
                  fprintf(file,"sc_biguint<%d> ",$3);
                  fprintf(file,"sc_biguint<%d> ",$3);
                }
                }
 
 
                ;
                ;
 
 
bool:
bool:
                BOOL
                BOOL
                        {
                        {
                    if(translate==1&& verilog==0){
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
                                if(processfound)
                                if(processfound)
                                {
                                {
                                        fprintf(regs_file,"reg ");
                                        fprintf(regs_file,"reg ");
                                        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
                        {
                        {
                    if(translate==1&& verilog==0){
  defineparenthesis = 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
                        {
                        {
                        if(translate==1&& verilog==0){
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
                                if(processfound)
                                if(processfound)
                                        if(reg_found)
                                        if(reg_found)
                                        {
                                        {
                                            if(opencorchfound)
                                            if(opencorchfound)
                                                fprintf(regs_file,"%d:0", -1 + $1);
                                                fprintf(regs_file,"%d:0", -1 + $1);
Line 388... Line 480...
                                        }
                                        }
                                        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);
                        }
                        }
 
 
                        ;
                        ;
word:
word:
                WORD
                WORD
                        {
                        {
                    if(translate==1&& verilog==0){
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
                          if(processfound)
                          if(processfound)
                          {
                          {
                             if(openedcase)
                             if(openedcase)
                             {
                             {
                                fprintf(file," :\n");
                                fprintf(file," :\n");
Line 415... Line 511...
 
 
                             if(reg_found)
                             if(reg_found)
                             {
                             {
 
 
                              regname=malloc(sizeof(char)*(strlen((char *)$1)+1));
                              regname=malloc(sizeof(char)*(strlen((char *)$1)+1));
                              regname2=malloc(sizeof(char)*(strlen((char *)$1)+strlen(processname))+1);
              regname2 =
 
                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);
Line 437... Line 535...
                                   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)
 
                        {
                                           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;
 
                        }
 
                    }
 
                  else
 
                    {
 
                      fprintf (file, "%s ", (char *) $1);
                                         }
                                         }
                                   }
                                   }
                                   else
                                   else
                                         fprintf(file,"%s",regname2);
                                         fprintf(file,"%s",regname2);
 
 
Line 456... Line 562...
                          }
                          }
                          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);
                    };
                    };
 
 
symbol:
symbol:
                SYMBOL
                SYMBOL
                        {
                        {
                        if(translate==1&& verilog==0){
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
                                if(processfound)
                                if(processfound)
                                {
                                {
                                   if(reg_found)
                                   if(reg_found)
                                        fprintf(regs_file,"%s",(char *)$1);
                                        fprintf(regs_file,"%s",(char *)$1);
                                   else
                                   else
Line 482... Line 592...
                                }
                                }
                                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);
                        };
                        };
 
 
 
 
write:
write:
                WRITE
                WRITE
                        {
                        {
                        if(translate==1&& verilog==0){
  defineparenthesis = 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
                        {
                        {
                    if(translate==1&& verilog==0){
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
                                if(processfound & !reg_found & !openedcase)
                                if(processfound & !reg_found & !openedcase)
                                {
                                {
                                        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
                        {
                        {
                        if(translate==1&& verilog==0){
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
                                if(processfound)
                                if(processfound)
                                {
                                {
                                  if(reg_found)
                                  if(reg_found)
                                  {
                                  {
                                        fprintf(regs_file,",");
                                        fprintf(regs_file,",");
Line 542... Line 662...
                                }
                                }
                                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
                        {
                        {
                    if(translate==1&& verilog==0){
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
                                if(processfound)
                                if(processfound)
                                {
                                {
                                  if(reg_found)
                                  if(reg_found)
                                  {
                                  {
                                        fprintf(regs_file,";\n");
                                        fprintf(regs_file,";\n");
                                        reg_found = 0;
                                        reg_found = 0;
                                  }
                                  }
                                  else if(defineinvocationfound)
 
                                  {
 
                                        defineinvocationfound = 0;
 
                                  }
 
                                  else
                                  else
                                  {
                                  {
 
              if (defineinvocationfound == 0)
                                        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,";");
 
 
 
  defineinvocationfound = 0;
                        };
                        };
 
 
 
 
openpar:
openpar:
                OPENPAR
                OPENPAR
                        {
                        {
            if(translate==1 && verilog==0){
  defineparenthesis = 1;
 
  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,"(");
                        };
    }
 
}
 
 
closepar:
closepar:
                CLOSEPAR
                CLOSEPAR
                        {
                        {
                    if(translate==1&& verilog==0){
  if (translate == 1 && verilog == 0)
 
    {
 
 
                                if(processfound)
                                if(processfound)
                                {
                                {
 
          if (defineparenthesis == 0)
 
            {
                                        fprintf(file,")");
                                        fprintf(file,")");
 
              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
                        {
                        {
                        if(translate==1&& verilog==0){
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
                                if(processfound)
                                if(processfound)
                                {
                                {
                                  if(reg_found)
                                  if(reg_found)
                                  {
                                  {
                                        fprintf(regs_file,"[");
                                        fprintf(regs_file,"[");
Line 625... Line 767...
                                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
                        {
                        {
                    if(translate==1&& verilog==0){
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
                                if(processfound)
                                if(processfound)
                                {
                                {
                                  if(reg_found)
                                  if(reg_found)
                                  {
                                  {
                                        fprintf(regs_file,"]");
                                        fprintf(regs_file,"]");
Line 647... Line 792...
                                }
                                }
                                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
                        {
                        {
                    if(translate==1 && verilog==0){
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
                                openedkeys++;
                                openedkeys++;
                                if(openedkeys==1 & !definefound)
      if (!definefound)
 
        {
 
          if (openedkeys == 1)
                                {
                                {
                                        printf("opening file => filename = %s\n",processname2);
                                        printf("opening file => filename = %s\n",processname2);
                                        file = fopen(processname2,(char *)"w");
                                        file = fopen(processname2,(char *)"w");
                                        printf("opening file => filename = %s\n",fileregs);
                                        printf("opening file => filename = %s\n",fileregs);
                                        regs_file = fopen(fileregs,(char *)"w");
                                        regs_file = fopen(fileregs,(char *)"w");
                                        processfound = 1;
                                        processfound = 1;
                                        regslist = (RegsList *)malloc(sizeof(RegsList));
                                        regslist = (RegsList *)malloc(sizeof(RegsList));
                                        InitializeRegsList(regslist);
                                        InitializeRegsList(regslist);
                        /*              regname = (char *)malloc(256*sizeof(int));
 
                                        regname2 = (char *)malloc(256*sizeof(int));*/
 
                                }
                                }
                                if(processfound)
                                if(processfound)
                                        if(openedkeys != switchparenthesis)
            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)
 
                       fprintf(file,"{");
 
                        }
                        }
                        ;
    }
 
  else if (verilog == 1)
 
    fprintf (file, "{");
 
};
 
 
closekey:
closekey:
                CLOSEKEY
                CLOSEKEY
                        {
                        {
            if(translate==1&& verilog==0){
  defineparenthesis = 0;
                                if(processfound)
  if (translate == 1 && verilog == 0)
 
    {
 
      if (processfound && !definefound)
                                {
                                {
                                        if(openedkeys==switchparenthesis & switchfound == 1)
          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; 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; i++)
              for (i = 0; i < openedkeys - 1; i++)
                                                        fprintf(file,"   ");
                                                        fprintf(file,"   ");
                                                fprintf(file,"endcase\n");
                                                fprintf(file,"endcase\n");
                                                newline = 1;
                                                newline = 1;
                                                switchfound = 0;
              switchparenthesis[switchfound] = 0;
                                                switchparenthesis = 0;
              switchfound--;
 
 
                                        }
                                        }
                                        else
                                        else
                                        {
                                        {
                                                fprintf(file,"\n");
                                                fprintf(file,"\n");
                                                for(i = 0; i < openedkeys; i++)
                                                for(i = 0; i < openedkeys; i++)
Line 721... Line 872...
 
 
                                openedkeys--;
                                openedkeys--;
                                if(definefound)
                                if(definefound)
                                {
                                {
                                        definefound = 0;
                                        definefound = 0;
 
          if (processfound)
 
            fprintf (file, "\n//Dummy Comment\n");
 
          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);
                                        free(regslist);
                                        free(regslist);
/*                                      free(regname);
 
                                        free(regname2);*/
 
                                        processfound = 0;
                                        processfound = 0;
                                }
                                }
                        }else if(verilog==1)
    }
 
  else if (verilog == 1)
                       fprintf(file,"}");
                       fprintf(file,"}");
                        };
                        };
 
 
 
 
bigger:
bigger:
                BIGGER
                BIGGER
                        {
                        {
            if(translate==1&& verilog==0){
  defineparenthesis = 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
                        {
                        {
                        if(translate==1&& verilog==0){
  defineparenthesis = 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
                        {
                        {
                        if(translate==1&& verilog==0){
    defineparenthesis = 0;
 
    if (translate == 1 && verilog == 0)
 
      {
                          if(processfound)
                          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,"case");
                                        fprintf(file,"case");
                                        switchfound = 1;
            switchfound++;
                                        switchparenthesis = 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
                        {
                        {
                        if(translate==1&& verilog==0){
  defineparenthesis = 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,"   ");
                                if(openedcase)
                                if(openedcase)
Line 804... Line 968...
 
 
                                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_word:
case_word:
                CASE WORD SYMBOL
                CASE WORD SYMBOL
                        {
                        {
                        if(translate==1&& verilog==0){
  defineparenthesis = 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,"   ");
                                if(openedcase)
                                if(openedcase)
Line 824... Line 992...
 
 
                                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
                        {
                        {
                        if(translate==1&& verilog==0){
  defineparenthesis = 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,"default:\n");
                                fprintf(file,"default:\n");
Line 843... Line 1014...
                                        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;
                //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
                        {
                        {
                        if(translate==1&& verilog==0){
  defineparenthesis = 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++)
Line 871... Line 1046...
                                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
                        {
                        {
                    if(translate==1&& verilog==0){
  defineparenthesis = 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;
                  translate=0;
                  translate=0;
                  fprintf(stderr,"Found Translate off directive \n");
                  fprintf(stderr,"Found Translate off directive \n");
        };
        };
 
 
translateon:
translateon:
        TRANSLATEON
        TRANSLATEON
                {
                {
 
  defineparenthesis = 0;
                  translate=1;
                  translate=1;
                  fprintf(stderr,"Found Translate on directive \n");
                  fprintf(stderr,"Found Translate on directive \n");
        };
        };
 
 
verilogbegin:
verilogbegin:
        VERILOGBEGIN
        VERILOGBEGIN
                {
                {
 
  defineparenthesis = 0;
                  verilog=1;
                  verilog=1;
                  fprintf(stderr,"Found Verilog Begin directive \n");
                  fprintf(stderr,"Found Verilog Begin directive \n");
        };
        };
 
 
verilogend:
verilogend:
        VERILOGEND
        VERILOGEND
                {
                {
 
  defineparenthesis = 0;
                  verilog=0;
                  verilog=0;
                  fprintf(stderr,"Found Verilog End directive \n");
                  fprintf(stderr,"Found Verilog End directive \n");
        };
        };
 
 
ifdef:
ifdef:
       PIFDEF
       PIFDEF
           {
           {
            if(translate==1&& verilog==0){
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
                                if(processfound)
                                if(processfound)
                                {
                                {
 
          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");
                        };
                        };
 
 
endif:
endif:
       PENDDEF
       PENDDEF
           {
           {
            if(translate==1&& verilog==0){
  defineparenthesis = 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
           {
           {
            if(translate==1&& verilog==0){
  defineparenthesis = 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
          {
          {
                if(translate==1&& verilog==0){
  defineparenthesis = 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
          {
          {
                if(translate==1&& verilog==0){
  defineparenthesis = 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");
                        };
                        };

powered by: WebSVN 2.1.0

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