Add UNPACKED warning to convert unpacked structs.
This commit is contained in:
parent
b50542531d
commit
4f6d80c602
2
Changes
2
Changes
|
|
@ -5,6 +5,8 @@ indicates the contributor was also the author of the fix; Thanks!
|
||||||
|
|
||||||
* Verilator 3.854 devel
|
* Verilator 3.854 devel
|
||||||
|
|
||||||
|
*** Add UNPACKED warning to convert unpacked structs. [Jeremy Bennett]
|
||||||
|
|
||||||
**** Support vpi_get of vpiSuppressVal, bug687. [Varun Koyyalagunta]
|
**** Support vpi_get of vpiSuppressVal, bug687. [Varun Koyyalagunta]
|
||||||
|
|
||||||
**** Support vpi_get_time, bug688. [Varun Koyyalagunta]
|
**** Support vpi_get_time, bug688. [Varun Koyyalagunta]
|
||||||
|
|
|
||||||
|
|
@ -3225,6 +3225,13 @@ section for more details.
|
||||||
Ignoring this warning will only slow simulations, it will simulate
|
Ignoring this warning will only slow simulations, it will simulate
|
||||||
correctly.
|
correctly.
|
||||||
|
|
||||||
|
=item UNPACKED
|
||||||
|
|
||||||
|
Warns that unpacked structs and unions are not supported.
|
||||||
|
|
||||||
|
Ignoring this warning will make Verilator treat the structure as packed,
|
||||||
|
which may make Verilator simulations differ from other simulators.
|
||||||
|
|
||||||
=item UNSIGNED
|
=item UNSIGNED
|
||||||
|
|
||||||
Warns that you are comparing a unsigned value in a way that implies it is
|
Warns that you are comparing a unsigned value in a way that implies it is
|
||||||
|
|
|
||||||
|
|
@ -1597,6 +1597,7 @@ public:
|
||||||
AstMemberDType* membersp() const { return op1p()->castMemberDType(); } // op1 = AstMember list
|
AstMemberDType* membersp() const { return op1p()->castMemberDType(); } // op1 = AstMember list
|
||||||
void addMembersp(AstNode* nodep) { addNOp1p(nodep); }
|
void addMembersp(AstNode* nodep) { addNOp1p(nodep); }
|
||||||
bool packed() const { return m_packed; }
|
bool packed() const { return m_packed; }
|
||||||
|
bool packedUnsup() const { return true; } // packed() but as don't support unpacked, presently all structs
|
||||||
void clearCache() { m_members.clear(); }
|
void clearCache() { m_members.clear(); }
|
||||||
void repairMemberCache();
|
void repairMemberCache();
|
||||||
AstMemberDType* findMember(const string& name) const {
|
AstMemberDType* findMember(const string& name) const {
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ private:
|
||||||
AstUnpackArrayDType* arrayp = varp->dtypeSkipRefp()->castUnpackArrayDType();
|
AstUnpackArrayDType* arrayp = varp->dtypeSkipRefp()->castUnpackArrayDType();
|
||||||
AstStructDType *structp = varp->dtypeSkipRefp()->castStructDType();
|
AstStructDType *structp = varp->dtypeSkipRefp()->castStructDType();
|
||||||
bool isArray = arrayp;
|
bool isArray = arrayp;
|
||||||
bool isStruct = structp && structp->packed();
|
bool isStruct = structp && structp->packedUnsup();
|
||||||
int elements = isArray ? arrayp->elementsConst() : 1;
|
int elements = isArray ? arrayp->elementsConst() : 1;
|
||||||
if (isArray && (elements > DETECTARRAY_MAX_INDEXES)) {
|
if (isArray && (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)
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ public:
|
||||||
UNDRIVEN, // No drivers
|
UNDRIVEN, // No drivers
|
||||||
UNOPT, // Unoptimizable block
|
UNOPT, // Unoptimizable block
|
||||||
UNOPTFLAT, // Unoptimizable block after flattening
|
UNOPTFLAT, // Unoptimizable block after flattening
|
||||||
|
UNPACKED, // Unsupported unpacked
|
||||||
UNSIGNED, // Comparison is constant due to unsigned arithmetic
|
UNSIGNED, // Comparison is constant due to unsigned arithmetic
|
||||||
UNUSED, // No receivers
|
UNUSED, // No receivers
|
||||||
VARHIDDEN, // Hiding variable
|
VARHIDDEN, // Hiding variable
|
||||||
|
|
@ -129,7 +130,7 @@ public:
|
||||||
"PINMISSING", "PINNOCONNECT",
|
"PINMISSING", "PINNOCONNECT",
|
||||||
"REALCVT", "REDEFMACRO",
|
"REALCVT", "REDEFMACRO",
|
||||||
"SELRANGE", "STMTDLY", "SYMRSVDWORD", "SYNCASYNCNET",
|
"SELRANGE", "STMTDLY", "SYMRSVDWORD", "SYNCASYNCNET",
|
||||||
"UNDRIVEN", "UNOPT", "UNOPTFLAT", "UNSIGNED", "UNUSED",
|
"UNDRIVEN", "UNOPT", "UNOPTFLAT", "UNPACKED", "UNSIGNED", "UNUSED",
|
||||||
"VARHIDDEN", "WIDTH", "WIDTHCONCAT",
|
"VARHIDDEN", "WIDTH", "WIDTHCONCAT",
|
||||||
" MAX"
|
" MAX"
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1088,7 +1088,9 @@ private:
|
||||||
if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed
|
if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed
|
||||||
UINFO(5," NODECLASS "<<nodep<<endl);
|
UINFO(5," NODECLASS "<<nodep<<endl);
|
||||||
//if (debug()>=9) nodep->dumpTree("-class-in--");
|
//if (debug()>=9) nodep->dumpTree("-class-in--");
|
||||||
if (!nodep->packed()) nodep->v3error("Unsupported: Unpacked struct/union");
|
if (!nodep->packed()) {
|
||||||
|
nodep->v3warn(UNPACKED, "Unsupported: Unpacked struct/union");
|
||||||
|
}
|
||||||
nodep->iterateChildren(*this); // First size all members
|
nodep->iterateChildren(*this); // First size all members
|
||||||
nodep->repairMemberCache();
|
nodep->repairMemberCache();
|
||||||
// Determine bit assignments and width
|
// Determine bit assignments and width
|
||||||
|
|
|
||||||
|
|
@ -389,7 +389,7 @@ private:
|
||||||
VNumRange fromRange = fromdata.m_fromRange;
|
VNumRange fromRange = fromdata.m_fromRange;
|
||||||
if (ddtypep->castBasicDType()
|
if (ddtypep->castBasicDType()
|
||||||
|| (ddtypep->castNodeClassDType()
|
|| (ddtypep->castNodeClassDType()
|
||||||
&& ddtypep->castNodeClassDType()->packed())) {
|
&& ddtypep->castNodeClassDType()->packedUnsup())) {
|
||||||
AstSel* newp = NULL;
|
AstSel* newp = NULL;
|
||||||
if (nodep->castSelPlus()) {
|
if (nodep->castSelPlus()) {
|
||||||
if (fromRange.littleEndian()) {
|
if (fromRange.littleEndian()) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/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 (
|
||||||
|
);
|
||||||
|
|
||||||
|
execute (
|
||||||
|
check_finished=>1,
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
|
//
|
||||||
|
// This file ONLY is placed into the Public Domain, for any use,
|
||||||
|
// without warranty, 2009 by Wilson Snyder.
|
||||||
|
|
||||||
|
module x;
|
||||||
|
|
||||||
|
// verilator lint_off UNPACKED
|
||||||
|
typedef struct {
|
||||||
|
int a;
|
||||||
|
} notpacked_t;
|
||||||
|
// verilator lint_on UNPACKED
|
||||||
|
|
||||||
|
typedef struct packed {
|
||||||
|
notpacked_t b;
|
||||||
|
} ispacked_t;
|
||||||
|
|
||||||
|
ispacked_t p;
|
||||||
|
|
||||||
|
initial begin
|
||||||
|
p.b = 1;
|
||||||
|
if (p.b != 1) $stop;
|
||||||
|
$write("*-* All Finished *-*\n");
|
||||||
|
$finish;
|
||||||
|
end
|
||||||
|
endmodule
|
||||||
|
|
@ -10,7 +10,8 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
|
||||||
compile (
|
compile (
|
||||||
fails=>$Self->{v3},
|
fails=>$Self->{v3},
|
||||||
expect=>
|
expect=>
|
||||||
q{%Error: t/t_struct_unpacked_bad.v:8: Unsupported: Unpacked struct/union
|
q{%Warning-UNPACKED: t/t_struct_unpacked_bad.v:\d+: Unsupported: Unpacked struct/union
|
||||||
|
%Warning-UNPACKED: Use .*
|
||||||
.*%Error: Exiting due to.*},
|
.*%Error: Exiting due to.*},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,15 @@ module x;
|
||||||
} notpacked_t;
|
} notpacked_t;
|
||||||
|
|
||||||
typedef struct packed {
|
typedef struct packed {
|
||||||
notpacked_t a;
|
notpacked_t b;
|
||||||
} ispacked_t;
|
} ispacked_t;
|
||||||
|
|
||||||
|
ispacked_t p;
|
||||||
|
|
||||||
|
initial begin
|
||||||
|
p.b = 1;
|
||||||
|
if (p.b != 1) $stop;
|
||||||
|
$write("*-* All Finished *-*\n");
|
||||||
|
$finish;
|
||||||
|
end
|
||||||
endmodule
|
endmodule
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue