forked from github/verilator
Fix DETECTARRAY error on packed arrays, bug770.
This commit is contained in:
parent
5da5678e64
commit
69468708e2
2
Changes
2
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 gate primitives with arrays and non-arrayed pins.
|
||||||
|
|
||||||
|
**** Fix DETECTARRAY error on packed arrays, bug770. [Jie Xu]
|
||||||
|
|
||||||
**** Fix ENDLABEL warnings on escaped identifiers.
|
**** Fix ENDLABEL warnings on escaped identifiers.
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,17 +83,19 @@ private:
|
|||||||
void genChangeDet(AstVarScope* vscp) {
|
void genChangeDet(AstVarScope* vscp) {
|
||||||
AstVar* varp = vscp->varp();
|
AstVar* varp = vscp->varp();
|
||||||
vscp->v3warn(IMPERFECTSCH,"Imperfect scheduling of variable: "<<vscp);
|
vscp->v3warn(IMPERFECTSCH,"Imperfect scheduling of variable: "<<vscp);
|
||||||
AstUnpackArrayDType* arrayp = varp->dtypeSkipRefp()->castUnpackArrayDType();
|
AstUnpackArrayDType* uarrayp = varp->dtypeSkipRefp()->castUnpackArrayDType();
|
||||||
|
AstPackArrayDType* parrayp = varp->dtypeSkipRefp()->castPackArrayDType();
|
||||||
AstNodeClassDType *classp = varp->dtypeSkipRefp()->castNodeClassDType();
|
AstNodeClassDType *classp = varp->dtypeSkipRefp()->castNodeClassDType();
|
||||||
bool isArray = arrayp;
|
bool isUnpackArray = uarrayp;
|
||||||
|
bool isPackArray = parrayp;
|
||||||
bool isClass = classp && classp->packedUnsup();
|
bool isClass = classp && classp->packedUnsup();
|
||||||
int elements = isArray ? arrayp->elementsConst() : 1;
|
int elements = isUnpackArray ? uarrayp->elementsConst() : 1;
|
||||||
if (isArray && (elements > DETECTARRAY_MAX_INDEXES)) {
|
if (isUnpackArray && (elements > DETECTARRAY_MAX_INDEXES)) {
|
||||||
vscp->v3warn(E_DETECTARRAY, "Unsupported: Can't detect more than "<<cvtToStr(DETECTARRAY_MAX_INDEXES)
|
vscp->v3warn(E_DETECTARRAY, "Unsupported: Can't detect more than "<<cvtToStr(DETECTARRAY_MAX_INDEXES)
|
||||||
<<" array indexes (probably with UNOPTFLAT warning suppressed): "<<varp->prettyName()<<endl
|
<<" array indexes (probably with UNOPTFLAT warning suppressed): "<<varp->prettyName()<<endl
|
||||||
<<vscp->warnMore()
|
<<vscp->warnMore()
|
||||||
<<"... Could recompile with DETECTARRAY_MAX_INDEXES increased to at least "<<cvtToStr(elements));
|
<<"... Could recompile with DETECTARRAY_MAX_INDEXES increased to at least "<<cvtToStr(elements));
|
||||||
} else if (!isArray && !isClass
|
} else if (!isUnpackArray && !isClass && !isPackArray
|
||||||
&& !varp->dtypeSkipRefp()->castBasicDType()) {
|
&& !varp->dtypeSkipRefp()->castBasicDType()) {
|
||||||
if (debug()) varp->dumpTree(cout,"-DETECTARRAY-");
|
if (debug()) varp->dumpTree(cout,"-DETECTARRAY-");
|
||||||
vscp->v3warn(E_DETECTARRAY, "Unsupported: Can't detect changes on complex variable (probably with UNOPTFLAT warning suppressed): "<<varp->prettyName());
|
vscp->v3warn(E_DETECTARRAY, "Unsupported: Can't detect changes on complex variable (probably with UNOPTFLAT warning suppressed): "<<varp->prettyName());
|
||||||
@ -110,17 +112,17 @@ private:
|
|||||||
for (int index=0; index<elements; ++index) {
|
for (int index=0; index<elements; ++index) {
|
||||||
AstChangeDet* changep
|
AstChangeDet* changep
|
||||||
= new AstChangeDet (vscp->fileline(),
|
= new AstChangeDet (vscp->fileline(),
|
||||||
aselIfNeeded(isArray, index,
|
aselIfNeeded(isUnpackArray, index,
|
||||||
new AstVarRef(vscp->fileline(), vscp, false)),
|
new AstVarRef(vscp->fileline(), vscp, false)),
|
||||||
aselIfNeeded(isArray, index,
|
aselIfNeeded(isUnpackArray, index,
|
||||||
new AstVarRef(vscp->fileline(), newvscp, false)),
|
new AstVarRef(vscp->fileline(), newvscp, false)),
|
||||||
false);
|
false);
|
||||||
m_chgFuncp->addStmtsp(changep);
|
m_chgFuncp->addStmtsp(changep);
|
||||||
AstAssign* initp
|
AstAssign* initp
|
||||||
= new AstAssign (vscp->fileline(),
|
= new AstAssign (vscp->fileline(),
|
||||||
aselIfNeeded(isArray, index,
|
aselIfNeeded(isUnpackArray, index,
|
||||||
new AstVarRef(vscp->fileline(), newvscp, true)),
|
new AstVarRef(vscp->fileline(), newvscp, true)),
|
||||||
aselIfNeeded(isArray, index,
|
aselIfNeeded(isUnpackArray, index,
|
||||||
new AstVarRef(vscp->fileline(), vscp, false)));
|
new AstVarRef(vscp->fileline(), vscp, false)));
|
||||||
m_chgFuncp->addFinalsp(initp);
|
m_chgFuncp->addFinalsp(initp);
|
||||||
}
|
}
|
||||||
|
19
test_regress/t/t_detectarray_3.pl
Executable file
19
test_regress/t/t_detectarray_3.pl
Executable file
@ -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;
|
39
test_regress/t/t_detectarray_3.v
Normal file
39
test_regress/t/t_detectarray_3.v
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user