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

Subversion Repositories sc2v

[/] [sc2v/] [trunk/] [src/] [sc2v_step1.y] - Diff between revs 33 and 35

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

Rev 33 Rev 35
Line 36... Line 36...
  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 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;
Line 89... Line 90...
    defineslist = NULL;
    defineslist = NULL;
    regslist = NULL;
    regslist = NULL;
    structslist = NULL;
    structslist = NULL;
    structsreglist = NULL;
    structsreglist = NULL;
 
 
    fprintf (stderr, "\nSystemC to Verilog Translator v0.4");
    fprintf (stderr, "\nSystemC to Verilog Translator v0.6");
    fprintf (stderr,
    fprintf (stderr,
             "\nProvided by URJC(Universidad Rey Juan Carlos)\nhttp://www.escet.urjc.es/~jmartine\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));
Line 127... Line 128...
    fprintf (stderr, "\nDone\n\n");
    fprintf (stderr, "\nDone\n\n");
  }
  }
 
 
%}
%}
 
 
%token NUMBER WORD SC_REG BOOL BIGGER LOWER OPENKEY CLOSEKEY WRITE WORD 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
 
 
Line 153... Line 154...
  |
  |
  read
  read
  |
  |
  sc_reg
  sc_reg
  |
  |
 
  sc_sigreg
 
  |
  integer
  integer
  |
  |
  number
  number
  |
  |
  bool
  bool
Line 253... Line 256...
  ;
  ;
 
 
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;
 
 
 free(regname2);
 
 
 
 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
{
{
Line 450... Line 455...
          reg_found = 1;
          reg_found = 1;
        }
        }
    }
    }
};
};
 
 
 
sc_sigreg:
 
SC_SIGREG LOWER NUMBER BIGGER
 
{
 
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
 
      if (processfound)
 
        {
 
          writelenght=1;
 
          reglenght = $3;
 
          sigreg_found = 1;
 
        }
 
    }
 
};
 
 
integer:
integer:
INTEGER
INTEGER
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
Line 508... Line 528...
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
       if(opencorchfound && reg_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);
Line 606... Line 626...
               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;
             );}
             );}
 
 
          }else if(struct_found && reg_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){
          }else if (reg_found || sigreg_found){
              if(writelenght){
              if(writelenght){
               writelenght=0;
               writelenght=0;
               if(reglenght==0)
               if(reglenght==0)
 
            if(sigreg_found)
 
                    fprintf (regs_file, "reg signed");
 
            else
                fprintf (regs_file, "reg ");
                fprintf (regs_file, "reg ");
               else
               else
 
            if(sigreg_found)
 
               fprintf (regs_file, "reg signed [%d:0] ", (-1 +reglenght));
 
            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);
Line 699... Line 726...
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          if (reg_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)
Line 718... Line 745...
equal:
equal:
EQUALS
EQUALS
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  reg_found=0;
  reg_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;
Line 762... Line 790...
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  writingvar=0;
  writingvar=0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound & !reg_found & !openedcase)
      if (processfound & !reg_found & !openedcase & !sigreg_found)
        {
        {
          fprintf (file, "\n");
          fprintf (file, "\n");
          newline = 1;
          newline = 1;
        }
        }
      else if (definefound)
      else if (definefound)
Line 785... Line 813...
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          if (reg_found)
          if (reg_found || sigreg_found)
            {
            {
              fprintf (regs_file, ",");
              fprintf (regs_file, ",");
            }
            }
          else
          else
            fprintf (file, ",");
            fprintf (file, ",");
Line 809... Line 837...
  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)
          if (reg_found || sigreg_found)
            {
            {
              fprintf (regs_file, ";\n");
              fprintf (regs_file, ";\n");
              reg_found = 0;
              reg_found = 0;
 
         sigreg_found = 0;
            }
            }
          else
          else
            {
            {
            if (defineinvocationfound == 0 || writingvar)
            if (defineinvocationfound == 0 || writingvar)
                  fprintf (file, ";");
                  fprintf (file, ";");
Line 856... Line 885...
    {
    {
      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;
}
}
 
 
closepar:
closepar:
CLOSEPAR
CLOSEPAR
{
{
Line 892... Line 922...
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
        {
        {
          opencorchfound = 1;
          opencorchfound = 1;
          if (reg_found)
          if (reg_found || sigreg_found)
            {
            {
              fprintf (regs_file, "[");
              fprintf (regs_file, "[");
            }
            }
          else
          else
            fprintf (file, "[");
            fprintf (file, "[");
Line 918... Line 948...
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      if (processfound)
      if (processfound)
          {
          {
          opencorchfound = 0;
          opencorchfound = 0;
          if (reg_found)
          if (reg_found || sigreg_found)
            {
            {
              fprintf (regs_file, "]");
              fprintf (regs_file, "]");
            }
            }
          else
          else
            fprintf (file, "]");
            fprintf (file, "]");

powered by: WebSVN 2.1.0

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