From cb0a9b254ecb4e342530074be94e3391b8765433 Mon Sep 17 00:00:00 2001 From: steve Date: Mon, 28 Apr 2003 17:50:57 +0000 Subject: [PATCH] More 2001 port declaration support. --- parse.y | 48 +++++++++++++++++++++++++++++++++++++++++++----- pform.cc | 15 ++++++++++----- pform.h | 8 ++++++-- 3 files changed, 59 insertions(+), 12 deletions(-) diff --git a/parse.y b/parse.y index 81dd61201..61643bb63 100644 --- a/parse.y +++ b/parse.y @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if HAVE_CVS_IDENT -#ident "$Id: parse.y,v 1.176 2003/04/25 02:28:53 steve Exp $" +#ident "$Id: parse.y,v 1.177 2003/04/28 17:50:57 steve Exp $" #endif # include "config.h" @@ -1424,7 +1424,8 @@ range_delay : range_opt delay3_opt module_item : attribute_list_opt net_type signed_opt range_delay list_of_identifiers ';' - { pform_makewire(@2, $4.range, $3, $5, $2, $1); + { pform_makewire(@2, $4.range, $3, $5, $2, + NetNet::NOT_A_PORT, $1); if ($4.delay != 0) { yyerror(@4, "sorry: net delays not supported."); delete $4.delay; @@ -1457,6 +1458,33 @@ module_item | port_type signed_opt range_delay list_of_identifiers ';' { pform_set_port_type(@1, $4, $3.range, $2, $1); } + + /* The next two rules handle Verilog 2001 statements of the form: + input wire signed [h:l] ; + This creates the wire and sets the port type all at once. */ + + | port_type net_type signed_opt range_opt list_of_identifiers ';' + { pform_makewire(@1, $4, $3, $5, $2, $1, 0); + } + + | K_output var_type signed_opt range_opt list_of_identifiers ';' + { pform_makewire(@1, $4, $3, $5, $2, NetNet::POUTPUT, 0); + } + + /* var_type declaration (reg variables) cannot be input or output, + because the port declaration implies an external driver, which + cannot be attached to a reg. These rules catch that error early. */ + + | K_input var_type signed_opt range_opt list_of_identifiers ';' + { pform_makewire(@1, $4, $3, $5, $2, NetNet::PINPUT, 0); + yyerror(@2, "error: reg variables cannot be inputs."); + } + + | K_inout var_type signed_opt range_opt list_of_identifiers ';' + { pform_makewire(@1, $4, $3, $5, $2, NetNet::PINOUT, 0); + yyerror(@2, "error: reg variables cannot be inouts."); + } + | port_type signed_opt range_delay error ';' { yyerror(@3, "error: Invalid variable list" " in port declaration."); @@ -1464,7 +1492,14 @@ module_item if ($3.delay) delete $3.delay; yyerrok; } + + /* block_item_decl rule is shared with task blocks and named + begin/end. */ + | block_item_decl + + /* */ + | K_defparam defparam_assign_list ';' | K_event list_of_identifiers ';' { pform_make_events($2, @1.text, @1.first_line); @@ -2065,11 +2100,13 @@ range_or_type_opt so that bit ranges can be assigned. */ register_variable : IDENTIFIER - { pform_makewire(@1, $1, NetNet::REG, 0); + { pform_makewire(@1, $1, NetNet::REG, + NetNet::NOT_A_PORT, 0); $$ = $1; } | IDENTIFIER '=' expression - { pform_makewire(@1, $1, NetNet::REG, 0); + { pform_makewire(@1, $1, NetNet::REG, + NetNet::NOT_A_PORT, 0); if (! pform_expression_is_constant($3)) yyerror(@3, "error: register declaration assignment" " value must be a constant expression."); @@ -2077,7 +2114,8 @@ register_variable $$ = $1; } | IDENTIFIER '[' expression ':' expression ']' - { pform_makewire(@1, $1, NetNet::REG, 0); + { pform_makewire(@1, $1, NetNet::REG, + NetNet::NOT_A_PORT, 0); if (! pform_expression_is_constant($3)) yyerror(@3, "error: msb of register range must be constant."); if (! pform_expression_is_constant($5)) diff --git a/pform.cc b/pform.cc index 2dd7f95e0..4c9567a73 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.112 2003/04/14 03:39:15 steve Exp $" +#ident "$Id: pform.cc,v 1.113 2003/04/28 17:50:57 steve Exp $" #endif # include "config.h" @@ -950,7 +950,8 @@ void pform_module_define_port(const struct vlltype&li, * function is called for every declaration. */ void pform_makewire(const vlltype&li, const char*nm, - NetNet::Type type, svector*attr) + NetNet::Type type, NetNet::PortType pt, + svector*attr) { hname_t name = hier_name(nm); PWire*cur = pform_cur_module->get_wire(name); @@ -977,7 +978,7 @@ void pform_makewire(const vlltype&li, const char*nm, return; } - cur = new PWire(name, type, NetNet::NOT_A_PORT); + cur = new PWire(name, type, pt); cur->set_file(li.text); cur->set_lineno(li.first_line); @@ -996,13 +997,14 @@ void pform_makewire(const vlltype&li, bool signed_flag, list*names, NetNet::Type type, + NetNet::PortType pt, svector*attr) { for (list::iterator cur = names->begin() ; cur != names->end() ; cur ++ ) { char*txt = *cur; - pform_makewire(li, txt, type, attr); + pform_makewire(li, txt, type, pt, attr); pform_set_net_range(txt, range, signed_flag); free(txt); } @@ -1026,7 +1028,7 @@ void pform_makewire(const vlltype&li, while (first) { net_decl_assign_t*next = first->next; - pform_makewire(li, first->name, type, 0); + pform_makewire(li, first->name, type, NetNet::NOT_A_PORT, 0); pform_set_net_range(first->name, range, signed_flag); hname_t name = hier_name(first->name); @@ -1464,6 +1466,9 @@ int pform_parse(const char*path, FILE*file) /* * $Log: pform.cc,v $ + * Revision 1.113 2003/04/28 17:50:57 steve + * More 2001 port declaration support. + * * Revision 1.112 2003/04/14 03:39:15 steve * Break sized constants into a size token * and a based numeric constant. diff --git a/pform.h b/pform.h index 2db261894..b2e886369 100644 --- a/pform.h +++ b/pform.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: pform.h,v 1.69 2003/04/14 03:39:15 steve Exp $" +#ident "$Id: pform.h,v 1.70 2003/04/28 17:50:57 steve Exp $" #endif # include "netlist.h" @@ -157,7 +157,7 @@ extern verinum* pform_verinum_with_size(verinum*s, verinum*val, * go into a module that is currently opened. */ extern void pform_makewire(const struct vlltype&li, const char*name, - NetNet::Type type, + NetNet::Type type, NetNet::PortType pt, svector*attr); extern void pform_makewire(const struct vlltype&li, @@ -165,6 +165,7 @@ extern void pform_makewire(const struct vlltype&li, bool signed_flag, list*names, NetNet::Type type, + NetNet::PortType, svector*attr); extern void pform_makewire(const struct vlltype&li, svector*range, @@ -279,6 +280,9 @@ extern void pform_dump(ostream&out, Module*mod); /* * $Log: pform.h,v $ + * Revision 1.70 2003/04/28 17:50:57 steve + * More 2001 port declaration support. + * * Revision 1.69 2003/04/14 03:39:15 steve * Break sized constants into a size token * and a based numeric constant.