From 9d9d647c1f6d63e0d4c6e16a83dead52cac48db9 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 29 Aug 2022 22:28:02 -0400 Subject: [PATCH] Fix indentation of --protect import function SV code. --- src/V3File.cpp | 8 +++++++- src/V3File.h | 1 + src/V3ProtectLib.cpp | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/V3File.cpp b/src/V3File.cpp index 98e4d5628..54aef8915 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -654,6 +654,10 @@ bool V3OutFormatter::tokenEnd(const char* cp) { || tokenMatch(cp, "endtask")); } +bool V3OutFormatter::tokenNotStart(const char* cp) { + return (tokenMatch(cp, "export") || tokenMatch(cp, "import")); +} + int V3OutFormatter::endLevels(const char* strg) { int levels = m_indentLevel; { @@ -702,12 +706,14 @@ void V3OutFormatter::puts(const char* strg) { putsNoTracking(indentSpaces(endLevels(strg))); m_prependIndent = false; } + bool notstart = false; bool wordstart = true; bool equalsForBracket = false; // Looking for "= {" for (const char* cp = strg; *cp; ++cp) { putcNoTracking(*cp); if (isalpha(*cp)) { - if (wordstart && m_lang == LA_VERILOG && tokenStart(cp)) indentInc(); + if (wordstart && m_lang == LA_VERILOG && tokenNotStart(cp)) notstart = true; + if (wordstart && m_lang == LA_VERILOG && !notstart && tokenStart(cp)) indentInc(); if (wordstart && m_lang == LA_VERILOG && tokenEnd(cp)) indentDec(); } switch (*cp) { diff --git a/src/V3File.h b/src/V3File.h index 28c49e326..309f136c9 100644 --- a/src/V3File.h +++ b/src/V3File.h @@ -173,6 +173,7 @@ public: // Add escaped characters to strings static string quoteNameControls(const string& namein, Language lang = LA_C); static bool tokenMatch(const char* cp, const char* cmp); + static bool tokenNotStart(const char* cp); // Import/export meaning no endfunction static bool tokenStart(const char* cp); static bool tokenEnd(const char* cp); diff --git a/src/V3ProtectLib.cpp b/src/V3ProtectLib.cpp index 0bb5db9a5..1c7631e8a 100644 --- a/src/V3ProtectLib.cpp +++ b/src/V3ProtectLib.cpp @@ -250,7 +250,7 @@ private: // Combinatorial process addComment(txtp, fl, "Combinatorialy evaluate changes to inputs"); m_comboParamsp = new AstTextBlock{fl, - "always @(*) begin\n" + "always @* begin\n" "last_combo_seqnum__V = " + m_libName + "_protectlib_combo_update(\n", false, true}; @@ -283,7 +283,7 @@ private: // Select between combinatorial and sequential results addComment(txtp, fl, "Select between combinatorial and sequential results"); - txtp->addText(fl, "always @(*) begin\n"); + txtp->addText(fl, "always @* begin\n"); if (m_hasClk) { m_seqAssignsp = new AstTextBlock{fl, "if (last_seq_seqnum__V > " "last_combo_seqnum__V) begin\n"};