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 |
|
|
* -----------------------------------------------------------------------------
|
7 |
|
|
* This program is free software; you can redistribute it and/or modify
|
8 |
|
|
* it under the terms of the GNU General Public License as published by
|
9 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
10 |
|
|
* (at your option) any later version.
|
11 |
|
|
*
|
12 |
|
|
* This program is distributed in the hope that it will be useful,
|
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
|
|
* GNU Library General Public License for more details.
|
16 |
|
|
*
|
17 |
|
|
* You should have received a copy of the GNU General Public License
|
18 |
|
|
* along with this program; if not, write to the Free Software
|
19 |
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
20 |
|
|
*/
|
21 |
|
|
|
22 |
|
|
#include "sglib.h"
|
23 |
|
|
|
24 |
|
|
#define MAX_NAME_LENGTH 256
|
25 |
|
|
|
26 |
|
|
typedef struct _write_node
|
27 |
|
|
{
|
28 |
|
|
char name[MAX_NAME_LENGTH];
|
29 |
|
|
struct _write_node *next;
|
30 |
|
|
} WriteNode;
|
31 |
|
|
|
32 |
|
|
typedef struct _port_node
|
33 |
|
|
{
|
34 |
|
|
char name[MAX_NAME_LENGTH];
|
35 |
|
|
char tipo[MAX_NAME_LENGTH];
|
36 |
|
|
int size;
|
37 |
|
|
struct _port_node *next;
|
38 |
|
|
} PortNode;
|
39 |
|
|
|
40 |
|
|
typedef struct _signal_node
|
41 |
|
|
{
|
42 |
|
|
char name[MAX_NAME_LENGTH];
|
43 |
|
|
int size;
|
44 |
20 |
jcastillo |
int arraysize;
|
45 |
14 |
jcastillo |
struct _signal_node *next;
|
46 |
|
|
} SignalNode;
|
47 |
|
|
|
48 |
|
|
typedef struct _bind_node
|
49 |
|
|
{
|
50 |
|
|
char nameport[MAX_NAME_LENGTH];
|
51 |
|
|
char namebind[MAX_NAME_LENGTH];
|
52 |
|
|
struct _bind_node *next;
|
53 |
|
|
} BindNode;
|
54 |
|
|
|
55 |
|
|
typedef struct _instance_node
|
56 |
|
|
{
|
57 |
|
|
char nameinstance[MAX_NAME_LENGTH];
|
58 |
|
|
char namemodulo[MAX_NAME_LENGTH];
|
59 |
|
|
BindNode *bindslist;
|
60 |
|
|
struct _instance_node *next;
|
61 |
|
|
} InstanceNode;
|
62 |
|
|
|
63 |
16 |
jcastillo |
typedef struct _funcinput_node
|
64 |
|
|
{
|
65 |
|
|
int lenght;
|
66 |
|
|
char name[MAX_NAME_LENGTH];
|
67 |
|
|
struct _funcinput_node *next;
|
68 |
|
|
} FunctionInputNode;
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
typedef struct _function_node
|
72 |
|
|
{
|
73 |
|
|
char name[MAX_NAME_LENGTH];
|
74 |
|
|
int outputlenght;
|
75 |
|
|
FunctionInputNode *list;
|
76 |
|
|
struct _function_node *next;
|
77 |
|
|
} FunctionNode;
|
78 |
|
|
|
79 |
14 |
jcastillo |
typedef struct _sensibility_node
|
80 |
|
|
{
|
81 |
|
|
char tipo[MAX_NAME_LENGTH];
|
82 |
|
|
char name[MAX_NAME_LENGTH];
|
83 |
|
|
struct _sensibility_node *next;
|
84 |
|
|
} SensibilityNode;
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
typedef struct _process_node
|
88 |
|
|
{
|
89 |
|
|
char name[MAX_NAME_LENGTH];
|
90 |
|
|
char tipo[MAX_NAME_LENGTH]; //comb or seq
|
91 |
|
|
SensibilityNode *list;
|
92 |
|
|
struct _process_node *next;
|
93 |
|
|
} ProcessNode;
|
94 |
|
|
|
95 |
|
|
typedef struct _enumerates_node
|
96 |
|
|
{
|
97 |
|
|
char name[MAX_NAME_LENGTH];
|
98 |
|
|
struct _enumerates_node *next;
|
99 |
|
|
} EnumeratesNode;
|
100 |
|
|
|
101 |
|
|
typedef struct _enumlist_node
|
102 |
|
|
{
|
103 |
|
|
char name[MAX_NAME_LENGTH];
|
104 |
|
|
int istype;
|
105 |
|
|
EnumeratesNode *list;
|
106 |
|
|
struct _enumlist_node *next;
|
107 |
|
|
} EnumListNode;
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
/*Global var to read from file_writes.sc2v*/
|
111 |
|
|
WriteNode *writeslist;
|
112 |
|
|
/*Global var to store ports*/
|
113 |
|
|
PortNode *portlist;
|
114 |
|
|
/* Global var to store signals*/
|
115 |
|
|
SignalNode *signalslist;
|
116 |
|
|
/* Global var to store sensitivity list*/
|
117 |
|
|
SensibilityNode *sensibilitylist;
|
118 |
|
|
/* Global var to store process list*/
|
119 |
|
|
ProcessNode *processlist;
|
120 |
|
|
/* Global var to store instantiated modules*/
|
121 |
|
|
InstanceNode *instanceslist;
|
122 |
|
|
/*List of enumerates*/
|
123 |
|
|
EnumeratesNode *enumerateslist;
|
124 |
|
|
EnumListNode *enumlistlist;
|
125 |
16 |
jcastillo |
/* Global var to store functions inputs list*/
|
126 |
|
|
FunctionInputNode *funcinputslist;
|
127 |
|
|
/* Global var to store process list*/
|
128 |
|
|
FunctionNode *functionslist;
|
129 |
14 |
jcastillo |
|
130 |
16 |
jcastillo |
|
131 |
|
|
|
132 |
14 |
jcastillo |
/* Functions for DEFINES list*/
|
133 |
|
|
void ShowDefines (char *filedefines);
|
134 |
|
|
|
135 |
|
|
/* Functions for WRITES list*/
|
136 |
|
|
WriteNode *InsertWrite (WriteNode *list,char *name);
|
137 |
|
|
int IsWrite (WriteNode *list,char *name);
|
138 |
|
|
WriteNode *ReadWritesFile (WriteNode *list,char *name);
|
139 |
|
|
|
140 |
|
|
/* Functions for ports list*/
|
141 |
|
|
PortNode *InsertPort (PortNode *list,char *name, char *tipo, int size);
|
142 |
|
|
void ShowPortList (PortNode *list);
|
143 |
|
|
void EnumeratePorts (PortNode *list);
|
144 |
|
|
|
145 |
|
|
/* Functions for signals list*/
|
146 |
20 |
jcastillo |
SignalNode *InsertSignal (SignalNode *list,char *name, int size,int arraysize);
|
147 |
15 |
jcastillo |
void ShowSignalsList (SignalNode* list, WriteNode* writeslist);
|
148 |
14 |
jcastillo |
int IsWire (char *name, InstanceNode * list);
|
149 |
|
|
|
150 |
|
|
/* Functions for sensitivity list*/
|
151 |
|
|
SensibilityNode *InsertSensibility (SensibilityNode * list, char *name, char *tipo);
|
152 |
|
|
void ShowSensibilityList (SensibilityNode * list);
|
153 |
|
|
|
154 |
|
|
/* Functions for process list*/
|
155 |
|
|
ProcessNode *InsertProcess (ProcessNode * list, char *name,SensibilityNode *SensibilityList, char *tipo);
|
156 |
|
|
void ShowProcessList (ProcessNode *list);
|
157 |
|
|
void ShowProcessCode (ProcessNode *list);
|
158 |
|
|
|
159 |
|
|
/* Functions for instances and binds list*/
|
160 |
|
|
InstanceNode *InsertInstance (InstanceNode *list, char *nameInstance,char *namemodulo);
|
161 |
|
|
BindNode *InsertBind (BindNode *list, char *namePort, char *namebind);
|
162 |
|
|
void ShowInstancedModules (InstanceNode * list);
|
163 |
|
|
|
164 |
|
|
/* Functions for enumerates list*/
|
165 |
|
|
EnumeratesNode *InsertEnumerates (EnumeratesNode * list, char *name);
|
166 |
|
|
int ShowEnumeratesList (EnumeratesNode * list);
|
167 |
|
|
|
168 |
|
|
/*Functions of list of enumerates list*/
|
169 |
|
|
EnumListNode *InsertEnumList (EnumListNode * list, EnumeratesNode * enumlist,char *name, int istype);
|
170 |
|
|
void ShowEnumListList (EnumListNode * list);
|
171 |
|
|
int findEnumList (EnumListNode * list, char *name);
|
172 |
|
|
int findEnumerateLength (EnumListNode * list, int offset);
|
173 |
16 |
jcastillo |
|
174 |
|
|
/* Functions for functions inputs list*/
|
175 |
|
|
FunctionInputNode *InsertFunctionInput (FunctionInputNode * list, char *name, int lenght);
|
176 |
|
|
void ShowFunctionInputs (FunctionInputNode * list);
|
177 |
|
|
|
178 |
|
|
/* Functions for functions list*/
|
179 |
|
|
FunctionNode *InsertFunction (FunctionNode *list, char *name,FunctionInputNode *InputsList,int outputlenght);
|
180 |
|
|
void ShowFunctionCode (FunctionNode *list);
|