forked from github/verilator
Fix indentation of --protect import function SV code.
This commit is contained in:
parent
d47a37fb76
commit
9d9d647c1f
@ -654,6 +654,10 @@ bool V3OutFormatter::tokenEnd(const char* cp) {
|
|||||||
|| tokenMatch(cp, "endtask"));
|
|| tokenMatch(cp, "endtask"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool V3OutFormatter::tokenNotStart(const char* cp) {
|
||||||
|
return (tokenMatch(cp, "export") || tokenMatch(cp, "import"));
|
||||||
|
}
|
||||||
|
|
||||||
int V3OutFormatter::endLevels(const char* strg) {
|
int V3OutFormatter::endLevels(const char* strg) {
|
||||||
int levels = m_indentLevel;
|
int levels = m_indentLevel;
|
||||||
{
|
{
|
||||||
@ -702,12 +706,14 @@ void V3OutFormatter::puts(const char* strg) {
|
|||||||
putsNoTracking(indentSpaces(endLevels(strg)));
|
putsNoTracking(indentSpaces(endLevels(strg)));
|
||||||
m_prependIndent = false;
|
m_prependIndent = false;
|
||||||
}
|
}
|
||||||
|
bool notstart = false;
|
||||||
bool wordstart = true;
|
bool wordstart = true;
|
||||||
bool equalsForBracket = false; // Looking for "= {"
|
bool equalsForBracket = false; // Looking for "= {"
|
||||||
for (const char* cp = strg; *cp; ++cp) {
|
for (const char* cp = strg; *cp; ++cp) {
|
||||||
putcNoTracking(*cp);
|
putcNoTracking(*cp);
|
||||||
if (isalpha(*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();
|
if (wordstart && m_lang == LA_VERILOG && tokenEnd(cp)) indentDec();
|
||||||
}
|
}
|
||||||
switch (*cp) {
|
switch (*cp) {
|
||||||
|
@ -173,6 +173,7 @@ public:
|
|||||||
// Add escaped characters to strings
|
// Add escaped characters to strings
|
||||||
static string quoteNameControls(const string& namein, Language lang = LA_C);
|
static string quoteNameControls(const string& namein, Language lang = LA_C);
|
||||||
static bool tokenMatch(const char* cp, const char* cmp);
|
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 tokenStart(const char* cp);
|
||||||
static bool tokenEnd(const char* cp);
|
static bool tokenEnd(const char* cp);
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ private:
|
|||||||
// Combinatorial process
|
// Combinatorial process
|
||||||
addComment(txtp, fl, "Combinatorialy evaluate changes to inputs");
|
addComment(txtp, fl, "Combinatorialy evaluate changes to inputs");
|
||||||
m_comboParamsp = new AstTextBlock{fl,
|
m_comboParamsp = new AstTextBlock{fl,
|
||||||
"always @(*) begin\n"
|
"always @* begin\n"
|
||||||
"last_combo_seqnum__V = "
|
"last_combo_seqnum__V = "
|
||||||
+ m_libName + "_protectlib_combo_update(\n",
|
+ m_libName + "_protectlib_combo_update(\n",
|
||||||
false, true};
|
false, true};
|
||||||
@ -283,7 +283,7 @@ private:
|
|||||||
|
|
||||||
// Select between combinatorial and sequential results
|
// Select between combinatorial and sequential results
|
||||||
addComment(txtp, fl, "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) {
|
if (m_hasClk) {
|
||||||
m_seqAssignsp = new AstTextBlock{fl, "if (last_seq_seqnum__V > "
|
m_seqAssignsp = new AstTextBlock{fl, "if (last_seq_seqnum__V > "
|
||||||
"last_combo_seqnum__V) begin\n"};
|
"last_combo_seqnum__V) begin\n"};
|
||||||
|
Loading…
Reference in New Issue
Block a user