| 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 |
35 |
jcastillo |
int pflag;
|
| 39 |
14 |
jcastillo |
} PortNode;
|
| 40 |
|
|
|
| 41 |
|
|
typedef struct _signal_node
|
| 42 |
|
|
{
|
| 43 |
|
|
char name[MAX_NAME_LENGTH];
|
| 44 |
|
|
int size;
|
| 45 |
20 |
jcastillo |
int arraysize;
|
| 46 |
14 |
jcastillo |
struct _signal_node *next;
|
| 47 |
35 |
jcastillo |
int sflag;
|
| 48 |
14 |
jcastillo |
} SignalNode;
|
| 49 |
|
|
|
| 50 |
|
|
typedef struct _bind_node
|
| 51 |
|
|
{
|
| 52 |
|
|
char nameport[MAX_NAME_LENGTH];
|
| 53 |
|
|
char namebind[MAX_NAME_LENGTH];
|
| 54 |
|
|
struct _bind_node *next;
|
| 55 |
|
|
} BindNode;
|
| 56 |
|
|
|
| 57 |
|
|
typedef struct _instance_node
|
| 58 |
|
|
{
|
| 59 |
|
|
char nameinstance[MAX_NAME_LENGTH];
|
| 60 |
|
|
char namemodulo[MAX_NAME_LENGTH];
|
| 61 |
|
|
BindNode *bindslist;
|
| 62 |
|
|
struct _instance_node *next;
|
| 63 |
|
|
} InstanceNode;
|
| 64 |
|
|
|
| 65 |
16 |
jcastillo |
typedef struct _funcinput_node
|
| 66 |
|
|
{
|
| 67 |
|
|
int lenght;
|
| 68 |
|
|
char name[MAX_NAME_LENGTH];
|
| 69 |
|
|
struct _funcinput_node *next;
|
| 70 |
35 |
jcastillo |
int sgnflag;
|
| 71 |
16 |
jcastillo |
} FunctionInputNode;
|
| 72 |
|
|
|
| 73 |
|
|
|
| 74 |
|
|
typedef struct _function_node
|
| 75 |
|
|
{
|
| 76 |
|
|
char name[MAX_NAME_LENGTH];
|
| 77 |
|
|
int outputlenght;
|
| 78 |
|
|
FunctionInputNode *list;
|
| 79 |
|
|
struct _function_node *next;
|
| 80 |
35 |
jcastillo |
int sgnflag;
|
| 81 |
16 |
jcastillo |
} FunctionNode;
|
| 82 |
|
|
|
| 83 |
14 |
jcastillo |
typedef struct _sensibility_node
|
| 84 |
|
|
{
|
| 85 |
|
|
char tipo[MAX_NAME_LENGTH];
|
| 86 |
|
|
char name[MAX_NAME_LENGTH];
|
| 87 |
|
|
struct _sensibility_node *next;
|
| 88 |
|
|
} SensibilityNode;
|
| 89 |
|
|
|
| 90 |
|
|
|
| 91 |
|
|
typedef struct _process_node
|
| 92 |
|
|
{
|
| 93 |
|
|
char name[MAX_NAME_LENGTH];
|
| 94 |
|
|
char tipo[MAX_NAME_LENGTH]; //comb or seq
|
| 95 |
|
|
SensibilityNode *list;
|
| 96 |
|
|
struct _process_node *next;
|
| 97 |
|
|
} ProcessNode;
|
| 98 |
|
|
|
| 99 |
|
|
typedef struct _enumerates_node
|
| 100 |
|
|
{
|
| 101 |
|
|
char name[MAX_NAME_LENGTH];
|
| 102 |
|
|
struct _enumerates_node *next;
|
| 103 |
|
|
} EnumeratesNode;
|
| 104 |
|
|
|
| 105 |
|
|
typedef struct _enumlist_node
|
| 106 |
|
|
{
|
| 107 |
|
|
char name[MAX_NAME_LENGTH];
|
| 108 |
|
|
int istype;
|
| 109 |
|
|
EnumeratesNode *list;
|
| 110 |
|
|
struct _enumlist_node *next;
|
| 111 |
|
|
} EnumListNode;
|
| 112 |
|
|
|
| 113 |
|
|
|
| 114 |
|
|
/*Global var to read from file_writes.sc2v*/
|
| 115 |
|
|
WriteNode *writeslist;
|
| 116 |
|
|
/*Global var to store ports*/
|
| 117 |
|
|
PortNode *portlist;
|
| 118 |
|
|
/* Global var to store signals*/
|
| 119 |
|
|
SignalNode *signalslist;
|
| 120 |
|
|
/* Global var to store sensitivity list*/
|
| 121 |
|
|
SensibilityNode *sensibilitylist;
|
| 122 |
|
|
/* Global var to store process list*/
|
| 123 |
|
|
ProcessNode *processlist;
|
| 124 |
|
|
/* Global var to store instantiated modules*/
|
| 125 |
|
|
InstanceNode *instanceslist;
|
| 126 |
|
|
/*List of enumerates*/
|
| 127 |
|
|
EnumeratesNode *enumerateslist;
|
| 128 |
|
|
EnumListNode *enumlistlist;
|
| 129 |
16 |
jcastillo |
/* Global var to store functions inputs list*/
|
| 130 |
|
|
FunctionInputNode *funcinputslist;
|
| 131 |
|
|
/* Global var to store process list*/
|
| 132 |
|
|
FunctionNode *functionslist;
|
| 133 |
14 |
jcastillo |
|
| 134 |
16 |
jcastillo |
|
| 135 |
|
|
|
| 136 |
14 |
jcastillo |
/* Functions for DEFINES list*/
|
| 137 |
|
|
void ShowDefines (char *filedefines);
|
| 138 |
|
|
|
| 139 |
|
|
/* Functions for WRITES list*/
|
| 140 |
|
|
WriteNode *InsertWrite (WriteNode *list,char *name);
|
| 141 |
|
|
int IsWrite (WriteNode *list,char *name);
|
| 142 |
|
|
WriteNode *ReadWritesFile (WriteNode *list,char *name);
|
| 143 |
|
|
|
| 144 |
|
|
/* Functions for ports list*/
|
| 145 |
35 |
jcastillo |
PortNode *InsertPort (PortNode *list,char *name, char *tipo, int size, int pflag);
|
| 146 |
14 |
jcastillo |
void ShowPortList (PortNode *list);
|
| 147 |
|
|
void EnumeratePorts (PortNode *list);
|
| 148 |
|
|
|
| 149 |
|
|
/* Functions for signals list*/
|
| 150 |
35 |
jcastillo |
SignalNode *InsertSignal (SignalNode *list,char *name, int size,int arraysize,int sflag);
|
| 151 |
15 |
jcastillo |
void ShowSignalsList (SignalNode* list, WriteNode* writeslist);
|
| 152 |
14 |
jcastillo |
int IsWire (char *name, InstanceNode * list);
|
| 153 |
|
|
|
| 154 |
|
|
/* Functions for sensitivity list*/
|
| 155 |
|
|
SensibilityNode *InsertSensibility (SensibilityNode * list, char *name, char *tipo);
|
| 156 |
|
|
void ShowSensibilityList (SensibilityNode * list);
|
| 157 |
|
|
|
| 158 |
|
|
/* Functions for process list*/
|
| 159 |
|
|
ProcessNode *InsertProcess (ProcessNode * list, char *name,SensibilityNode *SensibilityList, char *tipo);
|
| 160 |
|
|
void ShowProcessList (ProcessNode *list);
|
| 161 |
|
|
void ShowProcessCode (ProcessNode *list);
|
| 162 |
|
|
|
| 163 |
|
|
/* Functions for instances and binds list*/
|
| 164 |
|
|
InstanceNode *InsertInstance (InstanceNode *list, char *nameInstance,char *namemodulo);
|
| 165 |
|
|
BindNode *InsertBind (BindNode *list, char *namePort, char *namebind);
|
| 166 |
|
|
void ShowInstancedModules (InstanceNode * list);
|
| 167 |
|
|
|
| 168 |
|
|
/* Functions for enumerates list*/
|
| 169 |
|
|
EnumeratesNode *InsertEnumerates (EnumeratesNode * list, char *name);
|
| 170 |
|
|
int ShowEnumeratesList (EnumeratesNode * list);
|
| 171 |
|
|
|
| 172 |
|
|
/*Functions of list of enumerates list*/
|
| 173 |
|
|
EnumListNode *InsertEnumList (EnumListNode * list, EnumeratesNode * enumlist,char *name, int istype);
|
| 174 |
|
|
void ShowEnumListList (EnumListNode * list);
|
| 175 |
|
|
int findEnumList (EnumListNode * list, char *name);
|
| 176 |
|
|
int findEnumerateLength (EnumListNode * list, int offset);
|
| 177 |
16 |
jcastillo |
|
| 178 |
|
|
/* Functions for functions inputs list*/
|
| 179 |
35 |
jcastillo |
FunctionInputNode *InsertFunctionInput (FunctionInputNode * list, char *name, int lenght, int flag);
|
| 180 |
16 |
jcastillo |
void ShowFunctionInputs (FunctionInputNode * list);
|
| 181 |
|
|
|
| 182 |
|
|
/* Functions for functions list*/
|
| 183 |
35 |
jcastillo |
FunctionNode *InsertFunction (FunctionNode *list, char *name,FunctionInputNode *InputsList,int outputlenght,int flag);
|
| 184 |
16 |
jcastillo |
void ShowFunctionCode (FunctionNode *list);
|