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