diff --git a/Changes b/Changes index 768f64b2c..11bc827bb 100644 --- a/Changes +++ b/Changes @@ -25,6 +25,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix gate primitives with arrays and non-arrayed pins. +**** Fix DETECTARRAY error on packed arrays, bug770. [Jie Xu] + **** Fix ENDLABEL warnings on escaped identifiers. diff --git a/src/V3Changed.cpp b/src/V3Changed.cpp index 14857c300..542b8ac1b 100644 --- a/src/V3Changed.cpp +++ b/src/V3Changed.cpp @@ -83,17 +83,19 @@ private: void genChangeDet(AstVarScope* vscp) { AstVar* varp = vscp->varp(); vscp->v3warn(IMPERFECTSCH,"Imperfect scheduling of variable: "<dtypeSkipRefp()->castUnpackArrayDType(); + AstUnpackArrayDType* uarrayp = varp->dtypeSkipRefp()->castUnpackArrayDType(); + AstPackArrayDType* parrayp = varp->dtypeSkipRefp()->castPackArrayDType(); AstNodeClassDType *classp = varp->dtypeSkipRefp()->castNodeClassDType(); - bool isArray = arrayp; + bool isUnpackArray = uarrayp; + bool isPackArray = parrayp; bool isClass = classp && classp->packedUnsup(); - int elements = isArray ? arrayp->elementsConst() : 1; - if (isArray && (elements > DETECTARRAY_MAX_INDEXES)) { + int elements = isUnpackArray ? uarrayp->elementsConst() : 1; + if (isUnpackArray && (elements > DETECTARRAY_MAX_INDEXES)) { vscp->v3warn(E_DETECTARRAY, "Unsupported: Can't detect more than "<prettyName()<warnMore() <<"... Could recompile with DETECTARRAY_MAX_INDEXES increased to at least "<dtypeSkipRefp()->castBasicDType()) { if (debug()) varp->dumpTree(cout,"-DETECTARRAY-"); vscp->v3warn(E_DETECTARRAY, "Unsupported: Can't detect changes on complex variable (probably with UNOPTFLAT warning suppressed): "<prettyName()); @@ -110,17 +112,17 @@ private: for (int index=0; indexfileline(), - aselIfNeeded(isArray, index, + aselIfNeeded(isUnpackArray, index, new AstVarRef(vscp->fileline(), vscp, false)), - aselIfNeeded(isArray, index, + aselIfNeeded(isUnpackArray, index, new AstVarRef(vscp->fileline(), newvscp, false)), false); m_chgFuncp->addStmtsp(changep); AstAssign* initp = new AstAssign (vscp->fileline(), - aselIfNeeded(isArray, index, + aselIfNeeded(isUnpackArray, index, new AstVarRef(vscp->fileline(), newvscp, true)), - aselIfNeeded(isArray, index, + aselIfNeeded(isUnpackArray, index, new AstVarRef(vscp->fileline(), vscp, false))); m_chgFuncp->addFinalsp(initp); } diff --git a/test_regress/t/t_detectarray_3.pl b/test_regress/t/t_detectarray_3.pl new file mode 100755 index 000000000..0ab9fe201 --- /dev/null +++ b/test_regress/t/t_detectarray_3.pl @@ -0,0 +1,19 @@ +#!/usr/bin/perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003 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. + +compile ( + verilator_flags2 => ["-Wno-UNOPTFLAT -Wno-WIDTH"] + ); + +execute ( + check_finished=>1, + ); + +ok(1); +1; diff --git a/test_regress/t/t_detectarray_3.v b/test_regress/t/t_detectarray_3.v new file mode 100644 index 000000000..932bebb89 --- /dev/null +++ b/test_regress/t/t_detectarray_3.v @@ -0,0 +1,39 @@ +// DESCRIPTION: Verilator: Simple test of unoptflat +// +// Trigger the DETECTARRAY error on packed structure. +// +// This file ONLY is placed into the Public Domain, for any use, +// without warranty, 2014 by Jie Xu. + +localparam ID_MSB = 1; + + +module t (/*AUTOARG*/ + // Inputs + clk, + res + ); + input clk; + output [8:0][8:0] res; + + logic a = 1'b1; + logic [8:0] b [8:0]; // where the error is reported + logic [8:0][8:0] c; // where the error is reported + + // following just to make c as circular + assign c[0] = c[0] | a << 1; + assign b[0] = b[0] | a << 2; + + assign res[0] = c[0]; + assign res[1] = b[0]; + + + always @(posedge clk or negedge clk) begin + + if (res != 0) begin + $write("*-* All Finished *-*\n"); + $finish; + end + end + +endmodule