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

Subversion Repositories sc2v

[/] [sc2v/] [trunk/] [src/] [sc2v_step1.y] - Diff between revs 15 and 16

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

Rev 15 Rev 16
Line 1... Line 1...
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
 *
 *
 *  SystemC to Verilog Translator v0.3
 *  SystemC to Verilog Translator v0.4
 *  Provided by OpenSoc Design
 *  Provided by OpenSoc Design
 *
 *
 *  www.opensocdesign.com
 *  www.opensocdesign.com
 *
 *
 * -----------------------------------------------------------------------------
 * -----------------------------------------------------------------------------
Line 80... Line 80...
 
 
        defineslist=NULL;
        defineslist=NULL;
        regslist=NULL;
        regslist=NULL;
 
 
        fprintf(stderr,"\nSystemC to Verilog Translator v0.3");
        fprintf(stderr,"\nSystemC to Verilog Translator v0.3");
        fprintf(stderr,"\nProvided by OpenSoc http://www.opensocdesign.com\n\n");
    fprintf (stderr,
 
             "\nProvided by OpenSoc http://www.opensocdesign.com\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 115... Line 116...
        fprintf(stderr,"\nDone\n\n");
        fprintf(stderr,"\nDone\n\n");
  }
  }
 
 
%}
%}
 
 
%token NUMBER WORD SC_INT SC_UINT 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 SC_BIGINT SC_BIGUINT HEXA DEFINE READ TRANSLATEOFF TRANSLATEON VERILOGBEGIN VERILOGEND TAB DOLLAR INTCONV
%token HEXA DEFINE READ TRANSLATEOFF TRANSLATEON VERILOGBEGIN VERILOGEND TAB DOLLAR INTCONV
%token VOID TTRUE TFALSE
%token VOID TTRUE TFALSE ENDFUNC
%token PIFDEF PENDDEF PELSE
%token PIFDEF PENDDEF PELSE
 
 
%% commands:/* empty */
%% commands:/* empty */
|commands command;
|commands command;
 
 
 
 
command:
command:
 
endfunc
 
  |
  voidword
  voidword
  |
  |
  include
  include
  |
  |
  dollar
  dollar
Line 138... Line 141...
  |
  |
  tab
  tab
  |
  |
  read
  read
  |
  |
  sc_int
  sc_reg
  |
 
  sc_uint
 
  |
 
  sc_bigint
 
  |
 
  sc_biguint
 
  |
  |
  number
  number
  |
  |
  bool
  bool
  |
  |
Line 170... Line 167...
  |
  |
  range
  range
  |
  |
  openpar
  openpar
  |
  |
  closepar
  closepar | void |opencorch | closecorch | bigger | lower | switch |case_only
  |
  |case_number
  void
 
  |
 
  opencorch
 
  |
 
  closecorch
 
  |
 
  bigger
 
  |
 
  lower
 
  |
 
  switch
 
  |
 
  case_only
 
  |
 
  case_number
 
  |
  |
  case_word
  case_word
  |
  |
  case_default
  case_default
  |
  |
  break
  break
  |
    |hexa
  hexa
 
  |
  |
  definemacro
  definemacro
  |
  |
  defineword
  defineword
  |
  |
  definenumber
  definenumber
  |
  |
  translateoff
  translateoff
  |
  |
  translateon
  translateon
  |
    | verilogbegin | verilogend | ifdef | endif | pelse | ttrue | tfalse;
  verilogbegin
 
  |
 
  verilogend
 
  |
 
  ifdef
 
  |
 
  endif
 
  |
 
  pelse
 
  |
 
  ttrue
 
  |
 
  tfalse;
 
 
 
 
 
 
endfunc:
 
ENDFUNC
 
{
 
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
 
      if (processfound)
 
        {
 
          for (i = 0; i < openedkeys; i++)
 
            fprintf (file, "   ");
 
          fprintf (file, "%s = ", processname);
 
        }
 
    }
 
  else if (verilog == 1)
 
    fprintf (file, "return ");
 
};
 
 
 
 
voidword:
voidword:
VOID
VOID
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
Line 323... Line 308...
 
 
 
 
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);
Line 341... Line 324...
    }
    }
  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 CLOSEPAR
 
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
  if (translate == 1 && verilog == 0)
  if (translate == 1 && verilog == 0)
    {
    {
      strcpy (processname, (char *) $4);
      strcpy (processname, (char *) $4);
Line 358... Line 340...
  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_int:
sc_reg:
SC_INT 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)
        {
        {
          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)
};
    fprintf (file, "sc_int<%d>", $3);
 
 
 
}
 
 
 
;
 
 
 
sc_uint:
 
SC_UINT LOWER NUMBER BIGGER
 
{
 
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
 
      if (processfound)
 
        {
 
          fprintf (regs_file, "reg[%d:0] ", (-1 + $3));
 
          reg_found = 1;
 
        }
 
    }
 
  else if (verilog == 1)
 
    fprintf (file, "sc_uint<%d>", $3);
 
}
 
 
 
;
 
 
 
sc_bigint:
 
SC_BIGINT LOWER NUMBER BIGGER
 
{
 
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
 
      if (processfound)
 
        {
 
          fprintf (regs_file, "reg[%d:0] ", (-1 + $3));
 
          reg_found = 1;
 
        }
 
    }
 
  else if (verilog == 1)
 
    fprintf (file, "sc_bigint<%d> ", $3);
 
}
 
 
 
;
 
 
 
sc_biguint:
 
SC_BIGUINT LOWER NUMBER BIGGER
 
{
 
  defineparenthesis = 0;
 
  if (translate == 1 && verilog == 0)
 
    {
 
      if (processfound)
 
        {
 
          fprintf (regs_file, "reg[%d:0] ", (-1 + $3));
 
          reg_found = 1;
 
        }
 
    }
 
  else if (verilog == 1)
 
    fprintf (file, "sc_biguint<%d> ", $3);
 
}
 
 
 
;
 
 
 
bool:
bool:
BOOL
BOOL
{
{
  defineparenthesis = 0;
  defineparenthesis = 0;
Line 515... Line 438...
          strcpy (lastword, (char *) $1);
          strcpy (lastword, (char *) $1);
 
 
          if (reg_found)
          if (reg_found)
            {
            {
 
 
              regname = (char *)malloc (sizeof (char) * (strlen ((char *) $1) + 1));
              regname =
              regname2 =(char *)malloc (sizeof (char) *(strlen ((char *) $1) + strlen (processname)) + 1);
                (char *) malloc (sizeof (char) * (strlen ((char *) $1) + 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);
Line 740... Line 667...
          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, ")");
        }
        }

powered by: WebSVN 2.1.0

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