Add UNPACKED warning to convert unpacked structs.

This commit is contained in:
Wilson Snyder 2013-10-28 20:41:05 -04:00
parent b50542531d
commit 4f6d80c602
11 changed files with 72 additions and 6 deletions

View File

@ -5,6 +5,8 @@ indicates the contributor was also the author of the fix; Thanks!
* Verilator 3.854 devel
*** Add UNPACKED warning to convert unpacked structs. [Jeremy Bennett]
**** Support vpi_get of vpiSuppressVal, bug687. [Varun Koyyalagunta]
**** Support vpi_get_time, bug688. [Varun Koyyalagunta]

View File

@ -3225,6 +3225,13 @@ section for more details.
Ignoring this warning will only slow simulations, it will simulate
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
Warns that you are comparing a unsigned value in a way that implies it is

View File

@ -1597,6 +1597,7 @@ public:
AstMemberDType* membersp() const { return op1p()->castMemberDType(); } // op1 = AstMember list
void addMembersp(AstNode* nodep) { addNOp1p(nodep); }
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 repairMemberCache();
AstMemberDType* findMember(const string& name) const {

View File

@ -89,7 +89,7 @@ private:
AstUnpackArrayDType* arrayp = varp->dtypeSkipRefp()->castUnpackArrayDType();
AstStructDType *structp = varp->dtypeSkipRefp()->castStructDType();
bool isArray = arrayp;
bool isStruct = structp && structp->packed();
bool isStruct = structp && structp->packedUnsup();
int elements = isArray ? arrayp->elementsConst() : 1;
if (isArray && (elements > DETECTARRAY_MAX_INDEXES)) {
vscp->v3warn(E_DETECTARRAY, "Unsupported: Can't detect more than "<<cvtToStr(DETECTARRAY_MAX_INDEXES)

View File

@ -93,6 +93,7 @@ public:
UNDRIVEN, // No drivers
UNOPT, // Unoptimizable block
UNOPTFLAT, // Unoptimizable block after flattening
UNPACKED, // Unsupported unpacked
UNSIGNED, // Comparison is constant due to unsigned arithmetic
UNUSED, // No receivers
VARHIDDEN, // Hiding variable
@ -129,7 +130,7 @@ public:
"PINMISSING", "PINNOCONNECT",
"REALCVT", "REDEFMACRO",
"SELRANGE", "STMTDLY", "SYMRSVDWORD", "SYNCASYNCNET",
"UNDRIVEN", "UNOPT", "UNOPTFLAT", "UNSIGNED", "UNUSED",
"UNDRIVEN", "UNOPT", "UNOPTFLAT", "UNPACKED", "UNSIGNED", "UNUSED",
"VARHIDDEN", "WIDTH", "WIDTHCONCAT",
" MAX"
};

View File

@ -1088,7 +1088,9 @@ private:
if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed
UINFO(5," NODECLASS "<<nodep<<endl);
//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->repairMemberCache();
// Determine bit assignments and width

View File

@ -389,7 +389,7 @@ private:
VNumRange fromRange = fromdata.m_fromRange;
if (ddtypep->castBasicDType()
|| (ddtypep->castNodeClassDType()
&& ddtypep->castNodeClassDType()->packed())) {
&& ddtypep->castNodeClassDType()->packedUnsup())) {
AstSel* newp = NULL;
if (nodep->castSelPlus()) {
if (fromRange.littleEndian()) {

View File

@ -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;

View File

@ -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

View File

@ -10,7 +10,8 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
compile (
fails=>$Self->{v3},
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.*},
);

View File

@ -10,7 +10,15 @@ module x;
} notpacked_t;
typedef struct packed {
notpacked_t a;
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