Make integer width controllable.

This commit is contained in:
steve 2007-03-07 04:24:59 +00:00
parent 74ac5dbf58
commit f23a5bfa96
9 changed files with 82 additions and 40 deletions

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: compiler.h,v 1.31 2006/09/28 04:35:18 steve Exp $" #ident "$Id: compiler.h,v 1.32 2007/03/07 04:24:59 steve Exp $"
#endif #endif
# include <list> # include <list>
@ -32,11 +32,8 @@
*/ */
/* The INTEGER_WIDTH is the default width of integer variables, and /* The integer_width is the width of integer variables. */
the presumed width of unsigned literal numbers. */ extern unsigned integer_width;
#ifndef INTEGER_WIDTH
# define INTEGER_WIDTH 32
#endif
/* The TIME_WIDTH is the width of time variables. */ /* The TIME_WIDTH is the width of time variables. */
#ifndef TIME_WIDTH #ifndef TIME_WIDTH
@ -148,6 +145,9 @@ extern int load_sys_func_table(const char*path);
/* /*
* $Log: compiler.h,v $ * $Log: compiler.h,v $
* Revision 1.32 2007/03/07 04:24:59 steve
* Make integer width controllable.
*
* Revision 1.31 2006/09/28 04:35:18 steve * Revision 1.31 2006/09/28 04:35:18 steve
* Support selective control of specify and xtypes features. * Support selective control of specify and xtypes features.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: cflexor.lex,v 1.9 2006/11/30 06:00:28 steve Exp $" #ident "$Id: cflexor.lex,v 1.10 2007/03/07 04:24:59 steve Exp $"
#endif #endif
# include "cfparse.h" # include "cfparse.h"
@ -78,6 +78,7 @@ static int comment_enter;
"+libext+" { BEGIN(PLUS_ARGS); return TOK_LIBEXT; } "+libext+" { BEGIN(PLUS_ARGS); return TOK_LIBEXT; }
"+integer-width+" { BEGIN(PLUS_ARGS); return TOK_INTEGER_WIDTH; }
/* If it is not any known plus-flag, return the generic form. */ /* If it is not any known plus-flag, return the generic form. */
"+"[^\n \t\b\f\r+]* { "+"[^\n \t\b\f\r+]* {

View File

@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: cfparse.y,v 1.10 2003/09/26 21:25:58 steve Exp $" #ident "$Id: cfparse.y,v 1.11 2007/03/07 04:24:59 steve Exp $"
#endif #endif
@ -62,6 +62,7 @@ static void translate_file_name(char*text)
%token TOK_Da TOK_Dv TOK_Dy %token TOK_Da TOK_Dv TOK_Dy
%token TOK_DEFINE TOK_INCDIR TOK_LIBDIR TOK_LIBDIR_NOCASE TOK_LIBEXT %token TOK_DEFINE TOK_INCDIR TOK_LIBDIR TOK_LIBDIR_NOCASE TOK_LIBEXT
%token TOK_INTEGER_WIDTH
%token <text> TOK_PLUSARG TOK_PLUSWORD TOK_STRING %token <text> TOK_PLUSARG TOK_PLUSWORD TOK_STRING
%% %%
@ -145,6 +146,15 @@ item
| TOK_LIBEXT libext_args | TOK_LIBEXT libext_args
/* These are various misc flags that are supported. */
| TOK_INTEGER_WIDTH TOK_PLUSARG
{ char*tmp = substitutions($2);
free($2);
integer_width = strtoul(tmp,0,10);
free(tmp);
}
/* The +<word> tokens that are not otherwise matched, are /* The +<word> tokens that are not otherwise matched, are
ignored. The skip_args rule arranges for all the argument words ignored. The skip_args rule arranges for all the argument words
to be consumed. */ to be consumed. */

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: globals.h,v 1.19 2003/11/18 06:31:46 steve Exp $" #ident "$Id: globals.h,v 1.20 2007/03/07 04:24:59 steve Exp $"
#endif #endif
# include <stddef.h> # include <stddef.h>
@ -49,6 +49,9 @@ extern int synth_flag;
/* This is the name of the selected target. */ /* This is the name of the selected target. */
extern const char*targ; extern const char*targ;
/* This is the integer-width argument that will be passed to ivl. */
extern unsigned integer_width;
/* Perform variable substitutions on the string. */ /* Perform variable substitutions on the string. */
extern char* substitutions(const char*str); extern char* substitutions(const char*str);
@ -77,6 +80,9 @@ extern char* library_flags2;
/* /*
* $Log: globals.h,v $ * $Log: globals.h,v $
* Revision 1.20 2007/03/07 04:24:59 steve
* Make integer width controllable.
*
* Revision 1.19 2003/11/18 06:31:46 steve * Revision 1.19 2003/11/18 06:31:46 steve
* Remove the iverilog.conf file. * Remove the iverilog.conf file.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: main.c,v 1.72 2006/10/02 18:15:47 steve Exp $" #ident "$Id: main.c,v 1.73 2007/03/07 04:24:59 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -113,6 +113,8 @@ const char*gen_xtypes = "xtypes";
char warning_flags[16] = ""; char warning_flags[16] = "";
unsigned integer_width = 32;
char*mod_list = 0; char*mod_list = 0;
char*command_filename = 0; char*command_filename = 0;
@ -724,6 +726,8 @@ int main(int argc, char **argv)
return 0; return 0;
} }
fprintf(iconfig_file, "iwidth:%u\n", integer_width);
/* Write the preprocessor command needed to preprocess a /* Write the preprocessor command needed to preprocess a
single file. This may be used to preprocess library single file. This may be used to preprocess library
files. */ files. */
@ -740,6 +744,9 @@ int main(int argc, char **argv)
/* /*
* $Log: main.c,v $ * $Log: main.c,v $
* Revision 1.73 2007/03/07 04:24:59 steve
* Make integer width controllable.
*
* Revision 1.72 2006/10/02 18:15:47 steve * Revision 1.72 2006/10/02 18:15:47 steve
* Fix handling of dep path in new argument passing method. * Fix handling of dep path in new argument passing method.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: elab_sig.cc,v 1.46 2007/03/06 05:22:49 steve Exp $" #ident "$Id: elab_sig.cc,v 1.47 2007/03/07 04:24:59 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -356,7 +356,7 @@ void PFunction::elaborate_sig(Design*des, NetScope*scope) const
break; break;
case PTF_INTEGER: case PTF_INTEGER:
ret_sig = new NetNet(scope, fname, NetNet::REG, INTEGER_WIDTH); ret_sig = new NetNet(scope, fname, NetNet::REG, integer_width);
ret_sig->set_line(*this); ret_sig->set_line(*this);
ret_sig->set_signed(true); ret_sig->set_signed(true);
ret_sig->set_isint(true); ret_sig->set_isint(true);
@ -732,6 +732,9 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const
/* /*
* $Log: elab_sig.cc,v $ * $Log: elab_sig.cc,v $
* Revision 1.47 2007/03/07 04:24:59 steve
* Make integer width controllable.
*
* Revision 1.46 2007/03/06 05:22:49 steve * Revision 1.46 2007/03/06 05:22:49 steve
* Support signed function return values. * Support signed function return values.
* *

14
main.cc
View File

@ -19,7 +19,7 @@ const char COPYRIGHT[] =
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: main.cc,v 1.93 2006/09/28 04:35:18 steve Exp $" #ident "$Id: main.cc,v 1.94 2007/03/07 04:24:59 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -125,6 +125,8 @@ bool debug_synth2 = false;
*/ */
bool verbose_flag = false; bool verbose_flag = false;
unsigned integer_width = 32;
/* /*
* Keep a heap of identifier strings that I encounter. This is a more * Keep a heap of identifier strings that I encounter. This is a more
* efficient way to allocate those strings. * efficient way to allocate those strings.
@ -277,6 +279,10 @@ static void parm_to_flagmap(const string&flag)
* This specifies the ivlpp command line used to process * This specifies the ivlpp command line used to process
* library modules as I read them in. * library modules as I read them in.
* *
* iwidth:<bits>
* This specifies the width of integer variables. (that is,
* variables declared using the "integer" keyword.)
*
* module:<name> * module:<name>
* Load a VPI module. * Load a VPI module.
* *
@ -367,6 +373,9 @@ static void read_iconfig_file(const char*ipath)
} else if (strcmp(buf, "ivlpp") == 0) { } else if (strcmp(buf, "ivlpp") == 0) {
ivlpp_string = strdup(cp); ivlpp_string = strdup(cp);
} else if (strcmp(buf, "iwidth") == 0) {
integer_width = strtoul(cp,0,10);
} else if (strcmp(buf,"module") == 0) { } else if (strcmp(buf,"module") == 0) {
if (vpi_module_list == 0) { if (vpi_module_list == 0) {
vpi_module_list = strdup(cp); vpi_module_list = strdup(cp);
@ -787,6 +796,9 @@ int main(int argc, char*argv[])
/* /*
* $Log: main.cc,v $ * $Log: main.cc,v $
* Revision 1.94 2007/03/07 04:24:59 steve
* Make integer width controllable.
*
* Revision 1.93 2006/09/28 04:35:18 steve * Revision 1.93 2006/09/28 04:35:18 steve
* Support selective control of specify and xtypes features. * Support selective control of specify and xtypes features.
* *

44
parse.y
View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: parse.y,v 1.230 2007/03/06 05:22:49 steve Exp $" #ident "$Id: parse.y,v 1.231 2007/03/07 04:24:59 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -1149,10 +1149,10 @@ function_item
{ svector<PExpr*>*range_stub { svector<PExpr*>*range_stub
= new svector<PExpr*>(2); = new svector<PExpr*>(2);
PExpr*re; PExpr*re;
re = new PENumber(new verinum(INTEGER_WIDTH-1, re = new PENumber(new verinum(integer_width-1,
INTEGER_WIDTH)); integer_width));
(*range_stub)[0] = re; (*range_stub)[0] = re;
re = new PENumber(new verinum((uint64_t)0, INTEGER_WIDTH)); re = new PENumber(new verinum((uint64_t)0, integer_width));
(*range_stub)[1] = re; (*range_stub)[1] = re;
svector<PWire*>*tmp svector<PWire*>*tmp
= pform_make_task_ports(NetNet::PINPUT, = pform_make_task_ports(NetNet::PINPUT,
@ -3199,10 +3199,10 @@ task_port_item
{ svector<PExpr*>*range_stub { svector<PExpr*>*range_stub
= new svector<PExpr*>(2); = new svector<PExpr*>(2);
PExpr*re; PExpr*re;
re = new PENumber(new verinum(INTEGER_WIDTH-1, re = new PENumber(new verinum(integer_width-1,
INTEGER_WIDTH)); integer_width));
(*range_stub)[0] = re; (*range_stub)[0] = re;
re = new PENumber(new verinum((uint64_t)0, INTEGER_WIDTH)); re = new PENumber(new verinum((uint64_t)0, integer_width));
(*range_stub)[1] = re; (*range_stub)[1] = re;
svector<PWire*>*tmp svector<PWire*>*tmp
= pform_make_task_ports(NetNet::PINPUT, = pform_make_task_ports(NetNet::PINPUT,
@ -3215,10 +3215,10 @@ task_port_item
{ svector<PExpr*>*range_stub { svector<PExpr*>*range_stub
= new svector<PExpr*>(2); = new svector<PExpr*>(2);
PExpr*re; PExpr*re;
re = new PENumber(new verinum(INTEGER_WIDTH-1, re = new PENumber(new verinum(integer_width-1,
INTEGER_WIDTH)); integer_width));
(*range_stub)[0] = re; (*range_stub)[0] = re;
re = new PENumber(new verinum((uint64_t)0, INTEGER_WIDTH)); re = new PENumber(new verinum((uint64_t)0, integer_width));
(*range_stub)[1] = re; (*range_stub)[1] = re;
svector<PWire*>*tmp svector<PWire*>*tmp
= pform_make_task_ports(NetNet::POUTPUT, = pform_make_task_ports(NetNet::POUTPUT,
@ -3231,10 +3231,10 @@ task_port_item
{ svector<PExpr*>*range_stub { svector<PExpr*>*range_stub
= new svector<PExpr*>(2); = new svector<PExpr*>(2);
PExpr*re; PExpr*re;
re = new PENumber(new verinum(INTEGER_WIDTH-1, re = new PENumber(new verinum(integer_width-1,
INTEGER_WIDTH)); integer_width));
(*range_stub)[0] = re; (*range_stub)[0] = re;
re = new PENumber(new verinum((uint64_t)0, INTEGER_WIDTH)); re = new PENumber(new verinum((uint64_t)0, integer_width));
(*range_stub)[1] = re; (*range_stub)[1] = re;
svector<PWire*>*tmp svector<PWire*>*tmp
= pform_make_task_ports(NetNet::PINOUT, = pform_make_task_ports(NetNet::PINOUT,
@ -3322,10 +3322,10 @@ task_port_decl
{ svector<PExpr*>*range_stub { svector<PExpr*>*range_stub
= new svector<PExpr*>(2); = new svector<PExpr*>(2);
PExpr*re; PExpr*re;
re = new PENumber(new verinum(INTEGER_WIDTH-1, re = new PENumber(new verinum(integer_width-1,
INTEGER_WIDTH)); integer_width));
(*range_stub)[0] = re; (*range_stub)[0] = re;
re = new PENumber(new verinum((uint64_t)0, INTEGER_WIDTH)); re = new PENumber(new verinum((uint64_t)0, integer_width));
(*range_stub)[1] = re; (*range_stub)[1] = re;
svector<PWire*>*tmp svector<PWire*>*tmp
= pform_make_task_ports(NetNet::PINPUT, = pform_make_task_ports(NetNet::PINPUT,
@ -3339,10 +3339,10 @@ task_port_decl
{ svector<PExpr*>*range_stub { svector<PExpr*>*range_stub
= new svector<PExpr*>(2); = new svector<PExpr*>(2);
PExpr*re; PExpr*re;
re = new PENumber(new verinum(INTEGER_WIDTH-1, re = new PENumber(new verinum(integer_width-1,
INTEGER_WIDTH)); integer_width));
(*range_stub)[0] = re; (*range_stub)[0] = re;
re = new PENumber(new verinum((uint64_t)0, INTEGER_WIDTH)); re = new PENumber(new verinum((uint64_t)0, integer_width));
(*range_stub)[1] = re; (*range_stub)[1] = re;
svector<PWire*>*tmp svector<PWire*>*tmp
= pform_make_task_ports(NetNet::POUTPUT, = pform_make_task_ports(NetNet::POUTPUT,
@ -3356,10 +3356,10 @@ task_port_decl
{ svector<PExpr*>*range_stub { svector<PExpr*>*range_stub
= new svector<PExpr*>(2); = new svector<PExpr*>(2);
PExpr*re; PExpr*re;
re = new PENumber(new verinum(INTEGER_WIDTH-1, re = new PENumber(new verinum(integer_width-1,
INTEGER_WIDTH)); integer_width));
(*range_stub)[0] = re; (*range_stub)[0] = re;
re = new PENumber(new verinum((uint64_t)0, INTEGER_WIDTH)); re = new PENumber(new verinum((uint64_t)0, integer_width));
(*range_stub)[1] = re; (*range_stub)[1] = re;
svector<PWire*>*tmp svector<PWire*>*tmp
= pform_make_task_ports(NetNet::PINOUT, = pform_make_task_ports(NetNet::PINOUT,

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: pform.cc,v 1.141 2007/03/05 05:59:10 steve Exp $" #ident "$Id: pform.cc,v 1.142 2007/03/07 04:24:59 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -1639,8 +1639,8 @@ static void pform_set_reg_integer(const char*nm)
} }
assert(cur); assert(cur);
cur->set_range(new PENumber(new verinum(INTEGER_WIDTH-1, INTEGER_WIDTH)), cur->set_range(new PENumber(new verinum(integer_width-1, integer_width)),
new PENumber(new verinum((uint64_t)0, INTEGER_WIDTH))); new PENumber(new verinum((uint64_t)0, integer_width)));
cur->set_signed(true); cur->set_signed(true);
} }
@ -1670,8 +1670,8 @@ static void pform_set_reg_time(const char*nm)
} }
assert(cur); assert(cur);
cur->set_range(new PENumber(new verinum(TIME_WIDTH-1, INTEGER_WIDTH)), cur->set_range(new PENumber(new verinum(TIME_WIDTH-1, integer_width)),
new PENumber(new verinum((uint64_t)0, INTEGER_WIDTH))); new PENumber(new verinum((uint64_t)0, integer_width)));
} }
void pform_set_reg_time(list<perm_string>*names) void pform_set_reg_time(list<perm_string>*names)
@ -1768,6 +1768,9 @@ int pform_parse(const char*path, FILE*file)
/* /*
* $Log: pform.cc,v $ * $Log: pform.cc,v $
* Revision 1.142 2007/03/07 04:24:59 steve
* Make integer width controllable.
*
* Revision 1.141 2007/03/05 05:59:10 steve * Revision 1.141 2007/03/05 05:59:10 steve
* Handle processes within generate loops. * Handle processes within generate loops.
* *