1 |
11 |
jcastillo |
/* -----------------------------------------------------------------------------
|
2 |
|
|
*
|
3 |
14 |
jcastillo |
* SystemC to Verilog Translator v0.3
|
4 |
11 |
jcastillo |
* 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 |
|
|
%{
|
25 |
|
|
#include
|
26 |
|
|
#include "y.tab.h"
|
27 |
|
|
|
28 |
|
|
extern int yylval;
|
29 |
|
|
|
30 |
|
|
int includefound = 0;
|
31 |
|
|
int linecomment = 0;
|
32 |
|
|
int multilinecomment = 0;
|
33 |
|
|
%}
|
34 |
|
|
|
35 |
|
|
%%
|
36 |
|
|
"\t" /* ignore whitespace */
|
37 |
|
|
" " /* ignore whitespace */
|
38 |
|
|
[0-9]+ if(!includefound & !linecomment & !multilinecomment) {
|
39 |
|
|
yylval=atoi(yytext);
|
40 |
|
|
return NUMBER;
|
41 |
|
|
}
|
42 |
|
|
SC_MODULE if(!includefound & !linecomment & !multilinecomment) return SC_MODULE;
|
43 |
|
|
SC_METHOD if(!includefound & !linecomment & !multilinecomment) return SC_METHOD;
|
44 |
|
|
SC_CTOR if(!includefound & !linecomment & !multilinecomment) return SC_CTOR;
|
45 |
|
|
"void" if(!includefound & !linecomment & !multilinecomment) return VOID;
|
46 |
|
|
sensitive_pos if(!includefound & !linecomment & !multilinecomment) return SENSITIVE_POS;
|
47 |
|
|
sensitive_neg if(!includefound & !linecomment & !multilinecomment) return SENSITIVE_NEG;
|
48 |
|
|
sensitive if(!includefound & !linecomment & !multilinecomment) return SENSITIVE;
|
49 |
|
|
"<<" if(!includefound & !linecomment & !multilinecomment) return SENSIBLE;
|
50 |
|
|
sc_in if(!includefound & !linecomment & !multilinecomment) return SC_IN;
|
51 |
|
|
sc_out if(!includefound & !linecomment & !multilinecomment) return SC_OUT;
|
52 |
|
|
sc_signal if(!includefound & !linecomment & !multilinecomment) return SC_SIGNAL;
|
53 |
|
|
"bool" if(!includefound & !linecomment & !multilinecomment) return BOOL;
|
54 |
|
|
"<" if(!includefound & !linecomment & !multilinecomment) return MENOR;
|
55 |
|
|
">" if(!includefound & !linecomment & !multilinecomment) return MAYOR;
|
56 |
|
|
sc_int if(!includefound & !linecomment & !multilinecomment) return SC_INT;
|
57 |
|
|
sc_uint if(!includefound & !linecomment & !multilinecomment) return SC_UINT;
|
58 |
|
|
sc_bigint if(!includefound & !linecomment & !multilinecomment) return SC_INT;
|
59 |
|
|
sc_biguint if(!includefound & !linecomment & !multilinecomment) return SC_UINT;
|
60 |
|
|
\( if(!includefound & !linecomment & !multilinecomment) return OPENPAR;
|
61 |
|
|
\) if(!includefound & !linecomment & !multilinecomment) return CLOSEPAR;
|
62 |
|
|
; if(!includefound & !linecomment & !multilinecomment) return SEMICOLON;
|
63 |
|
|
"enum" if(!includefound & !linecomment & !multilinecomment) return ENUM;
|
64 |
|
|
"," if(!includefound & !linecomment & !multilinecomment) return COLON;
|
65 |
|
|
"{" if(!includefound & !linecomment & !multilinecomment) return OPENKEY;
|
66 |
|
|
"}" if(!includefound & !linecomment & !multilinecomment) return CLOSEKEY;
|
67 |
|
|
"->" if(!includefound & !linecomment & !multilinecomment) return ARROW;
|
68 |
|
|
"=" if(!includefound & !linecomment & !multilinecomment) return EQUALS;
|
69 |
|
|
"new" if(!includefound & !linecomment & !multilinecomment) return NEW;
|
70 |
|
|
"\"" if(!includefound & !linecomment & !multilinecomment) return QUOTE;
|
71 |
|
|
[a-zA-Z][a-z_A-Z0-9]* if(!includefound & !linecomment & !multilinecomment) {
|
72 |
|
|
yylval=(int)strdup(yytext);
|
73 |
|
|
return WORD;
|
74 |
|
|
}
|
75 |
|
|
"*" if(!includefound & !linecomment & !multilinecomment) return ASTERISCO;
|
76 |
|
|
"\n" includefound = 0; linecomment = 0;
|
77 |
|
|
"\\\n" /* no new line */
|
78 |
|
|
"$" /* ignore */
|
79 |
|
|
"." /* ignore */
|
80 |
|
|
":" /* ignore */
|
81 |
|
|
"#include" includefound = 1;
|
82 |
|
|
"//" if (!multilinecomment) linecomment = 1;
|
83 |
|
|
"/*" if (!linecomment) multilinecomment = 1;
|
84 |
|
|
"*/" if (multilinecomment) multilinecomment = 0;
|
85 |
|
|
"/" /* ignore */
|
86 |
|
|
"-"
|
87 |
|
|
"#"
|
88 |
|
|
"@"
|
89 |
|
|
"|"
|
90 |
|
|
"~"
|
91 |
|
|
|
92 |
|
|
"//"[ ]*[tT][rR][aA][nN][sS][lL][aA][tT][eE][ ]*[oO][fF][fF] return TRANSLATEOFF; /*Translate directive*/
|
93 |
|
|
"//"[ ]*[tT][rR][aA][nN][sS][lL][aA][tT][eE][ ]*[oO][nN] return TRANSLATEON; /*Translate directive*/
|
94 |
|
|
%%
|