<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://www.verific.com/faq/index.php?action=history&amp;feed=atom&amp;title=Test-based_design_modification</id>
		<title>Test-based design modification - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://www.verific.com/faq/index.php?action=history&amp;feed=atom&amp;title=Test-based_design_modification"/>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Test-based_design_modification&amp;action=history"/>
		<updated>2026-05-02T12:40:27Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.3</generator>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Test-based_design_modification&amp;diff=414&amp;oldid=prev</id>
		<title>Amber: Created page with &quot;C++:  &lt;nowiki&gt; #include &lt;iostream&gt;  #include &quot;veri_file.h&quot;  #include &quot;VeriModule.h&quot; #include &quot;VeriStatement.h&quot;  #include &quot;Array.h&quot;  #include &quot;Strings.h&quot; #include &quot;TextBasedDes...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Test-based_design_modification&amp;diff=414&amp;oldid=prev"/>
				<updated>2019-07-18T21:00:23Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;C++:  &amp;lt;nowiki&amp;gt; #include &amp;lt;iostream&amp;gt;  #include &amp;quot;veri_file.h&amp;quot;  #include &amp;quot;VeriModule.h&amp;quot; #include &amp;quot;VeriStatement.h&amp;quot;  #include &amp;quot;Array.h&amp;quot;  #include &amp;quot;Strings.h&amp;quot; #include &amp;quot;TextBasedDes...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;C++:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;veri_file.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;VeriModule.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriStatement.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Array.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Strings.h&amp;quot;&lt;br /&gt;
#include &amp;quot;TextBasedDesignMod.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#ifdef VERIFIC_NAMESPACE&lt;br /&gt;
using namespace Verific ;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
void CommentStmtInParseTree(VeriModule *mod)&lt;br /&gt;
{&lt;br /&gt;
    if (!mod) return ;&lt;br /&gt;
&lt;br /&gt;
    Array *mod_items = mod-&amp;gt;GetModuleItems() ;&lt;br /&gt;
    unsigned i ;&lt;br /&gt;
    VeriModuleItem *item ;&lt;br /&gt;
    FOREACH_ARRAY_ITEM(mod_items, i, item) {&lt;br /&gt;
        if (!item) continue ;&lt;br /&gt;
        // Get statement from the module item (initial block)&lt;br /&gt;
        VeriStatement *stmt = item-&amp;gt;GetStmt() ;&lt;br /&gt;
        if (!stmt) continue ;&lt;br /&gt;
        // Get all statements from the statement (squential block in initial block)&lt;br /&gt;
        Array *stmts = stmt-&amp;gt;GetStatements() ;&lt;br /&gt;
        if (stmts) {&lt;br /&gt;
            unsigned j ;&lt;br /&gt;
            VeriStatement *child ;&lt;br /&gt;
            // Iterate over the child statement:&lt;br /&gt;
            FOREACH_ARRAY_ITEM(stmts, j, child) {&lt;br /&gt;
                if (!child) continue ;&lt;br /&gt;
                // Get the string of the statement:&lt;br /&gt;
                char *tmp = child-&amp;gt;GetPrettyPrintedString() ;&lt;br /&gt;
                // Remove the last new-line:&lt;br /&gt;
                unsigned len = Strings::len(tmp) ;&lt;br /&gt;
                if (!tmp || !len) continue ;&lt;br /&gt;
                if (tmp[len-1] == '\n') tmp[len-1] = '\0' ;&lt;br /&gt;
                // Comment out the string:&lt;br /&gt;
                char *str = Strings::save(&amp;quot;/* &amp;quot;, tmp, &amp;quot; */&amp;quot;) ;&lt;br /&gt;
                Strings::free(tmp) ;&lt;br /&gt;
                // Create a null statement:&lt;br /&gt;
                VeriStatement *new_stmt = new VeriNullStatement() ;&lt;br /&gt;
                new_stmt-&amp;gt;SetLinefile(child-&amp;gt;Linefile()) ;&lt;br /&gt;
                // Create a comment node with the comment string:&lt;br /&gt;
                VeriCommentNode *comment = new VeriCommentNode(child-&amp;gt;Linefile()) ;&lt;br /&gt;
                comment-&amp;gt;AppendComment(str) ;&lt;br /&gt;
                Strings::free(str) ;&lt;br /&gt;
                // Add the comment on the null-statement:&lt;br /&gt;
                Array *comments = new Array(1) ;&lt;br /&gt;
                comments-&amp;gt;InsertLast(comment) ;&lt;br /&gt;
                new_stmt-&amp;gt;AddComments(comments) ;&lt;br /&gt;
                // Finally replace the original statement with the created null-statement:&lt;br /&gt;
                if (!stmt-&amp;gt;ReplaceChildStmt(child, new_stmt, 1 /* delete old stmt */)) delete new_stmt ;&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
                // Get the string of the statement:&lt;br /&gt;
            char *tmp = stmt-&amp;gt;GetPrettyPrintedString() ;&lt;br /&gt;
                // Remove the last new-line:&lt;br /&gt;
            unsigned len = Strings::len(tmp) ;&lt;br /&gt;
            if (!tmp || !len) continue ;&lt;br /&gt;
            if (tmp[len-1] == '\n') tmp[len-1] = '\0' ;&lt;br /&gt;
                // Comment out the string:&lt;br /&gt;
            char *str = Strings::save(&amp;quot;/* &amp;quot;, tmp, &amp;quot; */&amp;quot;) ;&lt;br /&gt;
            Strings::free(tmp) ;&lt;br /&gt;
                // Create a null statement:&lt;br /&gt;
            VeriStatement *new_stmt = new VeriNullStatement() ;&lt;br /&gt;
            new_stmt-&amp;gt;SetLinefile(stmt-&amp;gt;Linefile()) ;&lt;br /&gt;
            // Create a comment node with the comment string:&lt;br /&gt;
            VeriCommentNode *comment = new VeriCommentNode(stmt-&amp;gt;Linefile()) ;&lt;br /&gt;
            comment-&amp;gt;AppendComment(str) ;&lt;br /&gt;
            Strings::free(str) ;&lt;br /&gt;
            // Add the comment on the null-statement:&lt;br /&gt;
            Array *comments = new Array(1) ;&lt;br /&gt;
            comments-&amp;gt;InsertLast(comment) ;&lt;br /&gt;
            new_stmt-&amp;gt;AddComments(comments) ;&lt;br /&gt;
            // Finally replace the original statement with the created null-statement:&lt;br /&gt;
            if (!item-&amp;gt;ReplaceChildStmt(stmt, new_stmt, 1 /* delete old stmt */)) delete new_stmt ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    veri_file::PrettyPrint(&amp;quot;test_pp.v.golden.new&amp;quot;, 0) ;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void CommentStmtViaTBDM(VeriModule *mod, TextBasedDesignMod &amp;amp;tbdm)&lt;br /&gt;
{&lt;br /&gt;
    if (!mod) return ;&lt;br /&gt;
&lt;br /&gt;
    Array *mod_items = mod-&amp;gt;GetModuleItems() ;&lt;br /&gt;
    unsigned i ;&lt;br /&gt;
    VeriModuleItem *item ;&lt;br /&gt;
    FOREACH_ARRAY_ITEM(mod_items, i, item) {&lt;br /&gt;
        if (!item) continue ;&lt;br /&gt;
        // Get statement from the module item (initial block)&lt;br /&gt;
        VeriStatement *stmt = item-&amp;gt;GetStmt() ;&lt;br /&gt;
        if (!stmt) continue ;&lt;br /&gt;
        // Get all statements from the statement (squential block in initial block)&lt;br /&gt;
        Array *stmts = stmt-&amp;gt;GetStatements() ;&lt;br /&gt;
        if (stmts) {&lt;br /&gt;
            unsigned j ;&lt;br /&gt;
            VeriStatement *child ;&lt;br /&gt;
            // Iterate over the child statement:&lt;br /&gt;
            FOREACH_ARRAY_ITEM(stmts, j, child) {&lt;br /&gt;
                if (!child) continue ;&lt;br /&gt;
                // Comment the whole statement:&lt;br /&gt;
                tbdm.InsertBefore(child-&amp;gt;Linefile(), &amp;quot;; /* &amp;quot;) ;&lt;br /&gt;
                tbdm.InsertAfter(child-&amp;gt;Linefile(), &amp;quot; */&amp;quot;) ;&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            // Comment the whole statement:&lt;br /&gt;
            tbdm.InsertBefore(stmt-&amp;gt;Linefile(), &amp;quot;; /* &amp;quot;) ;&lt;br /&gt;
            tbdm.InsertAfter(stmt-&amp;gt;Linefile(), &amp;quot; */&amp;quot;) ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    if (!veri_file::Analyze(&amp;quot;test.v&amp;quot;)) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    VeriModule *mod = veri_file::GetModule(&amp;quot;test&amp;quot;) ;&lt;br /&gt;
    if (!mod) return 2 ;&lt;br /&gt;
&lt;br /&gt;
    CommentStmtInParseTree(mod) ;&lt;br /&gt;
&lt;br /&gt;
    TextBasedDesignMod tbdm(0) ;&lt;br /&gt;
    CommentStmtViaTBDM(mod, tbdm) ;&lt;br /&gt;
    tbdm.WriteFile(&amp;quot;test.v&amp;quot;, &amp;quot;test_out.v.golden.new&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
    return 0 ;&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input Verilog:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module test ;&lt;br /&gt;
    reg A, b ;&lt;br /&gt;
    initial&lt;br /&gt;
        A = b ;&lt;br /&gt;
    initial&lt;br /&gt;
    begin&lt;br /&gt;
        A = b ;&lt;br /&gt;
    end&lt;br /&gt;
endmodule&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output Verilog:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module test ;&lt;br /&gt;
    reg A, b ;&lt;br /&gt;
    initial&lt;br /&gt;
        ; /* A = b ; */&lt;br /&gt;
    initial&lt;br /&gt;
    begin&lt;br /&gt;
        ; /* A = b ; */&lt;br /&gt;
    end&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Amber</name></author>	</entry>

	</feed>