From 90cbcd2dfd572c22e5a1330bd5a9e82196a7d197 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 17 Jan 2015 15:35:45 -0500 Subject: [PATCH] Fix non-ANSI modport instantiations, bug868. --- Changes | 2 ++ src/verilog.y | 18 +++++++++++++++++ test_regress/t/t_interface1_modport.v | 8 ++++++++ test_regress/t/t_interface1_modport_nansi.pl | 21 ++++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100755 test_regress/t/t_interface1_modport_nansi.pl diff --git a/Changes b/Changes index ea3ff5b84..ac10303a9 100644 --- a/Changes +++ b/Changes @@ -15,6 +15,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix VM_PARALLEL_BUILDS broke in 3.868, bug870. [Hiroki Honda] +**** Fix non-ANSI modport instantiations, bug868. [Kevin Thompson] + * Verilator 3.868 2014-12-20 diff --git a/src/verilog.y b/src/verilog.y index 5f52298f4..d0b535523 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -1237,6 +1237,9 @@ port_declaration: // ==IEEE: port_declaration list_of_variable_decl_assignments { $$ = $5; } | port_directionReset port_declNetE /*implicit*/ { VARDTYPE(NULL);/*default_nettype*/} list_of_variable_decl_assignments { $$ = $4; } + // // IEEE: interface_declaration + // // Looks just like variable declaration unless has a period + // // See etcInst ; tf_port_declaration: // ==IEEE: tf_port_declaration @@ -2011,9 +2014,24 @@ etcInst: // IEEE: module_instantiation + gate_instantiation + udp_insta instDecl: id parameter_value_assignmentE {INSTPREP(*$1,$2);} instnameList ';' { $$ = $4; GRAMMARP->m_impliedDecl=false;} + // // IEEE: interface_identifier' .' modport_identifier list_of_interface_identifiers + | id/*interface*/ '.' id/*modport*/ + { VARRESET_NONLIST(AstVarType::IFACEREF); + VARDTYPE(new AstIfaceRefDType($1,"",*$1,*$3)); } + mpInstnameList ';' + { $$ = VARDONEP($5,NULL,NULL); } //UNSUP: strengthSpecE for udp_instantiations ; +mpInstnameList: // Similar to instnameList, but for modport instantiations which have no parenthesis + mpInstnameParen { $$ = $1; } + | mpInstnameList ',' mpInstnameParen { $$ = $1->addNext($3); } + ; + +mpInstnameParen: // Similar to instnameParen, but for modport instantiations which have no parenthesis + id instRangeE sigAttrListE { $$ = VARDONEA($1,*$1,$2,$3); } + ; + instnameList: instnameParen { $$ = $1; } | instnameList ',' instnameParen { $$ = $1->addNext($3); } diff --git a/test_regress/t/t_interface1_modport.v b/test_regress/t/t_interface1_modport.v index 2d41333bb..bf6923337 100644 --- a/test_regress/t/t_interface1_modport.v +++ b/test_regress/t/t_interface1_modport.v @@ -37,10 +37,18 @@ module t (/*AUTOARG*/ endmodule module sub +`ifdef NANSI // bug868 + ( + isub, i_value + ); + ifc.out_modport isub; // Note parenthesis are not legal here + input integer i_value; +`else ( ifc.out_modport isub, input integer i_value ); +`endif always @* begin isub.value = i_value; diff --git a/test_regress/t/t_interface1_modport_nansi.pl b/test_regress/t/t_interface1_modport_nansi.pl new file mode 100755 index 000000000..13c82af1a --- /dev/null +++ b/test_regress/t/t_interface1_modport_nansi.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003-2009 by Wilson Snyder. This program is free software; you can +# redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. + +top_filename("t/t_interface1_modport.v"); + +compile ( + v_flags2 => ['+define+NANSI'], + ); + +execute ( + check_finished=>1, + ); + +ok(1); +1;