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

Subversion Repositories sc2v

[/] [sc2v/] [trunk/] [src/] [sc2v_step1.c] - Diff between revs 33 and 36

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 33 Rev 36
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
 *
 *
 *  SystemC to Verilog Translator v0.4
 *  SystemC to Verilog Translator v0.4
 *  Provided by Universidad Rey Juan Carlos
 *  Provided by Universidad Rey Juan Carlos
 *
 *
 *  This program is free software; you can redistribute it and/or modify
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *  (at your option) any later version.
 *
 *
 *  This program is distributed in the hope that it will be useful,
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *  GNU Library General Public License for more details.
 *
 *
 *  You should have received a copy of the GNU General Public License
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston,MA 02111-1307, USA.
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston,MA 02111-1307, USA.
 */
 */
 
 
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#include <math.h>
#include <math.h>
 
 
#include "sc2v_step1.h"
#include "sc2v_step1.h"
 
 
DefineNode *InsertDefine(DefineNode *list,char *name){
DefineNode *InsertDefine(DefineNode *list,char *name){
    DefineNode *dl;
    DefineNode *dl;
 
 
        dl=(DefineNode *)malloc(sizeof(DefineNode));
        dl=(DefineNode *)malloc(sizeof(DefineNode));
        strcpy(dl->name,name);
        strcpy(dl->name,name);
        SGLIB_LIST_ADD(DefineNode,list,dl,next);
        SGLIB_LIST_ADD(DefineNode,list,dl,next);
 
 
        return(list);
        return(list);
}
}
 
 
int IsDefine(DefineNode *list,char *name){
int IsDefine(DefineNode *list,char *name){
 
 
        DefineNode *dll;
        DefineNode *dll;
        SGLIB_LIST_MAP_ON_ELEMENTS (DefineNode, list, dll, next,
        SGLIB_LIST_MAP_ON_ELEMENTS (DefineNode, list, dll, next,
         {
         {
                 if ((strcmp (name, (char *)dll->name) == 0)) return(1);
                 if ((strcmp (name, (char *)dll->name) == 0)) return(1);
     }
     }
     );
     );
         return(0);
         return(0);
}
}
 
 
 
 
RegNode *InsertReg(RegNode *list, char *name, char *name2){
RegNode *InsertReg(RegNode *list, char *name, char *name2){
 
 
        RegNode *rl;
        RegNode *rl;
 
 
        rl=(RegNode *)malloc(sizeof(RegNode));
        rl=(RegNode *)malloc(sizeof(RegNode));
        strcpy(rl->name,name);
        strcpy(rl->name,name);
        strcpy(rl->name2,name2);
        strcpy(rl->name2,name2);
        SGLIB_LIST_ADD(RegNode,list,rl,next);
        SGLIB_LIST_ADD(RegNode,list,rl,next);
        return(list);
        return(list);
 
 
}
}
 
 
 
 
/*Looks if a WORD of func.y file is a register of the process*/
/*Looks if a WORD of func.y file is a register of the process*/
char *
char *
IsReg (RegNode *list, char *name)
IsReg (RegNode *list, char *name)
{
{
 
 
  RegNode *rll;
  RegNode *rll;
  SGLIB_LIST_MAP_ON_ELEMENTS (RegNode, list, rll, next,
  SGLIB_LIST_MAP_ON_ELEMENTS (RegNode, list, rll, next,
                              {
                              {
                                  if ((strcmp (name, (char *)rll->name) == 0))
                                  if ((strcmp (name, (char *)rll->name) == 0))
                              {
                              {
                              return (rll->name2);}
                              return (rll->name2);}
                              }
                              }
  );
  );
  return NULL;
  return NULL;
}
}
 
 
StructNode *InsertStruct(StructNode *list, char *name, StructRegNode *reglist){
StructNode *InsertStruct(StructNode *list, char *name, StructRegNode *reglist){
 
 
        StructNode *sl;
        StructNode *sl;
 
 
        sl=(StructNode *)malloc(sizeof(StructNode));
        sl=(StructNode *)malloc(sizeof(StructNode));
        strcpy(sl->name,name);
        strcpy(sl->name,name);
        sl->list=reglist;
        sl->list=reglist;
        SGLIB_LIST_ADD(StructNode,list,sl,next);
        SGLIB_LIST_ADD(StructNode,list,sl,next);
        return(list);
        return(list);
 
 
}
}
 
 
StructRegNode *InsertStructReg(StructRegNode *list, char *name, int length){
StructRegNode *InsertStructReg(StructRegNode *list, char *name, int length){
 
 
        StructRegNode *sl;
        StructRegNode *sl;
 
 
        sl=(StructRegNode *)malloc(sizeof(StructRegNode));
        sl=(StructRegNode *)malloc(sizeof(StructRegNode));
        strcpy(sl->name,name);
        strcpy(sl->name,name);
        sl->length=length;
        sl->length=length;
        SGLIB_LIST_ADD(StructRegNode,list,sl,next);
        SGLIB_LIST_ADD(StructRegNode,list,sl,next);
        return(list);
        return(list);
 
 
}
}
 
 
void
void
ShowStructs (StructNode * list)
ShowStructs (StructNode * list)
{
{
  StructNode *sll;
  StructNode *sll;
  SGLIB_LIST_MAP_ON_ELEMENTS (StructNode, list, sll, next,
  SGLIB_LIST_MAP_ON_ELEMENTS (StructNode, list, sll, next,
  {
  {
        printf ("%s\n", sll->name);
        printf ("%s\n", sll->name);
        StructRegNode *srll;
        StructRegNode *srll;
        SGLIB_LIST_MAP_ON_ELEMENTS (StructRegNode,sll->list, srll,next,
        SGLIB_LIST_MAP_ON_ELEMENTS (StructRegNode,sll->list, srll,next,
        {
        {
          printf ("\t%s %d\n",srll->name,srll->length);
          printf ("\t%s %d\n",srll->name,srll->length);
    );}
    );}
  );
  );
  }
  }
}
}
 
 

powered by: WebSVN 2.1.0

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