diff options
author | Rodrigo Alejandro Melo <rodrigomelo9@gmail.com> | 2017-02-09 23:39:08 -0300 |
---|---|---|
committer | Rodrigo Alejandro Melo <rodrigomelo9@gmail.com> | 2017-02-09 23:39:08 -0300 |
commit | fd94b98a5c5f7ec819511445bdcf4bbe34338b7b (patch) | |
tree | a579584f72c499974942cbf00814b5be5a384f18 /src | |
parent | 4a0c6c57511eabbb32031d468ec09ce7987cc680 (diff) | |
download | vhdl2vl-fd94b98a5c5f7ec819511445bdcf4bbe34338b7b.tar.gz vhdl2vl-fd94b98a5c5f7ec819511445bdcf4bbe34338b7b.zip |
Added scientific notation supports for integers and floats
Also support was added for real numbers especially thinking in generics.
Files called scientific.vhd and scientific.v were added for test.
Diffstat (limited to 'src')
-rw-r--r-- | src/vhd2vl.l | 8 | ||||
-rw-r--r-- | src/vhd2vl.y | 10 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/vhd2vl.l b/src/vhd2vl.l index 661824f..e7419de 100644 --- a/src/vhd2vl.l +++ b/src/vhd2vl.l @@ -84,6 +84,7 @@ void getbasedstring(unsigned skip); "unsigned" | "std_logic_vector" | "std_ulogic_vector" { return BITVECT; } +"real" { return REAL; } "downto" { return DOWNTO; } "to" { return TO; } "type" {return TYPE; } @@ -148,6 +149,13 @@ void getbasedstring(unsigned skip); return NATURAL; } +[0-9]+e[0-9]+ | +[0-9]+\.[0-9]+e[0-9]+ { + yylval.txt=malloc(strlen(yytext)+1); + strcpy(yylval.txt, yytext); + return SCIENTIFIC; +} + [0-9]+\.[0-9]+ { getstring(0); return FLOAT; diff --git a/src/vhd2vl.y b/src/vhd2vl.y index 9847f4a..9525785 100644 --- a/src/vhd2vl.y +++ b/src/vhd2vl.y @@ -703,6 +703,7 @@ slist *emit_io_list(slist *sl) %token <txt> LASTVALUE EVENT POSEDGE NEGEDGE %token <txt> STRING NAME RANGE NULLV OPEN %token <txt> CONVFUNC_1 CONVFUNC_2 BASED FLOAT LEFT +%token <txt> SCIENTIFIC REAL %token <n> NATURAL %type <n> trad @@ -1033,6 +1034,9 @@ type : BIT { $$->nlo = addtxt(NULL,"0"); $$->nhi = addtxt(NULL,"31"); } + | REAL { + $$=new_vrange(tSCALAR); + } | BITVECT '(' vec_range ')' {$$=$3;} | NAME { sglist *sg; @@ -2054,6 +2058,12 @@ expr : signal { e->sl=addvec(NULL,$1); $$=e; } + | SCIENTIFIC { + expdata *e=xmalloc(sizeof(expdata)); + e->op='t'; /* Terminal symbol */ + e->sl=addtxt(NULL,$1); + $$=e; + } | FLOAT { expdata *e=xmalloc(sizeof(expdata)); e->op='t'; /* Terminal symbol */ |