<?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=Access_attributes_in_parsetree</id>
		<title>Access attributes in parsetree - 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=Access_attributes_in_parsetree"/>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Access_attributes_in_parsetree&amp;action=history"/>
		<updated>2026-05-02T12:45:40Z</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=Access_attributes_in_parsetree&amp;diff=784&amp;oldid=prev</id>
		<title>Hoa at 21:22, 3 May 2022</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Access_attributes_in_parsetree&amp;diff=784&amp;oldid=prev"/>
				<updated>2022-05-03T21:22:37Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;' lang='en'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 21:22, 3 May 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l48&quot; &gt;Line 48:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 48:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; if (!veri_file::Analyze(&amp;quot;test.v&amp;quot;)) return 1 ;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; if (!veri_file::Analyze(&amp;quot;test.v&amp;quot;)) return 1 ;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; if (!veri_file::ElaborateAllStatic()) return 2 ;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; if (!veri_file::ElaborateAllStatic()) return 2 ; &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;// requires Static Elaborator&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; MapIter mi ;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; MapIter mi ;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Access_attributes_in_parsetree&amp;diff=562&amp;oldid=prev</id>
		<title>Hoa: Created page with &quot; &lt;nowiki&gt; #include &quot;veri_file.h&quot; #include &quot;VeriModule.h&quot; #include &quot;VeriExpression.h&quot; #include &quot;VeriMisc.h&quot; #include &quot;VeriId.h&quot;  #include &quot;Map.h&quot; #include &quot;Array.h&quot;  #include &quot;...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Access_attributes_in_parsetree&amp;diff=562&amp;oldid=prev"/>
				<updated>2020-12-07T20:49:12Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot; &amp;lt;nowiki&amp;gt; #include &amp;quot;veri_file.h&amp;quot; #include &amp;quot;VeriModule.h&amp;quot; #include &amp;quot;VeriExpression.h&amp;quot; #include &amp;quot;VeriMisc.h&amp;quot; #include &amp;quot;VeriId.h&amp;quot;  #include &amp;quot;Map.h&amp;quot; #include &amp;quot;Array.h&amp;quot;  #include &amp;quot;...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt; &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;veri_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriModule.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriMisc.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriId.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Map.h&amp;quot;&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;
&lt;br /&gt;
#ifdef VERIFIC_NAMESPACE&lt;br /&gt;
using namespace Verific ;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
void&lt;br /&gt;
PrintAttrs(const char *type, const char *name, const VeriTreeNode *node)&lt;br /&gt;
{&lt;br /&gt;
    if (!node) return ;&lt;br /&gt;
&lt;br /&gt;
#if 1&lt;br /&gt;
    // Print all attributes:&lt;br /&gt;
    const Array *attr_insts = node-&amp;gt;GetAttributeInstances() ;&lt;br /&gt;
    unsigned i ;&lt;br /&gt;
    const VeriAttributeInstance *attr_inst ;&lt;br /&gt;
    FOREACH_ARRAY_ITEM(attr_insts, i, attr_inst) {&lt;br /&gt;
        if (!attr_inst) continue ;&lt;br /&gt;
        char *str = attr_inst-&amp;gt;GetPrettyPrintedString() ;&lt;br /&gt;
        node-&amp;gt;Info(&amp;quot;%s %s : Attribute : %s&amp;quot;, ((type)?type:&amp;quot;&amp;quot;), ((name)?name:&amp;quot;&amp;quot;), str) ;&lt;br /&gt;
        Strings::free(str) ;&lt;br /&gt;
    }&lt;br /&gt;
#else&lt;br /&gt;
    // Print a specific attribute whose name is known:&lt;br /&gt;
    VeriExpression *attr_val = node-&amp;gt;GetAttribute(&amp;quot;attr1&amp;quot;) ;&lt;br /&gt;
    if (attr_val) {&lt;br /&gt;
        char *str = attr_val-&amp;gt;GetPrettyPrintedString() ;&lt;br /&gt;
        node-&amp;gt;Info(&amp;quot;%s %s : Attribute : attr = %s&amp;quot;, ((type)?type:&amp;quot;&amp;quot;), ((name)?name:&amp;quot;&amp;quot;), str) ;&lt;br /&gt;
        Strings::free(str) ;&lt;br /&gt;
    }&lt;br /&gt;
#endif&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    // Optional depending on flow - RuntimeFlags::SetVar(&amp;quot;veri_do_not_touch_parse_tree&amp;quot;, 1) ;&lt;br /&gt;
    // Optional depending on flow - RuntimeFlags::SetVar(&amp;quot;veri_uniquify_all_instances&amp;quot;, 0) ;&lt;br /&gt;
&lt;br /&gt;
    if (!veri_file::Analyze(&amp;quot;test.v&amp;quot;)) return 1 ;&lt;br /&gt;
    if (!veri_file::ElaborateAllStatic()) return 2 ;&lt;br /&gt;
&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    VeriModule *mod ;&lt;br /&gt;
    FOREACH_VERILOG_MODULE(mi, mod) {&lt;br /&gt;
        if (!mod) continue ;&lt;br /&gt;
        PrintAttrs(&amp;quot;Module&amp;quot;, mod-&amp;gt;Name(), mod) ;&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;
            Array *ids = item-&amp;gt;GetIds() ;&lt;br /&gt;
            VeriIdDef *id = (ids &amp;amp;&amp;amp; ids-&amp;gt;Size()) ? (VeriIdDef *)ids-&amp;gt;GetFirst() : 0 ;&lt;br /&gt;
            PrintAttrs(&amp;quot;Module item&amp;quot;, ((id)?id-&amp;gt;Name():0), item) ;&lt;br /&gt;
        }&lt;br /&gt;
    }&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;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ cat test.v&lt;br /&gt;
(*attr1=&amp;quot;attr_1&amp;quot;*)module a(in1,in2);&lt;br /&gt;
   (*attr2=&amp;quot;attr_2&amp;quot;*)input in1;&lt;br /&gt;
   input in2 ;&lt;br /&gt;
   parameter P = 0 ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
module test ;&lt;br /&gt;
    a a1 (w1, w2) ;&lt;br /&gt;
    a #(1) a2 (w1, w2) ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
$ test-linux&lt;br /&gt;
-- Analyzing Verilog file 'test.v' (VERI-1482)&lt;br /&gt;
test.v(7): INFO: compiling module 'test' (VERI-1018)&lt;br /&gt;
test.v(5): INFO: Module a : Attribute : (* attr1=&amp;quot;attr_1&amp;quot; *)&lt;br /&gt;
test.v(2): INFO: Module item in1 : Attribute : (* attr2=&amp;quot;attr_2&amp;quot; *)&lt;br /&gt;
test.v(5): INFO: Module a(P=1) : Attribute : (* attr1=&amp;quot;attr_1&amp;quot; *)&lt;br /&gt;
test.v(2): INFO: Module item in1 : Attribute : (* attr2=&amp;quot;attr_2&amp;quot; *)&lt;br /&gt;
&lt;br /&gt;
$&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	</feed>