From 2d52f525c57f8c7d6170c993b24e123241415f4d Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 7 Mar 2020 10:51:06 -0500 Subject: [PATCH] Add --structs-packed for forward compatibility, #1541. --- Changes | 2 ++ bin/verilator | 7 +++++++ src/V3Options.cpp | 2 ++ src/V3Options.h | 2 ++ src/V3Width.cpp | 3 +++ 5 files changed, 16 insertions(+) diff --git a/Changes b/Changes index 4c0ace434..671649dd1 100644 --- a/Changes +++ b/Changes @@ -15,6 +15,8 @@ The contributors that suggested a given feature are shown in []. Thanks! *** Add check for assertOn for asserts, #2162. [Tobias Wölfel] +*** Add --structs-packed for forward compatibility. + *** Fix genblk naming with directly nested generate blocks, #2176. [Alexander Grobman] **** Implement $displayb/o/h, $writeb/o/h, etc, #1637. diff --git a/bin/verilator b/bin/verilator index 57ae1c283..b321db9e7 100755 --- a/bin/verilator +++ b/bin/verilator @@ -1344,6 +1344,13 @@ Creates more detailed statistics, including a list of all the variables by size (plain --stats just gives a count). See --stats, which is implied by this. +=item --structs-packed + +Converts all unpacked structures to packed structures and issues a UNPACKED +warning. Currently this is the default and --no-structs-packed will not +work. Specifying this option allows for forward compatibility when a +future version of Verilator no longer always packs unpacked structures. + =item -sv Specifies SystemVerilog language features should be enabled; equivalent to diff --git a/src/V3Options.cpp b/src/V3Options.cpp index eb56d87b2..724fc37e4 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -786,6 +786,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char else if ( onoffb(sw, "-skip-identical", bflag/*ref*/)) { m_skipIdentical = bflag; } else if ( onoff (sw, "-stats", flag/*ref*/)) { m_stats = flag; } else if ( onoff (sw, "-stats-vars", flag/*ref*/)) { m_statsVars = flag; m_stats |= flag; } + else if ( onoff (sw, "-structs-unpacked", flag/*ref*/)) { m_structsPacked = flag; } else if (!strcmp(sw, "-sv")) { m_defaultLanguage = V3LangCode::L1800_2005; } else if ( onoff (sw, "-threads-coarsen", flag/*ref*/)) { m_threadsCoarsen = flag; } // Undocumented, debug else if ( onoff (sw, "-trace", flag/*ref*/)) { m_trace = flag; } @@ -1489,6 +1490,7 @@ V3Options::V3Options() { m_savable = false; m_stats = false; m_statsVars = false; + m_structsPacked = true; m_systemC = false; m_threads = 0; m_threadsDpiPure = true; diff --git a/src/V3Options.h b/src/V3Options.h index f89ab5a45..339349fdc 100644 --- a/src/V3Options.h +++ b/src/V3Options.h @@ -184,6 +184,7 @@ class V3Options { bool m_relativeIncludes; // main switch: --relative-includes bool m_reportUnoptflat; // main switch: --report-unoptflat bool m_savable; // main switch: --savable + bool m_structsPacked; // main switch: --structs-packed bool m_systemC; // main switch: --sc: System C instead of simple C++ bool m_stats; // main switch: --stats bool m_statsVars; // main switch: --stats-vars @@ -322,6 +323,7 @@ class V3Options { bool savable() const { return m_savable; } bool stats() const { return m_stats; } bool statsVars() const { return m_statsVars; } + bool structsPacked() const { return m_structsPacked; } bool assertOn() const { return m_assert; } // assertOn as __FILE__ may be defined bool autoflush() const { return m_autoflush; } bool bboxSys() const { return m_bboxSys; } diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 8283ce30c..485dbd7e0 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -1745,6 +1745,9 @@ private: //if (debug()>=9) nodep->dumpTree("-class-in--"); if (!nodep->packed()) { nodep->v3warn(UNPACKED, "Unsupported: Unpacked struct/union"); + if (!v3Global.opt.structsPacked()) { + nodep->v3warn(UNPACKED, "Unsupported: --no-structs-packed"); + } } userIterateChildren(nodep, NULL); // First size all members nodep->repairMemberCache();