diff --git a/Changes b/Changes index 6ecc68aba..e2f3dc076 100644 --- a/Changes +++ b/Changes @@ -23,6 +23,9 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix parameter constant propagation from package, bug1004. [Johan Bjork] +**** Fix array slicing of non-const indexes, bug1006. [Johan Bjork] + + * Verilator 3.878 2015-11-01 diff --git a/src/V3Inst.cpp b/src/V3Inst.cpp index 8a8abffdb..64e226d2c 100644 --- a/src/V3Inst.cpp +++ b/src/V3Inst.cpp @@ -36,6 +36,7 @@ #include "V3Inst.h" #include "V3Ast.h" #include "V3Changed.h" +#include "V3Const.h" //###################################################################### // Inst state, as a visitor of each AstNode @@ -250,6 +251,7 @@ private: if (!arrp->subDTypep()->castIfaceRefDType()) return; + V3Const::constifyParamsEdit(arrselp->rhsp()); AstConst *constp = arrselp->rhsp()->castConst(); if (!constp) { nodep->v3error("Unsupported: Non-constant index when passing interface to module"); diff --git a/test_regress/t/t_array_interface.v b/test_regress/t/t_array_interface.v index 6f688647c..3d8eaa78c 100644 --- a/test_regress/t/t_array_interface.v +++ b/test_regress/t/t_array_interface.v @@ -17,6 +17,10 @@ intf.source intf_inst assign intf_inst.logic_in_intf = value; endmodule +function integer return_3(); + return 3; +endfunction + module t #( parameter N = 6 @@ -27,16 +31,19 @@ module t generate genvar i; - for (i = 0;i < 4; i++) begin + for (i = 0;i < 3; i++) begin assign ifs[i].logic_in_intf = data[i]; end endgenerate + modify_interface m3 ( + .value(data[return_3()]), + .intf_inst(ifs[return_3()])); - modify_interface m ( + modify_interface m4 ( .value(data[4]), .intf_inst(ifs[4])); - modify_interface m1 ( + modify_interface m5 ( .value(~ifs[4].logic_in_intf), .intf_inst(ifs[5]));