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

Subversion Repositories sc2v

[/] [sc2v/] [trunk/] [src/] [sc2v_step1.y] - Diff between revs 27 and 28

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

Rev 27 Rev 28
Line 56... Line 56...
  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 default_break_found = 0;
  int default_break_found = 0;
  int default_found;
  int default_found;
 
 
//Directives variables
//Directives variables
Line 125... Line 125...
 
 
%token NUMBER WORD SC_REG BOOL BIGGER LOWER OPENKEY CLOSEKEY WRITE WORD SYMBOL NEWLINE ENUM INCLUDE
%token NUMBER WORD SC_REG BOOL BIGGER LOWER OPENKEY CLOSEKEY WRITE WORD 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
%token PIFDEF PIFNDEF PENDDEF PELSE COMMENT
 
 
%% commands:    /* empty */
%% commands:    /* empty */
|commands command;
|commands command;
 
 
 
 
Line 236... Line 236...
  |
  |
  decrement
  decrement
  |
  |
  equal
  equal
  |
  |
  minorequal;
  minorequal
 
  |
 
  comment;
 
 
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
Line 522... Line 524...
{
{
 
 
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
 
          if(opencorchfound==0){
 
                strcpy (lastword, (char *) $1);
 
          }
 
 
      if (processfound)
      if (processfound)
        {
        {
          if(lastswitch){
          if(lastswitch){
            openedcase=0;
            openedcase=0;
          }else if (openedcase)
          }else if (openedcase)
Line 537... Line 543...
 
 
              fprintf(file,"begin\n");
              fprintf(file,"begin\n");
              openedcase=0;
              openedcase=0;
            }
            }
 
 
          strcpy (lastword, (char *) $1);
 
 
 
          if (reg_found)
          if (reg_found)
            {
            {
              if(writelenght){
              if(writelenght){
               writelenght=0;
               writelenght=0;
               if(reglenght==0)
               if(reglenght==0)
Line 662... Line 666...
  reg_found=0;
  reg_found=0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
  {
  {
      if (processfound)
      if (processfound)
        fprintf (file, "=");
        fprintf (file, "=");
 
        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, "=");
Line 698... Line 703...
 
 
newline:
newline:
NEWLINE
NEWLINE
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
 
  writingvar=0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound & !reg_found & !openedcase)
      if (processfound & !reg_found & !openedcase)
        {
        {
          fprintf (file, "\n");
          fprintf (file, "\n");
Line 754... Line 760...
              fprintf (regs_file, ";\n");
              fprintf (regs_file, ";\n");
              reg_found = 0;
              reg_found = 0;
            }
            }
          else
          else
            {
            {
              if (defineinvocationfound == 0)
            if (defineinvocationfound == 0 || writingvar)
                fprintf (file, ";");
                fprintf (file, ";");
            }
            }
        }
        }
      else if (definefound)
      else if (definefound)
        {
        {
Line 766... Line 772...
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, ";");
    fprintf (file, ";");
 
 
 
  writingvar=0;
  defineinvocationfound = 0;
  defineinvocationfound = 0;
};
};
 
 
 
 
openpar:
openpar:
Line 827... Line 834...
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
 
          opencorchfound = 1;
          if (reg_found)
          if (reg_found)
            {
            {
              fprintf (regs_file, "[");
              fprintf (regs_file, "[");
              opencorchfound = 1;
 
            }
            }
          else
          else
            fprintf (file, "[");
            fprintf (file, "[");
        }
        }
      else if (definefound)
      else if (definefound)
Line 853... Line 860...
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
 
          opencorchfound = 0;
          if (reg_found)
          if (reg_found)
            {
            {
              fprintf (regs_file, "]");
              fprintf (regs_file, "]");
              opencorchfound = 0;
 
            }
            }
          else
          else
            fprintf (file, "]");
            fprintf (file, "]");
        }
        }
      else if (definefound)
      else if (definefound)
Line 1144... Line 1151...
      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))
 
              fprintf (file, ", `%s", (char *) $2);
 
                else
            fprintf (file, ", %s", (char *) $2);
            fprintf (file, ", %s", (char *) $2);
 
          }else{
 
            if (IsDefine (defineslist, (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;
 
 
        }
        }
    }
    }
Line 1372... Line 1385...
        }
        }
    }
    }
  else if (verilog == 1)
  else if (verilog == 1)
    fprintf (file, "0");
    fprintf (file, "0");
};
};
 
 
 
comment:
 
COMMENT
 
{
 
if(processfound){
 
  //To manage comments inside switch statements
 
  if(lastswitch){
 
        openedcase=0;
 
  }else if (openedcase){
 
        fprintf (file, " :\n");
 
      for (i = 0; i < openedkeys; i++)
 
                fprintf (file, "   ");
 
        fprintf(file,"begin\n");
 
        openedcase=0;
 
  }
 
  //indent
 
  if(newline){
 
    for (i = 0; i < openedkeys; i++)
 
          fprintf (file, "   ");
 
        newline=0;
 
  }
 
  fprintf (file, " %s", (char *)$1);
 
 }
 
}
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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