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

Subversion Repositories sc2v

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 8 to Rev 9
    Reverse comparison

Rev 8 → Rev 9

/trunk/sc2v.pdf Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
/trunk/ChangeLog
1,6 → 1,13
18-01-2005 Version 0.2.2
 
Contribution of Harald Devos:
Corrected bug when using keywords in comments
Adding multilines with \
 
17-01-2005 Version 0.2.1
Corrected bug in else if
Corrected bug in else if
Translate true and false into 1 and 0
 
 
/trunk/src/sc2v_step1.l
1,85 → 1,92
/* -----------------------------------------------------------------------------
*
* SystemC to Verilog Translator v0.2
* Provided by OpenSoc Design
*
* www.opensocdesign.com
*
* -----------------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
 
 
%{
#include <stdio.h>
#include "y.tab.h"
 
extern int yylval;
 
%}
 
%%
"void" return VOID;
"true" return TTRUE;
"false" return TFALSE;
[0-9]+ yylval=atoi(yytext); return NUMBER;
"::" return TWODOUBLEPOINTS;
sc_int return SC_INT;
sc_uint return SC_UINT;
sc_bigint return SC_BIGINT;
sc_biguint return SC_BIGUINT;
bool return BOOL;
">" return BIGGER;
"<" return LOWER;
"{" return OPENKEY;
"}" return CLOSEKEY;
"(" return OPENPAR;
")" return CLOSEPAR;
"[" return OPENCORCH;
"]" return CLOSECORCH;
".write" return WRITE;
"switch" return SWITCH;
"case" return CASE;
"default" return DEFAULT;
"break" return BREAK;
".read" return READ;
".range" return RANGE;
[a-zA-Z][_a-zA-Z0-9]* yylval=(int)strdup(yytext); return WORD;
[.:"^"!%()=/+*_"&""?""|""\\"] yylval=(int)strdup(yytext); return SYMBOL;
"-" yylval=(int)strdup(yytext); return SYMBOL;
"~" yylval=(int)strdup(yytext); return SYMBOL;
"@" yylval=(int)strdup(yytext); return SYMBOL;
"," return COLON;
";" return SEMICOLON;
[" "]+ /*Ignore white spaces*/
"\t" return TAB; /*Ignore Tab*/
"\n" return NEWLINE;
"0x" return HEXA;
"$" return DOLLAR; /* Ignore $ */
"(int)" return INTCONV; /* Ignore int type conversions*/
 
"#define" return DEFINE;
"#include"
"#ifdef" return PIFDEF;
"#else" return PELSE;
"#endif" return PENDDEF;
 
 
"//"[ ]*[tT][rR][aA][nN][sS][lL][aA][tT][eE][ ]*[oO][fF][fF] return TRANSLATEOFF; /*Translate directive*/
"//"[ ]*[tT][rR][aA][nN][sS][lL][aA][tT][eE][ ]*[oO][nN] return TRANSLATEON; /*Translate directive*/
"/*"[ ]*[vV][eE][rR][iI][lL][oO][gG][ ]*[bB][eE][gG][iI][nN] return VERILOGBEGIN;
[vV][eE][rR][iI][lL][oO][gG][ ]*[eE][nN][dD]"*/" return VERILOGEND;
 
%%
/* -----------------------------------------------------------------------------
*
* SystemC to Verilog Translator v0.2
* Provided by OpenSoc Design
*
* www.opensocdesign.com
*
* -----------------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
 
 
%{
#include <stdio.h>
#include "y.tab.h"
 
extern int yylval;
 
int includefound = 0;
int linecomment = 0;
int multilinecomment = 0;
%}
 
%%
"void" if(!includefound & !linecomment & !multilinecomment) return VOID; else {yylval=(int)strdup(yytext);} return WORD;
"true" if(!includefound & !linecomment & !multilinecomment) return TTRUE; else {yylval=(int)strdup(yytext);} return WORD;
"false" if(!includefound & !linecomment & !multilinecomment) return TFALSE; else {yylval=(int)strdup(yytext);} return WORD;
[0-9]+ yylval=atoi(yytext); return NUMBER;
"::" if(!includefound & !linecomment & !multilinecomment) return TWODOUBLEPOINTS; else {yylval=(int)strdup(yytext);} return WORD;
sc_int if(!includefound & !linecomment & !multilinecomment) return SC_INT; else {yylval=(int)strdup(yytext);} return WORD;
sc_uint if(!includefound & !linecomment & !multilinecomment) return SC_UINT; else {yylval=(int)strdup(yytext);} return WORD;
sc_bigint if(!includefound & !linecomment & !multilinecomment) return SC_BIGINT; else {yylval=(int)strdup(yytext);} return WORD;
sc_biguint if(!includefound & !linecomment & !multilinecomment) return SC_BIGUINT; else {yylval=(int)strdup(yytext);} return WORD;
bool if(!includefound & !linecomment & !multilinecomment) return BOOL; else {yylval=(int)strdup(yytext);} return WORD;
">" if(!includefound & !linecomment & !multilinecomment) return BIGGER; else {yylval=(int)strdup(yytext);} return WORD;
"<" if(!includefound & !linecomment & !multilinecomment) return LOWER; else {yylval=(int)strdup(yytext);} return WORD;
"{" if(!includefound & !linecomment & !multilinecomment) return OPENKEY; else {yylval=(int)strdup(yytext);} return WORD;
"}" if(!includefound & !linecomment & !multilinecomment) return CLOSEKEY; else {yylval=(int)strdup(yytext);} return WORD;
"(" if(!includefound & !linecomment & !multilinecomment) return OPENPAR; else {yylval=(int)strdup(yytext);} return WORD;
")" if(!includefound & !linecomment & !multilinecomment) return CLOSEPAR; else {yylval=(int)strdup(yytext);} return WORD;
"[" if(!includefound & !linecomment & !multilinecomment) return OPENCORCH; else {yylval=(int)strdup(yytext);} return WORD;
"]" if(!includefound & !linecomment & !multilinecomment) return CLOSECORCH; else {yylval=(int)strdup(yytext);} return WORD;
".write" if(!includefound & !linecomment & !multilinecomment) return WRITE; else {yylval=(int)strdup(yytext);} return WORD;
"switch" if(!includefound & !linecomment & !multilinecomment) return SWITCH; else {yylval=(int)strdup(yytext);} return WORD;
"case" if(!includefound & !linecomment & !multilinecomment) return CASE; else {yylval=(int)strdup(yytext);} return WORD;
"default" if(!includefound & !linecomment & !multilinecomment) return DEFAULT; else {yylval=(int)strdup(yytext);} return WORD;
"break" if(!includefound & !linecomment & !multilinecomment) return BREAK; else {yylval=(int)strdup(yytext);} return WORD;
".read" if(!includefound & !linecomment & !multilinecomment) return READ; else {yylval=(int)strdup(yytext);} return WORD;
".range" if(!includefound & !linecomment & !multilinecomment) return RANGE; else {yylval=(int)strdup(yytext);} return WORD;
[a-zA-Z][_a-zA-Z0-9]* yylval=(int)strdup(yytext); return WORD;
[.:"^"!%()=/+*_"&""?""|""\\"] yylval=(int)strdup(yytext); return SYMBOL;
"-" yylval=(int)strdup(yytext); return SYMBOL;
"~" yylval=(int)strdup(yytext); return SYMBOL;
"@" yylval=(int)strdup(yytext); return SYMBOL;
"," if(!includefound & !linecomment & !multilinecomment) return COLON; else {yylval=(int)strdup(yytext);} return WORD;
";" if(!includefound & !linecomment & !multilinecomment) return SEMICOLON; else {yylval=(int)strdup(yytext);} return WORD;
[" "]+ /*Ignore white spaces*/
"\t" return TAB; /*Ignore Tab*/
"\n" if (linecomment) linecomment=0; else if(includefound) includefound=0; return NEWLINE;
"\\\n" /* no new line */
"0x" if(!includefound & !linecomment & !multilinecomment) return HEXA; else {yylval=(int)strdup(yytext);} return WORD;
"$" if(!includefound & !linecomment & !multilinecomment) return DOLLAR; else {yylval=(int)strdup(yytext);} return WORD;/* Ignore if(!includefound & !linecomment & !multilinecomment) $ */
"(int)" if(!includefound & !linecomment & !multilinecomment) return INTCONV; else {yylval=(int)strdup(yytext);} return WORD;/* Ignore int type if(!includefound & !linecomment & !multilinecomment) conversions*/
 
"#define" if(!includefound & !linecomment & !multilinecomment) return DEFINE; else {yylval=(int)strdup(yytext);} return WORD;
"#include" includefound = 1;
"#ifdef" if(!includefound & !linecomment & !multilinecomment) return PIFDEF; else {yylval=(int)strdup(yytext);} return WORD;
"#else" if(!includefound & !linecomment & !multilinecomment) return PELSE; else {yylval=(int)strdup(yytext);} return WORD;
"#endif" if(!includefound & !linecomment & !multilinecomment) return PENDDEF; else {yylval=(int)strdup(yytext);} return WORD;
 
"//" if (!multilinecomment) linecomment = 1; yylval=(int)strdup(yytext); return WORD;
"/*" if (!linecomment) multilinecomment = 1; yylval=(int)strdup(yytext); return WORD;
"*/" if (multilinecomment) multilinecomment = 0; yylval=(int)strdup(yytext); return WORD;
 
"//"[ ]*[tT][rR][aA][nN][sS][lL][aA][tT][eE][ ]*[oO][fF][fF] return TRANSLATEOFF; /*Translate directive*/
"//"[ ]*[tT][rR][aA][nN][sS][lL][aA][tT][eE][ ]*[oO][nN] return TRANSLATEON; /*Translate directive*/
"/*"[ ]*[vV][eE][rR][iI][lL][oO][gG][ ]*[bB][eE][gG][iI][nN] return VERILOGBEGIN;
[vV][eE][rR][iI][lL][oO][gG][ ]*[eE][nN][dD]"*/" return VERILOGEND;
 
%%
/trunk/src/sc2v_step2.l
1,93 → 1,94
/* -----------------------------------------------------------------------------
*
* SystemC to Verilog Translator v0.2
* Provided by OpenSoc Design
*
* www.opensocdesign.com
*
* -----------------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
%{
#include <stdio.h>
#include "y.tab.h"
 
extern int yylval;
 
int includefound = 0;
int linecomment = 0;
int multilinecomment = 0;
%}
 
%%
"\t" /* ignore whitespace */
" " /* ignore whitespace */
[0-9]+ if(!includefound & !linecomment & !multilinecomment) {
yylval=atoi(yytext);
return NUMBER;
}
SC_MODULE if(!includefound & !linecomment & !multilinecomment) return SC_MODULE;
SC_METHOD if(!includefound & !linecomment & !multilinecomment) return SC_METHOD;
SC_CTOR if(!includefound & !linecomment & !multilinecomment) return SC_CTOR;
"void" if(!includefound & !linecomment & !multilinecomment) return VOID;
sensitive_pos if(!includefound & !linecomment & !multilinecomment) return SENSITIVE_POS;
sensitive_neg if(!includefound & !linecomment & !multilinecomment) return SENSITIVE_NEG;
sensitive if(!includefound & !linecomment & !multilinecomment) return SENSITIVE;
"<<" if(!includefound & !linecomment & !multilinecomment) return SENSIBLE;
sc_in if(!includefound & !linecomment & !multilinecomment) return SC_IN;
sc_out if(!includefound & !linecomment & !multilinecomment) return SC_OUT;
sc_signal if(!includefound & !linecomment & !multilinecomment) return SC_SIGNAL;
"bool" if(!includefound & !linecomment & !multilinecomment) return BOOL;
"<" if(!includefound & !linecomment & !multilinecomment) return MENOR;
">" if(!includefound & !linecomment & !multilinecomment) return MAYOR;
sc_int if(!includefound & !linecomment & !multilinecomment) return SC_INT;
sc_uint if(!includefound & !linecomment & !multilinecomment) return SC_UINT;
sc_bigint if(!includefound & !linecomment & !multilinecomment) return SC_INT;
sc_biguint if(!includefound & !linecomment & !multilinecomment) return SC_UINT;
\( if(!includefound & !linecomment & !multilinecomment) return OPENPAR;
\) if(!includefound & !linecomment & !multilinecomment) return CLOSEPAR;
; if(!includefound & !linecomment & !multilinecomment) return SEMICOLON;
"enum" if(!includefound & !linecomment & !multilinecomment) return ENUM;
"," if(!includefound & !linecomment & !multilinecomment) return COLON;
"{" if(!includefound & !linecomment & !multilinecomment) return OPENKEY;
"}" if(!includefound & !linecomment & !multilinecomment) return CLOSEKEY;
"->" if(!includefound & !linecomment & !multilinecomment) return ARROW;
"=" if(!includefound & !linecomment & !multilinecomment) return EQUALS;
"new" if(!includefound & !linecomment & !multilinecomment) return NEW;
"\"" if(!includefound & !linecomment & !multilinecomment) return QUOTE;
[a-zA-Z][a-z_A-Z0-9]* if(!includefound & !linecomment & !multilinecomment) {
yylval=(int)strdup(yytext);
return WORD;
}
"*" if(!includefound & !linecomment & !multilinecomment) return ASTERISCO;
"\n" includefound = 0; linecomment = 0;
"$" /* ignore */
"." /* ignore */
":" /* ignore */
"#include" includefound = 1;
"//" linecomment = 1;
"/*" multilinecomment = 1;
"*/" multilinecomment = 0;
"/" /* ignore */
"-"
"#"
"@"
"|"
"~"
 
"//"[ ]*[tT][rR][aA][nN][sS][lL][aA][tT][eE][ ]*[oO][fF][fF] return TRANSLATEOFF; /*Translate directive*/
"//"[ ]*[tT][rR][aA][nN][sS][lL][aA][tT][eE][ ]*[oO][nN] return TRANSLATEON; /*Translate directive*/
%%
/* -----------------------------------------------------------------------------
*
* SystemC to Verilog Translator v0.2
* Provided by OpenSoc Design
*
* www.opensocdesign.com
*
* -----------------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
%{
#include <stdio.h>
#include "y.tab.h"
 
extern int yylval;
 
int includefound = 0;
int linecomment = 0;
int multilinecomment = 0;
%}
 
%%
"\t" /* ignore whitespace */
" " /* ignore whitespace */
[0-9]+ if(!includefound & !linecomment & !multilinecomment) {
yylval=atoi(yytext);
return NUMBER;
}
SC_MODULE if(!includefound & !linecomment & !multilinecomment) return SC_MODULE;
SC_METHOD if(!includefound & !linecomment & !multilinecomment) return SC_METHOD;
SC_CTOR if(!includefound & !linecomment & !multilinecomment) return SC_CTOR;
"void" if(!includefound & !linecomment & !multilinecomment) return VOID;
sensitive_pos if(!includefound & !linecomment & !multilinecomment) return SENSITIVE_POS;
sensitive_neg if(!includefound & !linecomment & !multilinecomment) return SENSITIVE_NEG;
sensitive if(!includefound & !linecomment & !multilinecomment) return SENSITIVE;
"<<" if(!includefound & !linecomment & !multilinecomment) return SENSIBLE;
sc_in if(!includefound & !linecomment & !multilinecomment) return SC_IN;
sc_out if(!includefound & !linecomment & !multilinecomment) return SC_OUT;
sc_signal if(!includefound & !linecomment & !multilinecomment) return SC_SIGNAL;
"bool" if(!includefound & !linecomment & !multilinecomment) return BOOL;
"<" if(!includefound & !linecomment & !multilinecomment) return MENOR;
">" if(!includefound & !linecomment & !multilinecomment) return MAYOR;
sc_int if(!includefound & !linecomment & !multilinecomment) return SC_INT;
sc_uint if(!includefound & !linecomment & !multilinecomment) return SC_UINT;
sc_bigint if(!includefound & !linecomment & !multilinecomment) return SC_INT;
sc_biguint if(!includefound & !linecomment & !multilinecomment) return SC_UINT;
\( if(!includefound & !linecomment & !multilinecomment) return OPENPAR;
\) if(!includefound & !linecomment & !multilinecomment) return CLOSEPAR;
; if(!includefound & !linecomment & !multilinecomment) return SEMICOLON;
"enum" if(!includefound & !linecomment & !multilinecomment) return ENUM;
"," if(!includefound & !linecomment & !multilinecomment) return COLON;
"{" if(!includefound & !linecomment & !multilinecomment) return OPENKEY;
"}" if(!includefound & !linecomment & !multilinecomment) return CLOSEKEY;
"->" if(!includefound & !linecomment & !multilinecomment) return ARROW;
"=" if(!includefound & !linecomment & !multilinecomment) return EQUALS;
"new" if(!includefound & !linecomment & !multilinecomment) return NEW;
"\"" if(!includefound & !linecomment & !multilinecomment) return QUOTE;
[a-zA-Z][a-z_A-Z0-9]* if(!includefound & !linecomment & !multilinecomment) {
yylval=(int)strdup(yytext);
return WORD;
}
"*" if(!includefound & !linecomment & !multilinecomment) return ASTERISCO;
"\n" includefound = 0; linecomment = 0;
"\\\n" /* no new line */
"$" /* ignore */
"." /* ignore */
":" /* ignore */
"#include" includefound = 1;
"//" if (!multilinecomment) linecomment = 1;
"/*" if (!linecomment) multilinecomment = 1;
"*/" if (multilinecomment) multilinecomment = 0;
"/" /* ignore */
"-"
"#"
"@"
"|"
"~"
 
"//"[ ]*[tT][rR][aA][nN][sS][lL][aA][tT][eE][ ]*[oO][fF][fF] return TRANSLATEOFF; /*Translate directive*/
"//"[ ]*[tT][rR][aA][nN][sS][lL][aA][tT][eE][ ]*[oO][nN] return TRANSLATEON; /*Translate directive*/
%%
/trunk/Makefile
18,7 → 18,7
 
test:
cd src; make all
cd examples; ../bin/sc2v.sh rng; ../bin/sc2v.sh md5; ../bin/sc2v.sh fsm; echo ""; echo "sc2v translated the following files successfully"; echo ""; ls -l *.v
cd examples; ../bin/sc2v.sh stmach_k; ../bin/sc2v.sh rng; ../bin/sc2v.sh md5; ../bin/sc2v.sh fsm; echo ""; echo "sc2v translated the following files successfully"; echo ""; ls -l *.v
 
docs:
cd src; doxygen doxygen.cfg
/trunk/README
22,6 → 22,7
Contributors:
 
David Moloney
Harald Devos
 
 
64,29 → 65,7
4- Known bugs
 
-The usage of macros and defines may cause some errors.
-Using comments in switch case structures may cause errors. Specially
when using structures like:
case 1: //Comment here
case 2:
//Or comment here
case 3:
Better write it like this:
//Comment for 1, 2 and 3
case 1:
case 2:
case 3:
instructions . . .
instructions . . .
instructions . . .
 
A general rule would be: "Don't use comments in the same line of case or
in the inmediate next line. Use comments in the line before the case
statement"
 
5- For testing the application we recommend to use the systemcdes or the
systemcmd5 cores, both available at www.opencores.org.
 

powered by: WebSVN 2.1.0

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