diff --git a/parse.y b/parse.y index 7132063c9..60cbeba07 100644 --- a/parse.y +++ b/parse.y @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: parse.y,v 1.79 1999/12/31 17:39:00 steve Exp $" +#ident "$Id: parse.y,v 1.80 2000/01/01 23:47:58 steve Exp $" #endif # include "parse_misc.h" @@ -127,7 +127,7 @@ extern void lex_end_table(); %type expression expr_primary %type lavalue lpvalue %type delay_value -%type delay1 delay3 delay3_opt +%type delay1 delay3 delay3_opt parameter_value_opt %type expression_list %type assign assign_list @@ -1088,7 +1088,7 @@ module_item | gatetype delay3_opt gate_instance_list ';' { pform_makegates($1, $2, $3); } - | IDENTIFIER delay3_opt gate_instance_list ';' + | IDENTIFIER parameter_value_opt gate_instance_list ';' { pform_make_modgates($1, $2, $3); delete $1; } @@ -1217,6 +1217,20 @@ parameter_assign_list | parameter_assign_list ',' parameter_assign ; + + /* The parameters of a module instance can be overridden by writing + a list of expressions in a syntax much line a delay list. (The + difference being the list can have any length.) The pform that + attaches the expression list to the module checks that the + expressions are constant. */ + +parameter_value_opt + : '#' '(' expression_list ')' + { $$ = $3; } + | + { $$ = 0; } + ; + /* The port (of a module) is a fairle complex item. Each port is handled as a Module::port_t object. A simple port reference has a name and a PWire object, but more complex constructs are possible diff --git a/pform.cc b/pform.cc index 9a8b021b3..086587d04 100644 --- a/pform.cc +++ b/pform.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: pform.cc,v 1.49 1999/12/30 19:06:14 steve Exp $" +#ident "$Id: pform.cc,v 1.50 2000/01/01 23:47:58 steve Exp $" #endif # include "compiler.h" @@ -355,6 +355,13 @@ void pform_make_modgates(const string&type, svector*overrides, svector*gates) { + for (unsigned idx = 0 ; idx < overrides->count() ; idx += 1) + if (! pform_expression_is_constant((*overrides)[idx])) { + VLerror("error: Parameter override expression" + " must be constant."); + return; + } + for (unsigned idx = 0 ; idx < gates->count() ; idx += 1) { lgate cur = (*gates)[idx]; @@ -765,6 +772,9 @@ int pform_parse(const char*path, map&modules, /* * $Log: pform.cc,v $ + * Revision 1.50 2000/01/01 23:47:58 steve + * Fix module parameter override syntax. + * * Revision 1.49 1999/12/30 19:06:14 steve * Support reg initial assignment syntax. *