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

Subversion Repositories sc2v

[/] [sc2v/] [trunk/] [src/] [sc2v_step1.c] - Blame information for rev 39

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jcastillo
/* -----------------------------------------------------------------------------
2
 *
3 16 jcastillo
 *  SystemC to Verilog Translator v0.4
4 31 jcastillo
 *  Provided by Universidad Rey Juan Carlos
5 14 jcastillo
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  (at your option) any later version.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU Library General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU General Public License
17
 *  along with this program; if not, write to the Free Software
18
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston,MA 02111-1307, USA.
19
 */
20
 
21
#include <stdlib.h>
22
#include <stdio.h>
23
#include <math.h>
24
 
25
#include "sc2v_step1.h"
26
 
27
DefineNode *InsertDefine(DefineNode *list,char *name){
28
    DefineNode *dl;
29
 
30
        dl=(DefineNode *)malloc(sizeof(DefineNode));
31
        strcpy(dl->name,name);
32
        SGLIB_LIST_ADD(DefineNode,list,dl,next);
33
 
34
        return(list);
35
}
36
 
37
int IsDefine(DefineNode *list,char *name){
38
 
39
        DefineNode *dll;
40
        SGLIB_LIST_MAP_ON_ELEMENTS (DefineNode, list, dll, next,
41
         {
42
                 if ((strcmp (name, (char *)dll->name) == 0)) return(1);
43
     }
44
     );
45
         return(0);
46
}
47
 
48
 
49
RegNode *InsertReg(RegNode *list, char *name, char *name2){
50
 
51
        RegNode *rl;
52
 
53
        rl=(RegNode *)malloc(sizeof(RegNode));
54
        strcpy(rl->name,name);
55
        strcpy(rl->name2,name2);
56
        SGLIB_LIST_ADD(RegNode,list,rl,next);
57
        return(list);
58
 
59
}
60
 
61
 
62
/*Looks if a WORD of func.y file is a register of the process*/
63
char *
64
IsReg (RegNode *list, char *name)
65
{
66
 
67
  RegNode *rll;
68
  SGLIB_LIST_MAP_ON_ELEMENTS (RegNode, list, rll, next,
69
                              {
70
                                  if ((strcmp (name, (char *)rll->name) == 0))
71
                              {
72
                              return (rll->name2);}
73
                              }
74
  );
75
  return NULL;
76
}
77 33 jcastillo
 
78
StructNode *InsertStruct(StructNode *list, char *name, StructRegNode *reglist){
79
 
80
        StructNode *sl;
81
 
82
        sl=(StructNode *)malloc(sizeof(StructNode));
83
        strcpy(sl->name,name);
84
        sl->list=reglist;
85
        SGLIB_LIST_ADD(StructNode,list,sl,next);
86
        return(list);
87
 
88
}
89
 
90
StructRegNode *InsertStructReg(StructRegNode *list, char *name, int length){
91
 
92
        StructRegNode *sl;
93
 
94
        sl=(StructRegNode *)malloc(sizeof(StructRegNode));
95
        strcpy(sl->name,name);
96
        sl->length=length;
97
        SGLIB_LIST_ADD(StructRegNode,list,sl,next);
98
        return(list);
99
 
100
}
101
 
102
void
103
ShowStructs (StructNode * list)
104
{
105
  StructNode *sll;
106
  SGLIB_LIST_MAP_ON_ELEMENTS (StructNode, list, sll, next,
107
  {
108
        printf ("%s\n", sll->name);
109
        StructRegNode *srll;
110
        SGLIB_LIST_MAP_ON_ELEMENTS (StructRegNode,sll->list, srll,next,
111
        {
112
          printf ("\t%s %d\n",srll->name,srll->length);
113
    );}
114
  );
115
  }
116
}

powered by: WebSVN 2.1.0

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