From f23a5bfa964fc1860ce1a19d6a523fda1d5c728a Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 7 Mar 2007 04:24:59 +0000 Subject: [PATCH] Make integer width controllable. --- compiler.h | 12 ++++++------ driver/cflexor.lex | 3 ++- driver/cfparse.y | 12 +++++++++++- driver/globals.h | 8 +++++++- driver/main.c | 9 ++++++++- elab_sig.cc | 7 +++++-- main.cc | 14 +++++++++++++- parse.y | 44 ++++++++++++++++++++++---------------------- pform.cc | 13 ++++++++----- 9 files changed, 82 insertions(+), 40 deletions(-) diff --git a/compiler.h b/compiler.h index 65e97c1f6..f39b8836b 100644 --- a/compiler.h +++ b/compiler.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #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 # include @@ -32,11 +32,8 @@ */ -/* The INTEGER_WIDTH is the default width of integer variables, and - the presumed width of unsigned literal numbers. */ -#ifndef INTEGER_WIDTH -# define INTEGER_WIDTH 32 -#endif +/* The integer_width is the width of integer variables. */ +extern unsigned integer_width; /* The TIME_WIDTH is the width of time variables. */ #ifndef TIME_WIDTH @@ -148,6 +145,9 @@ extern int load_sys_func_table(const char*path); /* * $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 * Support selective control of specify and xtypes features. * diff --git a/driver/cflexor.lex b/driver/cflexor.lex index 93099733f..d2cf1cabe 100644 --- a/driver/cflexor.lex +++ b/driver/cflexor.lex @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #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 # include "cfparse.h" @@ -78,6 +78,7 @@ static int comment_enter; "+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. */ "+"[^\n \t\b\f\r+]* { diff --git a/driver/cfparse.y b/driver/cfparse.y index 234c8a476..69773c741 100644 --- a/driver/cfparse.y +++ b/driver/cfparse.y @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #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 @@ -62,6 +62,7 @@ static void translate_file_name(char*text) %token TOK_Da TOK_Dv TOK_Dy %token TOK_DEFINE TOK_INCDIR TOK_LIBDIR TOK_LIBDIR_NOCASE TOK_LIBEXT +%token TOK_INTEGER_WIDTH %token TOK_PLUSARG TOK_PLUSWORD TOK_STRING %% @@ -145,6 +146,15 @@ item | 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 + tokens that are not otherwise matched, are ignored. The skip_args rule arranges for all the argument words to be consumed. */ diff --git a/driver/globals.h b/driver/globals.h index 5b30a4a42..e210643ab 100644 --- a/driver/globals.h +++ b/driver/globals.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #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 # include @@ -49,6 +49,9 @@ extern int synth_flag; /* This is the name of the selected target. */ 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. */ extern char* substitutions(const char*str); @@ -77,6 +80,9 @@ extern char* library_flags2; /* * $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 * Remove the iverilog.conf file. * diff --git a/driver/main.c b/driver/main.c index d89af86fe..5467ab4f5 100644 --- a/driver/main.c +++ b/driver/main.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #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 # include "config.h" @@ -113,6 +113,8 @@ const char*gen_xtypes = "xtypes"; char warning_flags[16] = ""; +unsigned integer_width = 32; + char*mod_list = 0; char*command_filename = 0; @@ -724,6 +726,8 @@ int main(int argc, char **argv) return 0; } + fprintf(iconfig_file, "iwidth:%u\n", integer_width); + /* Write the preprocessor command needed to preprocess a single file. This may be used to preprocess library files. */ @@ -740,6 +744,9 @@ int main(int argc, char **argv) /* * $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 * Fix handling of dep path in new argument passing method. * diff --git a/elab_sig.cc b/elab_sig.cc index ef707cd04..5f0c586b1 100644 --- a/elab_sig.cc +++ b/elab_sig.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #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 # include "config.h" @@ -356,7 +356,7 @@ void PFunction::elaborate_sig(Design*des, NetScope*scope) const break; 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_signed(true); ret_sig->set_isint(true); @@ -732,6 +732,9 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const /* * $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 * Support signed function return values. * diff --git a/main.cc b/main.cc index 43df057ff..c15829d73 100644 --- a/main.cc +++ b/main.cc @@ -19,7 +19,7 @@ const char COPYRIGHT[] = * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #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 # include "config.h" @@ -125,6 +125,8 @@ bool debug_synth2 = false; */ bool verbose_flag = false; +unsigned integer_width = 32; + /* * Keep a heap of identifier strings that I encounter. This is a more * 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 * library modules as I read them in. * + * iwidth: + * This specifies the width of integer variables. (that is, + * variables declared using the "integer" keyword.) + * * module: * Load a VPI module. * @@ -367,6 +373,9 @@ static void read_iconfig_file(const char*ipath) } else if (strcmp(buf, "ivlpp") == 0) { ivlpp_string = strdup(cp); + } else if (strcmp(buf, "iwidth") == 0) { + integer_width = strtoul(cp,0,10); + } else if (strcmp(buf,"module") == 0) { if (vpi_module_list == 0) { vpi_module_list = strdup(cp); @@ -787,6 +796,9 @@ int main(int argc, char*argv[]) /* * $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 * Support selective control of specify and xtypes features. * diff --git a/parse.y b/parse.y index 9c3366fc1..88d89dbad 100644 --- a/parse.y +++ b/parse.y @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #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 # include "config.h" @@ -1149,10 +1149,10 @@ function_item { svector*range_stub = new svector(2); PExpr*re; - re = new PENumber(new verinum(INTEGER_WIDTH-1, - INTEGER_WIDTH)); + re = new PENumber(new verinum(integer_width-1, + integer_width)); (*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; svector*tmp = pform_make_task_ports(NetNet::PINPUT, @@ -3199,10 +3199,10 @@ task_port_item { svector*range_stub = new svector(2); PExpr*re; - re = new PENumber(new verinum(INTEGER_WIDTH-1, - INTEGER_WIDTH)); + re = new PENumber(new verinum(integer_width-1, + integer_width)); (*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; svector*tmp = pform_make_task_ports(NetNet::PINPUT, @@ -3215,10 +3215,10 @@ task_port_item { svector*range_stub = new svector(2); PExpr*re; - re = new PENumber(new verinum(INTEGER_WIDTH-1, - INTEGER_WIDTH)); + re = new PENumber(new verinum(integer_width-1, + integer_width)); (*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; svector*tmp = pform_make_task_ports(NetNet::POUTPUT, @@ -3231,10 +3231,10 @@ task_port_item { svector*range_stub = new svector(2); PExpr*re; - re = new PENumber(new verinum(INTEGER_WIDTH-1, - INTEGER_WIDTH)); + re = new PENumber(new verinum(integer_width-1, + integer_width)); (*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; svector*tmp = pform_make_task_ports(NetNet::PINOUT, @@ -3322,10 +3322,10 @@ task_port_decl { svector*range_stub = new svector(2); PExpr*re; - re = new PENumber(new verinum(INTEGER_WIDTH-1, - INTEGER_WIDTH)); + re = new PENumber(new verinum(integer_width-1, + integer_width)); (*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; svector*tmp = pform_make_task_ports(NetNet::PINPUT, @@ -3339,10 +3339,10 @@ task_port_decl { svector*range_stub = new svector(2); PExpr*re; - re = new PENumber(new verinum(INTEGER_WIDTH-1, - INTEGER_WIDTH)); + re = new PENumber(new verinum(integer_width-1, + integer_width)); (*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; svector*tmp = pform_make_task_ports(NetNet::POUTPUT, @@ -3356,10 +3356,10 @@ task_port_decl { svector*range_stub = new svector(2); PExpr*re; - re = new PENumber(new verinum(INTEGER_WIDTH-1, - INTEGER_WIDTH)); + re = new PENumber(new verinum(integer_width-1, + integer_width)); (*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; svector*tmp = pform_make_task_ports(NetNet::PINOUT, diff --git a/pform.cc b/pform.cc index 3320c42e9..88aaf8217 100644 --- a/pform.cc +++ b/pform.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #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 # include "config.h" @@ -1639,8 +1639,8 @@ static void pform_set_reg_integer(const char*nm) } assert(cur); - cur->set_range(new PENumber(new verinum(INTEGER_WIDTH-1, INTEGER_WIDTH)), - new PENumber(new verinum((uint64_t)0, INTEGER_WIDTH))); + cur->set_range(new PENumber(new verinum(integer_width-1, integer_width)), + new PENumber(new verinum((uint64_t)0, integer_width))); cur->set_signed(true); } @@ -1670,8 +1670,8 @@ static void pform_set_reg_time(const char*nm) } assert(cur); - cur->set_range(new PENumber(new verinum(TIME_WIDTH-1, INTEGER_WIDTH)), - new PENumber(new verinum((uint64_t)0, INTEGER_WIDTH))); + cur->set_range(new PENumber(new verinum(TIME_WIDTH-1, integer_width)), + new PENumber(new verinum((uint64_t)0, integer_width))); } void pform_set_reg_time(list*names) @@ -1768,6 +1768,9 @@ int pform_parse(const char*path, FILE*file) /* * $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 * Handle processes within generate loops. *