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

Subversion Repositories sc2v

[/] [sc2v/] [trunk/] [src/] [sc2v_step2.y] - Diff between revs 32 and 35

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

Rev 32 Rev 35
Line 45... Line 45...
 
 
/* Global var to store last port type*/
/* Global var to store last port type*/
  char *lastportkind;
  char *lastportkind;
  int lastportsize;
  int lastportsize;
  int activeport = 0;           // 1 -> reading port list
  int activeport = 0;           // 1 -> reading port list
 
  int portsign ;
 
 
/* Global var to store last signal type*/
/* Global var to store last signal type*/
  int lastsignalsize;
  int lastsignalsize;
  int signalactive = 0;
  int signalactive = 0;
 
  int signalsign ;
 
 
 
 
/* Global var to store last SC_METHOD found*/
/* Global var to store last SC_METHOD found*/
  char *active_method;
  char *active_method;
  char *active_method_type;
  char *active_method_type;
Line 64... Line 66...
  int sensibility_active = 0;
  int sensibility_active = 0;
 
 
/* Global var to store last function found*/
/* Global var to store last function found*/
  char *functionname;
  char *functionname;
  int outputlenght = 0;
  int outputlenght = 0;
 
  int fsgnflag = 0;
 
 
  int translate;
  int translate;
 
 
 
 
  void yyerror (const char *str)
  void yyerror (const char *str)
Line 95... Line 98...
    funcinputslist = NULL;
    funcinputslist = NULL;
    functionslist = NULL;
    functionslist = NULL;
 
 
    translate = 1;
    translate = 1;
 
 
    fprintf (stderr, "\nSystemC to Verilog Translator v0.4\n\n");
    fprintf (stderr, "\nSystemC to Verilog Translator v0.6\n\n");
    fprintf (stderr, "Parsing header file.......\n\n");
    fprintf (stderr, "Parsing header file.......\n\n");
 
 
    FILE *yyin = stdin;
    FILE *yyin = stdin;
    FILE *yyout = stdout;
    FILE *yyout = stdout;
 
 
Line 137... Line 140...
    fprintf (stderr, "\nDone\n");
    fprintf (stderr, "\nDone\n");
  }
  }
 
 
%}
%}
 
 
%token NUMBER SC_MODULE WORD OPENPAR CLOSEPAR SC_IN SC_OUT SEMICOLON BOOL ENUM
%token NUMBER SC_MODULE WORD OPENPAR CLOSEPAR SC_IN SC_OUT BOOL ENUM
%token MENOR MAYOR SC_REG SC_METHOD SENSITIVE_POS SENSITIVE_NEG SENSITIVE
%token MENOR MAYOR SC_REG SC_SGNREG SC_METHOD SENSITIVE_POS SENSITIVE_NEG SENSITIVE
%token SENSIBLE CLOSEKEY OPENKEY SEMICOLON COLON SC_SIGNAL ARROW EQUALS NEW QUOTE
%token SENSIBLE CLOSEKEY OPENKEY SEMICOLON COLON SC_SIGNAL ARROW EQUALS NEW QUOTE
%token SC_CTOR VOID ASTERISCO TRANSLATEON TRANSLATEOFF OPENCORCH CLOSECORCH
%token SC_CTOR VOID ASTERISCO TRANSLATEON TRANSLATEOFF OPENCORCH CLOSECORCH
 
 
%% commands:    /* empty */
%% commands:    /* empty */
|commands command;
|commands command;
Line 152... Line 155...
  |
  |
  in_bool
  in_bool
  |
  |
  in_sc_reg
  in_sc_reg
  |
  |
 
  in_sc_reg_sgn
 
  |
  out_bool
  out_bool
  |
  |
  out_sc_reg
  out_sc_reg
  |
  |
 
   out_sc_reg_sgn
 
  |
  sc_method
  sc_method
  |
  |
  sensitive_pos
  sensitive_pos
  |
  |
  sensitive_neg
  sensitive_neg
Line 188... Line 195...
  |
  |
  signal_bool
  signal_bool
  |
  |
  signal_reg
  signal_reg
  |
  |
 
  signal_reg_sgn
 
  |
  instantation
  instantation
  |
  |
  port_binding
  port_binding
  |
  |
  sc_ctor
  sc_ctor
Line 228... Line 237...
  |
  |
  functioninputs
  functioninputs
  |
  |
  finishfunctioninputs
  finishfunctioninputs
  |
  |
 
  function_sgn
 
  |
 
  functioninputs_sgn
 
  |
 
  finishfunctioninputs_sgn
 
  |
  boolfunction
  boolfunction
  |
  |
  boolfunctioninputs
  boolfunctioninputs
  |
  |
  arraycolon
  arraycolon
Line 271... Line 286...
  if (translate == 1)
  if (translate == 1)
    {
    {
      activeport = 1;
      activeport = 1;
      lastportsize = $5;
      lastportsize = $5;
      lastportkind = (char *) "input";
      lastportkind = (char *) "input";
 
      portsign = 0;
 
    }
 
};
 
 
 
in_sc_reg_sgn:
 
SC_IN MENOR SC_SGNREG MENOR NUMBER MAYOR MAYOR
 
{
 
  if (translate == 1)
 
    {
 
      activeport = 1;
 
      lastportsize = $5;
 
      lastportkind = (char *) "input";
 
      portsign = 1;
    }
    }
};
};
 
 
 
 
in_bool:
in_bool:
Line 283... Line 311...
  if (translate == 1)
  if (translate == 1)
    {
    {
      activeport = 1;
      activeport = 1;
      lastportsize = 0;
      lastportsize = 0;
      lastportkind = (char *) "input";
      lastportkind = (char *) "input";
 
      portsign = 0;
    }
    }
};
};
 
 
 
 
signal_bool:
signal_bool:
Line 305... Line 334...
{
{
  if (translate == 1)
  if (translate == 1)
    {
    {
      signalactive = 1;
      signalactive = 1;
      lastsignalsize = $5;
      lastsignalsize = $5;
 
      signalsign = 0;
 
    }
 
};
 
 
 
signal_reg_sgn:
 
SC_SIGNAL MENOR SC_SGNREG MENOR NUMBER MAYOR MAYOR
 
{
 
  if (translate == 1)
 
    {
 
      signalactive = 1;
 
      lastsignalsize = $5;
 
      signalsign = 1;
    }
    }
};
};
 
 
out_bool:
out_bool:
SC_OUT MENOR BOOL MAYOR
SC_OUT MENOR BOOL MAYOR
Line 316... Line 357...
  if (translate == 1)
  if (translate == 1)
    {
    {
      activeport = 1;
      activeport = 1;
      lastportsize = 0;
      lastportsize = 0;
      lastportkind = (char *) "output";
      lastportkind = (char *) "output";
 
      portsign = 0;
    }
    }
};
};
 
 
out_sc_reg:
out_sc_reg:
SC_OUT MENOR SC_REG MENOR NUMBER MAYOR MAYOR
SC_OUT MENOR SC_REG MENOR NUMBER MAYOR MAYOR
Line 327... Line 369...
  if (translate == 1)
  if (translate == 1)
    {
    {
      activeport = 1;
      activeport = 1;
      lastportsize = $5;
      lastportsize = $5;
      lastportkind = (char *) "output";
      lastportkind = (char *) "output";
 
      portsign = 0;
 
    }
 
 
 
};
 
 
 
out_sc_reg_sgn:
 
SC_OUT MENOR SC_SGNREG MENOR NUMBER MAYOR MAYOR
 
{
 
  if (translate == 1)
 
    {
 
      activeport = 1;
 
      lastportsize = $5;
 
      lastportkind = (char *) "output";
 
      portsign = 1;
    }
    }
 
 
};
};
 
 
 
 
Line 476... Line 532...
arraysemicolon:
arraysemicolon:
WORD OPENCORCH NUMBER CLOSECORCH SEMICOLON
WORD OPENCORCH NUMBER CLOSECORCH SEMICOLON
{
{
if (signalactive)
if (signalactive)
        {
        {
          signalslist = InsertSignal (signalslist, (char *) $1, lastsignalsize,$3);
          signalslist = InsertSignal (signalslist, (char *) $1, lastsignalsize,$3, signalsign);
          signalactive = 0;
          signalactive = 0;
        }
        }
}
}
 
 
arraycolon:
arraycolon:
WORD OPENCORCH NUMBER CLOSECORCH COLON
WORD OPENCORCH NUMBER CLOSECORCH COLON
{
{
if (signalactive)
if (signalactive)
        {
        {
          signalslist = InsertSignal (signalslist, (char *) $1, lastsignalsize,$3);
          signalslist = InsertSignal (signalslist, (char *) $1, lastsignalsize,$3,signalsign);
          signalactive = 0;
          signalactive = 0;
        }
        }
}
}
 
 
word_semicolon:
word_semicolon:
Line 499... Line 555...
  if (translate == 1)
  if (translate == 1)
    {
    {
      if (activeport)
      if (activeport)
        {
        {
          portlist =
          portlist =
            InsertPort (portlist, (char *) $1, lastportkind, lastportsize);
            InsertPort (portlist, (char *) $1, lastportkind, lastportsize,portsign);
          activeport = 0;
          activeport = 0;
        }
        }
      else if (signalactive)
      else if (signalactive)
        {
        {
          signalslist = InsertSignal (signalslist, (char *) $1, lastsignalsize,0);
          signalslist = InsertSignal (signalslist, (char *) $1, lastsignalsize,0,signalsign);
          signalactive = 0;
          signalactive = 0;
        }
        }
      else if (multipledec)
      else if (multipledec)
        {
        {
          int length, list_pos;
          int length, list_pos;
Line 519... Line 575...
 
 
          if (list_pos > -1)
          if (list_pos > -1)
            {
            {
              //Calculate the number of bits needed to represent the enumerate
              //Calculate the number of bits needed to represent the enumerate
              length = findEnumerateLength (enumlistlist, list_pos);
              length = findEnumerateLength (enumlistlist, list_pos);
              signalslist = InsertSignal (signalslist, (char *) $1, length, 0);
              signalslist = InsertSignal (signalslist, (char *) $1, length, 0,0);
              writeslist = InsertWrite (writeslist, (char *) $1);
              writeslist = InsertWrite (writeslist, (char *) $1);
              free (storedtype);
              free (storedtype);
              multipledec = 0;
              multipledec = 0;
            }
            }
          else
          else
Line 544... Line 600...
 
 
  if (translate == 1)
  if (translate == 1)
    {
    {
      if (activeport)
      if (activeport)
        {
        {
          portlist = InsertPort (portlist, (char *) $1, lastportkind, lastportsize);
          portlist = InsertPort (portlist, (char *) $1, lastportkind, lastportsize, portsign);
        }
        }
      else if (signalactive)
      else if (signalactive)
        {
        {
          signalslist = InsertSignal (signalslist, (char *) $1, lastsignalsize, 0);
          signalslist = InsertSignal (signalslist, (char *) $1, lastsignalsize, 0,signalsign);
        }
        }
      else if (reading_enumerates)
      else if (reading_enumerates)
        {
        {
          enumerateslist = InsertEnumerates (enumerateslist, (char *) $1);
          enumerateslist = InsertEnumerates (enumerateslist, (char *) $1);
        }
        }
Line 568... Line 624...
 
 
          if (list_pos > -1)
          if (list_pos > -1)
            {
            {
              //Calculate the number of bits needed to represent the enumerate
              //Calculate the number of bits needed to represent the enumerate
              length = findEnumerateLength (enumlistlist, list_pos);
              length = findEnumerateLength (enumlistlist, list_pos);
              signalslist = InsertSignal (signalslist, (char *) $1, length, 0);
              signalslist = InsertSignal (signalslist, (char *) $1, length, 0, 0);
              writeslist = InsertWrite (writeslist, (char *) $1);
              writeslist = InsertWrite (writeslist, (char *) $1);
              multipledec = 1;
              multipledec = 1;
            }
            }
          else
          else
            {
            {
Line 786... Line 842...
 
 
      if (list_pos > -1)
      if (list_pos > -1)
        {
        {
          //Calculate the number of bits needed to represent the enumerate
          //Calculate the number of bits needed to represent the enumerate
          length = findEnumerateLength (enumlistlist, list_pos);
          length = findEnumerateLength (enumlistlist, list_pos);
          signalslist = InsertSignal (signalslist, (char *) $2, length, 0);
          signalslist = InsertSignal (signalslist, (char *) $2, length, 0,0);
          writeslist = InsertWrite (writeslist, (char *) $2);
          writeslist = InsertWrite (writeslist, (char *) $2);
        }
        }
      else
      else
        {
        {
          fprintf (stderr, "\nline: %d Type %s unknow\n", lineno,
          fprintf (stderr, "\nline: %d Type %s unknow\n", lineno,
Line 823... Line 879...
 
 
          //Calculate the number of bits needed to represent the enumerate
          //Calculate the number of bits needed to represent the enumerate
          length = findEnumerateLength (enumlistlist, list_pos);
          length = findEnumerateLength (enumlistlist, list_pos);
 
 
 
 
          signalslist = InsertSignal (signalslist, (char *) $5, length, 0);
          signalslist = InsertSignal (signalslist, (char *) $5, length, 0,signalsign);
 
 
          writeslist = InsertWrite (writeslist, (char *) $5);
          writeslist = InsertWrite (writeslist, (char *) $5);
 
 
        }
        }
      else
      else
Line 870... Line 926...
 
 
          storedtype = (char *) malloc (sizeof (char) * strlen ((char *) $1));
          storedtype = (char *) malloc (sizeof (char) * strlen ((char *) $1));
 
 
          strcpy (storedtype, (char *) $1);
          strcpy (storedtype, (char *) $1);
 
 
          signalslist = InsertSignal (signalslist, (char *) $2, length,0);
          signalslist = InsertSignal (signalslist, (char *) $2, length,0,0);
 
 
          writeslist = InsertWrite (writeslist, (char *) $2);
          writeslist = InsertWrite (writeslist, (char *) $2);
 
 
          multipledec = 1;
          multipledec = 1;
 
 
Line 908... Line 964...
        {
        {
          //Calculate the number of bits needed to represent the enumerate
          //Calculate the number of bits needed to represent the enumerate
          length = findEnumerateLength (enumlistlist, list_pos);
          length = findEnumerateLength (enumlistlist, list_pos);
          storedtype = (char *) malloc (sizeof (char) * strlen ((char *) $3));
          storedtype = (char *) malloc (sizeof (char) * strlen ((char *) $3));
          strcpy (storedtype, (char *) $3);
          strcpy (storedtype, (char *) $3);
          signalslist = InsertSignal (signalslist, (char *) $5, length, 0);
          signalslist = InsertSignal (signalslist, (char *) $5, length, 0,0);
          writeslist = InsertWrite (writeslist, (char *) $5);
          writeslist = InsertWrite (writeslist, (char *) $5);
          multipledec = 1;
          multipledec = 1;
        }
        }
      else
      else
        {
        {
Line 947... Line 1003...
  fprintf (stderr, "line: %d Found Function Declaration \n", lineno);
  fprintf (stderr, "line: %d Found Function Declaration \n", lineno);
  /* New inputs list */
  /* New inputs list */
  functionname = (char *) $5;
  functionname = (char *) $5;
  outputlenght = $3;
  outputlenght = $3;
  funcinputslist = NULL;
  funcinputslist = NULL;
 
  fsgnflag = 0;
 
};
 
 
 
function_sgn:
 
SC_SGNREG MENOR NUMBER MAYOR WORD OPENPAR
 
{
 
  fprintf (stderr, "line: %d Found {signed} Function Declaration \n", lineno);
 
  /* New inputs list */
 
  functionname = (char *) $5;
 
  outputlenght = $3;
 
  funcinputslist = NULL;
 
  fsgnflag = 1;
 
 
};
};
 
 
functioninputs:
functioninputs:
SC_REG MENOR NUMBER MAYOR WORD COLON
SC_REG MENOR NUMBER MAYOR WORD COLON
{
{
  funcinputslist = InsertFunctionInput (funcinputslist, (char *) $5, $3);
  funcinputslist = InsertFunctionInput (funcinputslist, (char *) $5, $3,0);
 
};
 
 
 
functioninputs_sgn:
 
SC_SGNREG MENOR NUMBER MAYOR WORD COLON
 
{
 
  funcinputslist = InsertFunctionInput (funcinputslist, (char *) $5, $3,1);
};
};
 
 
finishfunctioninputs:
finishfunctioninputs:
SC_REG MENOR NUMBER MAYOR WORD CLOSEPAR SEMICOLON
SC_REG MENOR NUMBER MAYOR WORD CLOSEPAR SEMICOLON
{
{
  funcinputslist = InsertFunctionInput (funcinputslist, (char *) $5, $3);
  funcinputslist = InsertFunctionInput (funcinputslist, (char *) $5, $3,0);
 
  functionslist =
 
    InsertFunction (functionslist, functionname, funcinputslist,
 
                    outputlenght,fsgnflag);
 
};
 
 
 
finishfunctioninputs_sgn:
 
SC_SGNREG MENOR NUMBER MAYOR WORD CLOSEPAR SEMICOLON
 
{
 
  funcinputslist = InsertFunctionInput (funcinputslist, (char *) $5, $3, 1);
  functionslist =
  functionslist =
    InsertFunction (functionslist, functionname, funcinputslist,
    InsertFunction (functionslist, functionname, funcinputslist,
                    outputlenght);
                    outputlenght, fsgnflag);
};
};
 
 
boolfunction:
boolfunction:
BOOL WORD OPENPAR
BOOL WORD OPENPAR
{
{
Line 977... Line 1061...
};
};
 
 
boolfunctioninputs:
boolfunctioninputs:
BOOL WORD COLON
BOOL WORD COLON
{
{
  funcinputslist = InsertFunctionInput (funcinputslist, (char *) $2, 1);
  funcinputslist = InsertFunctionInput (funcinputslist, (char *) $2,1,0);
};
};
 
 
boolfinishfunctioninputs:
boolfinishfunctioninputs:
BOOL WORD CLOSEPAR SEMICOLON
BOOL WORD CLOSEPAR SEMICOLON
{
{
  funcinputslist = InsertFunctionInput (funcinputslist, (char *) $2, 1);
  funcinputslist = InsertFunctionInput (funcinputslist, (char *) $2,1,0);
  functionslist =
  functionslist =
    InsertFunction (functionslist, functionname, funcinputslist,
    InsertFunction (functionslist, functionname, funcinputslist,
                    outputlenght);
                    outputlenght,0);
};
};

powered by: WebSVN 2.1.0

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