<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://www.verific.com/faq/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Hoa</id>
		<title>Verific Design Automation FAQ - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://www.verific.com/faq/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Hoa"/>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Special:Contributions/Hoa"/>
		<updated>2026-05-02T11:11:23Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.26.3</generator>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Modules/design_units_with_%22_default%22_suffix_in_their_names&amp;diff=971</id>
		<title>Modules/design units with &quot; default&quot; suffix in their names</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Modules/design_units_with_%22_default%22_suffix_in_their_names&amp;diff=971"/>
				<updated>2026-03-11T22:25:39Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt; This article is currently under construction &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Q: After static elaboration, there are modules/design units with &amp;quot;_default&amp;quot; or &amp;quot;_1, _2&amp;quot; suffix in their names. Why? And what are they? '''&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_default&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Static elaboration process is a multiple-iteration process and modules/design units may be modified differently in each iteration.&lt;br /&gt;
&lt;br /&gt;
We need to keep original version of modules/design units as they are immediately after analysis so that they can be copied for different parameter/generic settings in each iteration and body of copied modules/design units can be elaborated (generate unroll, array instance processing, etc.) differently for each parameter/generic setting.&lt;br /&gt;
&lt;br /&gt;
Another reason to copy instantiated modules/design units with &amp;quot;_default&amp;quot; name is in mixed language elaboration. Here a Verilog module may instantiate a VHDL entity which has been elaborated earlier with different generic values. In that case during Verilog elaboration we will not get original contents of instantiated entity.&lt;br /&gt;
&lt;br /&gt;
Moreover, to support incremental elaboration we need to keep original modules/design units, as lower level units can be elaborated earlier.&lt;br /&gt;
&lt;br /&gt;
In Verilog, we have a runtime-flag &amp;quot;veri_remove_suffix_default_from_copied_module_names&amp;quot; to rename modules from &amp;quot;&amp;lt;orig_name&amp;gt;_default&amp;quot; to &amp;quot;&amp;lt;orig_name&amp;gt;&amp;quot;. This will work only when runtime-flag &amp;quot;veri_cleanup_base_modules&amp;quot; is set.&lt;br /&gt;
&lt;br /&gt;
The flag &amp;quot;veri_remove_suffix_default_from_copied_module_names&amp;quot; does not apply to interfaces, packages, and checkers.&lt;br /&gt;
&lt;br /&gt;
==== Interfaces with &amp;quot;_default&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
SystemVerilog interfaces can be used in any of the following ways :&lt;br /&gt;
&lt;br /&gt;
*  As interface instantiations.&lt;br /&gt;
*  As interface ports.&lt;br /&gt;
*  As virtual interfaces.&lt;br /&gt;
*  As hierarchical names.&lt;br /&gt;
&lt;br /&gt;
Interface is always copied with '_default' suffix since we do not know for sure if there is a virtual interface in the hierarchy below which is yet to be processed.&lt;br /&gt;
&lt;br /&gt;
The copied interface (with '_default' suffix) will be the one that is elaborated and specified in the virtual interface declaration, interface instance, or top-level module port.  Every instantiated module containing interface type ports will also be copied during static elaboration since its interface port names may have been modified as well.&lt;br /&gt;
&lt;br /&gt;
Virtual interfaces can appear in many different parts of a design, and may or may not be associated with interface instances. Virtual interfaces are not stored in Verific's pseudo-tree, so after static elaboration we do not know whether an interface is used as a virtual interface or not, or where it is being used.  Without this knowledge, we cannot arbitrarily change all the references of an interface from  '&amp;lt;interface_name&amp;gt;_default'  to  '&amp;lt;interface_name&amp;gt; because the references may become invalid. Because of this, we do not have flags to remove the '_default' from the interface names as we do for modules.&lt;br /&gt;
&lt;br /&gt;
The '_default_&amp;lt;n&amp;gt;' suffix may also be added due to the presence of hierarchical references in an interface or bind statements containing interface instantiations.&lt;br /&gt;
&lt;br /&gt;
Verific VIPER #19809 has more details.&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_&amp;lt;N&amp;gt;&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Modules can be copied with _&amp;lt;N&amp;gt; suffix for hier-ref present/going via them.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module top ;&lt;br /&gt;
    test      t  () ;&lt;br /&gt;
    test #(0) t0 () ;&lt;br /&gt;
    test #(1) t1 () ;&lt;br /&gt;
    test #(2) t2 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module test ;&lt;br /&gt;
    parameter P = 0 ;&lt;br /&gt;
    wire [P:0] sig ;&lt;br /&gt;
    bot b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot ;&lt;br /&gt;
    initial $display(test.sig) ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here &amp;quot;bot&amp;quot; has to be copied 3 times with _&amp;lt;N&amp;gt; suffix so that they can point to 3 different &amp;quot;sig&amp;quot; of 3 different sizes.&lt;br /&gt;
The same can happen for bind statements as well. Different bind instances can be added to different instances of the same module.&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_copy&amp;lt;N&amp;gt;&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Modules can be copied with _copy&amp;lt;N&amp;gt; suffix when a module with _&amp;lt;N&amp;gt; is already present in the same library.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module top ;&lt;br /&gt;
    test      t  () ;&lt;br /&gt;
    test #(0) t0 () ;&lt;br /&gt;
    test #(1) t1 () ;&lt;br /&gt;
    test #(2) t2 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module test ;&lt;br /&gt;
    parameter P = 0 ;&lt;br /&gt;
    wire [P:0] sig ;&lt;br /&gt;
    bot b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot ;&lt;br /&gt;
    initial $display(test.sig) ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot_2 ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here &amp;quot;bot_2&amp;quot; already exists and hence the copied &amp;quot;bot&amp;quot; which we wanted to name &amp;quot;bot_2&amp;quot; is renamed to &amp;quot;bot_copy&amp;lt;N&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_&amp;lt;N&amp;gt;_&amp;lt;M&amp;gt;&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Modules can even be copied with _&amp;lt;N&amp;gt;_&amp;lt;M&amp;gt; suffix in some corner cases with name conflict as well as hier-refs.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module top ;&lt;br /&gt;
    test      t  () ;&lt;br /&gt;
    test #(0) t0 () ;&lt;br /&gt;
    test #(1) t1 () ;&lt;br /&gt;
    test #(2) t2 () ;&lt;br /&gt;
    bot_2 b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module test ;&lt;br /&gt;
    parameter P = 0 ;&lt;br /&gt;
    wire [P:0] sig ;&lt;br /&gt;
    bot b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot ;&lt;br /&gt;
    initial $display(test.sig) ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot_2 ;&lt;br /&gt;
    generate&lt;br /&gt;
        test #(2) t1 () ;&lt;br /&gt;
    endgenerate&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here instead of &amp;quot;bot_copy&amp;lt;N&amp;gt;&amp;quot;, one of the elaborated versions of &amp;quot;bot&amp;quot; which is to be renamed to &amp;quot;bot_2&amp;quot; is actually named as &amp;quot;bot_2_1&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== How to get the original name or the original module ====&lt;br /&gt;
&lt;br /&gt;
APIs to retrieve the original name of the module or to get the original module itself (only when the original module is available):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
VeriModule::GetOriginalModuleName()&lt;br /&gt;
VeriModule::GetOriginalModule()&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Modules/design_units_with_%22_default%22_suffix_in_their_names&amp;diff=970</id>
		<title>Modules/design units with &quot; default&quot; suffix in their names</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Modules/design_units_with_%22_default%22_suffix_in_their_names&amp;diff=970"/>
				<updated>2026-03-11T22:25:17Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt; This article is currently under construction &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Q: After static elaboration, there are modules/design units with &amp;quot;_default&amp;quot; or &amp;quot;_1, _2&amp;quot; suffix in their names. Why? And what are they? '''&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_default&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Static elaboration process is a multiple-iteration process and modules/design units may be modified differently in each iteration.&lt;br /&gt;
&lt;br /&gt;
We need to keep original version of modules/design units as they are immediately after analysis so that they can be copied for different parameter/generic settings in each iteration and body of copied modules/design units can be elaborated (generate unroll, array instance processing, etc.) differently for each parameter/generic setting.&lt;br /&gt;
&lt;br /&gt;
Another reason to copy instantiated modules/design units with &amp;quot;_default&amp;quot; name is in mixed language elaboration. Here a Verilog module may instantiate a VHDL entity which has been elaborated earlier with different generic values. In that case during Verilog elaboration we will not get original contents of instantiated entity.&lt;br /&gt;
&lt;br /&gt;
Moreover, to support incremental elaboration we need to keep original modules/design units, as lower level units can be elaborated earlier.&lt;br /&gt;
&lt;br /&gt;
In Verilog, we have a runtime-flag &amp;quot;veri_remove_suffix_default_from_copied_module_names&amp;quot; to rename modules from &amp;quot;&amp;lt;orig_name&amp;gt;_default&amp;quot; to &amp;quot;&amp;lt;orig_name&amp;gt;&amp;quot;. This will work only when runtime-flag &amp;quot;veri_cleanup_base_modules&amp;quot; is set. Also, the flag &amp;quot;veri_remove_suffix_default_from_copied_module_names&amp;quot; does not apply to interfaces, packages, and checkers.&lt;br /&gt;
&lt;br /&gt;
==== Interfaces with &amp;quot;_default&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
SystemVerilog interfaces can be used in any of the following ways :&lt;br /&gt;
&lt;br /&gt;
*  As interface instantiations.&lt;br /&gt;
*  As interface ports.&lt;br /&gt;
*  As virtual interfaces.&lt;br /&gt;
*  As hierarchical names.&lt;br /&gt;
&lt;br /&gt;
Interface is always copied with '_default' suffix since we do not know for sure if there is a virtual interface in the hierarchy below which is yet to be processed.&lt;br /&gt;
&lt;br /&gt;
The copied interface (with '_default' suffix) will be the one that is elaborated and specified in the virtual interface declaration, interface instance, or top-level module port.  Every instantiated module containing interface type ports will also be copied during static elaboration since its interface port names may have been modified as well.&lt;br /&gt;
&lt;br /&gt;
Virtual interfaces can appear in many different parts of a design, and may or may not be associated with interface instances. Virtual interfaces are not stored in Verific's pseudo-tree, so after static elaboration we do not know whether an interface is used as a virtual interface or not, or where it is being used.  Without this knowledge, we cannot arbitrarily change all the references of an interface from  '&amp;lt;interface_name&amp;gt;_default'  to  '&amp;lt;interface_name&amp;gt; because the references may become invalid. Because of this, we do not have flags to remove the '_default' from the interface names as we do for modules.&lt;br /&gt;
&lt;br /&gt;
The '_default_&amp;lt;n&amp;gt;' suffix may also be added due to the presence of hierarchical references in an interface or bind statements containing interface instantiations.&lt;br /&gt;
&lt;br /&gt;
Verific VIPER #19809 has more details.&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_&amp;lt;N&amp;gt;&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Modules can be copied with _&amp;lt;N&amp;gt; suffix for hier-ref present/going via them.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module top ;&lt;br /&gt;
    test      t  () ;&lt;br /&gt;
    test #(0) t0 () ;&lt;br /&gt;
    test #(1) t1 () ;&lt;br /&gt;
    test #(2) t2 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module test ;&lt;br /&gt;
    parameter P = 0 ;&lt;br /&gt;
    wire [P:0] sig ;&lt;br /&gt;
    bot b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot ;&lt;br /&gt;
    initial $display(test.sig) ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here &amp;quot;bot&amp;quot; has to be copied 3 times with _&amp;lt;N&amp;gt; suffix so that they can point to 3 different &amp;quot;sig&amp;quot; of 3 different sizes.&lt;br /&gt;
The same can happen for bind statements as well. Different bind instances can be added to different instances of the same module.&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_copy&amp;lt;N&amp;gt;&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Modules can be copied with _copy&amp;lt;N&amp;gt; suffix when a module with _&amp;lt;N&amp;gt; is already present in the same library.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module top ;&lt;br /&gt;
    test      t  () ;&lt;br /&gt;
    test #(0) t0 () ;&lt;br /&gt;
    test #(1) t1 () ;&lt;br /&gt;
    test #(2) t2 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module test ;&lt;br /&gt;
    parameter P = 0 ;&lt;br /&gt;
    wire [P:0] sig ;&lt;br /&gt;
    bot b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot ;&lt;br /&gt;
    initial $display(test.sig) ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot_2 ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here &amp;quot;bot_2&amp;quot; already exists and hence the copied &amp;quot;bot&amp;quot; which we wanted to name &amp;quot;bot_2&amp;quot; is renamed to &amp;quot;bot_copy&amp;lt;N&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_&amp;lt;N&amp;gt;_&amp;lt;M&amp;gt;&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Modules can even be copied with _&amp;lt;N&amp;gt;_&amp;lt;M&amp;gt; suffix in some corner cases with name conflict as well as hier-refs.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module top ;&lt;br /&gt;
    test      t  () ;&lt;br /&gt;
    test #(0) t0 () ;&lt;br /&gt;
    test #(1) t1 () ;&lt;br /&gt;
    test #(2) t2 () ;&lt;br /&gt;
    bot_2 b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module test ;&lt;br /&gt;
    parameter P = 0 ;&lt;br /&gt;
    wire [P:0] sig ;&lt;br /&gt;
    bot b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot ;&lt;br /&gt;
    initial $display(test.sig) ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot_2 ;&lt;br /&gt;
    generate&lt;br /&gt;
        test #(2) t1 () ;&lt;br /&gt;
    endgenerate&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here instead of &amp;quot;bot_copy&amp;lt;N&amp;gt;&amp;quot;, one of the elaborated versions of &amp;quot;bot&amp;quot; which is to be renamed to &amp;quot;bot_2&amp;quot; is actually named as &amp;quot;bot_2_1&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== How to get the original name or the original module ====&lt;br /&gt;
&lt;br /&gt;
APIs to retrieve the original name of the module or to get the original module itself (only when the original module is available):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
VeriModule::GetOriginalModuleName()&lt;br /&gt;
VeriModule::GetOriginalModule()&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Modules/design_units_with_%22_default%22_suffix_in_their_names&amp;diff=969</id>
		<title>Modules/design units with &quot; default&quot; suffix in their names</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Modules/design_units_with_%22_default%22_suffix_in_their_names&amp;diff=969"/>
				<updated>2026-03-11T22:24:59Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt; This article is currently under construction &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Q: After static elaboration, there are modules/design units with &amp;quot;_default&amp;quot; or &amp;quot;_1, _2&amp;quot; suffix in their names. Why? And what are they? '''&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_default&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Static elaboration process is a multiple-iteration process and modules/design units may be modified differently in each iteration.&lt;br /&gt;
&lt;br /&gt;
We need to keep original version of modules/design units as they are immediately after analysis so that they can be copied for different parameter/generic settings in each iteration and body of copied modules/design units can be elaborated (generate unroll, array instance processing, etc.) differently for each parameter/generic setting.&lt;br /&gt;
&lt;br /&gt;
Another reason to copy instantiated modules/design units with &amp;quot;_default&amp;quot; name is in mixed language elaboration. Here a Verilog module may instantiate a VHDL entity which has been elaborated earlier with different generic values. In that case during Verilog elaboration we will not get original contents of instantiated entity.&lt;br /&gt;
&lt;br /&gt;
Moreover, to support incremental elaboration we need to keep original modules/design units, as lower level units can be elaborated earlier.&lt;br /&gt;
&lt;br /&gt;
In Verilog, we have a runtime-flag &amp;quot;veri_remove_suffix_default_from_copied_module_names&amp;quot; to rename modules from &amp;quot;&amp;lt;orig_name&amp;gt;_default&amp;quot; to &amp;quot;&amp;lt;orig_name&amp;gt;&amp;quot;. This will work only when runtime-flag &amp;quot;veri_cleanup_base_modules&amp;quot; is set. Also, the flag &amp;quot;veri_remove_suffix_default_from_copied_module_names&amp;quot; does not applied to interfaces, packages, and checkers.&lt;br /&gt;
&lt;br /&gt;
==== Interfaces with &amp;quot;_default&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
SystemVerilog interfaces can be used in any of the following ways :&lt;br /&gt;
&lt;br /&gt;
*  As interface instantiations.&lt;br /&gt;
*  As interface ports.&lt;br /&gt;
*  As virtual interfaces.&lt;br /&gt;
*  As hierarchical names.&lt;br /&gt;
&lt;br /&gt;
Interface is always copied with '_default' suffix since we do not know for sure if there is a virtual interface in the hierarchy below which is yet to be processed.&lt;br /&gt;
&lt;br /&gt;
The copied interface (with '_default' suffix) will be the one that is elaborated and specified in the virtual interface declaration, interface instance, or top-level module port.  Every instantiated module containing interface type ports will also be copied during static elaboration since its interface port names may have been modified as well.&lt;br /&gt;
&lt;br /&gt;
Virtual interfaces can appear in many different parts of a design, and may or may not be associated with interface instances. Virtual interfaces are not stored in Verific's pseudo-tree, so after static elaboration we do not know whether an interface is used as a virtual interface or not, or where it is being used.  Without this knowledge, we cannot arbitrarily change all the references of an interface from  '&amp;lt;interface_name&amp;gt;_default'  to  '&amp;lt;interface_name&amp;gt; because the references may become invalid. Because of this, we do not have flags to remove the '_default' from the interface names as we do for modules.&lt;br /&gt;
&lt;br /&gt;
The '_default_&amp;lt;n&amp;gt;' suffix may also be added due to the presence of hierarchical references in an interface or bind statements containing interface instantiations.&lt;br /&gt;
&lt;br /&gt;
Verific VIPER #19809 has more details.&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_&amp;lt;N&amp;gt;&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Modules can be copied with _&amp;lt;N&amp;gt; suffix for hier-ref present/going via them.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module top ;&lt;br /&gt;
    test      t  () ;&lt;br /&gt;
    test #(0) t0 () ;&lt;br /&gt;
    test #(1) t1 () ;&lt;br /&gt;
    test #(2) t2 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module test ;&lt;br /&gt;
    parameter P = 0 ;&lt;br /&gt;
    wire [P:0] sig ;&lt;br /&gt;
    bot b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot ;&lt;br /&gt;
    initial $display(test.sig) ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here &amp;quot;bot&amp;quot; has to be copied 3 times with _&amp;lt;N&amp;gt; suffix so that they can point to 3 different &amp;quot;sig&amp;quot; of 3 different sizes.&lt;br /&gt;
The same can happen for bind statements as well. Different bind instances can be added to different instances of the same module.&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_copy&amp;lt;N&amp;gt;&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Modules can be copied with _copy&amp;lt;N&amp;gt; suffix when a module with _&amp;lt;N&amp;gt; is already present in the same library.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module top ;&lt;br /&gt;
    test      t  () ;&lt;br /&gt;
    test #(0) t0 () ;&lt;br /&gt;
    test #(1) t1 () ;&lt;br /&gt;
    test #(2) t2 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module test ;&lt;br /&gt;
    parameter P = 0 ;&lt;br /&gt;
    wire [P:0] sig ;&lt;br /&gt;
    bot b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot ;&lt;br /&gt;
    initial $display(test.sig) ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot_2 ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here &amp;quot;bot_2&amp;quot; already exists and hence the copied &amp;quot;bot&amp;quot; which we wanted to name &amp;quot;bot_2&amp;quot; is renamed to &amp;quot;bot_copy&amp;lt;N&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_&amp;lt;N&amp;gt;_&amp;lt;M&amp;gt;&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Modules can even be copied with _&amp;lt;N&amp;gt;_&amp;lt;M&amp;gt; suffix in some corner cases with name conflict as well as hier-refs.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module top ;&lt;br /&gt;
    test      t  () ;&lt;br /&gt;
    test #(0) t0 () ;&lt;br /&gt;
    test #(1) t1 () ;&lt;br /&gt;
    test #(2) t2 () ;&lt;br /&gt;
    bot_2 b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module test ;&lt;br /&gt;
    parameter P = 0 ;&lt;br /&gt;
    wire [P:0] sig ;&lt;br /&gt;
    bot b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot ;&lt;br /&gt;
    initial $display(test.sig) ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot_2 ;&lt;br /&gt;
    generate&lt;br /&gt;
        test #(2) t1 () ;&lt;br /&gt;
    endgenerate&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here instead of &amp;quot;bot_copy&amp;lt;N&amp;gt;&amp;quot;, one of the elaborated versions of &amp;quot;bot&amp;quot; which is to be renamed to &amp;quot;bot_2&amp;quot; is actually named as &amp;quot;bot_2_1&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== How to get the original name or the original module ====&lt;br /&gt;
&lt;br /&gt;
APIs to retrieve the original name of the module or to get the original module itself (only when the original module is available):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
VeriModule::GetOriginalModuleName()&lt;br /&gt;
VeriModule::GetOriginalModule()&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Remove_Verific_data_structures&amp;diff=968</id>
		<title>Remove Verific data structures</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Remove_Verific_data_structures&amp;diff=968"/>
				<updated>2026-01-14T19:08:44Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Q: How do I remove all Verific data structures in memory?'''&lt;br /&gt;
&lt;br /&gt;
To remove hdl file sorting data:&lt;br /&gt;
&lt;br /&gt;
    hdl_file_sort::Reset();&lt;br /&gt;
&lt;br /&gt;
To reset file system cache:&lt;br /&gt;
&lt;br /&gt;
    FileSystem::ResetDirectoryCache();&lt;br /&gt;
&lt;br /&gt;
To remove Verilog parsetree:&lt;br /&gt;
&lt;br /&gt;
    veri_file::Reset();&lt;br /&gt;
&lt;br /&gt;
To remove VHDL parsetree:&lt;br /&gt;
&lt;br /&gt;
    vhdl_file::Reset();&lt;br /&gt;
&lt;br /&gt;
To remove synlib parsetree:&lt;br /&gt;
&lt;br /&gt;
    synlib_file::Reset();&lt;br /&gt;
&lt;br /&gt;
To remove hierarchy tree:&lt;br /&gt;
&lt;br /&gt;
    hier_tree::DeleteHierarchicalTree() ;&lt;br /&gt;
&lt;br /&gt;
To remove UPF data structures:&lt;br /&gt;
&lt;br /&gt;
    upf_file::DeleteAll();&lt;br /&gt;
&lt;br /&gt;
To remove the netlist database:&lt;br /&gt;
&lt;br /&gt;
    Libset::Reset();&lt;br /&gt;
&lt;br /&gt;
To remove linefile data (make sure that you've removed all parsetrees and the netlist database):&lt;br /&gt;
&lt;br /&gt;
    LineFile::DeleteAllLineFiles();&lt;br /&gt;
    LineFile::ResetFileIdMaps();&lt;br /&gt;
    #if defined(VERIFIC_LINEFILE_INCLUDES_COLUMNS) || defined(VERIFIC_LARGE_LINEFILE)&lt;br /&gt;
        ColLineFile::DeleteAllLineFiles() ;&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
To remove message type settings:&lt;br /&gt;
&lt;br /&gt;
    Message::Reset();&lt;br /&gt;
&lt;br /&gt;
To reset run-time flags:&lt;br /&gt;
&lt;br /&gt;
    RuntimeFlags::DeleteAllFlags();&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=How_to_save_computer_resources&amp;diff=967</id>
		<title>How to save computer resources</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=How_to_save_computer_resources&amp;diff=967"/>
				<updated>2026-01-12T17:54:21Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are compile flags &amp;amp; runtime flags that may help to reduce memory consumption and/or runtime.&lt;br /&gt;
Below are some common ones.&lt;br /&gt;
&lt;br /&gt;
 - Compile flag &amp;quot;VERIFIC_MEMORY_MANAGER&amp;quot;    in util/VerificSystem.h&lt;br /&gt;
Highly recommended.&lt;br /&gt;
&lt;br /&gt;
Enables the new, zero-overhead, Verific memory manager. Typically reduces memory usage of the Verific software by an additional 20% over the default system memory manager.&lt;br /&gt;
 - Compile flag &amp;quot;DB_USE_PORT_ORDERED_PORTREF&amp;quot;     in database/DBCompileFlags.h&lt;br /&gt;
Highly recommended.&lt;br /&gt;
&lt;br /&gt;
Organizes the PortRef structures in an ordered array rather than a hash table. This saves a significant amount of memory since PortRefs are no longer individually allocated,&lt;br /&gt;
and the overhead of a hash table is also saved.&lt;br /&gt;
&lt;br /&gt;
 - Compile flag &amp;quot;VERILOG_QUICK_PARSE_V_FILES&amp;quot;     in verilog/VeriCompileFlags.h&lt;br /&gt;
Normally a -v file may contain multiple module definitions. The Verilog parser is supposed to pick only the required modules from that file.&lt;br /&gt;
&lt;br /&gt;
However, the file may not contain any of the required modules; instead it is a large file containing many other modules of no interest. In such a case, analyzing and creating a parse tree for the full file will consume much time and memory.&lt;br /&gt;
&lt;br /&gt;
To prevent this, we provide this compile flag to quickly parse the file and see if it is actually required or not, without creating the parse tree. If it is not required we will ignore the file, otherwise we will fully parse it and pick the required modules.&lt;br /&gt;
&lt;br /&gt;
 - Compile flag &amp;quot;VERIFIC_LINEFILE_INCLUDES_COLUMNS&amp;quot;     in util/VerificSystem.h&lt;br /&gt;
If you don't need the starting and ending locations including column info, turn this flag off.&lt;br /&gt;
&lt;br /&gt;
For more details, see [[LineFile data from input files|LineFile data from input files]]&lt;br /&gt;
 - Runtime flag &amp;quot;veri_improve_include_dir_processing_runtime_for_network_file_system&amp;quot;&lt;br /&gt;
Adds directory caching for include directories with simple files (files without a directory specification).&lt;br /&gt;
&lt;br /&gt;
We read the contents of the directory on first encountering it while checking for an include file. Subsequent searches will find the file in the cache instead of the actual disk.&lt;br /&gt;
&lt;br /&gt;
The cache is automatically cleared at the end of the veri_file::Analyze() or veri_file::AnalyzeMultipleFiles() calls. Note that we cannot keep it alive after these two analyze calls since there could possibly be a chdir() call which would make the cache invalid.&lt;br /&gt;
 - Runtime flag &amp;quot;veri_share_nodes_in_static_elab&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Reduces memory and runtime for large designs. This flag will ensure that only one node will be created in static elaboration for each unique signature of a module, regardless of whether it is a top module or instantiated. The number of nodes that can be reduced depends on the nature of the design. For more details on this flag check [https://www.verific.com/faq/index.php?title=Parse_tree_node_sharing_in_Static_Elaboration here]&lt;br /&gt;
&lt;br /&gt;
 - Runtime flag &amp;quot;veri_ignore_always_constructs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This enables a &amp;quot;light-weighed&amp;quot; RTL elaboration. &amp;quot;always&amp;quot; constructs in the input RTL Verilog file will be skipped over.&lt;br /&gt;
&lt;br /&gt;
The output netlist is not complete, but is useful if you are interested only in module interfaces and instantiations.&lt;br /&gt;
&lt;br /&gt;
Note that this flag is active only during RTL elaboration, not analysis. The input files still need to be Verilog-legal.&lt;br /&gt;
&lt;br /&gt;
 - Runtime flag &amp;quot;edif_delete_view_contents_after_processing&amp;quot;&lt;br /&gt;
&lt;br /&gt;
For EDIF input.&lt;br /&gt;
&lt;br /&gt;
Highly recommended.&lt;br /&gt;
&lt;br /&gt;
Deletes the &amp;quot;contents&amp;quot; of a &amp;quot;view&amp;quot; after processing it, i.e., after creating the netlist. We still keep the &amp;quot;interface&amp;quot;, i.e., ports alive so that the view can be instantiated.&lt;br /&gt;
&lt;br /&gt;
 - Runtime flag &amp;quot;edif_link_case_insensitive&amp;quot;&lt;br /&gt;
&lt;br /&gt;
For EDIF input.&lt;br /&gt;
&lt;br /&gt;
EDIF LRM does not define how existing external cells (maybe parsed from another language) should be linked to EDIF cells. We implemented case-insensitive (linear) search for these, which causes an N^2 complexity problem that slows down the reader for very large designs. Switching to case-sensitive search significantly speeds up the process, but there may be incidental cases where the EDIF reader does not link to an existing cell parsed from a different file.&lt;br /&gt;
&lt;br /&gt;
 - Runtime flag &amp;quot;edif_keep_existing_view&amp;quot;&lt;br /&gt;
&lt;br /&gt;
For EDIF input.&lt;br /&gt;
&lt;br /&gt;
When stitching designs from multiple files, a view may be defined in more than one file. By default (&amp;quot;edif_keep_existing_view&amp;quot; disabled), the view being currently read survives, replacing the existing view. This may slow down the process because the existing view and all of its references in the Netlist Database has to be updated.&lt;br /&gt;
&lt;br /&gt;
Enabling &amp;quot;edif_keep_existing_view&amp;quot; allows the reader to ignore the (duplicated) view being currently read. All references to the view being ignored will be updated to point to the existing view in the Netlist Database. Only the references to the current view (in the current read operation) need to be updated to point to the existing view.&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=955</id>
		<title>How to evaluate a Verilog expression</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=955"/>
				<updated>2025-09-03T21:44:48Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Evaluating a Verilog expression requires 'Static Elaboration' or 'Hierarchy Tree' feature.&lt;br /&gt;
&lt;br /&gt;
In the example below, a, b, and c are declared in the Verilog module. There is no need to run static elaboration on the whole module. But 'Static Elaboration' feature is still required because the API VeriExpression::StaticEvaluate() is available only with 'Static Elaboration' feature.&lt;br /&gt;
&lt;br /&gt;
C++:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;veri_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriModule.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriBaseValue_Stat.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Strings.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Array.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Map.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;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = (argc &amp;gt; 1) ? argv[1] : &amp;quot;test.v&amp;quot; ;&lt;br /&gt;
    const char *module_name = (argc &amp;gt; 2) ? argv[2] : &amp;quot;test_module&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    Array files(1) ;&lt;br /&gt;
    files.Insert(file_name) ;&lt;br /&gt;
    if (!veri_file::AnalyzeMultipleFiles(&amp;amp;files, veri_file::SYSTEM_VERILOG)) return 1 ; &lt;br /&gt;
&lt;br /&gt;
    const VeriModule *mod = veri_file::GetModule(module_name) ;&lt;br /&gt;
    if (!mod) return 2 ; &lt;br /&gt;
&lt;br /&gt;
    // Apply following known values to evaluate &amp;quot;a[b] + c&amp;quot;: &lt;br /&gt;
    //   a = {1'b1, 1'b1}&lt;br /&gt;
    //   b = 2'b00&lt;br /&gt;
    //   c = 2'b01  &lt;br /&gt;
&lt;br /&gt;
    const char *expr_string = &amp;quot;a[b] + c&amp;quot; ;&lt;br /&gt;
    Map known_values(STRING_HASH) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;a&amp;quot;, &amp;quot;{1'b1, 1'b1}&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;b&amp;quot;, &amp;quot;2'b00&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;c&amp;quot;, &amp;quot;2'b01&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
    ValueTable df ;&lt;br /&gt;
&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    const char *id_name ;&lt;br /&gt;
    const char *val_str ;&lt;br /&gt;
    FOREACH_MAP_ITEM(&amp;amp;known_values, mi, &amp;amp;id_name, &amp;amp;val_str) {&lt;br /&gt;
        if (!id_name || !val_str) continue ;&lt;br /&gt;
&lt;br /&gt;
        // Find the identifier:&lt;br /&gt;
        VeriIdDef *id = mod-&amp;gt;FindDeclared(id_name) ;&lt;br /&gt;
        if (!id) return 3 ; &lt;br /&gt;
&lt;br /&gt;
        // Create the expression:&lt;br /&gt;
        VeriExpression *expr = veri_file::AnalyzeExpr(val_str, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
        if (!expr) return 4 ;&lt;br /&gt;
&lt;br /&gt;
        // Evaluate the expression:&lt;br /&gt;
        // If this is a literal expression, we do not need the value value or Resolve() call or else we need both:&lt;br /&gt;
        VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, 0 /* value table */) ;&lt;br /&gt;
        delete expr ;&lt;br /&gt;
        if (!val) return 5 ; &lt;br /&gt;
&lt;br /&gt;
        // Insert into the table to be used later:&lt;br /&gt;
        if (!df.Insert(id, val)) {&lt;br /&gt;
            delete val ;&lt;br /&gt;
            return 6 ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Now create the expression for to be evaluated:&lt;br /&gt;
    VeriExpression *expr = veri_file::AnalyzeExpr(expr_string, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
    if (!expr) return 7 ;&lt;br /&gt;
&lt;br /&gt;
    // Resolve the expression so that the id-refs are resolved:&lt;br /&gt;
    expr-&amp;gt;Resolve(mod-&amp;gt;GetScope(), VeriTreeNode::VERI_UNDEF_ENV) ;&lt;br /&gt;
&lt;br /&gt;
    VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, &amp;amp;df /* use this table with the known values */) ;&lt;br /&gt;
    delete expr ;&lt;br /&gt;
    if (!val) return 8 ; // Failed to evaluate&lt;br /&gt;
&lt;br /&gt;
    char *image = val-&amp;gt;Image() ;&lt;br /&gt;
    int result = val-&amp;gt;GetIntegerValue() ;&lt;br /&gt;
    mod-&amp;gt;Info(&amp;quot;Evaluated value: %s (%d)&amp;quot;, ((image)?image:&amp;quot;&amp;quot;), result) ;&lt;br /&gt;
    Strings::free(image) ;&lt;br /&gt;
    delete val ;&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;
Verilog testcase:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module test_module;&lt;br /&gt;
    wire a [1:0];&lt;br /&gt;
    wire [1:0] b;&lt;br /&gt;
    wire [1:0] c;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'test.v' (VERI-1482)&lt;br /&gt;
test.v(5): INFO: Evaluated value: 2'b10 (2)&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If an element in the expression to be evaluated crosses module boundaries, elaboration needs to be run as in the Verilog testcase below ('my_int' is to be evaluated):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
interface ifc #(int N=10);&lt;br /&gt;
    logic [N-1:0] data;&lt;br /&gt;
endinterface&lt;br /&gt;
 &lt;br /&gt;
module test();&lt;br /&gt;
    ifc #(.N(13)) I();&lt;br /&gt;
    int my_int = $bits(I.data); // want to evaluated 'my_int' or '$bits(I.data)'&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The C++ example below calls static elaboration:&lt;br /&gt;
&lt;br /&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;VeriVisitor.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.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;
class MyVisitor : public VeriVisitor&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
    MyVisitor() : VeriVisitor() { }&lt;br /&gt;
    virtual ~MyVisitor() { }&lt;br /&gt;
&lt;br /&gt;
    virtual void VERI_VISIT(VeriExpression, node)&lt;br /&gt;
    {&lt;br /&gt;
        char *str = node.GetPrettyPrintedString() ;&lt;br /&gt;
        VeriExpression *new_exp = node.StaticEvaluateToExpr(0,0,0);&lt;br /&gt;
        if (new_exp) {&lt;br /&gt;
            char *str2 = new_exp-&amp;gt;GetPrettyPrintedString() ;&lt;br /&gt;
            node.Info(&amp;quot;    Expression: '%s', evaluated to '%s'&amp;quot;, str, str2) ;&lt;br /&gt;
            Strings::free(str) ;&lt;br /&gt;
            Strings::free(str2) ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
} ;&lt;br /&gt;
&lt;br /&gt;
int main (int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = &amp;quot;test.sv&amp;quot; ; // defaulf input filename&lt;br /&gt;
    if (argc &amp;gt; 1) file_name = argv[1] ; // Set the file name as specified by the user&lt;br /&gt;
    if (!veri_file::Analyze(file_name, veri_file::SYSTEM_VERILOG)) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    if (!veri_file::ElaborateAllStatic()) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    MyVisitor mv ;&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;
    mod-&amp;gt;Info(&amp;quot;In module '%s'&amp;quot;, mod-&amp;gt;Name()) ;&lt;br /&gt;
    mod-&amp;gt;Accept(mv) ;&lt;br /&gt;
    return 0 ;&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'test.sv' (VERI-1482)&lt;br /&gt;
test.sv(5): INFO: compiling module 'test' (VERI-1018)&lt;br /&gt;
test.sv(8): INFO: In module 'test'&lt;br /&gt;
test.sv(7): INFO:     Expression: 'int ', evaluated to 'int '&lt;br /&gt;
test.sv(7): INFO:     Expression: '$bits(I.data)', evaluated to '13'&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If for some reason static elaboration is not desirable (it does take memory and CPU time), hierarchy-tree elaboration can be run instead. Hierarchy-tree elaboration takes much less memory anc CPU time than static elaborations does.&lt;br /&gt;
&lt;br /&gt;
Reference: https://www.verific.com/docs/index.php?title=Hierarchy_Tree&lt;br /&gt;
&lt;br /&gt;
The C++ example below uses hierarchy-tree elaboration instead of static elaboration:&lt;br /&gt;
&lt;br /&gt;
C++:&lt;br /&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;VeriId.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriBaseValue_Stat.h&amp;quot;&lt;br /&gt;
#include &amp;quot;hier_tree.h&amp;quot;&lt;br /&gt;
#include &amp;quot;HierTreeNode.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;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = &amp;quot;test.sv&amp;quot; ;&lt;br /&gt;
    const char *top_name = &amp;quot;test&amp;quot; ;&lt;br /&gt;
    const char *my_name = &amp;quot;my_int&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    if (!veri_file::Analyze(file_name, veri_file::SYSTEM_VERILOG)) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    VeriModule *top = veri_file::GetModule(top_name) ;&lt;br /&gt;
    if (!top) return 2 ;&lt;br /&gt;
&lt;br /&gt;
    VeriIdDef *my_id = top-&amp;gt;FindDeclared(my_name) ;&lt;br /&gt;
    if (!my_id) return 3 ;&lt;br /&gt;
&lt;br /&gt;
    VeriExpression *init_val = my_id-&amp;gt;GetInitialValue() ;&lt;br /&gt;
    if (!init_val) return 4 ;&lt;br /&gt;
&lt;br /&gt;
    Array top_mods(1) ;&lt;br /&gt;
    top_mods.Insert(top) ;&lt;br /&gt;
&lt;br /&gt;
    const Map *top_nodes = hier_tree::CreateHierarchicalTree(&amp;amp;top_mods, 0, 0, 0) ;&lt;br /&gt;
    if (!top_nodes) return 5 ;&lt;br /&gt;
&lt;br /&gt;
    HierTreeNode *top_node = (HierTreeNode *)top_nodes-&amp;gt;GetValue(top_name) ;&lt;br /&gt;
    if (!top_node) {&lt;br /&gt;
        hier_tree::DeleteHierarchicalTree() ;&lt;br /&gt;
        return 6 ;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    InterfaceInfo *info = top_node-&amp;gt;GetParamValue(my_id) ;&lt;br /&gt;
    VeriBaseValue *val = 0 ;&lt;br /&gt;
    VeriBaseValue *delete_val = 0 ;&lt;br /&gt;
    if (info) {&lt;br /&gt;
        // We already have the value evaluated, get from node:&lt;br /&gt;
        val = info-&amp;gt;GetVeriEvaluatedValue() ;&lt;br /&gt;
    } else {&lt;br /&gt;
        // Need to evaluate the value, use the context from the node:&lt;br /&gt;
        Map *context = top_node-&amp;gt;PushContext() ;&lt;br /&gt;
        hier_tree::PushNode(top_node) ;&lt;br /&gt;
&lt;br /&gt;
        val = init_val-&amp;gt;StaticEvaluate(0, 0, 0, 0) ;&lt;br /&gt;
        delete_val = val ;&lt;br /&gt;
&lt;br /&gt;
        hier_tree::PopNode() ;&lt;br /&gt;
        top_node-&amp;gt;PopContext(context) ;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    char *val_img = (val) ? val-&amp;gt;Image() : 0 ;&lt;br /&gt;
    init_val-&amp;gt;Info(&amp;quot;%s(%s) evaluated to %s&amp;quot;, my_name, my_id-&amp;gt;GetPrettyPrintedString(), ((val_img)?val_img:&amp;quot;&amp;lt;NULL&amp;gt;&amp;quot;)) ;&lt;br /&gt;
    Strings::free(val_img) ;&lt;br /&gt;
&lt;br /&gt;
    delete delete_val ;&lt;br /&gt;
&lt;br /&gt;
    hier_tree::DeleteHierarchicalTree() ;&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;
Run:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'test.sv' (VERI-1482)&lt;br /&gt;
test.sv(7): INFO: my_int(my_int = $bits(I.data)) evaluated to 13&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=954</id>
		<title>How to evaluate a Verilog expression</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=954"/>
				<updated>2025-09-03T21:39:56Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Evaluating a Verilog expression requires 'Static Elaboration' or 'Hierarchy Tree' feature.&lt;br /&gt;
&lt;br /&gt;
In the example below, a, b, and c are declared in the Verilog module. There is no need to run static elaboration on the whole module. But 'Static Elaboration' feature is still required because the API VeriExpression::StaticEvaluate() is available only with 'Static Elaboration' feature.&lt;br /&gt;
&lt;br /&gt;
C++:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;veri_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriModule.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriBaseValue_Stat.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Strings.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Array.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Map.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;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = (argc &amp;gt; 1) ? argv[1] : &amp;quot;test.v&amp;quot; ;&lt;br /&gt;
    const char *module_name = (argc &amp;gt; 2) ? argv[2] : &amp;quot;test_module&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    Array files(1) ;&lt;br /&gt;
    files.Insert(file_name) ;&lt;br /&gt;
    if (!veri_file::AnalyzeMultipleFiles(&amp;amp;files, veri_file::SYSTEM_VERILOG)) return 1 ; &lt;br /&gt;
&lt;br /&gt;
    const VeriModule *mod = veri_file::GetModule(module_name) ;&lt;br /&gt;
    if (!mod) return 2 ; &lt;br /&gt;
&lt;br /&gt;
    // Apply following known values to evaluate &amp;quot;a[b] + c&amp;quot;: &lt;br /&gt;
    //   a = {1'b1, 1'b1}&lt;br /&gt;
    //   b = 2'b00&lt;br /&gt;
    //   c = 2'b01  &lt;br /&gt;
&lt;br /&gt;
    const char *expr_string = &amp;quot;a[b] + c&amp;quot; ;&lt;br /&gt;
    Map known_values(STRING_HASH) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;a&amp;quot;, &amp;quot;{1'b1, 1'b1}&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;b&amp;quot;, &amp;quot;2'b00&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;c&amp;quot;, &amp;quot;2'b01&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
    ValueTable df ;&lt;br /&gt;
&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    const char *id_name ;&lt;br /&gt;
    const char *val_str ;&lt;br /&gt;
    FOREACH_MAP_ITEM(&amp;amp;known_values, mi, &amp;amp;id_name, &amp;amp;val_str) {&lt;br /&gt;
        if (!id_name || !val_str) continue ;&lt;br /&gt;
&lt;br /&gt;
        // Find the identifier:&lt;br /&gt;
        VeriIdDef *id = mod-&amp;gt;FindDeclared(id_name) ;&lt;br /&gt;
        if (!id) return 3 ; &lt;br /&gt;
&lt;br /&gt;
        // Create the expression:&lt;br /&gt;
        VeriExpression *expr = veri_file::AnalyzeExpr(val_str, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
        if (!expr) return 4 ;&lt;br /&gt;
&lt;br /&gt;
        // Evaluate the expression:&lt;br /&gt;
        // If this is a literal expression, we do not need the value value or Resolve() call or else we need both:&lt;br /&gt;
        VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, 0 /* value table */) ;&lt;br /&gt;
        delete expr ;&lt;br /&gt;
        if (!val) return 5 ; &lt;br /&gt;
&lt;br /&gt;
        // Insert into the table to be used later:&lt;br /&gt;
        if (!df.Insert(id, val)) {&lt;br /&gt;
            delete val ;&lt;br /&gt;
            return 6 ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Now create the expression for to be evaluated:&lt;br /&gt;
    VeriExpression *expr = veri_file::AnalyzeExpr(expr_string, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
    if (!expr) return 7 ;&lt;br /&gt;
&lt;br /&gt;
    // Resolve the expression so that the id-refs are resolved:&lt;br /&gt;
    expr-&amp;gt;Resolve(mod-&amp;gt;GetScope(), VeriTreeNode::VERI_UNDEF_ENV) ;&lt;br /&gt;
&lt;br /&gt;
    VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, &amp;amp;df /* use this table with the known values */) ;&lt;br /&gt;
    delete expr ;&lt;br /&gt;
    if (!val) return 8 ; // Failed to evaluate&lt;br /&gt;
&lt;br /&gt;
    char *image = val-&amp;gt;Image() ;&lt;br /&gt;
    int result = val-&amp;gt;GetIntegerValue() ;&lt;br /&gt;
    mod-&amp;gt;Info(&amp;quot;Evaluated value: %s (%d)&amp;quot;, ((image)?image:&amp;quot;&amp;quot;), result) ;&lt;br /&gt;
    Strings::free(image) ;&lt;br /&gt;
    delete val ;&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;
Verilog testcase:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module test_module;&lt;br /&gt;
    wire a [1:0];&lt;br /&gt;
    wire [1:0] b;&lt;br /&gt;
    wire [1:0] c;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'test.v' (VERI-1482)&lt;br /&gt;
test.v(5): INFO: Evaluated value: 2'b10 (2)&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If an element in the expression crosses module boundaries, elaboration needs to be run as in the example below:&lt;br /&gt;
&lt;br /&gt;
Verilog testcase:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
interface ifc #(int N=10);&lt;br /&gt;
    logic [N-1:0] data;&lt;br /&gt;
endinterface&lt;br /&gt;
 &lt;br /&gt;
module test();&lt;br /&gt;
    ifc #(.N(13)) I();&lt;br /&gt;
    int my_int = $bits(I.data);&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The C++ example below calls static elaboration:&lt;br /&gt;
&lt;br /&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;VeriVisitor.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.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;
class MyVisitor : public VeriVisitor&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
    MyVisitor() : VeriVisitor() { }&lt;br /&gt;
    virtual ~MyVisitor() { }&lt;br /&gt;
&lt;br /&gt;
    virtual void VERI_VISIT(VeriExpression, node)&lt;br /&gt;
    {&lt;br /&gt;
        char *str = node.GetPrettyPrintedString() ;&lt;br /&gt;
        VeriExpression *new_exp = node.StaticEvaluateToExpr(0,0,0);&lt;br /&gt;
        if (new_exp) {&lt;br /&gt;
            char *str2 = new_exp-&amp;gt;GetPrettyPrintedString() ;&lt;br /&gt;
            node.Info(&amp;quot;    Expression: '%s', evaluated to '%s'&amp;quot;, str, str2) ;&lt;br /&gt;
            Strings::free(str) ;&lt;br /&gt;
            Strings::free(str2) ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
} ;&lt;br /&gt;
&lt;br /&gt;
int main (int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = &amp;quot;test.sv&amp;quot; ; // defaulf input filename&lt;br /&gt;
    if (argc &amp;gt; 1) file_name = argv[1] ; // Set the file name as specified by the user&lt;br /&gt;
    if (!veri_file::Analyze(file_name, veri_file::SYSTEM_VERILOG)) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    if (!veri_file::ElaborateAllStatic()) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    MyVisitor mv ;&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;
    mod-&amp;gt;Info(&amp;quot;In module '%s'&amp;quot;, mod-&amp;gt;Name()) ;&lt;br /&gt;
    mod-&amp;gt;Accept(mv) ;&lt;br /&gt;
    return 0 ;&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'test.sv' (VERI-1482)&lt;br /&gt;
test.sv(5): INFO: compiling module 'test' (VERI-1018)&lt;br /&gt;
test.sv(8): INFO: In module 'test'&lt;br /&gt;
test.sv(7): INFO:     Expression: 'int ', evaluated to 'int '&lt;br /&gt;
test.sv(7): INFO:     Expression: '$bits(I.data)', evaluated to '13'&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If for some reason static elaboration is not desirable (it does take memory and CPU time), hierarchy-tree elaboration can be run instead. Hierarchy-tree elaboration takes much less memory anc CPU time than static elaborations does.&lt;br /&gt;
&lt;br /&gt;
Reference: https://www.verific.com/docs/index.php?title=Hierarchy_Tree&lt;br /&gt;
&lt;br /&gt;
The C++ example below uses hierarchy-tree elaboration:&lt;br /&gt;
&lt;br /&gt;
C++:&lt;br /&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;VeriId.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriBaseValue_Stat.h&amp;quot;&lt;br /&gt;
#include &amp;quot;hier_tree.h&amp;quot;&lt;br /&gt;
#include &amp;quot;HierTreeNode.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;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = &amp;quot;test.sv&amp;quot; ;&lt;br /&gt;
    const char *top_name = &amp;quot;test&amp;quot; ;&lt;br /&gt;
    const char *my_name = &amp;quot;my_int&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    if (!veri_file::Analyze(file_name, veri_file::SYSTEM_VERILOG)) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    VeriModule *top = veri_file::GetModule(top_name) ;&lt;br /&gt;
    if (!top) return 2 ;&lt;br /&gt;
&lt;br /&gt;
    VeriIdDef *my_id = top-&amp;gt;FindDeclared(my_name) ;&lt;br /&gt;
    if (!my_id) return 3 ;&lt;br /&gt;
&lt;br /&gt;
    VeriExpression *init_val = my_id-&amp;gt;GetInitialValue() ;&lt;br /&gt;
    if (!init_val) return 4 ;&lt;br /&gt;
&lt;br /&gt;
    Array top_mods(1) ;&lt;br /&gt;
    top_mods.Insert(top) ;&lt;br /&gt;
&lt;br /&gt;
    const Map *top_nodes = hier_tree::CreateHierarchicalTree(&amp;amp;top_mods, 0, 0, 0) ;&lt;br /&gt;
    if (!top_nodes) return 5 ;&lt;br /&gt;
&lt;br /&gt;
    HierTreeNode *top_node = (HierTreeNode *)top_nodes-&amp;gt;GetValue(top_name) ;&lt;br /&gt;
    if (!top_node) {&lt;br /&gt;
        hier_tree::DeleteHierarchicalTree() ;&lt;br /&gt;
        return 6 ;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    InterfaceInfo *info = top_node-&amp;gt;GetParamValue(my_id) ;&lt;br /&gt;
    VeriBaseValue *val = 0 ;&lt;br /&gt;
    VeriBaseValue *delete_val = 0 ;&lt;br /&gt;
    if (info) {&lt;br /&gt;
        // We already have the value evaluated, get from node:&lt;br /&gt;
        val = info-&amp;gt;GetVeriEvaluatedValue() ;&lt;br /&gt;
    } else {&lt;br /&gt;
        // Need to evaluate the value, use the context from the node:&lt;br /&gt;
        Map *context = top_node-&amp;gt;PushContext() ;&lt;br /&gt;
        hier_tree::PushNode(top_node) ;&lt;br /&gt;
&lt;br /&gt;
        val = init_val-&amp;gt;StaticEvaluate(0, 0, 0, 0) ;&lt;br /&gt;
        delete_val = val ;&lt;br /&gt;
&lt;br /&gt;
        hier_tree::PopNode() ;&lt;br /&gt;
        top_node-&amp;gt;PopContext(context) ;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    char *val_img = (val) ? val-&amp;gt;Image() : 0 ;&lt;br /&gt;
    init_val-&amp;gt;Info(&amp;quot;%s(%s) evaluated to %s&amp;quot;, my_name, my_id-&amp;gt;GetPrettyPrintedString(), ((val_img)?val_img:&amp;quot;&amp;lt;NULL&amp;gt;&amp;quot;)) ;&lt;br /&gt;
    Strings::free(val_img) ;&lt;br /&gt;
&lt;br /&gt;
    delete delete_val ;&lt;br /&gt;
&lt;br /&gt;
    hier_tree::DeleteHierarchicalTree() ;&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;
Run:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'test.sv' (VERI-1482)&lt;br /&gt;
test.sv(7): INFO: my_int(my_int = $bits(I.data)) evaluated to 13&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=953</id>
		<title>How to evaluate a Verilog expression</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=953"/>
				<updated>2025-09-03T21:38:35Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Evaluating a Verilog expression requires 'Static Elaboration' or 'Hierarchy Tree' feature.&lt;br /&gt;
&lt;br /&gt;
In the example below, a, b, and c are declared in the Verilog module. There is no need to run static elaboration on the whole module. But 'Static Elaboration' feature is still required because the API VeriExpression::StaticEvaluate() is available only with 'Static Elaboration' feature.&lt;br /&gt;
&lt;br /&gt;
C++:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;veri_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriModule.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriBaseValue_Stat.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Strings.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Array.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Map.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;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = (argc &amp;gt; 1) ? argv[1] : &amp;quot;test.v&amp;quot; ;&lt;br /&gt;
    const char *module_name = (argc &amp;gt; 2) ? argv[2] : &amp;quot;test_module&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    Array files(1) ;&lt;br /&gt;
    files.Insert(file_name) ;&lt;br /&gt;
    if (!veri_file::AnalyzeMultipleFiles(&amp;amp;files, veri_file::SYSTEM_VERILOG)) return 1 ; &lt;br /&gt;
&lt;br /&gt;
    const VeriModule *mod = veri_file::GetModule(module_name) ;&lt;br /&gt;
    if (!mod) return 2 ; &lt;br /&gt;
&lt;br /&gt;
    // Apply following known values to evaluate &amp;quot;a[b] + c&amp;quot;: &lt;br /&gt;
    //   a = {1'b1, 1'b1}&lt;br /&gt;
    //   b = 2'b00&lt;br /&gt;
    //   c = 2'b01  &lt;br /&gt;
&lt;br /&gt;
    const char *expr_string = &amp;quot;a[b] + c&amp;quot; ;&lt;br /&gt;
    Map known_values(STRING_HASH) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;a&amp;quot;, &amp;quot;{1'b1, 1'b1}&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;b&amp;quot;, &amp;quot;2'b00&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;c&amp;quot;, &amp;quot;2'b01&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
    ValueTable df ;&lt;br /&gt;
&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    const char *id_name ;&lt;br /&gt;
    const char *val_str ;&lt;br /&gt;
    FOREACH_MAP_ITEM(&amp;amp;known_values, mi, &amp;amp;id_name, &amp;amp;val_str) {&lt;br /&gt;
        if (!id_name || !val_str) continue ;&lt;br /&gt;
&lt;br /&gt;
        // Find the identifier:&lt;br /&gt;
        VeriIdDef *id = mod-&amp;gt;FindDeclared(id_name) ;&lt;br /&gt;
        if (!id) return 3 ; &lt;br /&gt;
&lt;br /&gt;
        // Create the expression:&lt;br /&gt;
        VeriExpression *expr = veri_file::AnalyzeExpr(val_str, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
        if (!expr) return 4 ;&lt;br /&gt;
&lt;br /&gt;
        // Evaluate the expression:&lt;br /&gt;
        // If this is a literal expression, we do not need the value value or Resolve() call or else we need both:&lt;br /&gt;
        VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, 0 /* value table */) ;&lt;br /&gt;
        delete expr ;&lt;br /&gt;
        if (!val) return 5 ; &lt;br /&gt;
&lt;br /&gt;
        // Insert into the table to be used later:&lt;br /&gt;
        if (!df.Insert(id, val)) {&lt;br /&gt;
            delete val ;&lt;br /&gt;
            return 6 ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Now create the expression for to be evaluated:&lt;br /&gt;
    VeriExpression *expr = veri_file::AnalyzeExpr(expr_string, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
    if (!expr) return 7 ;&lt;br /&gt;
&lt;br /&gt;
    // Resolve the expression so that the id-refs are resolved:&lt;br /&gt;
    expr-&amp;gt;Resolve(mod-&amp;gt;GetScope(), VeriTreeNode::VERI_UNDEF_ENV) ;&lt;br /&gt;
&lt;br /&gt;
    VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, &amp;amp;df /* use this table with the known values */) ;&lt;br /&gt;
    delete expr ;&lt;br /&gt;
    if (!val) return 8 ; // Failed to evaluate&lt;br /&gt;
&lt;br /&gt;
    char *image = val-&amp;gt;Image() ;&lt;br /&gt;
    int result = val-&amp;gt;GetIntegerValue() ;&lt;br /&gt;
    mod-&amp;gt;Info(&amp;quot;Evaluated value: %s (%d)&amp;quot;, ((image)?image:&amp;quot;&amp;quot;), result) ;&lt;br /&gt;
    Strings::free(image) ;&lt;br /&gt;
    delete val ;&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;
Verilog testcase:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module test_module;&lt;br /&gt;
    wire a [1:0];&lt;br /&gt;
    wire [1:0] b;&lt;br /&gt;
    wire [1:0] c;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'test.v' (VERI-1482)&lt;br /&gt;
test.v(5): INFO: Evaluated value: 2'b10 (2)&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If an element in the expression crosses module boundaries, elaboration needs to be run as in the example below:&lt;br /&gt;
&lt;br /&gt;
Verilog testcase:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
interface ifc #(int N=10);&lt;br /&gt;
    logic [N-1:0] data;&lt;br /&gt;
endinterface&lt;br /&gt;
 &lt;br /&gt;
module test();&lt;br /&gt;
    ifc #(.N(13)) I();&lt;br /&gt;
    int my_int = $bits(I.data);&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
C++:&lt;br /&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;VeriVisitor.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.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;
class MyVisitor : public VeriVisitor&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
    MyVisitor() : VeriVisitor() { }&lt;br /&gt;
    virtual ~MyVisitor() { }&lt;br /&gt;
&lt;br /&gt;
    virtual void VERI_VISIT(VeriExpression, node)&lt;br /&gt;
    {&lt;br /&gt;
        char *str = node.GetPrettyPrintedString() ;&lt;br /&gt;
        VeriExpression *new_exp = node.StaticEvaluateToExpr(0,0,0);&lt;br /&gt;
        if (new_exp) {&lt;br /&gt;
            char *str2 = new_exp-&amp;gt;GetPrettyPrintedString() ;&lt;br /&gt;
            node.Info(&amp;quot;    Expression: '%s', evaluated to '%s'&amp;quot;, str, str2) ;&lt;br /&gt;
            Strings::free(str) ;&lt;br /&gt;
            Strings::free(str2) ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
} ;&lt;br /&gt;
&lt;br /&gt;
int main (int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = &amp;quot;test.sv&amp;quot; ; // defaulf input filename&lt;br /&gt;
    if (argc &amp;gt; 1) file_name = argv[1] ; // Set the file name as specified by the user&lt;br /&gt;
    if (!veri_file::Analyze(file_name, veri_file::SYSTEM_VERILOG)) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    if (!veri_file::ElaborateAllStatic()) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    MyVisitor mv ;&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;
    mod-&amp;gt;Info(&amp;quot;In module '%s'&amp;quot;, mod-&amp;gt;Name()) ;&lt;br /&gt;
    mod-&amp;gt;Accept(mv) ;&lt;br /&gt;
    return 0 ;&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'test.sv' (VERI-1482)&lt;br /&gt;
test.sv(5): INFO: compiling module 'test' (VERI-1018)&lt;br /&gt;
test.sv(8): INFO: In module 'test'&lt;br /&gt;
test.sv(7): INFO:     Expression: 'int ', evaluated to 'int '&lt;br /&gt;
test.sv(7): INFO:     Expression: '$bits(I.data)', evaluated to '13'&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If for some reason static elaboration is not desirable (it does take memory and CPU time), hierarchy-tree elaboration can be run instead. Hierarchy-tree elaboration takes much less memory anc CPU time than static elaborations does.&lt;br /&gt;
&lt;br /&gt;
Reference: https://www.verific.com/docs/index.php?title=Hierarchy_Tree&lt;br /&gt;
&lt;br /&gt;
The C++ example below uses hierarchy-tree elaboration:&lt;br /&gt;
&lt;br /&gt;
C++:&lt;br /&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;VeriId.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriBaseValue_Stat.h&amp;quot;&lt;br /&gt;
#include &amp;quot;hier_tree.h&amp;quot;&lt;br /&gt;
#include &amp;quot;HierTreeNode.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;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = &amp;quot;test.sv&amp;quot; ;&lt;br /&gt;
    const char *top_name = &amp;quot;test&amp;quot; ;&lt;br /&gt;
    const char *my_name = &amp;quot;my_int&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    if (!veri_file::Analyze(file_name, veri_file::SYSTEM_VERILOG)) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    VeriModule *top = veri_file::GetModule(top_name) ;&lt;br /&gt;
    if (!top) return 2 ;&lt;br /&gt;
&lt;br /&gt;
    VeriIdDef *my_id = top-&amp;gt;FindDeclared(my_name) ;&lt;br /&gt;
    if (!my_id) return 3 ;&lt;br /&gt;
&lt;br /&gt;
    VeriExpression *init_val = my_id-&amp;gt;GetInitialValue() ;&lt;br /&gt;
    if (!init_val) return 4 ;&lt;br /&gt;
&lt;br /&gt;
    Array top_mods(1) ;&lt;br /&gt;
    top_mods.Insert(top) ;&lt;br /&gt;
&lt;br /&gt;
    const Map *top_nodes = hier_tree::CreateHierarchicalTree(&amp;amp;top_mods, 0, 0, 0) ;&lt;br /&gt;
    if (!top_nodes) return 5 ;&lt;br /&gt;
&lt;br /&gt;
    HierTreeNode *top_node = (HierTreeNode *)top_nodes-&amp;gt;GetValue(top_name) ;&lt;br /&gt;
    if (!top_node) {&lt;br /&gt;
        hier_tree::DeleteHierarchicalTree() ;&lt;br /&gt;
        return 6 ;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    InterfaceInfo *info = top_node-&amp;gt;GetParamValue(my_id) ;&lt;br /&gt;
    VeriBaseValue *val = 0 ;&lt;br /&gt;
    VeriBaseValue *delete_val = 0 ;&lt;br /&gt;
    if (info) {&lt;br /&gt;
        // We already have the value evaluated, get from node:&lt;br /&gt;
        val = info-&amp;gt;GetVeriEvaluatedValue() ;&lt;br /&gt;
    } else {&lt;br /&gt;
        // Need to evaluate the value, use the context from the node:&lt;br /&gt;
        Map *context = top_node-&amp;gt;PushContext() ;&lt;br /&gt;
        hier_tree::PushNode(top_node) ;&lt;br /&gt;
&lt;br /&gt;
        val = init_val-&amp;gt;StaticEvaluate(0, 0, 0, 0) ;&lt;br /&gt;
        delete_val = val ;&lt;br /&gt;
&lt;br /&gt;
        hier_tree::PopNode() ;&lt;br /&gt;
        top_node-&amp;gt;PopContext(context) ;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    char *val_img = (val) ? val-&amp;gt;Image() : 0 ;&lt;br /&gt;
    init_val-&amp;gt;Info(&amp;quot;%s(%s) evaluated to %s&amp;quot;, my_name, my_id-&amp;gt;GetPrettyPrintedString(), ((val_img)?val_img:&amp;quot;&amp;lt;NULL&amp;gt;&amp;quot;)) ;&lt;br /&gt;
    Strings::free(val_img) ;&lt;br /&gt;
&lt;br /&gt;
    delete delete_val ;&lt;br /&gt;
&lt;br /&gt;
    hier_tree::DeleteHierarchicalTree() ;&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;
Run:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'test.sv' (VERI-1482)&lt;br /&gt;
test.sv(7): INFO: my_int(my_int = $bits(I.data)) evaluated to 13&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=952</id>
		<title>How to evaluate a Verilog expression</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=952"/>
				<updated>2025-09-03T19:18:49Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Evaluating a Verilog expression requires 'Static Elaboration' or 'Hierarchy Tree' feature.&lt;br /&gt;
&lt;br /&gt;
In the example below, a, b, and c are declared in the Verilog module. There is no need to run static elaboration on the whole module. But 'Static Elaboration' feature is still required because the API VeriExpression::StaticEvaluate() is available only with 'Static Elaboration' feature.&lt;br /&gt;
&lt;br /&gt;
C++:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;veri_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriModule.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriBaseValue_Stat.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Strings.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Array.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Map.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;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = (argc &amp;gt; 1) ? argv[1] : &amp;quot;test.v&amp;quot; ;&lt;br /&gt;
    const char *module_name = (argc &amp;gt; 2) ? argv[2] : &amp;quot;test_module&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    Array files(1) ;&lt;br /&gt;
    files.Insert(file_name) ;&lt;br /&gt;
    if (!veri_file::AnalyzeMultipleFiles(&amp;amp;files, veri_file::SYSTEM_VERILOG)) return 1 ; &lt;br /&gt;
&lt;br /&gt;
    const VeriModule *mod = veri_file::GetModule(module_name) ;&lt;br /&gt;
    if (!mod) return 2 ; &lt;br /&gt;
&lt;br /&gt;
    // Apply following known values to evaluate &amp;quot;a[b] + c&amp;quot;: &lt;br /&gt;
    //   a = {1'b1, 1'b1}&lt;br /&gt;
    //   b = 2'b00&lt;br /&gt;
    //   c = 2'b01  &lt;br /&gt;
&lt;br /&gt;
    const char *expr_string = &amp;quot;a[b] + c&amp;quot; ;&lt;br /&gt;
    Map known_values(STRING_HASH) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;a&amp;quot;, &amp;quot;{1'b1, 1'b1}&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;b&amp;quot;, &amp;quot;2'b00&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;c&amp;quot;, &amp;quot;2'b01&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
    ValueTable df ;&lt;br /&gt;
&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    const char *id_name ;&lt;br /&gt;
    const char *val_str ;&lt;br /&gt;
    FOREACH_MAP_ITEM(&amp;amp;known_values, mi, &amp;amp;id_name, &amp;amp;val_str) {&lt;br /&gt;
        if (!id_name || !val_str) continue ;&lt;br /&gt;
&lt;br /&gt;
        // Find the identifier:&lt;br /&gt;
        VeriIdDef *id = mod-&amp;gt;FindDeclared(id_name) ;&lt;br /&gt;
        if (!id) return 3 ; &lt;br /&gt;
&lt;br /&gt;
        // Create the expression:&lt;br /&gt;
        VeriExpression *expr = veri_file::AnalyzeExpr(val_str, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
        if (!expr) return 4 ;&lt;br /&gt;
&lt;br /&gt;
        // Evaluate the expression:&lt;br /&gt;
        // If this is a literal expression, we do not need the value value or Resolve() call or else we need both:&lt;br /&gt;
        VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, 0 /* value table */) ;&lt;br /&gt;
        delete expr ;&lt;br /&gt;
        if (!val) return 5 ; &lt;br /&gt;
&lt;br /&gt;
        // Insert into the table to be used later:&lt;br /&gt;
        if (!df.Insert(id, val)) {&lt;br /&gt;
            delete val ;&lt;br /&gt;
            return 6 ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Now create the expression for to be evaluated:&lt;br /&gt;
    VeriExpression *expr = veri_file::AnalyzeExpr(expr_string, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
    if (!expr) return 7 ;&lt;br /&gt;
&lt;br /&gt;
    // Resolve the expression so that the id-refs are resolved:&lt;br /&gt;
    expr-&amp;gt;Resolve(mod-&amp;gt;GetScope(), VeriTreeNode::VERI_UNDEF_ENV) ;&lt;br /&gt;
&lt;br /&gt;
    VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, &amp;amp;df /* use this table with the known values */) ;&lt;br /&gt;
    delete expr ;&lt;br /&gt;
    if (!val) return 8 ; // Failed to evaluate&lt;br /&gt;
&lt;br /&gt;
    char *image = val-&amp;gt;Image() ;&lt;br /&gt;
    int result = val-&amp;gt;GetIntegerValue() ;&lt;br /&gt;
    mod-&amp;gt;Info(&amp;quot;Evaluated value: %s (%d)&amp;quot;, ((image)?image:&amp;quot;&amp;quot;), result) ;&lt;br /&gt;
    Strings::free(image) ;&lt;br /&gt;
    delete val ;&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;
Verilog testcase:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module test_module;&lt;br /&gt;
    wire a [1:0];&lt;br /&gt;
    wire [1:0] b;&lt;br /&gt;
    wire [1:0] c;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'test.v' (VERI-1482)&lt;br /&gt;
test.v(5): INFO: Evaluated value: 2'b10 (2)&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=951</id>
		<title>How to evaluate a Verilog expression</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=951"/>
				<updated>2025-09-03T19:17:54Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Evaluating a Verilog expression requires 'Static Elaboration' or 'Hierarchy Tree' feature.&lt;br /&gt;
&lt;br /&gt;
In the example below, a, b, and c are declared in the Verilog module. But 'Static Elaboration' feature is still required because the API VeriExpression::StaticEvaluate() is available only with 'Static Elaboration' feature.&lt;br /&gt;
&lt;br /&gt;
C++:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;veri_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriModule.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriBaseValue_Stat.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Strings.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Array.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Map.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;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = (argc &amp;gt; 1) ? argv[1] : &amp;quot;test.v&amp;quot; ;&lt;br /&gt;
    const char *module_name = (argc &amp;gt; 2) ? argv[2] : &amp;quot;test_module&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    Array files(1) ;&lt;br /&gt;
    files.Insert(file_name) ;&lt;br /&gt;
    if (!veri_file::AnalyzeMultipleFiles(&amp;amp;files, veri_file::SYSTEM_VERILOG)) return 1 ; &lt;br /&gt;
&lt;br /&gt;
    const VeriModule *mod = veri_file::GetModule(module_name) ;&lt;br /&gt;
    if (!mod) return 2 ; &lt;br /&gt;
&lt;br /&gt;
    // Apply following known values to evaluate &amp;quot;a[b] + c&amp;quot;: &lt;br /&gt;
    //   a = {1'b1, 1'b1}&lt;br /&gt;
    //   b = 2'b00&lt;br /&gt;
    //   c = 2'b01  &lt;br /&gt;
&lt;br /&gt;
    const char *expr_string = &amp;quot;a[b] + c&amp;quot; ;&lt;br /&gt;
    Map known_values(STRING_HASH) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;a&amp;quot;, &amp;quot;{1'b1, 1'b1}&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;b&amp;quot;, &amp;quot;2'b00&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;c&amp;quot;, &amp;quot;2'b01&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
    ValueTable df ;&lt;br /&gt;
&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    const char *id_name ;&lt;br /&gt;
    const char *val_str ;&lt;br /&gt;
    FOREACH_MAP_ITEM(&amp;amp;known_values, mi, &amp;amp;id_name, &amp;amp;val_str) {&lt;br /&gt;
        if (!id_name || !val_str) continue ;&lt;br /&gt;
&lt;br /&gt;
        // Find the identifier:&lt;br /&gt;
        VeriIdDef *id = mod-&amp;gt;FindDeclared(id_name) ;&lt;br /&gt;
        if (!id) return 3 ; &lt;br /&gt;
&lt;br /&gt;
        // Create the expression:&lt;br /&gt;
        VeriExpression *expr = veri_file::AnalyzeExpr(val_str, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
        if (!expr) return 4 ;&lt;br /&gt;
&lt;br /&gt;
        // Evaluate the expression:&lt;br /&gt;
        // If this is a literal expression, we do not need the value value or Resolve() call or else we need both:&lt;br /&gt;
        VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, 0 /* value table */) ;&lt;br /&gt;
        delete expr ;&lt;br /&gt;
        if (!val) return 5 ; &lt;br /&gt;
&lt;br /&gt;
        // Insert into the table to be used later:&lt;br /&gt;
        if (!df.Insert(id, val)) {&lt;br /&gt;
            delete val ;&lt;br /&gt;
            return 6 ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Now create the expression for to be evaluated:&lt;br /&gt;
    VeriExpression *expr = veri_file::AnalyzeExpr(expr_string, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
    if (!expr) return 7 ;&lt;br /&gt;
&lt;br /&gt;
    // Resolve the expression so that the id-refs are resolved:&lt;br /&gt;
    expr-&amp;gt;Resolve(mod-&amp;gt;GetScope(), VeriTreeNode::VERI_UNDEF_ENV) ;&lt;br /&gt;
&lt;br /&gt;
    VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, &amp;amp;df /* use this table with the known values */) ;&lt;br /&gt;
    delete expr ;&lt;br /&gt;
    if (!val) return 8 ; // Failed to evaluate&lt;br /&gt;
&lt;br /&gt;
    char *image = val-&amp;gt;Image() ;&lt;br /&gt;
    int result = val-&amp;gt;GetIntegerValue() ;&lt;br /&gt;
    mod-&amp;gt;Info(&amp;quot;Evaluated value: %s (%d)&amp;quot;, ((image)?image:&amp;quot;&amp;quot;), result) ;&lt;br /&gt;
    Strings::free(image) ;&lt;br /&gt;
    delete val ;&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;
Verilog testcase:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module test_module;&lt;br /&gt;
    wire a [1:0];&lt;br /&gt;
    wire [1:0] b;&lt;br /&gt;
    wire [1:0] c;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'test.v' (VERI-1482)&lt;br /&gt;
test.v(5): INFO: Evaluated value: 2'b10 (2)&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=950</id>
		<title>How to evaluate a Verilog expression</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=950"/>
				<updated>2025-09-03T19:15:31Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Evaluating a Verilog expression Verific 'Static Elaboration' or 'Hierarchy Tree' feature.&lt;br /&gt;
&lt;br /&gt;
In the example below, a, b, and c are declared in the Verilog module. But 'Static Elaboration' feature is still required because the API VeriExpression::StaticEvaluate() is available only with 'Static Elaboration' feature.&lt;br /&gt;
&lt;br /&gt;
C++:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;veri_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriModule.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriBaseValue_Stat.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Strings.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Array.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Map.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;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = (argc &amp;gt; 1) ? argv[1] : &amp;quot;test.v&amp;quot; ;&lt;br /&gt;
    const char *module_name = (argc &amp;gt; 2) ? argv[2] : &amp;quot;test_module&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    Array files(1) ;&lt;br /&gt;
    files.Insert(file_name) ;&lt;br /&gt;
    if (!veri_file::AnalyzeMultipleFiles(&amp;amp;files, veri_file::SYSTEM_VERILOG)) return 1 ; &lt;br /&gt;
&lt;br /&gt;
    const VeriModule *mod = veri_file::GetModule(module_name) ;&lt;br /&gt;
    if (!mod) return 2 ; &lt;br /&gt;
&lt;br /&gt;
    // Apply following known values to evaluate &amp;quot;a[b] + c&amp;quot;: &lt;br /&gt;
    //   a = {1'b1, 1'b1}&lt;br /&gt;
    //   b = 2'b00&lt;br /&gt;
    //   c = 2'b01  &lt;br /&gt;
&lt;br /&gt;
    const char *expr_string = &amp;quot;a[b] + c&amp;quot; ;&lt;br /&gt;
    Map known_values(STRING_HASH) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;a&amp;quot;, &amp;quot;{1'b1, 1'b1}&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;b&amp;quot;, &amp;quot;2'b00&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;c&amp;quot;, &amp;quot;2'b01&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
    ValueTable df ;&lt;br /&gt;
&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    const char *id_name ;&lt;br /&gt;
    const char *val_str ;&lt;br /&gt;
    FOREACH_MAP_ITEM(&amp;amp;known_values, mi, &amp;amp;id_name, &amp;amp;val_str) {&lt;br /&gt;
        if (!id_name || !val_str) continue ;&lt;br /&gt;
&lt;br /&gt;
        // Find the identifier:&lt;br /&gt;
        VeriIdDef *id = mod-&amp;gt;FindDeclared(id_name) ;&lt;br /&gt;
        if (!id) return 3 ; &lt;br /&gt;
&lt;br /&gt;
        // Create the expression:&lt;br /&gt;
        VeriExpression *expr = veri_file::AnalyzeExpr(val_str, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
        if (!expr) return 4 ;&lt;br /&gt;
&lt;br /&gt;
        // Evaluate the expression:&lt;br /&gt;
        // If this is a literal expression, we do not need the value value or Resolve() call or else we need both:&lt;br /&gt;
        VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, 0 /* value table */) ;&lt;br /&gt;
        delete expr ;&lt;br /&gt;
        if (!val) return 5 ; &lt;br /&gt;
&lt;br /&gt;
        // Insert into the table to be used later:&lt;br /&gt;
        if (!df.Insert(id, val)) {&lt;br /&gt;
            delete val ;&lt;br /&gt;
            return 6 ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Now create the expression for to be evaluated:&lt;br /&gt;
    VeriExpression *expr = veri_file::AnalyzeExpr(expr_string, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
    if (!expr) return 7 ;&lt;br /&gt;
&lt;br /&gt;
    // Resolve the expression so that the id-refs are resolved:&lt;br /&gt;
    expr-&amp;gt;Resolve(mod-&amp;gt;GetScope(), VeriTreeNode::VERI_UNDEF_ENV) ;&lt;br /&gt;
&lt;br /&gt;
    VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, &amp;amp;df /* use this table with the known values */) ;&lt;br /&gt;
    delete expr ;&lt;br /&gt;
    if (!val) return 8 ; // Failed to evaluate&lt;br /&gt;
&lt;br /&gt;
    char *image = val-&amp;gt;Image() ;&lt;br /&gt;
    int result = val-&amp;gt;GetIntegerValue() ;&lt;br /&gt;
    mod-&amp;gt;Info(&amp;quot;Evaluated value: %s (%d)&amp;quot;, ((image)?image:&amp;quot;&amp;quot;), result) ;&lt;br /&gt;
    Strings::free(image) ;&lt;br /&gt;
    delete val ;&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;
Verilog testcase:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module test_module;&lt;br /&gt;
    wire a [1:0];&lt;br /&gt;
    wire [1:0] b;&lt;br /&gt;
    wire [1:0] c;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'test.v' (VERI-1482)&lt;br /&gt;
test.v(5): INFO: Evaluated value: 2'b10 (2)&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=949</id>
		<title>How to evaluate a Verilog expression</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=949"/>
				<updated>2025-09-03T18:46:12Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This application example shows how to evaluate a Verilog expression. It requires Verific 'Static Elaboration' feature (the API VeriExpression::StaticEvaluate() available only with Verilog Static Elaboration feature).&lt;br /&gt;
&lt;br /&gt;
Note that a, b, and c are declared in the Verilog module. The application evaluates an expression of these variables.&lt;br /&gt;
&lt;br /&gt;
C++:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;veri_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriModule.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriBaseValue_Stat.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Strings.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Array.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Map.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;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = (argc &amp;gt; 1) ? argv[1] : &amp;quot;test.v&amp;quot; ;&lt;br /&gt;
    const char *module_name = (argc &amp;gt; 2) ? argv[2] : &amp;quot;test_module&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    Array files(1) ;&lt;br /&gt;
    files.Insert(file_name) ;&lt;br /&gt;
    if (!veri_file::AnalyzeMultipleFiles(&amp;amp;files, veri_file::SYSTEM_VERILOG)) return 1 ; &lt;br /&gt;
&lt;br /&gt;
    const VeriModule *mod = veri_file::GetModule(module_name) ;&lt;br /&gt;
    if (!mod) return 2 ; &lt;br /&gt;
&lt;br /&gt;
    // Apply following known values to evaluate &amp;quot;a[b] + c&amp;quot;: &lt;br /&gt;
    //   a = {1'b1, 1'b1}&lt;br /&gt;
    //   b = 2'b00&lt;br /&gt;
    //   c = 2'b01  &lt;br /&gt;
&lt;br /&gt;
    const char *expr_string = &amp;quot;a[b] + c&amp;quot; ;&lt;br /&gt;
    Map known_values(STRING_HASH) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;a&amp;quot;, &amp;quot;{1'b1, 1'b1}&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;b&amp;quot;, &amp;quot;2'b00&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;c&amp;quot;, &amp;quot;2'b01&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
    ValueTable df ;&lt;br /&gt;
&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    const char *id_name ;&lt;br /&gt;
    const char *val_str ;&lt;br /&gt;
    FOREACH_MAP_ITEM(&amp;amp;known_values, mi, &amp;amp;id_name, &amp;amp;val_str) {&lt;br /&gt;
        if (!id_name || !val_str) continue ;&lt;br /&gt;
&lt;br /&gt;
        // Find the identifier:&lt;br /&gt;
        VeriIdDef *id = mod-&amp;gt;FindDeclared(id_name) ;&lt;br /&gt;
        if (!id) return 3 ; &lt;br /&gt;
&lt;br /&gt;
        // Create the expression:&lt;br /&gt;
        VeriExpression *expr = veri_file::AnalyzeExpr(val_str, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
        if (!expr) return 4 ;&lt;br /&gt;
&lt;br /&gt;
        // Evaluate the expression:&lt;br /&gt;
        // If this is a literal expression, we do not need the value value or Resolve() call or else we need both:&lt;br /&gt;
        VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, 0 /* value table */) ;&lt;br /&gt;
        delete expr ;&lt;br /&gt;
        if (!val) return 5 ; &lt;br /&gt;
&lt;br /&gt;
        // Insert into the table to be used later:&lt;br /&gt;
        if (!df.Insert(id, val)) {&lt;br /&gt;
            delete val ;&lt;br /&gt;
            return 6 ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Now create the expression for to be evaluated:&lt;br /&gt;
    VeriExpression *expr = veri_file::AnalyzeExpr(expr_string, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
    if (!expr) return 7 ;&lt;br /&gt;
&lt;br /&gt;
    // Resolve the expression so that the id-refs are resolved:&lt;br /&gt;
    expr-&amp;gt;Resolve(mod-&amp;gt;GetScope(), VeriTreeNode::VERI_UNDEF_ENV) ;&lt;br /&gt;
&lt;br /&gt;
    VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, &amp;amp;df /* use this table with the known values */) ;&lt;br /&gt;
    delete expr ;&lt;br /&gt;
    if (!val) return 8 ; // Failed to evaluate&lt;br /&gt;
&lt;br /&gt;
    char *image = val-&amp;gt;Image() ;&lt;br /&gt;
    int result = val-&amp;gt;GetIntegerValue() ;&lt;br /&gt;
    mod-&amp;gt;Info(&amp;quot;Evaluated value: %s (%d)&amp;quot;, ((image)?image:&amp;quot;&amp;quot;), result) ;&lt;br /&gt;
    Strings::free(image) ;&lt;br /&gt;
    delete val ;&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;
Verilog testcase:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module test_module;&lt;br /&gt;
    wire a [1:0];&lt;br /&gt;
    wire [1:0] b;&lt;br /&gt;
    wire [1:0] c;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'test.v' (VERI-1482)&lt;br /&gt;
test.v(5): INFO: Evaluated value: 2'b10 (2)&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=948</id>
		<title>How to evaluate a Verilog expression</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=948"/>
				<updated>2025-09-03T18:44:19Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This application example shows how to evaluate a Verilog expression. It requires Verific 'Static Elaboration' feature.&lt;br /&gt;
&lt;br /&gt;
Note that a, b, and c are declared in the Verilog module. The application evaluates an expression of these variables.&lt;br /&gt;
&lt;br /&gt;
C++:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;veri_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriModule.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriBaseValue_Stat.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Strings.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Array.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Map.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;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = (argc &amp;gt; 1) ? argv[1] : &amp;quot;test.v&amp;quot; ;&lt;br /&gt;
    const char *module_name = (argc &amp;gt; 2) ? argv[2] : &amp;quot;test_module&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    Array files(1) ;&lt;br /&gt;
    files.Insert(file_name) ;&lt;br /&gt;
    if (!veri_file::AnalyzeMultipleFiles(&amp;amp;files, veri_file::SYSTEM_VERILOG)) return 1 ; &lt;br /&gt;
&lt;br /&gt;
    const VeriModule *mod = veri_file::GetModule(module_name) ;&lt;br /&gt;
    if (!mod) return 2 ; &lt;br /&gt;
&lt;br /&gt;
    // Apply following known values to evaluate &amp;quot;a[b] + c&amp;quot;: &lt;br /&gt;
    //   a = {1'b1, 1'b1}&lt;br /&gt;
    //   b = 2'b00&lt;br /&gt;
    //   c = 2'b01  &lt;br /&gt;
&lt;br /&gt;
    const char *expr_string = &amp;quot;a[b] + c&amp;quot; ;&lt;br /&gt;
    Map known_values(STRING_HASH) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;a&amp;quot;, &amp;quot;{1'b1, 1'b1}&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;b&amp;quot;, &amp;quot;2'b00&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;c&amp;quot;, &amp;quot;2'b01&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
    ValueTable df ;&lt;br /&gt;
&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    const char *id_name ;&lt;br /&gt;
    const char *val_str ;&lt;br /&gt;
    FOREACH_MAP_ITEM(&amp;amp;known_values, mi, &amp;amp;id_name, &amp;amp;val_str) {&lt;br /&gt;
        if (!id_name || !val_str) continue ;&lt;br /&gt;
&lt;br /&gt;
        // Find the identifier:&lt;br /&gt;
        VeriIdDef *id = mod-&amp;gt;FindDeclared(id_name) ;&lt;br /&gt;
        if (!id) return 3 ; &lt;br /&gt;
&lt;br /&gt;
        // Create the expression:&lt;br /&gt;
        VeriExpression *expr = veri_file::AnalyzeExpr(val_str, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
        if (!expr) return 4 ;&lt;br /&gt;
&lt;br /&gt;
        // Evaluate the expression:&lt;br /&gt;
        // If this is a literal expression, we do not need the value value or Resolve() call or else we need both:&lt;br /&gt;
        VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, 0 /* value table */) ;&lt;br /&gt;
        delete expr ;&lt;br /&gt;
        if (!val) return 5 ; &lt;br /&gt;
&lt;br /&gt;
        // Insert into the table to be used later:&lt;br /&gt;
        if (!df.Insert(id, val)) {&lt;br /&gt;
            delete val ;&lt;br /&gt;
            return 6 ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Now create the expression for to be evaluated:&lt;br /&gt;
    VeriExpression *expr = veri_file::AnalyzeExpr(expr_string, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
    if (!expr) return 7 ;&lt;br /&gt;
&lt;br /&gt;
    // Resolve the expression so that the id-refs are resolved:&lt;br /&gt;
    expr-&amp;gt;Resolve(mod-&amp;gt;GetScope(), VeriTreeNode::VERI_UNDEF_ENV) ;&lt;br /&gt;
&lt;br /&gt;
    VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, &amp;amp;df /* use this table with the known values */) ;&lt;br /&gt;
    delete expr ;&lt;br /&gt;
    if (!val) return 8 ; // Failed to evaluate&lt;br /&gt;
&lt;br /&gt;
    char *image = val-&amp;gt;Image() ;&lt;br /&gt;
    int result = val-&amp;gt;GetIntegerValue() ;&lt;br /&gt;
    mod-&amp;gt;Info(&amp;quot;Evaluated value: %s (%d)&amp;quot;, ((image)?image:&amp;quot;&amp;quot;), result) ;&lt;br /&gt;
    Strings::free(image) ;&lt;br /&gt;
    delete val ;&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;
Verilog testcase:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module test_module;&lt;br /&gt;
    wire a [1:0];&lt;br /&gt;
    wire [1:0] b;&lt;br /&gt;
    wire [1:0] c;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'test.v' (VERI-1482)&lt;br /&gt;
test.v(5): INFO: Evaluated value: 2'b10 (2)&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=How_to_evaluate_a_VHDL_expression&amp;diff=947</id>
		<title>How to evaluate a VHDL expression</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=How_to_evaluate_a_VHDL_expression&amp;diff=947"/>
				<updated>2025-09-02T22:36:07Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''&amp;gt;&amp;gt;&amp;gt; This page is under construction &amp;lt;&amp;lt;&amp;lt;'''&lt;br /&gt;
&lt;br /&gt;
Unlike in Verilog, expression evaluation in VHDL is fairly involved and needs all of the following:&lt;br /&gt;
&lt;br /&gt;
* Either static elaborated tree or context from correct HierTreeNode pushed into the parse tree.&lt;br /&gt;
* VhdlNode::_present_scope set to the container scope where the expression is defined or to be used.&lt;br /&gt;
* Expression evaluation method set to static elaboration with VhdlNode::SetStaticElab().&lt;br /&gt;
* Constant pwr/gnd/x/z nets set with VhdlNode::SetConstNets(). Constant nets also need to be deleted to avoid memory leaks, but should only be done after the evaluated value (that is using those nets) is deleted.&lt;br /&gt;
&lt;br /&gt;
The application examples below will illustrate the process.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
C++ example 1 (via static elaboration):&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;vhdl_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlUnits.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlIdDef.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlValue_Elab.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlDataFlow_Elab.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Strings.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Map.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;
// Restore back to the previous setting:&lt;br /&gt;
#define RETURN(N) { \&lt;br /&gt;
    if (!static_elab) VhdlNode::SetRtlElab() ; \&lt;br /&gt;
    VhdlNode::_present_scope = save_scope ; \&lt;br /&gt;
    VhdlNode::ResetConstNets() ; \&lt;br /&gt;
    return N ; \&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = (argc &amp;gt; 1) ? argv[1] : &amp;quot;test.vhd&amp;quot; ;&lt;br /&gt;
    const char *entity_name = (argc &amp;gt; 2) ? argv[2] : &amp;quot;test_entity&amp;quot; ;&lt;br /&gt;
    const char *arch_name = (argc &amp;gt; 2) ? argv[2] : &amp;quot;test_arch&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    const char *expr_string = &amp;quot;a(b) + c&amp;quot; ;&lt;br /&gt;
    const char *lib_name = &amp;quot;work&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    if (!vhdl_file::SetDefaultLibraryPath(&amp;quot;../vdbs&amp;quot;)) return 1 ;&lt;br /&gt;
    if (!vhdl_file::Analyze(file_name)) return 2 ; &lt;br /&gt;
&lt;br /&gt;
    // Step (0): Need to have the parse tree static elaborated already:&lt;br /&gt;
    if (!vhdl_file::Elaborate(entity_name, lib_name, arch_name, 0 /* generics */, 1 /* static elab */)) return 3 ;&lt;br /&gt;
&lt;br /&gt;
    const VhdlLibrary *work = vhdl_file::GetLibrary(lib_name) ;&lt;br /&gt;
    if (!work) return 4 ; &lt;br /&gt;
&lt;br /&gt;
    const VhdlPrimaryUnit *ent = work-&amp;gt;GetPrimUnit(entity_name) ;&lt;br /&gt;
    if (!ent) return 5 ;&lt;br /&gt;
&lt;br /&gt;
    const VhdlSecondaryUnit *arch = ent-&amp;gt;GetSecondaryUnit(arch_name) ;&lt;br /&gt;
    if (!arch) return 6 ;&lt;br /&gt;
&lt;br /&gt;
    VhdlScope *arch_scope = arch-&amp;gt;LocalScope() ;&lt;br /&gt;
    if (!arch_scope) return 7 ;&lt;br /&gt;
&lt;br /&gt;
    // Step (1): Need to set _present_scope:&lt;br /&gt;
    VhdlScope *save_scope = VhdlNode::_present_scope ;&lt;br /&gt;
    VhdlNode::_present_scope = arch_scope ;&lt;br /&gt;
&lt;br /&gt;
    // Step (2): Need to set constant _pwr, _gnd, _x, _z nets:&lt;br /&gt;
    VhdlNode::SetConstNets() ;&lt;br /&gt;
&lt;br /&gt;
    // Step (3): Need to set evaluation flow to use static elaboration:&lt;br /&gt;
    unsigned static_elab = VhdlNode::IsStaticElab() ;&lt;br /&gt;
    if (!static_elab) VhdlNode::SetStaticElab() ;&lt;br /&gt;
&lt;br /&gt;
    // Apply following known values to evaluate &amp;quot;a(b) + c&amp;quot;: &lt;br /&gt;
    //   a = (2, 3)&lt;br /&gt;
    //   b = 0&lt;br /&gt;
    //   c = 1&lt;br /&gt;
&lt;br /&gt;
    Map known_values(STRING_HASH) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;a&amp;quot;, &amp;quot;(2, 3)&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;b&amp;quot;, &amp;quot;0&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;c&amp;quot;, &amp;quot;1&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
    // Create a data-flow and set it to be in the &amp;quot;initial&amp;quot; phase&lt;br /&gt;
    // and in subprograms, so that static elab uses the values from there:&lt;br /&gt;
    VhdlDataFlow df(0) ;&lt;br /&gt;
    df.SetInInitial() ;&lt;br /&gt;
    df.SetInSubprogramOrProcess() ;&lt;br /&gt;
&lt;br /&gt;
    // The known values need to be in the condition-id-value Map to be picked up:&lt;br /&gt;
    Map *id_value_map = new Map(POINTER_HASH, known_values.Size()) ;&lt;br /&gt;
    df.SetConditionIdValueMap(id_value_map) ;&lt;br /&gt;
&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    const char *id_name ;&lt;br /&gt;
    const char *val_str ;&lt;br /&gt;
    FOREACH_MAP_ITEM(&amp;amp;known_values, mi, &amp;amp;id_name, &amp;amp;val_str) {&lt;br /&gt;
        if (!id_name || !val_str) continue ;&lt;br /&gt;
&lt;br /&gt;
        // Find the identifier:&lt;br /&gt;
        VhdlIdDef *id = arch-&amp;gt;FindDeclared(id_name) ;&lt;br /&gt;
        if (!id) RETURN(8) ;&lt;br /&gt;
&lt;br /&gt;
        // Create the expression:&lt;br /&gt;
        VhdlExpression *expr = vhdl_file::AnalyzeExpr(val_str) ;&lt;br /&gt;
        if (!expr) RETURN(9) ;&lt;br /&gt;
&lt;br /&gt;
        // Resolve the expression so that the id-refs are resolved:&lt;br /&gt;
        (void) expr-&amp;gt;TypeInfer(id-&amp;gt;Type() /* expected type */, 0 /* return types */, 0 /* environment */, arch_scope) ;&lt;br /&gt;
&lt;br /&gt;
        // Evaluate the expression:&lt;br /&gt;
        // If this is a literal expression, we do not need the value value or Resolve() call or else we need both:&lt;br /&gt;
        VhdlConstraint *constraint = id-&amp;gt;Constraint() ;&lt;br /&gt;
        VhdlValue *val = expr-&amp;gt;Evaluate(constraint, 0 /* DataFlow */, 0) ;&lt;br /&gt;
        delete expr ;&lt;br /&gt;
        if (!val) RETURN(10) ;&lt;br /&gt;
&lt;br /&gt;
        // Insert into the table to be used later:&lt;br /&gt;
        //df.SetAssignValue(id, val) ; // This only works for variables and not for signals&lt;br /&gt;
        (void) id_value_map-&amp;gt;Insert(id, val) ;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Now create the expression for to be evaluated:&lt;br /&gt;
    VhdlExpression *expr = vhdl_file::AnalyzeExpr(expr_string) ;&lt;br /&gt;
    if (!expr) RETURN(11) ;&lt;br /&gt;
&lt;br /&gt;
    // Resolve the expression (in self-context) so that the id-refs are resolved:&lt;br /&gt;
    // NOTE: May need to have the context (target) type for resolving context dependent expressions:&lt;br /&gt;
    VhdlIdDef *target_type = expr-&amp;gt;TypeInfer(0 /* expected type */, 0 /* return types */, 0 /* environment */, arch_scope) ;&lt;br /&gt;
    if (!target_type) RETURN(12) ;&lt;br /&gt;
&lt;br /&gt;
    // Evaluate the expression with the proper target type:&lt;br /&gt;
    VhdlValue *val = expr-&amp;gt;Evaluate(target_type-&amp;gt;Constraint(), &amp;amp;df /* use this table with the known values */, 0) ;&lt;br /&gt;
    delete expr ;&lt;br /&gt;
    if (!val) RETURN(13) ; // Failed to evaluate&lt;br /&gt;
&lt;br /&gt;
    // Show the result:&lt;br /&gt;
    char *image = val-&amp;gt;Image() ;&lt;br /&gt;
    verific_int64 result = val-&amp;gt;Integer() ;&lt;br /&gt;
    arch-&amp;gt;Info(&amp;quot;Evaluated value: %s (%d)&amp;quot;, ((image)?image:&amp;quot;&amp;quot;), result) ;&lt;br /&gt;
    Strings::free(image) ;&lt;br /&gt;
&lt;br /&gt;
    // Can create constant expression node so that the value can be deleted and ResetConstNets() can safely be called:&lt;br /&gt;
    expr = val-&amp;gt;CreateConstantVhdlExpression(0, target_type, 0) ;&lt;br /&gt;
    delete val ;&lt;br /&gt;
    if (!expr) RETURN(14) ;&lt;br /&gt;
&lt;br /&gt;
    // Show the expression node:&lt;br /&gt;
    image = expr-&amp;gt;GetPrettyPrintedString() ;&lt;br /&gt;
    arch-&amp;gt;Info(&amp;quot;Converted expression: %s&amp;quot;, image) ;&lt;br /&gt;
    Strings::free(image) ;&lt;br /&gt;
    delete expr ;&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;
VHDL testcase:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
library ieee ;&lt;br /&gt;
use ieee.std_logic_1164.all ;&lt;br /&gt;
entity test_entity is&lt;br /&gt;
end ;&lt;br /&gt;
&lt;br /&gt;
architecture test_arch of test_entity is&lt;br /&gt;
    type int_array is array (1 downto 0) of integer ;&lt;br /&gt;
    signal a : int_array ;&lt;br /&gt;
    signal b : integer ;&lt;br /&gt;
    signal c : integer ;&lt;br /&gt;
begin&lt;br /&gt;
end ;&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux&lt;br /&gt;
INFO: default VHDL library search path is now &amp;quot;/mnt/awing5_customers/Verific/extra_tests/vdbs&amp;quot; (VHDL-1504)&lt;br /&gt;
-- Analyzing VHDL file 'test.vhd' (VHDL-1481)&lt;br /&gt;
-- Restoring VHDL unit 'ieee.std_logic_1164' from file '/mnt/awing5_customers/Verific/extra_tests/vdbs/ieee/std_logic_1164.vdb' (VHDL-1493)&lt;br /&gt;
-- Restoring VHDL unit 'std.standard' from file '/mnt/awing5_customers/Verific/extra_tests/vdbs/std/standard.vdb' (VHDL-1493)&lt;br /&gt;
test.vhd(3): INFO: analyzing entity 'test_entity' (VHDL-1012)&lt;br /&gt;
test.vhd(6): INFO: analyzing architecture 'test_arch' (VHDL-1010)&lt;br /&gt;
test.vhd(3): INFO: processing 'test_entity(test_arch)' (VHDL-1067)&lt;br /&gt;
test.vhd(12): INFO: Evaluated value: 4 (4)&lt;br /&gt;
test.vhd(12): INFO: Converted expression: 4&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
C++ example 2 (via hierarchy tree creation):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;vhdl_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;vhdl_tokens.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlValue_Elab.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;hier_tree.h&amp;quot;&lt;br /&gt;
#include &amp;quot;HierTreeNode.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;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    vhdl_file::SetDefaultLibraryPath(&amp;quot;../vdbs&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
    const char *file_name = &amp;quot;design.vhdl&amp;quot; ;&lt;br /&gt;
    if (!vhdl_file::Analyze(file_name)) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    VhdlLibrary *work = vhdl_file::GetLibrary(&amp;quot;work&amp;quot;) ;&lt;br /&gt;
    if (!work) return 2 ;&lt;br /&gt;
&lt;br /&gt;
    Array vhdl_libs ;&lt;br /&gt;
    vhdl_libs.Insert(work) ;&lt;br /&gt;
    const Map *top_nodes = hier_tree::CreateHierarchicalTreeAll(0, &amp;amp;vhdl_libs, 0) ;&lt;br /&gt;
    if (!top_nodes) return 3 ;&lt;br /&gt;
&lt;br /&gt;
    HierTreeNode *test = (HierTreeNode *)top_nodes-&amp;gt;GetValue(&amp;quot;test&amp;quot;) ;&lt;br /&gt;
    if (!test) return 4 ;&lt;br /&gt;
&lt;br /&gt;
    HierTreeNode *u1 = test-&amp;gt;GetChild(&amp;quot;u1&amp;quot;) ;&lt;br /&gt;
    if (!u1) return 5 ;&lt;br /&gt;
&lt;br /&gt;
    Map *context = u1-&amp;gt;PushContext() ;&lt;br /&gt;
&lt;br /&gt;
    //VhdlScope *node_scope = u1-&amp;gt;GetNodeScope() ; // Entity scope&lt;br /&gt;
    VhdlScope *node_scope = u1-&amp;gt;GetVhdlArchitectureScope() ; // Architecture scope&lt;br /&gt;
    if (!node_scope) { u1-&amp;gt;PopContext(context) ; return 6 ; }&lt;br /&gt;
&lt;br /&gt;
    VhdlScope *save = VhdlNode::_present_scope ;&lt;br /&gt;
    unsigned stat_elab = VhdlNode::IsStaticElab() ;&lt;br /&gt;
&lt;br /&gt;
    VhdlNode::_present_scope = node_scope ;&lt;br /&gt;
    VhdlNode::SetConstNets() ;&lt;br /&gt;
    VhdlNode::SetStaticElab() ;&lt;br /&gt;
&lt;br /&gt;
    // If you have the expression, use that; or parse one:&lt;br /&gt;
    VhdlExpression *expr = vhdl_file::AnalyzeExpr(&amp;quot;A + B&amp;quot;) ;&lt;br /&gt;
    if (!expr) { u1-&amp;gt;PopContext(context) ; return 7 ; }&lt;br /&gt;
&lt;br /&gt;
    (void) expr-&amp;gt;TypeInfer(0, 0, VHDL_READ, node_scope) ;&lt;br /&gt;
    VhdlValue *val = expr-&amp;gt;Evaluate(0, 0, 0) ;&lt;br /&gt;
    if (!val) { delete expr ; u1-&amp;gt;PopContext(context) ; return 8 ; }&lt;br /&gt;
&lt;br /&gt;
    char *img = val-&amp;gt;Image() ;&lt;br /&gt;
    char *pp_str = expr-&amp;gt;GetPrettyPrintedString() ;&lt;br /&gt;
    expr-&amp;gt;Info(&amp;quot;Expression '%s' evaluated to '%s'&amp;quot;, pp_str, img) ;&lt;br /&gt;
    Strings::free(pp_str) ;&lt;br /&gt;
    Strings::free(img) ;&lt;br /&gt;
    delete val ;&lt;br /&gt;
    delete expr ;&lt;br /&gt;
&lt;br /&gt;
    VhdlNode::ResetConstNets() ;&lt;br /&gt;
    if (!stat_elab) VhdlNode::SetRtlElab() ;&lt;br /&gt;
    VhdlNode::_present_scope = save ;&lt;br /&gt;
&lt;br /&gt;
    u1-&amp;gt;PopContext(context) ;&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;
VHDL testcase:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
library ieee;&lt;br /&gt;
use ieee.std_logic_1164.all;&lt;br /&gt;
use ieee.std_logic_arith.all;&lt;br /&gt;
&lt;br /&gt;
entity mult is&lt;br /&gt;
  generic (&lt;br /&gt;
    A: integer :=0;&lt;br /&gt;
    B: integer :=7 );&lt;br /&gt;
&lt;br /&gt;
  port (ain : in integer range (A) to (B);&lt;br /&gt;
        z   : out integer range (A) to (B));&lt;br /&gt;
end mult;&lt;br /&gt;
&lt;br /&gt;
architecture xxx of mult is&lt;br /&gt;
  begin&lt;br /&gt;
    process(ain) begin&lt;br /&gt;
      z &amp;lt;= ain ;&lt;br /&gt;
    end process;&lt;br /&gt;
end xxx;&lt;br /&gt;
&lt;br /&gt;
library ieee;&lt;br /&gt;
use ieee.std_logic_1164.all;&lt;br /&gt;
use ieee.std_logic_arith.all;&lt;br /&gt;
&lt;br /&gt;
entity test is&lt;br /&gt;
  port (ain1 : in integer range (0) to (2);&lt;br /&gt;
        cout1: out integer range (0) to (2));&lt;br /&gt;
end test;&lt;br /&gt;
&lt;br /&gt;
architecture rtl of test is&lt;br /&gt;
  component mult&lt;br /&gt;
    generic (&lt;br /&gt;
      A: integer :=0;&lt;br /&gt;
      B: integer :=2 );&lt;br /&gt;
  port (ain : in integer range (A+B) to (B);&lt;br /&gt;
        z   : out integer range (A) to (B) );&lt;br /&gt;
  end component;&lt;br /&gt;
&lt;br /&gt;
  begin&lt;br /&gt;
    u1: mult&lt;br /&gt;
      generic map(&lt;br /&gt;
        A=&amp;gt; 0,&lt;br /&gt;
        B=&amp;gt; 1 &lt;br /&gt;
      )&lt;br /&gt;
      port map(ain=&amp;gt;ain1,z=&amp;gt;cout1);&lt;br /&gt;
end rtl;&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux&lt;br /&gt;
INFO: default VHDL library search path is now &amp;quot;/mnt/awing5_customers/Verific/extra_tests/vdbs&amp;quot; (VHDL-1504)&lt;br /&gt;
-- Analyzing VHDL file 'design.vhdl' (VHDL-1481)&lt;br /&gt;
-- Restoring VHDL unit 'ieee.std_logic_1164' from file '/mnt/awing5_customers/Verific/extra_tests/vdbs/ieee/std_logic_1164.vdb' (VHDL-1493)&lt;br /&gt;
-- Restoring VHDL unit 'std.standard' from file '/mnt/awing5_customers/Verific/extra_tests/vdbs/std/standard.vdb' (VHDL-1493)&lt;br /&gt;
-- Restoring VHDL unit 'ieee.std_logic_arith' from file '/mnt/awing5_customers/Verific/extra_tests/vdbs/ieee/std_logic_arith.vdb' (VHDL-1493)&lt;br /&gt;
design.vhdl(5): INFO: analyzing entity 'mult' (VHDL-1012)&lt;br /&gt;
design.vhdl(14): INFO: analyzing architecture 'xxx' (VHDL-1010)&lt;br /&gt;
design.vhdl(25): INFO: analyzing entity 'test' (VHDL-1012)&lt;br /&gt;
design.vhdl(30): INFO: analyzing architecture 'rtl' (VHDL-1010)&lt;br /&gt;
INFO: Expression '(a + b)' evaluated to '1'&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=How_to_evaluate_a_VHDL_expression&amp;diff=946</id>
		<title>How to evaluate a VHDL expression</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=How_to_evaluate_a_VHDL_expression&amp;diff=946"/>
				<updated>2025-09-02T22:33:39Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''&amp;gt;&amp;gt;&amp;gt; This page is under construction &amp;lt;&amp;lt;&amp;lt;'''&lt;br /&gt;
&lt;br /&gt;
Unlike in Verilog, expression evaluation in VHDL is fairly involved and needs all of the following:&lt;br /&gt;
&lt;br /&gt;
* Either static elaborated tree or context from correct HierTreeNode pushed into the parse tree.&lt;br /&gt;
* VhdlNode::_present_scope set to the container scope where the expression is defined or to be used.&lt;br /&gt;
* Expression evaluation method set to static elaboration with VhdlNode::SetStaticElab().&lt;br /&gt;
* Constant pwr/gnd/x/z nets set with VhdlNode::SetConstNets(). Constant nets also need to be deleted to avoid memory leaks, but should only be done after the evaluated value (that is using those nets) is deleted.&lt;br /&gt;
&lt;br /&gt;
The application examples below will illustrate the process.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
C++ example 1:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;vhdl_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlUnits.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlIdDef.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlValue_Elab.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlDataFlow_Elab.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Strings.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Map.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;
// Restore back to the previous setting:&lt;br /&gt;
#define RETURN(N) { \&lt;br /&gt;
    if (!static_elab) VhdlNode::SetRtlElab() ; \&lt;br /&gt;
    VhdlNode::_present_scope = save_scope ; \&lt;br /&gt;
    VhdlNode::ResetConstNets() ; \&lt;br /&gt;
    return N ; \&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = (argc &amp;gt; 1) ? argv[1] : &amp;quot;test.vhd&amp;quot; ;&lt;br /&gt;
    const char *entity_name = (argc &amp;gt; 2) ? argv[2] : &amp;quot;test_entity&amp;quot; ;&lt;br /&gt;
    const char *arch_name = (argc &amp;gt; 2) ? argv[2] : &amp;quot;test_arch&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    const char *expr_string = &amp;quot;a(b) + c&amp;quot; ;&lt;br /&gt;
    const char *lib_name = &amp;quot;work&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    if (!vhdl_file::SetDefaultLibraryPath(&amp;quot;../vdbs&amp;quot;)) return 1 ;&lt;br /&gt;
    if (!vhdl_file::Analyze(file_name)) return 2 ; &lt;br /&gt;
&lt;br /&gt;
    // Step (0): Need to have the parse tree static elaborated already:&lt;br /&gt;
    if (!vhdl_file::Elaborate(entity_name, lib_name, arch_name, 0 /* generics */, 1 /* static elab */)) return 3 ;&lt;br /&gt;
&lt;br /&gt;
    const VhdlLibrary *work = vhdl_file::GetLibrary(lib_name) ;&lt;br /&gt;
    if (!work) return 4 ; &lt;br /&gt;
&lt;br /&gt;
    const VhdlPrimaryUnit *ent = work-&amp;gt;GetPrimUnit(entity_name) ;&lt;br /&gt;
    if (!ent) return 5 ;&lt;br /&gt;
&lt;br /&gt;
    const VhdlSecondaryUnit *arch = ent-&amp;gt;GetSecondaryUnit(arch_name) ;&lt;br /&gt;
    if (!arch) return 6 ;&lt;br /&gt;
&lt;br /&gt;
    VhdlScope *arch_scope = arch-&amp;gt;LocalScope() ;&lt;br /&gt;
    if (!arch_scope) return 7 ;&lt;br /&gt;
&lt;br /&gt;
    // Step (1): Need to set _present_scope:&lt;br /&gt;
    VhdlScope *save_scope = VhdlNode::_present_scope ;&lt;br /&gt;
    VhdlNode::_present_scope = arch_scope ;&lt;br /&gt;
&lt;br /&gt;
    // Step (2): Need to set constant _pwr, _gnd, _x, _z nets:&lt;br /&gt;
    VhdlNode::SetConstNets() ;&lt;br /&gt;
&lt;br /&gt;
    // Step (3): Need to set evaluation flow to use static elaboration:&lt;br /&gt;
    unsigned static_elab = VhdlNode::IsStaticElab() ;&lt;br /&gt;
    if (!static_elab) VhdlNode::SetStaticElab() ;&lt;br /&gt;
&lt;br /&gt;
    // Apply following known values to evaluate &amp;quot;a(b) + c&amp;quot;: &lt;br /&gt;
    //   a = (2, 3)&lt;br /&gt;
    //   b = 0&lt;br /&gt;
    //   c = 1&lt;br /&gt;
&lt;br /&gt;
    Map known_values(STRING_HASH) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;a&amp;quot;, &amp;quot;(2, 3)&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;b&amp;quot;, &amp;quot;0&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;c&amp;quot;, &amp;quot;1&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
    // Create a data-flow and set it to be in the &amp;quot;initial&amp;quot; phase&lt;br /&gt;
    // and in subprograms, so that static elab uses the values from there:&lt;br /&gt;
    VhdlDataFlow df(0) ;&lt;br /&gt;
    df.SetInInitial() ;&lt;br /&gt;
    df.SetInSubprogramOrProcess() ;&lt;br /&gt;
&lt;br /&gt;
    // The known values need to be in the condition-id-value Map to be picked up:&lt;br /&gt;
    Map *id_value_map = new Map(POINTER_HASH, known_values.Size()) ;&lt;br /&gt;
    df.SetConditionIdValueMap(id_value_map) ;&lt;br /&gt;
&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    const char *id_name ;&lt;br /&gt;
    const char *val_str ;&lt;br /&gt;
    FOREACH_MAP_ITEM(&amp;amp;known_values, mi, &amp;amp;id_name, &amp;amp;val_str) {&lt;br /&gt;
        if (!id_name || !val_str) continue ;&lt;br /&gt;
&lt;br /&gt;
        // Find the identifier:&lt;br /&gt;
        VhdlIdDef *id = arch-&amp;gt;FindDeclared(id_name) ;&lt;br /&gt;
        if (!id) RETURN(8) ;&lt;br /&gt;
&lt;br /&gt;
        // Create the expression:&lt;br /&gt;
        VhdlExpression *expr = vhdl_file::AnalyzeExpr(val_str) ;&lt;br /&gt;
        if (!expr) RETURN(9) ;&lt;br /&gt;
&lt;br /&gt;
        // Resolve the expression so that the id-refs are resolved:&lt;br /&gt;
        (void) expr-&amp;gt;TypeInfer(id-&amp;gt;Type() /* expected type */, 0 /* return types */, 0 /* environment */, arch_scope) ;&lt;br /&gt;
&lt;br /&gt;
        // Evaluate the expression:&lt;br /&gt;
        // If this is a literal expression, we do not need the value value or Resolve() call or else we need both:&lt;br /&gt;
        VhdlConstraint *constraint = id-&amp;gt;Constraint() ;&lt;br /&gt;
        VhdlValue *val = expr-&amp;gt;Evaluate(constraint, 0 /* DataFlow */, 0) ;&lt;br /&gt;
        delete expr ;&lt;br /&gt;
        if (!val) RETURN(10) ;&lt;br /&gt;
&lt;br /&gt;
        // Insert into the table to be used later:&lt;br /&gt;
        //df.SetAssignValue(id, val) ; // This only works for variables and not for signals&lt;br /&gt;
        (void) id_value_map-&amp;gt;Insert(id, val) ;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Now create the expression for to be evaluated:&lt;br /&gt;
    VhdlExpression *expr = vhdl_file::AnalyzeExpr(expr_string) ;&lt;br /&gt;
    if (!expr) RETURN(11) ;&lt;br /&gt;
&lt;br /&gt;
    // Resolve the expression (in self-context) so that the id-refs are resolved:&lt;br /&gt;
    // NOTE: May need to have the context (target) type for resolving context dependent expressions:&lt;br /&gt;
    VhdlIdDef *target_type = expr-&amp;gt;TypeInfer(0 /* expected type */, 0 /* return types */, 0 /* environment */, arch_scope) ;&lt;br /&gt;
    if (!target_type) RETURN(12) ;&lt;br /&gt;
&lt;br /&gt;
    // Evaluate the expression with the proper target type:&lt;br /&gt;
    VhdlValue *val = expr-&amp;gt;Evaluate(target_type-&amp;gt;Constraint(), &amp;amp;df /* use this table with the known values */, 0) ;&lt;br /&gt;
    delete expr ;&lt;br /&gt;
    if (!val) RETURN(13) ; // Failed to evaluate&lt;br /&gt;
&lt;br /&gt;
    // Show the result:&lt;br /&gt;
    char *image = val-&amp;gt;Image() ;&lt;br /&gt;
    verific_int64 result = val-&amp;gt;Integer() ;&lt;br /&gt;
    arch-&amp;gt;Info(&amp;quot;Evaluated value: %s (%d)&amp;quot;, ((image)?image:&amp;quot;&amp;quot;), result) ;&lt;br /&gt;
    Strings::free(image) ;&lt;br /&gt;
&lt;br /&gt;
    // Can create constant expression node so that the value can be deleted and ResetConstNets() can safely be called:&lt;br /&gt;
    expr = val-&amp;gt;CreateConstantVhdlExpression(0, target_type, 0) ;&lt;br /&gt;
    delete val ;&lt;br /&gt;
    if (!expr) RETURN(14) ;&lt;br /&gt;
&lt;br /&gt;
    // Show the expression node:&lt;br /&gt;
    image = expr-&amp;gt;GetPrettyPrintedString() ;&lt;br /&gt;
    arch-&amp;gt;Info(&amp;quot;Converted expression: %s&amp;quot;, image) ;&lt;br /&gt;
    Strings::free(image) ;&lt;br /&gt;
    delete expr ;&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;
VHDL testcase:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
library ieee ;&lt;br /&gt;
use ieee.std_logic_1164.all ;&lt;br /&gt;
entity test_entity is&lt;br /&gt;
end ;&lt;br /&gt;
&lt;br /&gt;
architecture test_arch of test_entity is&lt;br /&gt;
    type int_array is array (1 downto 0) of integer ;&lt;br /&gt;
    signal a : int_array ;&lt;br /&gt;
    signal b : integer ;&lt;br /&gt;
    signal c : integer ;&lt;br /&gt;
begin&lt;br /&gt;
end ;&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux&lt;br /&gt;
INFO: default VHDL library search path is now &amp;quot;/mnt/awing5_customers/Verific/extra_tests/vdbs&amp;quot; (VHDL-1504)&lt;br /&gt;
-- Analyzing VHDL file 'test.vhd' (VHDL-1481)&lt;br /&gt;
-- Restoring VHDL unit 'ieee.std_logic_1164' from file '/mnt/awing5_customers/Verific/extra_tests/vdbs/ieee/std_logic_1164.vdb' (VHDL-1493)&lt;br /&gt;
-- Restoring VHDL unit 'std.standard' from file '/mnt/awing5_customers/Verific/extra_tests/vdbs/std/standard.vdb' (VHDL-1493)&lt;br /&gt;
test.vhd(3): INFO: analyzing entity 'test_entity' (VHDL-1012)&lt;br /&gt;
test.vhd(6): INFO: analyzing architecture 'test_arch' (VHDL-1010)&lt;br /&gt;
test.vhd(3): INFO: processing 'test_entity(test_arch)' (VHDL-1067)&lt;br /&gt;
test.vhd(12): INFO: Evaluated value: 4 (4)&lt;br /&gt;
test.vhd(12): INFO: Converted expression: 4&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
C++ example 2:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;vhdl_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;vhdl_tokens.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlValue_Elab.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;hier_tree.h&amp;quot;&lt;br /&gt;
#include &amp;quot;HierTreeNode.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;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    vhdl_file::SetDefaultLibraryPath(&amp;quot;../vdbs&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
    const char *file_name = &amp;quot;design.vhdl&amp;quot; ;&lt;br /&gt;
    if (!vhdl_file::Analyze(file_name)) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    VhdlLibrary *work = vhdl_file::GetLibrary(&amp;quot;work&amp;quot;) ;&lt;br /&gt;
    if (!work) return 2 ;&lt;br /&gt;
&lt;br /&gt;
    Array vhdl_libs ;&lt;br /&gt;
    vhdl_libs.Insert(work) ;&lt;br /&gt;
    const Map *top_nodes = hier_tree::CreateHierarchicalTreeAll(0, &amp;amp;vhdl_libs, 0) ;&lt;br /&gt;
    if (!top_nodes) return 3 ;&lt;br /&gt;
&lt;br /&gt;
    HierTreeNode *test = (HierTreeNode *)top_nodes-&amp;gt;GetValue(&amp;quot;test&amp;quot;) ;&lt;br /&gt;
    if (!test) return 4 ;&lt;br /&gt;
&lt;br /&gt;
    HierTreeNode *u1 = test-&amp;gt;GetChild(&amp;quot;u1&amp;quot;) ;&lt;br /&gt;
    if (!u1) return 5 ;&lt;br /&gt;
&lt;br /&gt;
    Map *context = u1-&amp;gt;PushContext() ;&lt;br /&gt;
&lt;br /&gt;
    //VhdlScope *node_scope = u1-&amp;gt;GetNodeScope() ; // Entity scope&lt;br /&gt;
    VhdlScope *node_scope = u1-&amp;gt;GetVhdlArchitectureScope() ; // Architecture scope&lt;br /&gt;
    if (!node_scope) { u1-&amp;gt;PopContext(context) ; return 6 ; }&lt;br /&gt;
&lt;br /&gt;
    VhdlScope *save = VhdlNode::_present_scope ;&lt;br /&gt;
    unsigned stat_elab = VhdlNode::IsStaticElab() ;&lt;br /&gt;
&lt;br /&gt;
    VhdlNode::_present_scope = node_scope ;&lt;br /&gt;
    VhdlNode::SetConstNets() ;&lt;br /&gt;
    VhdlNode::SetStaticElab() ;&lt;br /&gt;
&lt;br /&gt;
    // If you have the expression, use that; or parse one:&lt;br /&gt;
    VhdlExpression *expr = vhdl_file::AnalyzeExpr(&amp;quot;A + B&amp;quot;) ;&lt;br /&gt;
    if (!expr) { u1-&amp;gt;PopContext(context) ; return 7 ; }&lt;br /&gt;
&lt;br /&gt;
    (void) expr-&amp;gt;TypeInfer(0, 0, VHDL_READ, node_scope) ;&lt;br /&gt;
    VhdlValue *val = expr-&amp;gt;Evaluate(0, 0, 0) ;&lt;br /&gt;
    if (!val) { delete expr ; u1-&amp;gt;PopContext(context) ; return 8 ; }&lt;br /&gt;
&lt;br /&gt;
    char *img = val-&amp;gt;Image() ;&lt;br /&gt;
    char *pp_str = expr-&amp;gt;GetPrettyPrintedString() ;&lt;br /&gt;
    expr-&amp;gt;Info(&amp;quot;Expression '%s' evaluated to '%s'&amp;quot;, pp_str, img) ;&lt;br /&gt;
    Strings::free(pp_str) ;&lt;br /&gt;
    Strings::free(img) ;&lt;br /&gt;
    delete val ;&lt;br /&gt;
    delete expr ;&lt;br /&gt;
&lt;br /&gt;
    VhdlNode::ResetConstNets() ;&lt;br /&gt;
    if (!stat_elab) VhdlNode::SetRtlElab() ;&lt;br /&gt;
    VhdlNode::_present_scope = save ;&lt;br /&gt;
&lt;br /&gt;
    u1-&amp;gt;PopContext(context) ;&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;
VHDL testcase:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
library ieee;&lt;br /&gt;
use ieee.std_logic_1164.all;&lt;br /&gt;
use ieee.std_logic_arith.all;&lt;br /&gt;
&lt;br /&gt;
entity mult is&lt;br /&gt;
  generic (&lt;br /&gt;
    A: integer :=0;&lt;br /&gt;
    B: integer :=7 );&lt;br /&gt;
&lt;br /&gt;
  port (ain : in integer range (A) to (B);&lt;br /&gt;
        z   : out integer range (A) to (B));&lt;br /&gt;
end mult;&lt;br /&gt;
&lt;br /&gt;
architecture xxx of mult is&lt;br /&gt;
  begin&lt;br /&gt;
    process(ain) begin&lt;br /&gt;
      z &amp;lt;= ain ;&lt;br /&gt;
    end process;&lt;br /&gt;
end xxx;&lt;br /&gt;
&lt;br /&gt;
library ieee;&lt;br /&gt;
use ieee.std_logic_1164.all;&lt;br /&gt;
use ieee.std_logic_arith.all;&lt;br /&gt;
&lt;br /&gt;
entity test is&lt;br /&gt;
  port (ain1 : in integer range (0) to (2);&lt;br /&gt;
        cout1: out integer range (0) to (2));&lt;br /&gt;
end test;&lt;br /&gt;
&lt;br /&gt;
architecture rtl of test is&lt;br /&gt;
  component mult&lt;br /&gt;
    generic (&lt;br /&gt;
      A: integer :=0;&lt;br /&gt;
      B: integer :=2 );&lt;br /&gt;
  port (ain : in integer range (A+B) to (B);&lt;br /&gt;
        z   : out integer range (A) to (B) );&lt;br /&gt;
  end component;&lt;br /&gt;
&lt;br /&gt;
  begin&lt;br /&gt;
    u1: mult&lt;br /&gt;
      generic map(&lt;br /&gt;
        A=&amp;gt; 0,&lt;br /&gt;
        B=&amp;gt; 1 &lt;br /&gt;
      )&lt;br /&gt;
      port map(ain=&amp;gt;ain1,z=&amp;gt;cout1);&lt;br /&gt;
end rtl;&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux&lt;br /&gt;
INFO: default VHDL library search path is now &amp;quot;/mnt/awing5_customers/Verific/extra_tests/vdbs&amp;quot; (VHDL-1504)&lt;br /&gt;
-- Analyzing VHDL file 'design.vhdl' (VHDL-1481)&lt;br /&gt;
-- Restoring VHDL unit 'ieee.std_logic_1164' from file '/mnt/awing5_customers/Verific/extra_tests/vdbs/ieee/std_logic_1164.vdb' (VHDL-1493)&lt;br /&gt;
-- Restoring VHDL unit 'std.standard' from file '/mnt/awing5_customers/Verific/extra_tests/vdbs/std/standard.vdb' (VHDL-1493)&lt;br /&gt;
-- Restoring VHDL unit 'ieee.std_logic_arith' from file '/mnt/awing5_customers/Verific/extra_tests/vdbs/ieee/std_logic_arith.vdb' (VHDL-1493)&lt;br /&gt;
design.vhdl(5): INFO: analyzing entity 'mult' (VHDL-1012)&lt;br /&gt;
design.vhdl(14): INFO: analyzing architecture 'xxx' (VHDL-1010)&lt;br /&gt;
design.vhdl(25): INFO: analyzing entity 'test' (VHDL-1012)&lt;br /&gt;
design.vhdl(30): INFO: analyzing architecture 'rtl' (VHDL-1010)&lt;br /&gt;
INFO: Expression '(a + b)' evaluated to '1'&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=How_to_evaluate_a_VHDL_expression&amp;diff=945</id>
		<title>How to evaluate a VHDL expression</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=How_to_evaluate_a_VHDL_expression&amp;diff=945"/>
				<updated>2025-09-02T22:32:45Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''&amp;gt;&amp;gt;&amp;gt; This page is under construction &amp;lt;&amp;lt;&amp;lt;'''&lt;br /&gt;
&lt;br /&gt;
Unlike in Verilog, expression evaluation in VHDL is fairly involved and needs all of the following:&lt;br /&gt;
&lt;br /&gt;
* Either static elaborated tree or context from correct HierTreeNode pushed into the parse tree.&lt;br /&gt;
* VhdlNode::_present_scope set to the container scope where the expression is defined or to be used.&lt;br /&gt;
* Expression evaluation method set to static elaboration with VhdlNode::SetStaticElab().&lt;br /&gt;
* Constant pwr/gnd/x/z nets set with VhdlNode::SetConstNets(). Constant nets also need to be deleted to avoid memory leaks, but should only be done after the evaluated value (that is using those nets) is deleted.&lt;br /&gt;
&lt;br /&gt;
The application examples below will illustrate the process.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
C++ example 1:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;vhdl_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlUnits.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlIdDef.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlValue_Elab.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlDataFlow_Elab.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Strings.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Map.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;
// Restore back to the previous setting:&lt;br /&gt;
#define RETURN(N) { \&lt;br /&gt;
    if (!static_elab) VhdlNode::SetRtlElab() ; \&lt;br /&gt;
    VhdlNode::_present_scope = save_scope ; \&lt;br /&gt;
    VhdlNode::ResetConstNets() ; \&lt;br /&gt;
    return N ; \&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = (argc &amp;gt; 1) ? argv[1] : &amp;quot;test.vhd&amp;quot; ;&lt;br /&gt;
    const char *entity_name = (argc &amp;gt; 2) ? argv[2] : &amp;quot;test_entity&amp;quot; ;&lt;br /&gt;
    const char *arch_name = (argc &amp;gt; 2) ? argv[2] : &amp;quot;test_arch&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    const char *expr_string = &amp;quot;a(b) + c&amp;quot; ;&lt;br /&gt;
    const char *lib_name = &amp;quot;work&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    if (!vhdl_file::SetDefaultLibraryPath(&amp;quot;../vdbs&amp;quot;)) return 1 ;&lt;br /&gt;
    if (!vhdl_file::Analyze(file_name)) return 2 ; &lt;br /&gt;
&lt;br /&gt;
    // Step (0): Need to have the parse tree static elaborated already:&lt;br /&gt;
    if (!vhdl_file::Elaborate(entity_name, lib_name, arch_name, 0 /* generics */, 1 /* static elab */)) return 3 ;&lt;br /&gt;
&lt;br /&gt;
    const VhdlLibrary *work = vhdl_file::GetLibrary(lib_name) ;&lt;br /&gt;
    if (!work) return 4 ; &lt;br /&gt;
&lt;br /&gt;
    const VhdlPrimaryUnit *ent = work-&amp;gt;GetPrimUnit(entity_name) ;&lt;br /&gt;
    if (!ent) return 5 ;&lt;br /&gt;
&lt;br /&gt;
    const VhdlSecondaryUnit *arch = ent-&amp;gt;GetSecondaryUnit(arch_name) ;&lt;br /&gt;
    if (!arch) return 6 ;&lt;br /&gt;
&lt;br /&gt;
    VhdlScope *arch_scope = arch-&amp;gt;LocalScope() ;&lt;br /&gt;
    if (!arch_scope) return 7 ;&lt;br /&gt;
&lt;br /&gt;
    // Step (1): Need to set _present_scope:&lt;br /&gt;
    VhdlScope *save_scope = VhdlNode::_present_scope ;&lt;br /&gt;
    VhdlNode::_present_scope = arch_scope ;&lt;br /&gt;
&lt;br /&gt;
    // Step (2): Need to set constant _pwr, _gnd, _x, _z nets:&lt;br /&gt;
    VhdlNode::SetConstNets() ;&lt;br /&gt;
&lt;br /&gt;
    // Step (3): Need to set evaluation flow to use static elaboration:&lt;br /&gt;
    unsigned static_elab = VhdlNode::IsStaticElab() ;&lt;br /&gt;
    if (!static_elab) VhdlNode::SetStaticElab() ;&lt;br /&gt;
&lt;br /&gt;
    // Apply following known values to evaluate &amp;quot;a(b) + c&amp;quot;: &lt;br /&gt;
    //   a = (2, 3)&lt;br /&gt;
    //   b = 0&lt;br /&gt;
    //   c = 1&lt;br /&gt;
&lt;br /&gt;
    Map known_values(STRING_HASH) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;a&amp;quot;, &amp;quot;(2, 3)&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;b&amp;quot;, &amp;quot;0&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;c&amp;quot;, &amp;quot;1&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
    // Create a data-flow and set it to be in the &amp;quot;initial&amp;quot; phase&lt;br /&gt;
    // and in subprograms, so that static elab uses the values from there:&lt;br /&gt;
    VhdlDataFlow df(0) ;&lt;br /&gt;
    df.SetInInitial() ;&lt;br /&gt;
    df.SetInSubprogramOrProcess() ;&lt;br /&gt;
&lt;br /&gt;
    // The known values need to be in the condition-id-value Map to be picked up:&lt;br /&gt;
    Map *id_value_map = new Map(POINTER_HASH, known_values.Size()) ;&lt;br /&gt;
    df.SetConditionIdValueMap(id_value_map) ;&lt;br /&gt;
&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    const char *id_name ;&lt;br /&gt;
    const char *val_str ;&lt;br /&gt;
    FOREACH_MAP_ITEM(&amp;amp;known_values, mi, &amp;amp;id_name, &amp;amp;val_str) {&lt;br /&gt;
        if (!id_name || !val_str) continue ;&lt;br /&gt;
&lt;br /&gt;
        // Find the identifier:&lt;br /&gt;
        VhdlIdDef *id = arch-&amp;gt;FindDeclared(id_name) ;&lt;br /&gt;
        if (!id) RETURN(8) ;&lt;br /&gt;
&lt;br /&gt;
        // Create the expression:&lt;br /&gt;
        VhdlExpression *expr = vhdl_file::AnalyzeExpr(val_str) ;&lt;br /&gt;
        if (!expr) RETURN(9) ;&lt;br /&gt;
&lt;br /&gt;
        // Resolve the expression so that the id-refs are resolved:&lt;br /&gt;
        (void) expr-&amp;gt;TypeInfer(id-&amp;gt;Type() /* expected type */, 0 /* return types */, 0 /* environment */, arch_scope) ;&lt;br /&gt;
&lt;br /&gt;
        // Evaluate the expression:&lt;br /&gt;
        // If this is a literal expression, we do not need the value value or Resolve() call or else we need both:&lt;br /&gt;
        VhdlConstraint *constraint = id-&amp;gt;Constraint() ;&lt;br /&gt;
        VhdlValue *val = expr-&amp;gt;Evaluate(constraint, 0 /* DataFlow */, 0) ;&lt;br /&gt;
        delete expr ;&lt;br /&gt;
        if (!val) RETURN(10) ;&lt;br /&gt;
&lt;br /&gt;
        // Insert into the table to be used later:&lt;br /&gt;
        //df.SetAssignValue(id, val) ; // This only works for variables and not for signals&lt;br /&gt;
        (void) id_value_map-&amp;gt;Insert(id, val) ;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Now create the expression for to be evaluated:&lt;br /&gt;
    VhdlExpression *expr = vhdl_file::AnalyzeExpr(expr_string) ;&lt;br /&gt;
    if (!expr) RETURN(11) ;&lt;br /&gt;
&lt;br /&gt;
    // Resolve the expression (in self-context) so that the id-refs are resolved:&lt;br /&gt;
    // NOTE: May need to have the context (target) type for resolving context dependent expressions:&lt;br /&gt;
    VhdlIdDef *target_type = expr-&amp;gt;TypeInfer(0 /* expected type */, 0 /* return types */, 0 /* environment */, arch_scope) ;&lt;br /&gt;
    if (!target_type) RETURN(12) ;&lt;br /&gt;
&lt;br /&gt;
    // Evaluate the expression with the proper target type:&lt;br /&gt;
    VhdlValue *val = expr-&amp;gt;Evaluate(target_type-&amp;gt;Constraint(), &amp;amp;df /* use this table with the known values */, 0) ;&lt;br /&gt;
    delete expr ;&lt;br /&gt;
    if (!val) RETURN(13) ; // Failed to evaluate&lt;br /&gt;
&lt;br /&gt;
    // Show the result:&lt;br /&gt;
    char *image = val-&amp;gt;Image() ;&lt;br /&gt;
    verific_int64 result = val-&amp;gt;Integer() ;&lt;br /&gt;
    arch-&amp;gt;Info(&amp;quot;Evaluated value: %s (%d)&amp;quot;, ((image)?image:&amp;quot;&amp;quot;), result) ;&lt;br /&gt;
    Strings::free(image) ;&lt;br /&gt;
&lt;br /&gt;
    // Can create constant expression node so that the value can be deleted and ResetConstNets() can safely be called:&lt;br /&gt;
    expr = val-&amp;gt;CreateConstantVhdlExpression(0, target_type, 0) ;&lt;br /&gt;
    delete val ;&lt;br /&gt;
    if (!expr) RETURN(14) ;&lt;br /&gt;
&lt;br /&gt;
    // Show the expression node:&lt;br /&gt;
    image = expr-&amp;gt;GetPrettyPrintedString() ;&lt;br /&gt;
    arch-&amp;gt;Info(&amp;quot;Converted expression: %s&amp;quot;, image) ;&lt;br /&gt;
    Strings::free(image) ;&lt;br /&gt;
    delete expr ;&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;
VHDL testcase:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
library ieee ;&lt;br /&gt;
use ieee.std_logic_1164.all ;&lt;br /&gt;
entity test_entity is&lt;br /&gt;
end ;&lt;br /&gt;
&lt;br /&gt;
architecture test_arch of test_entity is&lt;br /&gt;
    type int_array is array (1 downto 0) of integer ;&lt;br /&gt;
    signal a : int_array ;&lt;br /&gt;
    signal b : integer ;&lt;br /&gt;
    signal c : integer ;&lt;br /&gt;
begin&lt;br /&gt;
end ;&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux&lt;br /&gt;
INFO: default VHDL library search path is now &amp;quot;/mnt/awing5_customers/Verific/extra_tests/vdbs&amp;quot; (VHDL-1504)&lt;br /&gt;
-- Analyzing VHDL file 'test.vhd' (VHDL-1481)&lt;br /&gt;
-- Restoring VHDL unit 'ieee.std_logic_1164' from file '/mnt/awing5_customers/Verific/extra_tests/vdbs/ieee/std_logic_1164.vdb' (VHDL-1493)&lt;br /&gt;
-- Restoring VHDL unit 'std.standard' from file '/mnt/awing5_customers/Verific/extra_tests/vdbs/std/standard.vdb' (VHDL-1493)&lt;br /&gt;
test.vhd(3): INFO: analyzing entity 'test_entity' (VHDL-1012)&lt;br /&gt;
test.vhd(6): INFO: analyzing architecture 'test_arch' (VHDL-1010)&lt;br /&gt;
test.vhd(3): INFO: processing 'test_entity(test_arch)' (VHDL-1067)&lt;br /&gt;
test.vhd(12): INFO: Evaluated value: 4 (4)&lt;br /&gt;
test.vhd(12): INFO: Converted expression: 4&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
C++ example 2:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;vhdl_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;vhdl_tokens.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlValue_Elab.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;hier_tree.h&amp;quot;&lt;br /&gt;
#include &amp;quot;HierTreeNode.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;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    vhdl_file::SetDefaultLibraryPath(&amp;quot;../vdbs&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
    const char *file_name = &amp;quot;design.vhdl&amp;quot; ;&lt;br /&gt;
    if (!vhdl_file::Analyze(file_name)) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    VhdlLibrary *work = vhdl_file::GetLibrary(&amp;quot;work&amp;quot;) ;&lt;br /&gt;
    if (!work) return 2 ;&lt;br /&gt;
&lt;br /&gt;
    Array vhdl_libs ;&lt;br /&gt;
    vhdl_libs.Insert(work) ;&lt;br /&gt;
    const Map *top_nodes = hier_tree::CreateHierarchicalTreeAll(0, &amp;amp;vhdl_libs, 0) ;&lt;br /&gt;
    if (!top_nodes) return 3 ;&lt;br /&gt;
&lt;br /&gt;
    HierTreeNode *test = (HierTreeNode *)top_nodes-&amp;gt;GetValue(&amp;quot;test&amp;quot;) ;&lt;br /&gt;
    if (!test) return 4 ;&lt;br /&gt;
&lt;br /&gt;
    HierTreeNode *u1 = test-&amp;gt;GetChild(&amp;quot;u1&amp;quot;) ;&lt;br /&gt;
    if (!u1) return 5 ;&lt;br /&gt;
&lt;br /&gt;
    Map *context = u1-&amp;gt;PushContext() ;&lt;br /&gt;
&lt;br /&gt;
    //VhdlScope *node_scope = u1-&amp;gt;GetNodeScope() ; // Entity scope&lt;br /&gt;
    VhdlScope *node_scope = u1-&amp;gt;GetVhdlArchitectureScope() ; // Architecture scope&lt;br /&gt;
    if (!node_scope) { u1-&amp;gt;PopContext(context) ; return 6 ; }&lt;br /&gt;
&lt;br /&gt;
    VhdlScope *save = VhdlNode::_present_scope ;&lt;br /&gt;
    unsigned stat_elab = VhdlNode::IsStaticElab() ;&lt;br /&gt;
&lt;br /&gt;
    VhdlNode::_present_scope = node_scope ;&lt;br /&gt;
    VhdlNode::SetConstNets() ;&lt;br /&gt;
    VhdlNode::SetStaticElab() ;&lt;br /&gt;
&lt;br /&gt;
    // If you have the expression, use that; or parse one:&lt;br /&gt;
    VhdlExpression *expr = vhdl_file::AnalyzeExpr(&amp;quot;A + B&amp;quot;) ;&lt;br /&gt;
    if (!expr) { u1-&amp;gt;PopContext(context) ; return 7 ; }&lt;br /&gt;
&lt;br /&gt;
    (void) expr-&amp;gt;TypeInfer(0, 0, VHDL_READ, node_scope) ;&lt;br /&gt;
    VhdlValue *val = expr-&amp;gt;Evaluate(0, 0, 0) ;&lt;br /&gt;
    if (!val) { delete expr ; u1-&amp;gt;PopContext(context) ; return 8 ; }&lt;br /&gt;
&lt;br /&gt;
    char *img = val-&amp;gt;Image() ;&lt;br /&gt;
    char *pp_str = expr-&amp;gt;GetPrettyPrintedString() ;&lt;br /&gt;
    expr-&amp;gt;Info(&amp;quot;Expression '%s' evaluated to '%s'&amp;quot;, pp_str, img) ;&lt;br /&gt;
    Strings::free(pp_str) ;&lt;br /&gt;
    Strings::free(img) ;&lt;br /&gt;
    delete val ;&lt;br /&gt;
    delete expr ;&lt;br /&gt;
&lt;br /&gt;
    VhdlNode::ResetConstNets() ;&lt;br /&gt;
    if (!stat_elab) VhdlNode::SetRtlElab() ;&lt;br /&gt;
    VhdlNode::_present_scope = save ;&lt;br /&gt;
&lt;br /&gt;
    u1-&amp;gt;PopContext(context) ;&lt;br /&gt;
&lt;br /&gt;
    return 0 ;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
VHDL testcase:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
library ieee;&lt;br /&gt;
use ieee.std_logic_1164.all;&lt;br /&gt;
use ieee.std_logic_arith.all;&lt;br /&gt;
&lt;br /&gt;
entity mult is&lt;br /&gt;
  generic (&lt;br /&gt;
    A: integer :=0;&lt;br /&gt;
    B: integer :=7 );&lt;br /&gt;
&lt;br /&gt;
  port (ain : in integer range (A) to (B);&lt;br /&gt;
        z   : out integer range (A) to (B));&lt;br /&gt;
end mult;&lt;br /&gt;
&lt;br /&gt;
architecture xxx of mult is&lt;br /&gt;
  begin&lt;br /&gt;
    process(ain) begin&lt;br /&gt;
      z &amp;lt;= ain ;&lt;br /&gt;
    end process;&lt;br /&gt;
end xxx;&lt;br /&gt;
&lt;br /&gt;
library ieee;&lt;br /&gt;
use ieee.std_logic_1164.all;&lt;br /&gt;
use ieee.std_logic_arith.all;&lt;br /&gt;
&lt;br /&gt;
entity test is&lt;br /&gt;
  port (ain1 : in integer range (0) to (2);&lt;br /&gt;
        cout1: out integer range (0) to (2));&lt;br /&gt;
end test;&lt;br /&gt;
&lt;br /&gt;
architecture rtl of test is&lt;br /&gt;
  component mult&lt;br /&gt;
    generic (&lt;br /&gt;
      A: integer :=0;&lt;br /&gt;
      B: integer :=2 );&lt;br /&gt;
  port (ain : in integer range (A+B) to (B);&lt;br /&gt;
        z   : out integer range (A) to (B) );&lt;br /&gt;
  end component;&lt;br /&gt;
&lt;br /&gt;
  begin&lt;br /&gt;
    u1: mult&lt;br /&gt;
      generic map(&lt;br /&gt;
        A=&amp;gt; 0,&lt;br /&gt;
        B=&amp;gt; 1 &lt;br /&gt;
      )&lt;br /&gt;
      port map(ain=&amp;gt;ain1,z=&amp;gt;cout1);&lt;br /&gt;
end rtl;&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux&lt;br /&gt;
INFO: default VHDL library search path is now &amp;quot;/mnt/awing5_customers/Verific/extra_tests/vdbs&amp;quot; (VHDL-1504)&lt;br /&gt;
-- Analyzing VHDL file 'design.vhdl' (VHDL-1481)&lt;br /&gt;
-- Restoring VHDL unit 'ieee.std_logic_1164' from file '/mnt/awing5_customers/Verific/extra_tests/vdbs/ieee/std_logic_1164.vdb' (VHDL-1493)&lt;br /&gt;
-- Restoring VHDL unit 'std.standard' from file '/mnt/awing5_customers/Verific/extra_tests/vdbs/std/standard.vdb' (VHDL-1493)&lt;br /&gt;
-- Restoring VHDL unit 'ieee.std_logic_arith' from file '/mnt/awing5_customers/Verific/extra_tests/vdbs/ieee/std_logic_arith.vdb' (VHDL-1493)&lt;br /&gt;
design.vhdl(5): INFO: analyzing entity 'mult' (VHDL-1012)&lt;br /&gt;
design.vhdl(14): INFO: analyzing architecture 'xxx' (VHDL-1010)&lt;br /&gt;
design.vhdl(25): INFO: analyzing entity 'test' (VHDL-1012)&lt;br /&gt;
design.vhdl(30): INFO: analyzing architecture 'rtl' (VHDL-1010)&lt;br /&gt;
INFO: Expression '(a + b)' evaluated to '1'&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=How_to_evaluate_a_VHDL_expression&amp;diff=944</id>
		<title>How to evaluate a VHDL expression</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=How_to_evaluate_a_VHDL_expression&amp;diff=944"/>
				<updated>2025-09-02T22:13:12Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: Created page with &amp;quot;'''&amp;gt;&amp;gt;&amp;gt; This page is under construction &amp;lt;&amp;lt;&amp;lt;'''  Unlike in Verilog, expression evaluation in VHDL is fairly involved and needs all of the following:  * Either static elaborated...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''&amp;gt;&amp;gt;&amp;gt; This page is under construction &amp;lt;&amp;lt;&amp;lt;'''&lt;br /&gt;
&lt;br /&gt;
Unlike in Verilog, expression evaluation in VHDL is fairly involved and needs all of the following:&lt;br /&gt;
&lt;br /&gt;
* Either static elaborated tree or context from correct HierTreeNode pushed into the parse tree.&lt;br /&gt;
* VhdlNode::_present_scope set to the container scope where the expression is defined or to be used.&lt;br /&gt;
* Expression evaluation method set to static elaboration with VhdlNode::SetStaticElab().&lt;br /&gt;
* Constant pwr/gnd/x/z nets set with VhdlNode::SetConstNets(). Constant nets also need to be deleted to avoid memory leaks, but should only be done after the evaluated value (that is using those nets) is deleted.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
C++ example 1:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;vhdl_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlUnits.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlIdDef.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlValue_Elab.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VhdlDataFlow_Elab.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Strings.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Map.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;
// Restore back to the previous setting:&lt;br /&gt;
#define RETURN(N) { \&lt;br /&gt;
    if (!static_elab) VhdlNode::SetRtlElab() ; \&lt;br /&gt;
    VhdlNode::_present_scope = save_scope ; \&lt;br /&gt;
    VhdlNode::ResetConstNets() ; \&lt;br /&gt;
    return N ; \&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = (argc &amp;gt; 1) ? argv[1] : &amp;quot;test.vhd&amp;quot; ;&lt;br /&gt;
    const char *entity_name = (argc &amp;gt; 2) ? argv[2] : &amp;quot;test_entity&amp;quot; ;&lt;br /&gt;
    const char *arch_name = (argc &amp;gt; 2) ? argv[2] : &amp;quot;test_arch&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    const char *expr_string = &amp;quot;a(b) + c&amp;quot; ;&lt;br /&gt;
    const char *lib_name = &amp;quot;work&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    if (!vhdl_file::SetDefaultLibraryPath(&amp;quot;../vdbs&amp;quot;)) return 1 ;&lt;br /&gt;
    if (!vhdl_file::Analyze(file_name)) return 2 ; &lt;br /&gt;
&lt;br /&gt;
    // Step (0): Need to have the parse tree static elaborated already:&lt;br /&gt;
    if (!vhdl_file::Elaborate(entity_name, lib_name, arch_name, 0 /* generics */, 1 /* static elab */)) return 3 ;&lt;br /&gt;
&lt;br /&gt;
    const VhdlLibrary *work = vhdl_file::GetLibrary(lib_name) ;&lt;br /&gt;
    if (!work) return 4 ; &lt;br /&gt;
&lt;br /&gt;
    const VhdlPrimaryUnit *ent = work-&amp;gt;GetPrimUnit(entity_name) ;&lt;br /&gt;
    if (!ent) return 5 ;&lt;br /&gt;
&lt;br /&gt;
    const VhdlSecondaryUnit *arch = ent-&amp;gt;GetSecondaryUnit(arch_name) ;&lt;br /&gt;
    if (!arch) return 6 ;&lt;br /&gt;
&lt;br /&gt;
    VhdlScope *arch_scope = arch-&amp;gt;LocalScope() ;&lt;br /&gt;
    if (!arch_scope) return 7 ;&lt;br /&gt;
&lt;br /&gt;
    // Step (1): Need to set _present_scope:&lt;br /&gt;
    VhdlScope *save_scope = VhdlNode::_present_scope ;&lt;br /&gt;
    VhdlNode::_present_scope = arch_scope ;&lt;br /&gt;
&lt;br /&gt;
    // Step (2): Need to set constant _pwr, _gnd, _x, _z nets:&lt;br /&gt;
    VhdlNode::SetConstNets() ;&lt;br /&gt;
&lt;br /&gt;
    // Step (3): Need to set evaluation flow to use static elaboration:&lt;br /&gt;
    unsigned static_elab = VhdlNode::IsStaticElab() ;&lt;br /&gt;
    if (!static_elab) VhdlNode::SetStaticElab() ;&lt;br /&gt;
&lt;br /&gt;
    // Apply following known values to evaluate &amp;quot;a(b) + c&amp;quot;: &lt;br /&gt;
    //   a = (2, 3)&lt;br /&gt;
    //   b = 0&lt;br /&gt;
    //   c = 1&lt;br /&gt;
&lt;br /&gt;
    Map known_values(STRING_HASH) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;a&amp;quot;, &amp;quot;(2, 3)&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;b&amp;quot;, &amp;quot;0&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;c&amp;quot;, &amp;quot;1&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
    // Create a data-flow and set it to be in the &amp;quot;initial&amp;quot; phase&lt;br /&gt;
    // and in subprograms, so that static elab uses the values from there:&lt;br /&gt;
    VhdlDataFlow df(0) ;&lt;br /&gt;
    df.SetInInitial() ;&lt;br /&gt;
    df.SetInSubprogramOrProcess() ;&lt;br /&gt;
&lt;br /&gt;
    // The known values need to be in the condition-id-value Map to be picked up:&lt;br /&gt;
    Map *id_value_map = new Map(POINTER_HASH, known_values.Size()) ;&lt;br /&gt;
    df.SetConditionIdValueMap(id_value_map) ;&lt;br /&gt;
&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    const char *id_name ;&lt;br /&gt;
    const char *val_str ;&lt;br /&gt;
    FOREACH_MAP_ITEM(&amp;amp;known_values, mi, &amp;amp;id_name, &amp;amp;val_str) {&lt;br /&gt;
        if (!id_name || !val_str) continue ;&lt;br /&gt;
&lt;br /&gt;
        // Find the identifier:&lt;br /&gt;
        VhdlIdDef *id = arch-&amp;gt;FindDeclared(id_name) ;&lt;br /&gt;
        if (!id) RETURN(8) ;&lt;br /&gt;
&lt;br /&gt;
        // Create the expression:&lt;br /&gt;
        VhdlExpression *expr = vhdl_file::AnalyzeExpr(val_str) ;&lt;br /&gt;
        if (!expr) RETURN(9) ;&lt;br /&gt;
&lt;br /&gt;
        // Resolve the expression so that the id-refs are resolved:&lt;br /&gt;
        (void) expr-&amp;gt;TypeInfer(id-&amp;gt;Type() /* expected type */, 0 /* return types */, 0 /* environment */, arch_scope) ;&lt;br /&gt;
&lt;br /&gt;
        // Evaluate the expression:&lt;br /&gt;
        // If this is a literal expression, we do not need the value value or Resolve() call or else we need both:&lt;br /&gt;
        VhdlConstraint *constraint = id-&amp;gt;Constraint() ;&lt;br /&gt;
        VhdlValue *val = expr-&amp;gt;Evaluate(constraint, 0 /* DataFlow */, 0) ;&lt;br /&gt;
        delete expr ;&lt;br /&gt;
        if (!val) RETURN(10) ;&lt;br /&gt;
&lt;br /&gt;
        // Insert into the table to be used later:&lt;br /&gt;
        //df.SetAssignValue(id, val) ; // This only works for variables and not for signals&lt;br /&gt;
        (void) id_value_map-&amp;gt;Insert(id, val) ;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Now create the expression for to be evaluated:&lt;br /&gt;
    VhdlExpression *expr = vhdl_file::AnalyzeExpr(expr_string) ;&lt;br /&gt;
    if (!expr) RETURN(11) ;&lt;br /&gt;
&lt;br /&gt;
    // Resolve the expression (in self-context) so that the id-refs are resolved:&lt;br /&gt;
    // NOTE: May need to have the context (target) type for resolving context dependent expressions:&lt;br /&gt;
    VhdlIdDef *target_type = expr-&amp;gt;TypeInfer(0 /* expected type */, 0 /* return types */, 0 /* environment */, arch_scope) ;&lt;br /&gt;
    if (!target_type) RETURN(12) ;&lt;br /&gt;
&lt;br /&gt;
    // Evaluate the expression with the proper target type:&lt;br /&gt;
    VhdlValue *val = expr-&amp;gt;Evaluate(target_type-&amp;gt;Constraint(), &amp;amp;df /* use this table with the known values */, 0) ;&lt;br /&gt;
    delete expr ;&lt;br /&gt;
    if (!val) RETURN(13) ; // Failed to evaluate&lt;br /&gt;
&lt;br /&gt;
    // Show the result:&lt;br /&gt;
    char *image = val-&amp;gt;Image() ;&lt;br /&gt;
    verific_int64 result = val-&amp;gt;Integer() ;&lt;br /&gt;
    arch-&amp;gt;Info(&amp;quot;Evaluated value: %s (%d)&amp;quot;, ((image)?image:&amp;quot;&amp;quot;), result) ;&lt;br /&gt;
    Strings::free(image) ;&lt;br /&gt;
&lt;br /&gt;
    // Can create constant expression node so that the value can be deleted and ResetConstNets() can safely be called:&lt;br /&gt;
    expr = val-&amp;gt;CreateConstantVhdlExpression(0, target_type, 0) ;&lt;br /&gt;
    delete val ;&lt;br /&gt;
    if (!expr) RETURN(14) ;&lt;br /&gt;
&lt;br /&gt;
    // Show the expression node:&lt;br /&gt;
    image = expr-&amp;gt;GetPrettyPrintedString() ;&lt;br /&gt;
    arch-&amp;gt;Info(&amp;quot;Converted expression: %s&amp;quot;, image) ;&lt;br /&gt;
    Strings::free(image) ;&lt;br /&gt;
    delete expr ;&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;
VHDL testcase:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
library ieee ;&lt;br /&gt;
use ieee.std_logic_1164.all ;&lt;br /&gt;
entity test_entity is&lt;br /&gt;
end ;&lt;br /&gt;
&lt;br /&gt;
architecture test_arch of test_entity is&lt;br /&gt;
    type int_array is array (1 downto 0) of integer ;&lt;br /&gt;
    signal a : int_array ;&lt;br /&gt;
    signal b : integer ;&lt;br /&gt;
    signal c : integer ;&lt;br /&gt;
begin&lt;br /&gt;
end ;&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux&lt;br /&gt;
INFO: default VHDL library search path is now &amp;quot;/mnt/awing5_customers/Verific/extra_tests/vdbs&amp;quot; (VHDL-1504)&lt;br /&gt;
-- Analyzing VHDL file 'test.vhd' (VHDL-1481)&lt;br /&gt;
-- Restoring VHDL unit 'ieee.std_logic_1164' from file '/mnt/awing5_customers/Verific/extra_tests/vdbs/ieee/std_logic_1164.vdb' (VHDL-1493)&lt;br /&gt;
-- Restoring VHDL unit 'std.standard' from file '/mnt/awing5_customers/Verific/extra_tests/vdbs/std/standard.vdb' (VHDL-1493)&lt;br /&gt;
test.vhd(3): INFO: analyzing entity 'test_entity' (VHDL-1012)&lt;br /&gt;
test.vhd(6): INFO: analyzing architecture 'test_arch' (VHDL-1010)&lt;br /&gt;
test.vhd(3): INFO: processing 'test_entity(test_arch)' (VHDL-1067)&lt;br /&gt;
test.vhd(12): INFO: Evaluated value: 4 (4)&lt;br /&gt;
test.vhd(12): INFO: Converted expression: 4&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Main_Page&amp;diff=943</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Main_Page&amp;diff=943"/>
				<updated>2025-09-02T22:00:10Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''General'''&lt;br /&gt;
* [[How to get best support from Verific | '''''How to get best support from Verific''''']]&lt;br /&gt;
* [[Source code customization &amp;amp; Stable release services | Source code customization &amp;amp; Stable release services]]&lt;br /&gt;
* [[How to save computer resources | How to save computer resources (memory consumption &amp;amp; runtime)]]&lt;br /&gt;
* [[Original RTL language | How do I know what language a Netlist in the netlist database comes from?]]&lt;br /&gt;
* [[Verific data structures | What are the data structures in Verific?]]&lt;br /&gt;
* [[Remove Verific data structures | How do I remove all Verific data structures in memory?]]&lt;br /&gt;
* [[Does Verific build CDFG? | Does Verific build control and data flow graph (CDFG)?]]&lt;br /&gt;
* [[Does Verific support XMR?| Does Verific support cross module references (XMR)?]]&lt;br /&gt;
* [[Compile-time/run-time flags | Are there options to control Verific software's behavior? Compile-time &amp;amp; run-time flags.]]&lt;br /&gt;
* [[Message handling | How do I downgrade/upgrade messages from Verific? How do I get messages with more details?]]&lt;br /&gt;
* [[Release version | How do I tell the version of a Verific software release? ]]&lt;br /&gt;
* [[Simulation models for Verific primitives | Where do I find simulation models for Verific primitives (VERIFIC_XOR, VERIFIC_DFFRS, ....)? ]]&lt;br /&gt;
* [[Tcl library path| How to correct building (linking) issue &amp;quot;/usr/bin/ld: cannot find -ltcl&amp;quot;]]&lt;br /&gt;
* [[LineFile data from input files | LineFile data from input files]]&lt;br /&gt;
* [[Difference between RTL and gate-level simulations - Flipflop with async set and async reset | Difference between RTL and gate-level simulations - Flipflop with async set and async reset]]&lt;br /&gt;
* [[Preserving user nets - preventing nets from being optimized away | Preserving user nets - preventing nets from being optimized away]]&lt;br /&gt;
* [[Python pretty-printer for gdb | Python pretty-printer for gdb]]&lt;br /&gt;
* [[Yosys-Verific Integration | Yosys-Verific integration]]&lt;br /&gt;
* [[How to enable long paths on Windows? | How to enable long paths on Windows?]]&lt;br /&gt;
&lt;br /&gt;
'''Input: VHDL, Verilog (and SystemVerilog), Liberty, EDIF'''&lt;br /&gt;
* [[How to get all Verilog files being analyzed | Verilog: I'm using -v, -y, .... After Verific is done with the analysis, how do I get a list of all the files being analyzed?]]&lt;br /&gt;
* [[Included files associated with a Verilog source file | Verilog: How do I get the list of included files associated with a Verilog source file?]]&lt;br /&gt;
* [[How to get type/initial value of parameters | Verilog: How to get type/initial value of parameters.]]&lt;br /&gt;
* [[Verilog ports being renamed | Verilog: Port Expressions]]&lt;br /&gt;
* [[Design with System Verilog and Verilog 2001 files | Verilog: For a design consisting of a mixture of Verilog 2001 and SystemVerilog input files, should I parse all the files as SystemVerilog?]]&lt;br /&gt;
* [[How to get module ports from Verilog parsetree | Verilog: From the Verilog parsetree, how can I get the ports of a module?]]&lt;br /&gt;
* [[How to change name of id in Verilog parsetree | Verilog: How do I change the name of an id (VeriidDef) in Verilog parsetree?]]&lt;br /&gt;
* [[How to get library containing nested module | Verilog: How do I get nested modules and get the library that contains the nested module?]]&lt;br /&gt;
* [[How to get linefile information of macro definitions | Verilog: How do I get linefile information of macro definitions?]]&lt;br /&gt;
* [[How to find port dimensions | Verilog: How do I get port dimensions?]]&lt;br /&gt;
* [[Instance - Module binding order | Verilog: What is the order of binding modules to instances?]]&lt;br /&gt;
* [[How Verific elaborator handles blackboxes/unknown boxes | Verilog: How Verific elaborator handles blackboxes/unknown boxes]]&lt;br /&gt;
* [[Constant expression replacement | Verilog: Does Verific replace constant expressions with their respective values?]]&lt;br /&gt;
* [[Modules with '_1' '_2' suffix in their names | Verilog: After static elaboration, there are modules with &amp;quot;_1&amp;quot;, &amp;quot;_2&amp;quot;, ..., suffix in their names. Why?]]&lt;br /&gt;
* [[Defined macros become undefined - MFCU vs SFCU | SystemVerilog: Why does Verific complain about undefined macros for macros defined in a different file (Compilation Unit)?]]&lt;br /&gt;
* [[Notes on analysis | SystemVerilog: Notes on analysis]]&lt;br /&gt;
* [[How to get enums from Verilog parsetree | SystemVerilog: From the parsetree, how can I get the enums declared in a module?]]&lt;br /&gt;
* [[How to identify packages being imported into a module | SystemVerilog: How do I identify packages being imported into a module?]]&lt;br /&gt;
* [[SystemVerilog &amp;quot;std&amp;quot; package | SystemVerilog: Support for SystemVerilog semaphore/process/mailbox constructs.]]&lt;br /&gt;
* [[Top level module with interface ports | SystemVerilog: Support for SystemVerilog top level module with interface ports.]]&lt;br /&gt;
* [[Design with VHDL-1993 and VHDL-2008 files | VHDL: VHDL-1993 and VHDL-2008 each has its own IEEE library set. How do I analyze/elaborate a design with a mixture of files of different VHDL dialects (1993 and 2008)?]]&lt;br /&gt;
* [[Escaped identifiers in RTL files and in Verific data structures | Verilog/VHDL: Escaped identifiers in RTL files and in Verific data structures]]&lt;br /&gt;
* [[Prettyprint to a string | Verilog/VHDL: How to prettyprint a parsetree node to a string.]]&lt;br /&gt;
* [[Static elaboration | Verilog/VHDL: What does 'static elaboration' do?]]&lt;br /&gt;
* [[How to ignore a (not used) parameter/generic in elaboration. | Verilog/VHDL: How to ignore a (not used) parameter/generic in elaboration.]]&lt;br /&gt;
* [[What VeriModule* or VhdlPrimaryUnit* the Netlist comes from? | Verilog/VHDL: For a Netlist in the netlist database, is there a clean way to look back at what VeriModule* or VhdlPrimaryUnit* the Netlist was derived from?]]&lt;br /&gt;
* [[Cross-reference between the original RTL files and the elaborated netlist | Verilog/VHDL: Is there a way to cross-reference between the original RTL design files and the elaboration netlist?]]&lt;br /&gt;
* [[How to ignore parameters/generics in elaboration | Verilog/VHDL: Is there a way to tell the elaborator to ignore certain parameters/generics so that the unit/module is not uniquified?]]&lt;br /&gt;
* [[How to check for errors in analysis/elaboration | Verilog/VHDL: Is there a way to tell if the analysis/elaboration process has errors?]]&lt;br /&gt;
* [[Modules/design units with &amp;quot;_default&amp;quot; suffix in their names | Verilog/VHDL: After static elaboration, there are modules/design units/interfaces with &amp;quot;_default&amp;quot; or &amp;quot;or &amp;quot;_1, _2&amp;quot; suffix in their names. What are they?]]&lt;br /&gt;
* [[How to parse a string | Verilog/VHDL: How to parse a string - Example of adding a module to the parsetree]]&lt;br /&gt;
* [[Support IEEE 1735 encryption standard | Verilog/VHDL: Does Verific support IEEE 1735 encryption standard?]]&lt;br /&gt;
'''Netlist Database'''&lt;br /&gt;
* [[Logic optimization across hierarchy boundaries | Netlist Database: Does Verific perform logic optimization across hierarchy boundaries?]]&lt;br /&gt;
* [[Bit-blasting a multi-port RAM instance | Netlist Database: Bit-blasting a multi-port RAM instance]]&lt;br /&gt;
* [[System attributes | Netlist Database: System attributes]]&lt;br /&gt;
&lt;br /&gt;
'''Output'''&lt;br /&gt;
* [[Output file formats | What language formats does Verific support as output?]]&lt;br /&gt;
&lt;br /&gt;
'''Scripting languages: TCL, Perl, Python'''&lt;br /&gt;
* [[What languages can I use with Verific software? | What programming languages can I use with Verific software?]]&lt;br /&gt;
&lt;br /&gt;
'''Code examples'''&lt;br /&gt;
* [[How to use RegisterCallBackMsg() | Util/C++: How to use RegisterCallBackMsg()]]&lt;br /&gt;
* [[How to use MessageCallBackHandler Class | Util/C++: How to use MessageCallBackHandler Class]]&lt;br /&gt;
* [[How to use RegisterPragmaRefCallBack() | Util/C++: How to use RegisterPragmaRefCallBack()]]&lt;br /&gt;
* [[Write out an encrypted netlist | Database/C++: Write out an encrypted netlist]]&lt;br /&gt;
* [[Extract clock enable | Database/C++: Extract clock enable]]&lt;br /&gt;
* [[Black box, empty box, and unknown box | Database/C++: Black box, empty box, and unknown box]]&lt;br /&gt;
* [[Post processing port resolution of black boxes | Database/C++: Post processing port resolution of black boxes]]&lt;br /&gt;
* [[Finding hierarchical paths of a Netlist | Database/C++: Finding hierarchical paths of a Netlist]]&lt;br /&gt;
* [[Replacing Verific built-in primitives/operators with user implementations | Database/C++: Replacing Verific built-in primitives/operators with user implementations]]&lt;br /&gt;
* [[Hierarchy tree RTL elaboration | Database/Perl: Simple example of hierarchy tree elaboration]]&lt;br /&gt;
* [[Create a Netlist Database from scratch (not from RTL elaboration) | Database/Perl/TCL: Create a Netlist Database from scratch (not from RTL elaboration)]]&lt;br /&gt;
* [[Buffering signals and ungrouping | Database/Verilog: Buffering signals and ungrouping (flattening) in the Netlist Database]]&lt;br /&gt;
* [[Memory elements of a RamNet | Database/Verilog/C++: Memory elements of a RamNet]]&lt;br /&gt;
* [[Process -f file and explore the Netlist Database (C++)| Database/Verilog/C++: Process -f file and explore the Netlist Database]]&lt;br /&gt;
* [[Process -f file and explore the Netlist Database (py)| Database/Verilog/Python: Process -f file and explore the Netlist Database]]&lt;br /&gt;
* [[Fanout cone and grouping | Database/Verilog/Perl: Fanout cone and grouping in the Netlist Database]]&lt;br /&gt;
* [[Type Range example | Database/Verilog/C++: Type Range example  (simple)]]&lt;br /&gt;
* [[Type Range example with multi-dimensional arrays| Database/Verilog/C++/Perl: Type Range example with multi-dimensional arrays]]&lt;br /&gt;
* [[Using TypeRange table to retrieve the originating type-range for an id | Database/Verilog/C++: Using TypeRange table to retrieve the originating type-range for an id]]&lt;br /&gt;
* [[Simple example of visitor pattern | Verilog/C++: Simple examples of visitor pattern]]&lt;br /&gt;
* [[Statically elaborate with different values of parameters | Verilog/C++: Statically elaborate with different values of parameters]]&lt;br /&gt;
* [[Prettyprint all modules in the design hierarchy | Verilog/C++: Prettyprint all modules in the design hierarchy]]&lt;br /&gt;
* [[Getting instances' parameters | Verilog/C++: Getting instances' parameters]]&lt;br /&gt;
* [[Accessing and evaluating module's parameters | Verilog/C++: Accessing and evaluating module's parameters]]&lt;br /&gt;
* [[Visiting Hierarchical References (VeriSelectedName) | Verilog/C++: Visiting Hierarchical References (VeriSelectedName)]]&lt;br /&gt;
* [[Using stream input to ignore input file | Verilog/C++: Using stream input to ignore input file]]&lt;br /&gt;
* [[How to ignore certain modules while analyzing input RTL files | Verilog/C++: How to ignore certain modules while analyzing input RTL files]]&lt;br /&gt;
* [[How to tell if a module has encrypted contents | Verilog/C++: How to tell if a module has encrypted contents]]&lt;br /&gt;
* [[Comment out a line using text based design modification and parsetree modification | Verilog/C++: Comment out a line using text-based design modification and parsetree modification]] &lt;br /&gt;
* [[Verilog/C++: How to use IsUserDeclared() : Example for port associations]]&lt;br /&gt;
* [[How to create new module in Verilog parsetree | Verilog/C++: How to create new module in Verilog parsetree]]&lt;br /&gt;
* [[In Verilog parsetree adding names to unnamed instances | Verilog/C++: In Verilog parsetree adding names to unnamed instances]]&lt;br /&gt;
* [[How to get full hierarchy ID path | Verilog/C++: How to get full hierarchy ID path]]&lt;br /&gt;
* [[How to traverse scope hierarchy | Verilog/C++: How to traverse scope hierarchy]]&lt;br /&gt;
* [[Getting design hierarchy from input RTL files | Verilog/C++/Python: Getting design hierarchy from input RTL files]]&lt;br /&gt;
* [[Access attributes in parsetree | Verilog/C++: How to access attributes in parsetree]]&lt;br /&gt;
* [[How to detect multiple-clock-edge condition in Verilog parsetree | Verilog/C++: How to detect multiple-clock-edge condition in Verilog parsetree]]&lt;br /&gt;
* [[How to get driving net of an instance | Verilog/C++: How to get driving net of an instance]]&lt;br /&gt;
* [[Parse select modules only and ignore the rest | Verilog/C++: Parse select modules only and ignore the rest]]&lt;br /&gt;
* [[Create DOT diagram of parse tree | Verilog/C++: Create DOT diagram of a parse tree]]&lt;br /&gt;
* [[How to evaluate a Verilog expression | Verilog/C++: How to evaluate a Verilog expression]]&lt;br /&gt;
* [[How to get parameters creation-time initial expression/value after Static Elaboration | Verilog/C++: How to get parameters creation-time initial expression/value after Static Elaboration]]&lt;br /&gt;
* [[How to get linefile data of macros - Macro callback function | Verilog/C++/Perl/Python: How to get linefile data of macros - Macro callback function]]&lt;br /&gt;
* [[Where in RTL does it get assigned? | Verilog/C++/Perl/Python: Where in RTL does it get assigned?]]&lt;br /&gt;
* [[Access attributes of ports in parsetree | Verilog/Perl: Access attributes of ports in parsetree and from netlist]]&lt;br /&gt;
* [[Evaluate 'for-generate' loop | Verilog/C++: Evaluate 'for-generate' loop]]&lt;br /&gt;
* [[Retrieve package name for user-defined variable types | SystemVerilog/C++/Python: Retrieve package name for user-defined variable types]]&lt;br /&gt;
* [[Pretty-print a module and the packages imported by the module | SystemVerilog/C++: Pretty-print a module and the packages imported by the module]]&lt;br /&gt;
* [[How to get packed dimensions of enum | SystemVerilog/C++: How to get packed dimensions of enum]]&lt;br /&gt;
* [[How to replace a statement that has a label | SystemVerilog/C++: How to replace a statement that has a label]]&lt;br /&gt;
* [[How to insert/add a statement, or a module item, into a sequential block and a generate block | SystemVerilog/C++: How to insert/add a statement, or a module item, into a sequential block and a generate block]]&lt;br /&gt;
* [[Simple examples of VHDL visitor pattern | VHDL/C++: Simple examples of VHDL visitor pattern]]&lt;br /&gt;
* [[Traverse instances in parsetree | VHDL/C++: Traverse instances in parsetree]]&lt;br /&gt;
* [[How to evaluate a VHDL expression | VHDL/C++: How to evaluate a VHDL expression]]&lt;br /&gt;
* [[Parsing from data in memory | Verilog/VHDL/C++: Parsing from data in memory]]&lt;br /&gt;
&lt;br /&gt;
'''INVIO Code examples'''&lt;br /&gt;
* [[Simple port modification | SystemVerilog/Python: Simple port modification]]&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Getting_design_hierarchy_from_input_RTL_files&amp;diff=942</id>
		<title>Getting design hierarchy from input RTL files</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Getting_design_hierarchy_from_input_RTL_files&amp;diff=942"/>
				<updated>2025-08-12T16:53:41Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;C++ application:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;lt;sstream&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;fstream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;quot;Array.h&amp;quot;          // Make class Array available&lt;br /&gt;
#include &amp;quot;Set.h&amp;quot;            // Make class Set available&lt;br /&gt;
#include &amp;quot;Message.h&amp;quot;        // Make message handlers available&lt;br /&gt;
#include &amp;quot;Strings.h&amp;quot;        // Definition of class to manipulate copy, concatenate, create etc...&lt;br /&gt;
#include &amp;quot;LineFile.h&amp;quot;&lt;br /&gt;
#include &amp;quot;veri_file.h&amp;quot;      // Make verilog reader available&lt;br /&gt;
#include &amp;quot;VeriModule.h&amp;quot;     // Definition of a VeriModule and VeriPrimitive&lt;br /&gt;
#include &amp;quot;VeriExpression.h&amp;quot; // Definition of VeriName&lt;br /&gt;
#include &amp;quot;VeriId.h&amp;quot;         // Definitions of all verilog identifier nodes&lt;br /&gt;
#include &amp;quot;VeriScope.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;
std::string PrintLocation(const linefile_type lf)&lt;br /&gt;
{&lt;br /&gt;
    std::ostringstream result(&amp;quot;&amp;quot;) ;&lt;br /&gt;
    if (lf) {&lt;br /&gt;
#ifdef VERIFIC_LINEFILE_INCLUDES_COLUMNS&lt;br /&gt;
    result &amp;lt;&amp;lt; lf-&amp;gt;GetFileName() ;&lt;br /&gt;
    result &amp;lt;&amp;lt; &amp;quot;[&amp;quot; ;&lt;br /&gt;
    result &amp;lt;&amp;lt; lf-&amp;gt;GetLeftLine() ;&lt;br /&gt;
    result &amp;lt;&amp;lt; &amp;quot;:&amp;quot; ;&lt;br /&gt;
    result &amp;lt;&amp;lt; lf-&amp;gt;GetLeftCol() ;&lt;br /&gt;
    result &amp;lt;&amp;lt; &amp;quot;]-[&amp;quot; ;&lt;br /&gt;
    result &amp;lt;&amp;lt; lf-&amp;gt;GetRightLine() ;&lt;br /&gt;
    result &amp;lt;&amp;lt; &amp;quot;:&amp;quot; ;&lt;br /&gt;
    result &amp;lt;&amp;lt; lf-&amp;gt;GetRightCol() ;&lt;br /&gt;
    result &amp;lt;&amp;lt; &amp;quot;]&amp;quot; ;&lt;br /&gt;
#else&lt;br /&gt;
    result &amp;lt;&amp;lt; LineFile::GetFileName(lf) ;&lt;br /&gt;
    result &amp;lt;&amp;lt; &amp;quot;[&amp;quot; ;&lt;br /&gt;
    result &amp;lt;&amp;lt; LineFile::GetLineNo(lf) ;&lt;br /&gt;
    result &amp;lt;&amp;lt; &amp;quot;]&amp;quot; ;&lt;br /&gt;
#endif&lt;br /&gt;
    }&lt;br /&gt;
    return result.str() ;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void PrintHierarchy(VeriModule *module, unsigned depth)&lt;br /&gt;
{&lt;br /&gt;
    if (!module) return ; // Ignore NULL netlists&lt;br /&gt;
&lt;br /&gt;
    char *prefix = 0 ;&lt;br /&gt;
    if (depth) {&lt;br /&gt;
        prefix = Strings::allocate(depth*4 +3) ;&lt;br /&gt;
        unsigned i ;&lt;br /&gt;
        for (i = 0; i &amp;lt; (depth *4); i++) prefix[i] = ' ' ;&lt;br /&gt;
        prefix[i] = 0 ;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Get the scope of the module:&lt;br /&gt;
    VeriScope *scope = module-&amp;gt;GetScope() ;&lt;br /&gt;
    // Find all the declared ids in this scope:&lt;br /&gt;
    Map *ids = scope ? scope-&amp;gt;DeclArea() : 0 ;&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    VeriIdDef *id ;&lt;br /&gt;
    FOREACH_MAP_ITEM(ids, mi, 0, &amp;amp;id) { // Traverse declared ids&lt;br /&gt;
        if (!id || !id-&amp;gt;IsInst()) continue ; // Consider only the instance ids&lt;br /&gt;
        VeriModuleInstantiation *mod_inst = id-&amp;gt;GetModuleInstance() ; // Take the module instance&lt;br /&gt;
        VeriModule *mod = mod_inst ? mod_inst-&amp;gt;GetInstantiatedModule() : 0 ; // The module instance is a module&lt;br /&gt;
        if (mod) { // This is module instantiation&lt;br /&gt;
            linefile_type lf = mod-&amp;gt;Linefile() ;&lt;br /&gt;
            const char *location =  PrintLocation(lf).c_str() ;&lt;br /&gt;
            char *inst_mod = Strings::save(prefix ? prefix : &amp;quot;&amp;quot;, id-&amp;gt;Name(), &amp;quot; (&amp;quot;, mod-&amp;gt;Name());&lt;br /&gt;
            Message::PrintLine(inst_mod, &amp;quot; {&amp;quot;, location, &amp;quot;})&amp;quot;) ;&lt;br /&gt;
            PrintHierarchy(mod, depth+1) ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = &amp;quot;top.v&amp;quot; ;&lt;br /&gt;
    const char *top_name = &amp;quot;top&amp;quot; ;&lt;br /&gt;
    const char *work_lib = &amp;quot;work&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    veri_file::AddVFile(&amp;quot;mbot.v&amp;quot;) ;&lt;br /&gt;
    veri_file::AddYDir(&amp;quot;.&amp;quot;) ;&lt;br /&gt;
    veri_file::AddIncludeDir(&amp;quot;.&amp;quot;) ;&lt;br /&gt;
    veri_file::AddLibExt(&amp;quot;.v&amp;quot;) ;&lt;br /&gt;
    if (!veri_file::Analyze(file_name, veri_file::VERILOG_2K /*Verilog 2000*/, work_lib)) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    if (veri_file::GetModule(top_name)) {&lt;br /&gt;
        if (!veri_file::ElaborateStatic(top_name)) return 2 ; // Component-module binding happens in static elaboration &lt;br /&gt;
        VeriModule *top_module = veri_file::GetModule(top_name) ; // Get the pointer to the top-level module&lt;br /&gt;
        if (!top_module) {&lt;br /&gt;
            return 3 ; // Exit from application if there is no top module by the given name in the given Verilog designs&lt;br /&gt;
        }&lt;br /&gt;
        linefile_type lf = top_module-&amp;gt;Linefile() ;&lt;br /&gt;
        const char *location =  PrintLocation(lf).c_str() ;&lt;br /&gt;
        Message::PrintLine(&amp;quot;Top module: &amp;quot;, top_module-&amp;gt;Name(), &amp;quot; {&amp;quot;, location, &amp;quot;}&amp;quot;) ;&lt;br /&gt;
        PrintHierarchy(top_module, 1) ;&lt;br /&gt;
    }&lt;br /&gt;
    return 0 ; // all good&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Python script:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#! /usr/bin/python&lt;br /&gt;
import sys&lt;br /&gt;
sys.path.append('../../pythonmain/install')&lt;br /&gt;
import Verific&lt;br /&gt;
&lt;br /&gt;
def PrintLocation(lf):&lt;br /&gt;
    result = '';&lt;br /&gt;
    if lf:&lt;br /&gt;
        # if 'VERIFIC_LINEFILE_INCLUDES_COLUMNS' is enabled&lt;br /&gt;
        result = result + lf.GetFileName() + '[' + Verific.Strings.itoa(lf.GetLeftLine()) + ':' \&lt;br /&gt;
                                                 + Verific.Strings.itoa(lf.GetLeftCol()) + ']-[' \&lt;br /&gt;
                                                 + Verific.Strings.itoa(lf.GetRightLine()) + ':' \&lt;br /&gt;
                                                 + Verific.Strings.itoa(lf.GetRightCol()) + ']'&lt;br /&gt;
        # if 'VERIFIC_LINEFILE_INCLUDES_COLUMNS' is disabled&lt;br /&gt;
        # result = result + Verific.LineFile.GetFileName(lf) + '[' + Verific.Strings.itoa(Verific.LineFile.GetLineNo(lf)) + ']'&lt;br /&gt;
    return result&lt;br /&gt;
&lt;br /&gt;
def PrintHierarchy(module, depth):&lt;br /&gt;
    if not module:&lt;br /&gt;
        return &lt;br /&gt;
    prefix = ''&lt;br /&gt;
    for i in range (depth):&lt;br /&gt;
        prefix = prefix + '    '&lt;br /&gt;
    scope = module.GetScope()&lt;br /&gt;
    ids = scope.DeclArea() # Map of VeriIdDefs&lt;br /&gt;
    id_iter = Verific.VeriIdDefMapIter(ids)&lt;br /&gt;
    id = id_iter.First()&lt;br /&gt;
    while (id):&lt;br /&gt;
        if (not id.IsInst()):&lt;br /&gt;
            id = id_iter.Next()&lt;br /&gt;
            continue&lt;br /&gt;
        mod_inst = id.GetModuleInstance() # Take the module instance - VeriModuleInstantiation&lt;br /&gt;
        mod = mod_inst.GetInstantiatedModule() # The module instance is a module - VeriModule&lt;br /&gt;
        if (not mod):&lt;br /&gt;
            id = id_iter.Next()&lt;br /&gt;
            continue&lt;br /&gt;
        location = PrintLocation(mod.Linefile());&lt;br /&gt;
        print ('%sInstance %s (%s {%s})' % (prefix, id.Name(), mod.Name(), location))&lt;br /&gt;
        id = id_iter.Next()&lt;br /&gt;
        PrintHierarchy(mod, depth+1);&lt;br /&gt;
&lt;br /&gt;
# main&lt;br /&gt;
reader = Verific.veri_file()&lt;br /&gt;
file_name = 'top.v'&lt;br /&gt;
top_name = 'top'&lt;br /&gt;
work_lib = 'work'&lt;br /&gt;
&lt;br /&gt;
reader.AddVFile(&amp;quot;mbot.v&amp;quot;) ;&lt;br /&gt;
reader.AddYDir(&amp;quot;.&amp;quot;) ;&lt;br /&gt;
reader.AddIncludeDir(&amp;quot;.&amp;quot;) ;&lt;br /&gt;
reader.AddLibExt(&amp;quot;.v&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
if (not reader.Analyze(file_name, reader.VERILOG_2K, work_lib)):&lt;br /&gt;
    print ('Error in Analyze')&lt;br /&gt;
    sys.exit(1)&lt;br /&gt;
&lt;br /&gt;
top_module = reader.GetModule(top_name) ;&lt;br /&gt;
if (not top_module):&lt;br /&gt;
    print ('Error in GetModule')&lt;br /&gt;
    sys.exit(2)&lt;br /&gt;
&lt;br /&gt;
# Component-module binding happens in static elaboration &lt;br /&gt;
if (not reader.ElaborateStatic(top_name)):&lt;br /&gt;
    print ('Error in ElaborateStatic')&lt;br /&gt;
    sys.exit(3)&lt;br /&gt;
&lt;br /&gt;
location = PrintLocation(top_module.Linefile());&lt;br /&gt;
print ('\nTop module: %s {%s}' % (top_module.Name(), location))&lt;br /&gt;
PrintHierarchy(top_module, 1)&lt;br /&gt;
&lt;br /&gt;
print ('\nDone')&lt;br /&gt;
&lt;br /&gt;
sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input RTL:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ cat top.v&lt;br /&gt;
// top module&lt;br /&gt;
module top(a, b, c, d, e, f, out, m, n, o) ;&lt;br /&gt;
    input a, b, c, d, e, f, m, n ;&lt;br /&gt;
    output out, o ;&lt;br /&gt;
&lt;br /&gt;
    wire tmp1, tmp2 ;&lt;br /&gt;
&lt;br /&gt;
    mid1 i1(a, b, c, d, tmp1) ;&lt;br /&gt;
    mid1 i2(a, d, e, f, tmp2) ;&lt;br /&gt;
    mid1 i3(tmp1, tmp2, e, f, out) ;&lt;br /&gt;
    bot bi(o, m, n);&lt;br /&gt;
&lt;br /&gt;
endmodule&lt;br /&gt;
$ cat mid1.v &lt;br /&gt;
module mid1 (mid1_inp1, mid1_inp2, mid1_inp3, mid1_inp4, mid1_out,&lt;br /&gt;
             mid1b_inp1, mid1b_inp2, mid1b_out) ;&lt;br /&gt;
    input mid1_inp1, mid1_inp2, mid1_inp3, mid1_inp4 ;&lt;br /&gt;
    output mid1_out ;&lt;br /&gt;
    input mid1b_inp1, mid1b_inp2 ;&lt;br /&gt;
    output mid1b_out ;&lt;br /&gt;
    &lt;br /&gt;
    wire tmp1, tmp2 ;&lt;br /&gt;
&lt;br /&gt;
    mid2 m1(mid1_inp1, mid1_inp2, tmp1) ;&lt;br /&gt;
    mid2 m2(mid1_inp3, mid1_inp4, tmp2) ;&lt;br /&gt;
    mid2 m3(tmp1, tmp2, mid1_out) ;&lt;br /&gt;
    bot b(mid1b_inp1, mid1b_inp2, mid1b_out) ;&lt;br /&gt;
&lt;br /&gt;
endmodule&lt;br /&gt;
$ cat mid2.v &lt;br /&gt;
module mid2 (mid2_inp1, mid2_inp2, mid2_out) ;&lt;br /&gt;
    input mid2_inp1, mid2_inp2 ;&lt;br /&gt;
    output mid2_out ;&lt;br /&gt;
&lt;br /&gt;
    bot b(mid2_inp1, mid2_inp2, mid2_out) ;&lt;br /&gt;
&lt;br /&gt;
endmodule&lt;br /&gt;
$ cat mbot.v &lt;br /&gt;
&lt;br /&gt;
module bot (bot_inp1, bot_inp2, bot_out) ;&lt;br /&gt;
    input bot_inp1, bot_inp2 ;&lt;br /&gt;
    output bot_out ;&lt;br /&gt;
&lt;br /&gt;
    assign bot_out = bot_inp1 &amp;amp; bot_inp2 ;&lt;br /&gt;
&lt;br /&gt;
endmodule&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'top.v' (VERI-1482)&lt;br /&gt;
-- Parsing library file mbot.v (VERI-1482)&lt;br /&gt;
-- Analyzing Verilog file 'mbot.v' (VERI-1482)&lt;br /&gt;
--       Resolving module 'bot' (VERI-1489)&lt;br /&gt;
-- Analyzing Verilog file './mid1.v' (VERI-1482)&lt;br /&gt;
--       Resolving module 'mid1' (VERI-1489)&lt;br /&gt;
-- Analyzing Verilog file './mid2.v' (VERI-1482)&lt;br /&gt;
--       Resolving module 'mid2' (VERI-1489)&lt;br /&gt;
top.v(2): INFO: compiling module 'top' (VERI-1018)&lt;br /&gt;
top.v(8): WARNING: port 'mid1b_inp1' is not connected on this instance (VERI-2435)&lt;br /&gt;
top.v(8): WARNING: port 'mid1b_out' remains unconnected for this instance (VERI-1927)&lt;br /&gt;
top.v(9): WARNING: port 'mid1b_inp1' is not connected on this instance (VERI-2435)&lt;br /&gt;
top.v(9): WARNING: port 'mid1b_out' remains unconnected for this instance (VERI-1927)&lt;br /&gt;
top.v(10): WARNING: port 'mid1b_inp1' is not connected on this instance (VERI-2435)&lt;br /&gt;
top.v(10): WARNING: port 'mid1b_out' remains unconnected for this instance (VERI-1927)&lt;br /&gt;
top.v(11): WARNING: assignment to input 'n' (VERI-1214)&lt;br /&gt;
-- Top module: top {top.v[2:1]-[13:10]}&lt;br /&gt;
--     i1 (mid1 {./mid1.v[1:1]-[15:10]})&lt;br /&gt;
--         m1 (mid2 {./mid2.v[1:1]-[7:10]})&lt;br /&gt;
--             b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--         m2 (mid2 {./mid2.v[1:1]-[7:10]})&lt;br /&gt;
--             b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--         m3 (mid2 {./mid2.v[1:1]-[7:10]})&lt;br /&gt;
--             b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--         b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--     i2 (mid1 {./mid1.v[1:1]-[15:10]})&lt;br /&gt;
--         m1 (mid2 {./mid2.v[1:1]-[7:10]})&lt;br /&gt;
--             b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--         m2 (mid2 {./mid2.v[1:1]-[7:10]})&lt;br /&gt;
--             b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--         m3 (mid2 {./mid2.v[1:1]-[7:10]})&lt;br /&gt;
--             b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--         b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--     i3 (mid1 {./mid1.v[1:1]-[15:10]})&lt;br /&gt;
--         m1 (mid2 {./mid2.v[1:1]-[7:10]})&lt;br /&gt;
--             b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--         m2 (mid2 {./mid2.v[1:1]-[7:10]})&lt;br /&gt;
--             b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--         m3 (mid2 {./mid2.v[1:1]-[7:10]})&lt;br /&gt;
--             b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--         b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--     bi (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
$&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Source_code_customization_%26_Stable_release_services&amp;diff=941</id>
		<title>Source code customization &amp; Stable release services</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Source_code_customization_%26_Stable_release_services&amp;diff=941"/>
				<updated>2025-07-22T22:11:20Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;On Verific's system, each of our licensees has a separate code branch. There are mechanisms in place to prevent cross-contamination among code branches, helping to ensure their privacy and security.  With this implementation Verific is able to offer two complimentary services to our licensees : ''Source Code Customization'' and ''Stable Release Maintenance''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''1. Source Code Customization&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
A licensee can send in custom code modifications to be merged into their branch maintained by Verific.  The customizations will be included in future source code releases so that the licensee will not need to merge them manually each time.  Please note the following :&lt;br /&gt;
&lt;br /&gt;
* The modified code should be complete and compilable on Verific's system.&lt;br /&gt;
&lt;br /&gt;
* Zip the modified code with the same password used for the monthly code releases.&lt;br /&gt;
&lt;br /&gt;
* Mention the Verific release version that the modifications are based upon.&lt;br /&gt;
&lt;br /&gt;
The licensee can include testcases that exercise the customized code. These testcases will be added to the regression testsuite of the licensee's code branch.&lt;br /&gt;
&lt;br /&gt;
The best way to initiate this process is for the licensee to file a VIPER issue with Type &amp;quot;Merge Request&amp;quot; and attach the zip file of the code modifications to the VIPER issue. This VIPER issue will be closed (not just &amp;quot;fixed&amp;quot;) when the code merge has been completed. The licensee will receive an email notice when the VIPER issue is closed.&lt;br /&gt;
&lt;br /&gt;
'''Important notes:''' Verific will maintain the code changes, but the ownership still lies with the licensee and issues arising from it, if any, need to be corrected by the licensee.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''2. Stable Release Maintenance&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
A stable release is a physically separate branch of a licensee's code on Verific's system.  It is treated as a distinct &amp;quot;customer&amp;quot; branch.  There are no connections between a Stable branch and the licensee's normal branch.  A stable branch is usually requested by a licensee when a specific monthly normal branch has been extensively tested and integrated into the licensee's tool and there is a need to maintain this branch of code for a longer period of time than the regular monthly Verific releases.  Some notes to keep in mind about the stable branch :&lt;br /&gt;
&lt;br /&gt;
*   After creation, stable branch code can only be changed to fix stable branch VIPER issues.  VIPER issues filed for a stable branch are treated as &amp;quot;customer-specific&amp;quot;.  In other words, VIPER fixes in a stable branch don't go into the normal branch and, likewise, VIPER fixes in the normal branch don't go into a stable branch.&lt;br /&gt;
&lt;br /&gt;
*   To avoid having new issues introduced into a stable branch, only defect (not enhancement) VIPERs are allowed for a stable branch.&lt;br /&gt;
&lt;br /&gt;
*   If an issue needs to be fixed in both a stable branch and in the normal branch, two separate VIPER issues will need to be filed: one for the stable branch and one for the normal branch.&lt;br /&gt;
&lt;br /&gt;
*   Stable branch code can not be merged into normal branch code.&lt;br /&gt;
&lt;br /&gt;
*   When a stable branch has served its purpose and is ready to be retired, the licensee should inform Verific about this decision as soon as possible.  We will then archive the branch and stop its maintenance, helping to free up our time and resources.&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Source_code_customization_%26_Stable_release_services&amp;diff=940</id>
		<title>Source code customization &amp; Stable release services</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Source_code_customization_%26_Stable_release_services&amp;diff=940"/>
				<updated>2025-07-22T22:09:24Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;On Verific's system, each of our licensees has a separate code branch. There are mechanisms in place to prevent cross-contamination among code branches, helping to ensure their privacy and security.  With this implementation Verific is able to offer two complimentary services to our licensees : ''Source Code Customization'' and ''Stable Release Maintenance''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''1. Source Code Customization&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
A licensee can send in custom code modifications to be merged into their branch maintained by Verific.  The customizations will be included in future source code releases so that the licensee will not need to merge them manually each time.  Please note the following :&lt;br /&gt;
&lt;br /&gt;
* The modified code should be complete and compilable on Verific's system.&lt;br /&gt;
&lt;br /&gt;
* Zip the modified code with the same password used for the monthly code releases.&lt;br /&gt;
&lt;br /&gt;
* Mention the Verific release version that the modifications are based upon.&lt;br /&gt;
&lt;br /&gt;
The licensee can include testcases that exercise the customized code. These testcases will be added to the regression testsuite of the licensee's code branch.&lt;br /&gt;
&lt;br /&gt;
The best way to initiate this process is for the licensee to file a VIPER issue with Type &amp;quot;Merge Request&amp;quot; and attach the zip file of the code modifications to the VIPER issue. This VIPER issue will be closed (not just &amp;quot;fixed&amp;quot;) when the code merge has been completed. The licensee will receive an email notice when the VIPER issue is closed.&lt;br /&gt;
&lt;br /&gt;
'''Important notes:''' Verific will maintain the code changes, but the ownership still lies with the licensee and issues arising from it, if any, need to be corrected by the licensee.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''2. Stable Release Maintenance&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
A Stable release is a physically separate branch of a licensee's code on Verific's system.  It is treated as a distinct &amp;quot;customer&amp;quot; branch.  There are no connections between a Stable branch and the licensee's normal branch.  A Stable branch is usually requested by a licensee when a specific monthly normal branch has been extensively tested and integrated into the licensee's tool and there is a need to maintain this branch of code for a longer period of time than the regular monthly Verific releases.  Some notes to keep in mind about the Stable branch :&lt;br /&gt;
&lt;br /&gt;
*   After creation, Stable branch code can only be changed to fix Stable branch VIPER issues.  VIPER issues filed for a Stable branch are treated as &amp;quot;customer-specific&amp;quot;.  In other words, VIPER fixes in a Stable branch don't go into the normal branch and, likewise, VIPER fixes in the normal branch don't go into a Stable branch.&lt;br /&gt;
&lt;br /&gt;
*   To avoid having new issues introduced into a Stable branch, only defect (not enhancement) VIPERs are allowed for a Stable branch.&lt;br /&gt;
&lt;br /&gt;
*   If an issue needs to be fixed in both a Stable branch and in the normal branch, two separate VIPER issues will need to be filed : one for the Stable branch and one for the normal branch.&lt;br /&gt;
&lt;br /&gt;
*   Stable branch code can not be merged into normal branch code.&lt;br /&gt;
&lt;br /&gt;
*   When a Stable branch has served its purpose and is ready to be retired, the licensee should inform Verific about this decision as soon as possible.  We will then archive the branch and stop its maintenance, helping to free up our time and resources.&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Getting_design_hierarchy_from_input_RTL_files&amp;diff=939</id>
		<title>Getting design hierarchy from input RTL files</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Getting_design_hierarchy_from_input_RTL_files&amp;diff=939"/>
				<updated>2025-07-14T19:12:36Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: Created page with &amp;quot;C++ application:  &amp;lt;nowiki&amp;gt; #include &amp;lt;sstream&amp;gt; #include &amp;lt;iostream&amp;gt; #include &amp;lt;fstream&amp;gt; #include &amp;lt;string&amp;gt; #include &amp;quot;Array.h&amp;quot;          // Make class Array available #include &amp;quot;Set....&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;C++ application:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;lt;sstream&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;fstream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;quot;Array.h&amp;quot;          // Make class Array available&lt;br /&gt;
#include &amp;quot;Set.h&amp;quot;            // Make class Set available&lt;br /&gt;
#include &amp;quot;Message.h&amp;quot;        // Make message handlers available&lt;br /&gt;
#include &amp;quot;Strings.h&amp;quot;        // Definition of class to manipulate copy, concatenate, create etc...&lt;br /&gt;
#include &amp;quot;LineFile.h&amp;quot;&lt;br /&gt;
#include &amp;quot;veri_file.h&amp;quot;      // Make verilog reader available&lt;br /&gt;
#include &amp;quot;VeriModule.h&amp;quot;     // Definition of a VeriModule and VeriPrimitive&lt;br /&gt;
#include &amp;quot;VeriExpression.h&amp;quot; // Definition of VeriName&lt;br /&gt;
#include &amp;quot;VeriId.h&amp;quot;         // Definitions of all verilog identifier nodes&lt;br /&gt;
#include &amp;quot;VeriScope.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;
std::string PrintLocation(const linefile_type lf)&lt;br /&gt;
{&lt;br /&gt;
    std::ostringstream result(&amp;quot;&amp;quot;) ;&lt;br /&gt;
    if (lf) {&lt;br /&gt;
#ifdef VERIFIC_LINEFILE_INCLUDES_COLUMNS&lt;br /&gt;
    result &amp;lt;&amp;lt; lf-&amp;gt;GetFileName() ;&lt;br /&gt;
    result &amp;lt;&amp;lt; &amp;quot;[&amp;quot; ;&lt;br /&gt;
    result &amp;lt;&amp;lt; lf-&amp;gt;GetLeftLine() ;&lt;br /&gt;
    result &amp;lt;&amp;lt; &amp;quot;:&amp;quot; ;&lt;br /&gt;
    result &amp;lt;&amp;lt; lf-&amp;gt;GetLeftCol() ;&lt;br /&gt;
    result &amp;lt;&amp;lt; &amp;quot;]-[&amp;quot; ;&lt;br /&gt;
    result &amp;lt;&amp;lt; lf-&amp;gt;GetRightLine() ;&lt;br /&gt;
    result &amp;lt;&amp;lt; &amp;quot;:&amp;quot; ;&lt;br /&gt;
    result &amp;lt;&amp;lt; lf-&amp;gt;GetRightCol() ;&lt;br /&gt;
    result &amp;lt;&amp;lt; &amp;quot;]&amp;quot; ;&lt;br /&gt;
#else&lt;br /&gt;
    result &amp;lt;&amp;lt; LineFile::GetFileName(lf) ;&lt;br /&gt;
    result &amp;lt;&amp;lt; &amp;quot;[&amp;quot; ;&lt;br /&gt;
    result &amp;lt;&amp;lt; LineFile::GetLineNo(lf) ;&lt;br /&gt;
    result &amp;lt;&amp;lt; &amp;quot;]&amp;quot; ;&lt;br /&gt;
#endif&lt;br /&gt;
    }&lt;br /&gt;
    return result.str() ;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void PrintHierarchy(VeriModule *module, unsigned depth)&lt;br /&gt;
{&lt;br /&gt;
    if (!module) return ; // Ignore NULL netlists&lt;br /&gt;
&lt;br /&gt;
    char *prefix = 0 ;&lt;br /&gt;
    if (depth) {&lt;br /&gt;
        prefix = Strings::allocate(depth*4 +3) ;&lt;br /&gt;
        unsigned i ;&lt;br /&gt;
        for (i = 0; i &amp;lt; (depth *4); i++) prefix[i] = ' ' ;&lt;br /&gt;
        prefix[i] = 0 ;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Get the scope of the module:&lt;br /&gt;
    VeriScope *scope = module-&amp;gt;GetScope() ;&lt;br /&gt;
    // Find all the declared ids in this scope:&lt;br /&gt;
    Map *ids = scope ? scope-&amp;gt;DeclArea() : 0 ;&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    VeriIdDef *id ;&lt;br /&gt;
    FOREACH_MAP_ITEM(ids, mi, 0, &amp;amp;id) { // Traverse declared ids&lt;br /&gt;
        if (!id || !id-&amp;gt;IsInst()) continue ; // Consider only the instance ids&lt;br /&gt;
        VeriModuleInstantiation *mod_inst = id-&amp;gt;GetModuleInstance() ; // Take the module instance&lt;br /&gt;
        VeriModule *mod = mod_inst ? mod_inst-&amp;gt;GetInstantiatedModule() : 0 ; // The module instance is a module&lt;br /&gt;
        if (mod) { // This is module instantiation&lt;br /&gt;
            linefile_type lf = mod-&amp;gt;Linefile() ;&lt;br /&gt;
            const char *location =  PrintLocation(lf).c_str() ;&lt;br /&gt;
            char *inst_mod = Strings::save(prefix ? prefix : &amp;quot;&amp;quot;, id-&amp;gt;Name(), &amp;quot; (&amp;quot;, mod-&amp;gt;Name());&lt;br /&gt;
            Message::PrintLine(inst_mod, &amp;quot; {&amp;quot;, location, &amp;quot;})&amp;quot;) ;&lt;br /&gt;
            PrintHierarchy(mod, depth+1) ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = &amp;quot;top.v&amp;quot; ;&lt;br /&gt;
    const char *top_name = &amp;quot;top&amp;quot; ;&lt;br /&gt;
    const char *work_lib = &amp;quot;work&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    veri_file::AddVFile(&amp;quot;mbot.v&amp;quot;) ;&lt;br /&gt;
    veri_file::AddYDir(&amp;quot;.&amp;quot;) ;&lt;br /&gt;
    veri_file::AddIncludeDir(&amp;quot;.&amp;quot;) ;&lt;br /&gt;
    veri_file::AddLibExt(&amp;quot;.v&amp;quot;) ;&lt;br /&gt;
    if (!veri_file::Analyze(file_name, veri_file::VERILOG_2K /*Verilog 2000*/, work_lib)) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    if (veri_file::GetModule(top_name)) {&lt;br /&gt;
        // Optional - statically elaborate all the top Verilog module. Return if any error shows up.&lt;br /&gt;
        if (!veri_file::ElaborateStatic(top_name)) return 2 ; // statically elaborates all verilog modules in the &amp;quot;work&amp;quot; libarary&lt;br /&gt;
&lt;br /&gt;
        VeriModule *top_module = veri_file::GetModule(top_name) ; // Get the pointer to the top-level module&lt;br /&gt;
        if (!top_module) {&lt;br /&gt;
            return 3 ; // Exit from application if there is no top module by the given name in the given Verilog designs&lt;br /&gt;
        }&lt;br /&gt;
        linefile_type lf = top_module-&amp;gt;Linefile() ;&lt;br /&gt;
        const char *location =  PrintLocation(lf).c_str() ;&lt;br /&gt;
        Message::PrintLine(&amp;quot;Top module: &amp;quot;, top_module-&amp;gt;Name(), &amp;quot; {&amp;quot;, location, &amp;quot;}&amp;quot;) ;&lt;br /&gt;
        PrintHierarchy(top_module, 1) ;&lt;br /&gt;
    }&lt;br /&gt;
    return 0 ; // all good&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Python script:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#! /usr/bin/python&lt;br /&gt;
import sys&lt;br /&gt;
sys.path.append('../../pythonmain/install')&lt;br /&gt;
import Verific&lt;br /&gt;
&lt;br /&gt;
def PrintLocation(lf):&lt;br /&gt;
    result = '';&lt;br /&gt;
    if lf:&lt;br /&gt;
        # if 'VERIFIC_LINEFILE_INCLUDES_COLUMNS' is enabled&lt;br /&gt;
        result = result + lf.GetFileName() + '[' + Verific.Strings.itoa(lf.GetLeftLine()) + ':' \&lt;br /&gt;
                                                 + Verific.Strings.itoa(lf.GetLeftCol()) + ']-[' \&lt;br /&gt;
                                                 + Verific.Strings.itoa(lf.GetRightLine()) + ':' \&lt;br /&gt;
                                                 + Verific.Strings.itoa(lf.GetRightCol()) + ']'&lt;br /&gt;
        # if 'VERIFIC_LINEFILE_INCLUDES_COLUMNS' is disabled&lt;br /&gt;
        # result = result + Verific.LineFile.GetFileName(lf) + '[' + Verific.Strings.itoa(Verific.LineFile.GetLineNo(lf)) + ']'&lt;br /&gt;
    return result&lt;br /&gt;
&lt;br /&gt;
def PrintHierarchy(module, depth):&lt;br /&gt;
    if not module:&lt;br /&gt;
        return &lt;br /&gt;
    prefix = ''&lt;br /&gt;
    for i in range (depth):&lt;br /&gt;
        prefix = prefix + '    '&lt;br /&gt;
    scope = module.GetScope()&lt;br /&gt;
    ids = scope.DeclArea() # Map of VeriIdDefs&lt;br /&gt;
    id_iter = Verific.VeriIdDefMapIter(ids)&lt;br /&gt;
    id = id_iter.First()&lt;br /&gt;
    while (id):&lt;br /&gt;
        if (not id.IsInst()):&lt;br /&gt;
            id = id_iter.Next()&lt;br /&gt;
            continue&lt;br /&gt;
        mod_inst = id.GetModuleInstance() # Take the module instance - VeriModuleInstantiation&lt;br /&gt;
        mod = mod_inst.GetInstantiatedModule() # The module instance is a module - VeriModule&lt;br /&gt;
        if (not mod):&lt;br /&gt;
            id = id_iter.Next()&lt;br /&gt;
            continue&lt;br /&gt;
        location = PrintLocation(mod.Linefile());&lt;br /&gt;
        print ('%sInstance %s (%s {%s})' % (prefix, id.Name(), mod.Name(), location))&lt;br /&gt;
        id = id_iter.Next()&lt;br /&gt;
        PrintHierarchy(mod, depth+1);&lt;br /&gt;
&lt;br /&gt;
# main&lt;br /&gt;
reader = Verific.veri_file()&lt;br /&gt;
file_name = 'top.v'&lt;br /&gt;
top_name = 'top'&lt;br /&gt;
work_lib = 'work'&lt;br /&gt;
&lt;br /&gt;
reader.AddVFile(&amp;quot;mbot.v&amp;quot;) ;&lt;br /&gt;
reader.AddYDir(&amp;quot;.&amp;quot;) ;&lt;br /&gt;
reader.AddIncludeDir(&amp;quot;.&amp;quot;) ;&lt;br /&gt;
reader.AddLibExt(&amp;quot;.v&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
if (not reader.Analyze(file_name, reader.VERILOG_2K, work_lib)):&lt;br /&gt;
    print ('Error in Analyze')&lt;br /&gt;
    sys.exit(1)&lt;br /&gt;
&lt;br /&gt;
top_module = reader.GetModule(top_name) ;&lt;br /&gt;
if (not top_module):&lt;br /&gt;
    print ('Error in GetModule')&lt;br /&gt;
    sys.exit(2)&lt;br /&gt;
&lt;br /&gt;
# Static elaboration is optional&lt;br /&gt;
if (not reader.ElaborateStatic(top_name)):&lt;br /&gt;
    print ('Error in ElaborateStatic')&lt;br /&gt;
    sys.exit(3)&lt;br /&gt;
&lt;br /&gt;
location = PrintLocation(top_module.Linefile());&lt;br /&gt;
print ('\nTop module: %s {%s}' % (top_module.Name(), location))&lt;br /&gt;
PrintHierarchy(top_module, 1)&lt;br /&gt;
&lt;br /&gt;
print ('\nDone')&lt;br /&gt;
&lt;br /&gt;
sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input RTL:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ cat top.v&lt;br /&gt;
// top module&lt;br /&gt;
module top(a, b, c, d, e, f, out, m, n, o) ;&lt;br /&gt;
    input a, b, c, d, e, f, m, n ;&lt;br /&gt;
    output out, o ;&lt;br /&gt;
&lt;br /&gt;
    wire tmp1, tmp2 ;&lt;br /&gt;
&lt;br /&gt;
    mid1 i1(a, b, c, d, tmp1) ;&lt;br /&gt;
    mid1 i2(a, d, e, f, tmp2) ;&lt;br /&gt;
    mid1 i3(tmp1, tmp2, e, f, out) ;&lt;br /&gt;
    bot bi(o, m, n);&lt;br /&gt;
&lt;br /&gt;
endmodule&lt;br /&gt;
$ cat mid1.v &lt;br /&gt;
module mid1 (mid1_inp1, mid1_inp2, mid1_inp3, mid1_inp4, mid1_out,&lt;br /&gt;
             mid1b_inp1, mid1b_inp2, mid1b_out) ;&lt;br /&gt;
    input mid1_inp1, mid1_inp2, mid1_inp3, mid1_inp4 ;&lt;br /&gt;
    output mid1_out ;&lt;br /&gt;
    input mid1b_inp1, mid1b_inp2 ;&lt;br /&gt;
    output mid1b_out ;&lt;br /&gt;
    &lt;br /&gt;
    wire tmp1, tmp2 ;&lt;br /&gt;
&lt;br /&gt;
    mid2 m1(mid1_inp1, mid1_inp2, tmp1) ;&lt;br /&gt;
    mid2 m2(mid1_inp3, mid1_inp4, tmp2) ;&lt;br /&gt;
    mid2 m3(tmp1, tmp2, mid1_out) ;&lt;br /&gt;
    bot b(mid1b_inp1, mid1b_inp2, mid1b_out) ;&lt;br /&gt;
&lt;br /&gt;
endmodule&lt;br /&gt;
$ cat mid2.v &lt;br /&gt;
module mid2 (mid2_inp1, mid2_inp2, mid2_out) ;&lt;br /&gt;
    input mid2_inp1, mid2_inp2 ;&lt;br /&gt;
    output mid2_out ;&lt;br /&gt;
&lt;br /&gt;
    bot b(mid2_inp1, mid2_inp2, mid2_out) ;&lt;br /&gt;
&lt;br /&gt;
endmodule&lt;br /&gt;
$ cat mbot.v &lt;br /&gt;
&lt;br /&gt;
module bot (bot_inp1, bot_inp2, bot_out) ;&lt;br /&gt;
    input bot_inp1, bot_inp2 ;&lt;br /&gt;
    output bot_out ;&lt;br /&gt;
&lt;br /&gt;
    assign bot_out = bot_inp1 &amp;amp; bot_inp2 ;&lt;br /&gt;
&lt;br /&gt;
endmodule&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
  &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'top.v' (VERI-1482)&lt;br /&gt;
-- Parsing library file mbot.v (VERI-1482)&lt;br /&gt;
-- Analyzing Verilog file 'mbot.v' (VERI-1482)&lt;br /&gt;
--       Resolving module 'bot' (VERI-1489)&lt;br /&gt;
-- Analyzing Verilog file './mid1.v' (VERI-1482)&lt;br /&gt;
--       Resolving module 'mid1' (VERI-1489)&lt;br /&gt;
-- Analyzing Verilog file './mid2.v' (VERI-1482)&lt;br /&gt;
--       Resolving module 'mid2' (VERI-1489)&lt;br /&gt;
top.v(2): INFO: compiling module 'top' (VERI-1018)&lt;br /&gt;
top.v(8): WARNING: port 'mid1b_inp1' is not connected on this instance (VERI-2435)&lt;br /&gt;
top.v(8): WARNING: port 'mid1b_out' remains unconnected for this instance (VERI-1927)&lt;br /&gt;
top.v(9): WARNING: port 'mid1b_inp1' is not connected on this instance (VERI-2435)&lt;br /&gt;
top.v(9): WARNING: port 'mid1b_out' remains unconnected for this instance (VERI-1927)&lt;br /&gt;
top.v(10): WARNING: port 'mid1b_inp1' is not connected on this instance (VERI-2435)&lt;br /&gt;
top.v(10): WARNING: port 'mid1b_out' remains unconnected for this instance (VERI-1927)&lt;br /&gt;
top.v(11): WARNING: assignment to input 'n' (VERI-1214)&lt;br /&gt;
-- Top module: top {top.v[2:1]-[13:10]}&lt;br /&gt;
--     i1 (mid1 {./mid1.v[1:1]-[15:10]})&lt;br /&gt;
--         m1 (mid2 {./mid2.v[1:1]-[7:10]})&lt;br /&gt;
--             b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--         m2 (mid2 {./mid2.v[1:1]-[7:10]})&lt;br /&gt;
--             b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--         m3 (mid2 {./mid2.v[1:1]-[7:10]})&lt;br /&gt;
--             b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--         b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--     i2 (mid1 {./mid1.v[1:1]-[15:10]})&lt;br /&gt;
--         m1 (mid2 {./mid2.v[1:1]-[7:10]})&lt;br /&gt;
--             b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--         m2 (mid2 {./mid2.v[1:1]-[7:10]})&lt;br /&gt;
--             b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--         m3 (mid2 {./mid2.v[1:1]-[7:10]})&lt;br /&gt;
--             b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--         b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--     i3 (mid1 {./mid1.v[1:1]-[15:10]})&lt;br /&gt;
--         m1 (mid2 {./mid2.v[1:1]-[7:10]})&lt;br /&gt;
--             b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--         m2 (mid2 {./mid2.v[1:1]-[7:10]})&lt;br /&gt;
--             b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--         m3 (mid2 {./mid2.v[1:1]-[7:10]})&lt;br /&gt;
--             b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--         b (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
--     bi (bot {mbot.v[2:1]-[8:10]})&lt;br /&gt;
$&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Main_Page&amp;diff=938</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Main_Page&amp;diff=938"/>
				<updated>2025-07-14T18:52:55Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''General'''&lt;br /&gt;
* [[How to get best support from Verific | '''''How to get best support from Verific''''']]&lt;br /&gt;
* [[Source code customization &amp;amp; Stable release services | Source code customization &amp;amp; Stable release services]]&lt;br /&gt;
* [[How to save computer resources | How to save computer resources (memory consumption &amp;amp; runtime)]]&lt;br /&gt;
* [[Original RTL language | How do I know what language a Netlist in the netlist database comes from?]]&lt;br /&gt;
* [[Verific data structures | What are the data structures in Verific?]]&lt;br /&gt;
* [[Remove Verific data structures | How do I remove all Verific data structures in memory?]]&lt;br /&gt;
* [[Does Verific build CDFG? | Does Verific build control and data flow graph (CDFG)?]]&lt;br /&gt;
* [[Does Verific support XMR?| Does Verific support cross module references (XMR)?]]&lt;br /&gt;
* [[Compile-time/run-time flags | Are there options to control Verific software's behavior? Compile-time &amp;amp; run-time flags.]]&lt;br /&gt;
* [[Message handling | How do I downgrade/upgrade messages from Verific? How do I get messages with more details?]]&lt;br /&gt;
* [[Release version | How do I tell the version of a Verific software release? ]]&lt;br /&gt;
* [[Simulation models for Verific primitives | Where do I find simulation models for Verific primitives (VERIFIC_XOR, VERIFIC_DFFRS, ....)? ]]&lt;br /&gt;
* [[Tcl library path| How to correct building (linking) issue &amp;quot;/usr/bin/ld: cannot find -ltcl&amp;quot;]]&lt;br /&gt;
* [[LineFile data from input files | LineFile data from input files]]&lt;br /&gt;
* [[Difference between RTL and gate-level simulations - Flipflop with async set and async reset | Difference between RTL and gate-level simulations - Flipflop with async set and async reset]]&lt;br /&gt;
* [[Preserving user nets - preventing nets from being optimized away | Preserving user nets - preventing nets from being optimized away]]&lt;br /&gt;
* [[Python pretty-printer for gdb | Python pretty-printer for gdb]]&lt;br /&gt;
* [[Yosys-Verific Integration | Yosys-Verific integration]]&lt;br /&gt;
* [[How to enable long paths on Windows? | How to enable long paths on Windows?]]&lt;br /&gt;
&lt;br /&gt;
'''Input: VHDL, Verilog (and SystemVerilog), Liberty, EDIF'''&lt;br /&gt;
* [[How to get all Verilog files being analyzed | Verilog: I'm using -v, -y, .... After Verific is done with the analysis, how do I get a list of all the files being analyzed?]]&lt;br /&gt;
* [[Included files associated with a Verilog source file | Verilog: How do I get the list of included files associated with a Verilog source file?]]&lt;br /&gt;
* [[How to get type/initial value of parameters | Verilog: How to get type/initial value of parameters.]]&lt;br /&gt;
* [[Verilog ports being renamed | Verilog: Port Expressions]]&lt;br /&gt;
* [[Design with System Verilog and Verilog 2001 files | Verilog: For a design consisting of a mixture of Verilog 2001 and SystemVerilog input files, should I parse all the files as SystemVerilog?]]&lt;br /&gt;
* [[How to get module ports from Verilog parsetree | Verilog: From the Verilog parsetree, how can I get the ports of a module?]]&lt;br /&gt;
* [[How to change name of id in Verilog parsetree | Verilog: How do I change the name of an id (VeriidDef) in Verilog parsetree?]]&lt;br /&gt;
* [[How to get library containing nested module | Verilog: How do I get nested modules and get the library that contains the nested module?]]&lt;br /&gt;
* [[How to get linefile information of macro definitions | Verilog: How do I get linefile information of macro definitions?]]&lt;br /&gt;
* [[How to find port dimensions | Verilog: How do I get port dimensions?]]&lt;br /&gt;
* [[Instance - Module binding order | Verilog: What is the order of binding modules to instances?]]&lt;br /&gt;
* [[How Verific elaborator handles blackboxes/unknown boxes | Verilog: How Verific elaborator handles blackboxes/unknown boxes]]&lt;br /&gt;
* [[Constant expression replacement | Verilog: Does Verific replace constant expressions with their respective values?]]&lt;br /&gt;
* [[Modules with '_1' '_2' suffix in their names | Verilog: After static elaboration, there are modules with &amp;quot;_1&amp;quot;, &amp;quot;_2&amp;quot;, ..., suffix in their names. Why?]]&lt;br /&gt;
* [[Defined macros become undefined - MFCU vs SFCU | SystemVerilog: Why does Verific complain about undefined macros for macros defined in a different file (Compilation Unit)?]]&lt;br /&gt;
* [[Notes on analysis | SystemVerilog: Notes on analysis]]&lt;br /&gt;
* [[How to get enums from Verilog parsetree | SystemVerilog: From the parsetree, how can I get the enums declared in a module?]]&lt;br /&gt;
* [[How to identify packages being imported into a module | SystemVerilog: How do I identify packages being imported into a module?]]&lt;br /&gt;
* [[SystemVerilog &amp;quot;std&amp;quot; package | SystemVerilog: Support for SystemVerilog semaphore/process/mailbox constructs.]]&lt;br /&gt;
* [[Top level module with interface ports | SystemVerilog: Support for SystemVerilog top level module with interface ports.]]&lt;br /&gt;
* [[Design with VHDL-1993 and VHDL-2008 files | VHDL: VHDL-1993 and VHDL-2008 each has its own IEEE library set. How do I analyze/elaborate a design with a mixture of files of different VHDL dialects (1993 and 2008)?]]&lt;br /&gt;
* [[Escaped identifiers in RTL files and in Verific data structures | Verilog/VHDL: Escaped identifiers in RTL files and in Verific data structures]]&lt;br /&gt;
* [[Prettyprint to a string | Verilog/VHDL: How to prettyprint a parsetree node to a string.]]&lt;br /&gt;
* [[Static elaboration | Verilog/VHDL: What does 'static elaboration' do?]]&lt;br /&gt;
* [[How to ignore a (not used) parameter/generic in elaboration. | Verilog/VHDL: How to ignore a (not used) parameter/generic in elaboration.]]&lt;br /&gt;
* [[What VeriModule* or VhdlPrimaryUnit* the Netlist comes from? | Verilog/VHDL: For a Netlist in the netlist database, is there a clean way to look back at what VeriModule* or VhdlPrimaryUnit* the Netlist was derived from?]]&lt;br /&gt;
* [[Cross-reference between the original RTL files and the elaborated netlist | Verilog/VHDL: Is there a way to cross-reference between the original RTL design files and the elaboration netlist?]]&lt;br /&gt;
* [[How to ignore parameters/generics in elaboration | Verilog/VHDL: Is there a way to tell the elaborator to ignore certain parameters/generics so that the unit/module is not uniquified?]]&lt;br /&gt;
* [[How to check for errors in analysis/elaboration | Verilog/VHDL: Is there a way to tell if the analysis/elaboration process has errors?]]&lt;br /&gt;
* [[Modules/design units with &amp;quot;_default&amp;quot; suffix in their names | Verilog/VHDL: After static elaboration, there are modules/design units/interfaces with &amp;quot;_default&amp;quot; or &amp;quot;or &amp;quot;_1, _2&amp;quot; suffix in their names. What are they?]]&lt;br /&gt;
* [[How to parse a string | Verilog/VHDL: How to parse a string - Example of adding a module to the parsetree]]&lt;br /&gt;
* [[Support IEEE 1735 encryption standard | Verilog/VHDL: Does Verific support IEEE 1735 encryption standard?]]&lt;br /&gt;
'''Netlist Database'''&lt;br /&gt;
* [[Logic optimization across hierarchy boundaries | Netlist Database: Does Verific perform logic optimization across hierarchy boundaries?]]&lt;br /&gt;
* [[Bit-blasting a multi-port RAM instance | Netlist Database: Bit-blasting a multi-port RAM instance]]&lt;br /&gt;
* [[System attributes | Netlist Database: System attributes]]&lt;br /&gt;
&lt;br /&gt;
'''Output'''&lt;br /&gt;
* [[Output file formats | What language formats does Verific support as output?]]&lt;br /&gt;
&lt;br /&gt;
'''Scripting languages: TCL, Perl, Python'''&lt;br /&gt;
* [[What languages can I use with Verific software? | What programming languages can I use with Verific software?]]&lt;br /&gt;
&lt;br /&gt;
'''Code examples'''&lt;br /&gt;
* [[How to use RegisterCallBackMsg() | Util/C++: How to use RegisterCallBackMsg()]]&lt;br /&gt;
* [[How to use MessageCallBackHandler Class | Util/C++: How to use MessageCallBackHandler Class]]&lt;br /&gt;
* [[How to use RegisterPragmaRefCallBack() | Util/C++: How to use RegisterPragmaRefCallBack()]]&lt;br /&gt;
* [[Write out an encrypted netlist | Database/C++: Write out an encrypted netlist]]&lt;br /&gt;
* [[Extract clock enable | Database/C++: Extract clock enable]]&lt;br /&gt;
* [[Black box, empty box, and unknown box | Database/C++: Black box, empty box, and unknown box]]&lt;br /&gt;
* [[Post processing port resolution of black boxes | Database/C++: Post processing port resolution of black boxes]]&lt;br /&gt;
* [[Finding hierarchical paths of a Netlist | Database/C++: Finding hierarchical paths of a Netlist]]&lt;br /&gt;
* [[Replacing Verific built-in primitives/operators with user implementations | Database/C++: Replacing Verific built-in primitives/operators with user implementations]]&lt;br /&gt;
* [[Hierarchy tree RTL elaboration | Database/Perl: Simple example of hierarchy tree elaboration]]&lt;br /&gt;
* [[Create a Netlist Database from scratch (not from RTL elaboration) | Database/Perl/TCL: Create a Netlist Database from scratch (not from RTL elaboration)]]&lt;br /&gt;
* [[Buffering signals and ungrouping | Database/Verilog: Buffering signals and ungrouping (flattening) in the Netlist Database]]&lt;br /&gt;
* [[Memory elements of a RamNet | Database/Verilog/C++: Memory elements of a RamNet]]&lt;br /&gt;
* [[Process -f file and explore the Netlist Database (C++)| Database/Verilog/C++: Process -f file and explore the Netlist Database]]&lt;br /&gt;
* [[Process -f file and explore the Netlist Database (py)| Database/Verilog/Python: Process -f file and explore the Netlist Database]]&lt;br /&gt;
* [[Fanout cone and grouping | Database/Verilog/Perl: Fanout cone and grouping in the Netlist Database]]&lt;br /&gt;
* [[Type Range example | Database/Verilog/C++: Type Range example  (simple)]]&lt;br /&gt;
* [[Type Range example with multi-dimensional arrays| Database/Verilog/C++/Perl: Type Range example with multi-dimensional arrays]]&lt;br /&gt;
* [[Using TypeRange table to retrieve the originating type-range for an id | Database/Verilog/C++: Using TypeRange table to retrieve the originating type-range for an id]]&lt;br /&gt;
* [[Simple example of visitor pattern | Verilog/C++: Simple examples of visitor pattern]]&lt;br /&gt;
* [[Statically elaborate with different values of parameters | Verilog/C++: Statically elaborate with different values of parameters]]&lt;br /&gt;
* [[Prettyprint all modules in the design hierarchy | Verilog/C++: Prettyprint all modules in the design hierarchy]]&lt;br /&gt;
* [[Getting instances' parameters | Verilog/C++: Getting instances' parameters]]&lt;br /&gt;
* [[Accessing and evaluating module's parameters | Verilog/C++: Accessing and evaluating module's parameters]]&lt;br /&gt;
* [[Visiting Hierarchical References (VeriSelectedName) | Verilog/C++: Visiting Hierarchical References (VeriSelectedName)]]&lt;br /&gt;
* [[Using stream input to ignore input file | Verilog/C++: Using stream input to ignore input file]]&lt;br /&gt;
* [[How to ignore certain modules while analyzing input RTL files | Verilog/C++: How to ignore certain modules while analyzing input RTL files]]&lt;br /&gt;
* [[How to tell if a module has encrypted contents | Verilog/C++: How to tell if a module has encrypted contents]]&lt;br /&gt;
* [[Comment out a line using text based design modification and parsetree modification | Verilog/C++: Comment out a line using text-based design modification and parsetree modification]] &lt;br /&gt;
* [[Verilog/C++: How to use IsUserDeclared() : Example for port associations]]&lt;br /&gt;
* [[How to create new module in Verilog parsetree | Verilog/C++: How to create new module in Verilog parsetree]]&lt;br /&gt;
* [[In Verilog parsetree adding names to unnamed instances | Verilog/C++: In Verilog parsetree adding names to unnamed instances]]&lt;br /&gt;
* [[How to get full hierarchy ID path | Verilog/C++: How to get full hierarchy ID path]]&lt;br /&gt;
* [[How to traverse scope hierarchy | Verilog/C++: How to traverse scope hierarchy]]&lt;br /&gt;
* [[Getting design hierarchy from input RTL files | Verilog/C++/Python: Getting design hierarchy from input RTL files]]&lt;br /&gt;
* [[Access attributes in parsetree | Verilog/C++: How to access attributes in parsetree]]&lt;br /&gt;
* [[How to detect multiple-clock-edge condition in Verilog parsetree | Verilog/C++: How to detect multiple-clock-edge condition in Verilog parsetree]]&lt;br /&gt;
* [[How to get driving net of an instance | Verilog/C++: How to get driving net of an instance]]&lt;br /&gt;
* [[Parse select modules only and ignore the rest | Verilog/C++: Parse select modules only and ignore the rest]]&lt;br /&gt;
* [[Create DOT diagram of parse tree | Verilog/C++: Create DOT diagram of a parse tree]]&lt;br /&gt;
* [[How to evaluate a Verilog expression | Verilog/C++: How to evaluate a Verilog expression]]&lt;br /&gt;
* [[How to get parameters creation-time initial expression/value after Static Elaboration | Verilog/C++: How to get parameters creation-time initial expression/value after Static Elaboration]]&lt;br /&gt;
* [[How to get linefile data of macros - Macro callback function | Verilog/C++/Perl/Python: How to get linefile data of macros - Macro callback function]]&lt;br /&gt;
* [[Where in RTL does it get assigned? | Verilog/C++/Perl/Python: Where in RTL does it get assigned?]]&lt;br /&gt;
* [[Access attributes of ports in parsetree | Verilog/Perl: Access attributes of ports in parsetree and from netlist]]&lt;br /&gt;
* [[Evaluate 'for-generate' loop | Verilog/C++: Evaluate 'for-generate' loop]]&lt;br /&gt;
* [[Retrieve package name for user-defined variable types | SystemVerilog/C++/Python: Retrieve package name for user-defined variable types]]&lt;br /&gt;
* [[Pretty-print a module and the packages imported by the module | SystemVerilog/C++: Pretty-print a module and the packages imported by the module]]&lt;br /&gt;
* [[How to get packed dimensions of enum | SystemVerilog/C++: How to get packed dimensions of enum]]&lt;br /&gt;
* [[How to replace a statement that has a label | SystemVerilog/C++: How to replace a statement that has a label]]&lt;br /&gt;
* [[How to insert/add a statement, or a module item, into a sequential block and a generate block | SystemVerilog/C++: How to insert/add a statement, or a module item, into a sequential block and a generate block]]&lt;br /&gt;
* [[Simple examples of VHDL visitor pattern | VHDL/C++: Simple examples of VHDL visitor pattern]]&lt;br /&gt;
* [[Traverse instances in parsetree | VHDL/C++: Traverse instances in parsetree]]&lt;br /&gt;
* [[Parsing from data in memory | Verilog/VHDL/C++: Parsing from data in memory]]&lt;br /&gt;
&lt;br /&gt;
'''INVIO Code examples'''&lt;br /&gt;
* [[Simple port modification | SystemVerilog/Python: Simple port modification]]&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Pretty-print_a_module_and_the_packages_imported_by_the_module&amp;diff=937</id>
		<title>Pretty-print a module and the packages imported by the module</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Pretty-print_a_module_and_the_packages_imported_by_the_module&amp;diff=937"/>
				<updated>2025-07-01T00:21:43Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&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;
#include &amp;lt;fstream&amp;gt;&lt;br /&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;VeriId.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriScope.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Map.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
using namespace std ;&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 print_packages_used (VeriModule *module, std::ofstream &amp;amp;out_stream)&lt;br /&gt;
{&lt;br /&gt;
    if (!module) return ;&lt;br /&gt;
    VeriScope *scope = module-&amp;gt;GetScope() ;&lt;br /&gt;
    Set *using_scopes = (scope) ? scope-&amp;gt;GetUsing() : 0 ; &lt;br /&gt;
    SetIter si ;&lt;br /&gt;
    VeriScope *using_scope ;&lt;br /&gt;
    FOREACH_SET_ITEM(using_scopes, si, &amp;amp;using_scope) {&lt;br /&gt;
        VeriIdDef *mod_id2 = using_scope-&amp;gt;GetContainingModule() ;&lt;br /&gt;
        VeriModule *mod2 = (mod_id2) ? mod_id2-&amp;gt;GetModule() : 0 ; &lt;br /&gt;
        print_packages_used (mod2, out_stream) ;    &lt;br /&gt;
        if (mod2-&amp;gt;IsPackage()) {&lt;br /&gt;
            std::cout &amp;lt;&amp;lt; &amp;quot;&amp;gt;&amp;gt;&amp;gt; Module '&amp;quot; &amp;lt;&amp;lt; module-&amp;gt;Name() &amp;lt;&amp;lt; &amp;quot;' uses package '&amp;quot; &amp;lt;&amp;lt; mod2-&amp;gt;Name() &amp;lt;&amp;lt; &amp;quot;' &amp;lt;&amp;lt;&amp;lt;\n&amp;quot;;&lt;br /&gt;
        }   &lt;br /&gt;
        out_stream &amp;lt;&amp;lt; &amp;quot;// Printing package &amp;quot; &amp;lt;&amp;lt; mod2-&amp;gt;Name() &amp;lt;&amp;lt; endl ;&lt;br /&gt;
        mod2-&amp;gt;PrettyPrint(out_stream, 0) ;&lt;br /&gt;
    }   &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    Array files(1) ;&lt;br /&gt;
    // files.InsertLast(&amp;quot;my_pack.sv&amp;quot;) ;&lt;br /&gt;
    files.InsertLast(&amp;quot;test.sv&amp;quot;) ;&lt;br /&gt;
    if (!veri_file::AnalyzeMultipleFiles(&amp;amp;files, veri_file::SYSTEM_VERILOG, &amp;quot;work&amp;quot;, veri_file::MFCU)) return 1 ; &lt;br /&gt;
&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    VeriModule *module ;&lt;br /&gt;
    FOREACH_VERILOG_MODULE(mi, module){&lt;br /&gt;
        if (!module) continue ;&lt;br /&gt;
&lt;br /&gt;
        if (module-&amp;gt;IsPackage()) continue ; // no need to dive into package&lt;br /&gt;
        // if (module-&amp;gt;IsRootModule()) continue ;&lt;br /&gt;
&lt;br /&gt;
        char *outputfilename = Strings::save(module-&amp;gt;Name(), &amp;quot;_pp_out.v&amp;quot;);&lt;br /&gt;
        std::ofstream f(outputfilename, std::ios::out) ;&lt;br /&gt;
        print_packages_used (module, f) ;&lt;br /&gt;
&lt;br /&gt;
        // Now  print the module:&lt;br /&gt;
        f &amp;lt;&amp;lt; &amp;quot;// Printing module &amp;quot; &amp;lt;&amp;lt; module-&amp;gt;Name() &amp;lt;&amp;lt; endl ;&lt;br /&gt;
        module-&amp;gt;PrettyPrint(f, 0) ;&lt;br /&gt;
        f.close() ;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    return 0 ;&lt;br /&gt;
}&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;
package PKG1 ;&lt;br /&gt;
    typedef int my_int ;&lt;br /&gt;
endpackage&lt;br /&gt;
&lt;br /&gt;
typedef byte my_byte ;&lt;br /&gt;
&lt;br /&gt;
module test ;&lt;br /&gt;
    import PKG1::* ;&lt;br /&gt;
    my_int int1 ;&lt;br /&gt;
    my_byte byte1 ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Console output:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
-- Analyzing Verilog file 'top.v' (VERI-1482)&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; Module 'top' uses package 'PKG1' &amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; Module 'top' uses package '$unit_top_v' &amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pretty-printed output:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
// Printing package PKG1&lt;br /&gt;
&lt;br /&gt;
package PKG1 ;&lt;br /&gt;
    typedef int my_int ;&lt;br /&gt;
endpackage&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Printing package $unit_test_sv&lt;br /&gt;
&lt;br /&gt;
typedef byte my_byte ;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// Printing module test&lt;br /&gt;
&lt;br /&gt;
module test ;&lt;br /&gt;
    import PKG1:: * ;&lt;br /&gt;
    my_int int1 ;&lt;br /&gt;
    my_byte byte1 ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Notes_on_analysis&amp;diff=936</id>
		<title>Notes on analysis</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Notes_on_analysis&amp;diff=936"/>
				<updated>2025-04-23T17:53:46Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;First, please read this article: [[Defined macros become undefined - MFCU vs SFCU]].&lt;br /&gt;
&lt;br /&gt;
'''Q: Can I use 'veri_file::Analyze()' to read SystemVerilog input files one by one, all of them belonging to one compilation unit?'''&lt;br /&gt;
 &lt;br /&gt;
Yes. But if you have multiple files, it’s better to use 'veri_file::AnalyzeMultipleFiles()'.&lt;br /&gt;
 &lt;br /&gt;
'veri_file::AnalyzeMultipleFiles()', besides analyzing each file, also:&lt;br /&gt;
 &lt;br /&gt;
* opens and ends the compilation unit&lt;br /&gt;
* processes –v and –y options&lt;br /&gt;
* removes include directories&lt;br /&gt;
* processes root module&lt;br /&gt;
* undefines user-defined macros, including command-line macros&lt;br /&gt;
* resets compile directives (e.g. `default_nettype, `timescale)&lt;br /&gt;
 &lt;br /&gt;
If you use 'veri_file::Analyze()' to analyze each file one by one, after all the calls to 'veri_file::Analyze(), depending on the application, you may want to run veri_file::RemoveAllIncludeDirs() and veri_file::EndCompilationUnit().&lt;br /&gt;
&lt;br /&gt;
The TCL command 'analyze' uses the API 'veri_file::AnalyzeMultipleFiles()'. In other words, it assumes a complete compilation unit for each execution.&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=LineFile_data_from_input_files&amp;diff=935</id>
		<title>LineFile data from input files</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=LineFile_data_from_input_files&amp;diff=935"/>
				<updated>2025-03-06T17:11:36Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Verific uses the 'LineFile' manager to preserve line/file origination information from HDL source files. This info is annotated on all objects in parse trees and netlist databases, as well as used in the message handler, so that from any object that Verific creates from an RTL design, information is available as to where it came from in the user's original RTL design.&lt;br /&gt;
&lt;br /&gt;
We have the following compile flags (see util/LineFile.h and util/VerificSystem.h) :&lt;br /&gt;
&lt;br /&gt;
# VERIFIC_LINEFILE_INCLUDES_COLUMNS&lt;br /&gt;
#: We define a class ColLineFile to have both the starting and ending locations including column info.&lt;br /&gt;
#: Valid values of NUM_LINE_BITS, NUM_COL_BITS and NUM_FILE_BITS are 1 to 31 bits.&lt;br /&gt;
#: Use as per your requirements. Making (NUM_LINE_BITS + NUM_COL_BITS) &amp;lt;= 32 will consume less memory.&lt;br /&gt;
#: You can use 31 as NUM_FILE_BITS without any extra memory overhead.&lt;br /&gt;
#: This flag needs to be enabled for applications using Text-Based Design Modification.&lt;br /&gt;
# VERIFIC_LARGE_LINEFILE&lt;br /&gt;
#: We still define the class ColLineFile, but it has only a single starting or ending location and does not include column info.&lt;br /&gt;
#: Valid values of NUM_LINE_BITS and NUM_FILE_BITS are 1 to 31 bits.&lt;br /&gt;
#: Use as per your requirements. Making (NUM_LINE_BITS + NUM_FILE_BITS) &amp;lt;= 32 will consume less memory.&lt;br /&gt;
# VERIFIC_LARGE_LINEFILE_FOR_64 (only for 64-bit Windows since long is 4 bytes there)&lt;br /&gt;
#: Same as (2) above but without the class and only for 64-bit Windows systems.&lt;br /&gt;
# VERILOG_STORE_ENDING_LINEFILE_INFO&lt;br /&gt;
#: If this compile flag is ON and  VERIFIC_LINEFILE_INCLUDES_COLUMNS is OFF, VeriModuleItem::StartingLinefile() API and VeriModuleItem::EndingLinefile() API will return the correct linefile as per their names. These two functions work for all derived classes of VeriModuleItem (VeriModule, VeriStatement, ....).&lt;br /&gt;
#: Note that the compile flag VERILOG_USE_STARTING_LINEFILE_INFO works independently from VERILOG_STORE_ENDING_LINEFILE_INFO.  It returns linefile of starting or ending location of a construct via Linefile() API.&lt;br /&gt;
&lt;br /&gt;
The compile flags (1), (2), and (3) above are mutually exclusive. You should have only one of them defined according to your requirements.&lt;br /&gt;
&lt;br /&gt;
If you do not define any of the above compile flags, Verific uses the following by default:&lt;br /&gt;
&lt;br /&gt;
* On a 64-bit (non-Windows) system, line number and file-id are encoded into a 64-bit unsigned long. You need to set (NUM_LINE_BITS + NUM_FILE_BITS) &amp;lt;= 64&lt;br /&gt;
&lt;br /&gt;
* On a 32-bit (and 64-bit Windows) system, line number and file-id are encoded into a 32-bit unsigned long. You need to set (NUM_LINE_BITS + NUM_FILE_BITS) &amp;lt;= 32&lt;br /&gt;
&lt;br /&gt;
If you do not need column numbers or both starting and ending locations, you can turn off column info.&lt;br /&gt;
&lt;br /&gt;
If the number of files overflows NUM_FILE_BITS, we issue &amp;quot;WARNING: number of file names exceeded maximum of %d&amp;quot; when there are too many files. However, producing the same warning for lines/columns would result in too many messages.&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=934</id>
		<title>How to evaluate a Verilog expression</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=934"/>
				<updated>2025-02-21T17:06:23Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This applicatione example shows how to evaluate a Verilog expression. It requires Verific 'Static Elaboration' feature.&lt;br /&gt;
&lt;br /&gt;
Note that a, b, and c are declared in the Verilog module. The application evaluates an expression of these variables.&lt;br /&gt;
&lt;br /&gt;
C++:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;veri_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriModule.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriBaseValue_Stat.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Strings.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Array.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Map.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;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = (argc &amp;gt; 1) ? argv[1] : &amp;quot;test.v&amp;quot; ;&lt;br /&gt;
    const char *module_name = (argc &amp;gt; 2) ? argv[2] : &amp;quot;test_module&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    Array files(1) ;&lt;br /&gt;
    files.Insert(file_name) ;&lt;br /&gt;
    if (!veri_file::AnalyzeMultipleFiles(&amp;amp;files, veri_file::SYSTEM_VERILOG)) return 1 ; &lt;br /&gt;
&lt;br /&gt;
    const VeriModule *mod = veri_file::GetModule(module_name) ;&lt;br /&gt;
    if (!mod) return 2 ; &lt;br /&gt;
&lt;br /&gt;
    // Apply following known values to evaluate &amp;quot;a[b] + c&amp;quot;: &lt;br /&gt;
    //   a = {1'b1, 1'b1}&lt;br /&gt;
    //   b = 2'b00&lt;br /&gt;
    //   c = 2'b01  &lt;br /&gt;
&lt;br /&gt;
    const char *expr_string = &amp;quot;a[b] + c&amp;quot; ;&lt;br /&gt;
    Map known_values(STRING_HASH) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;a&amp;quot;, &amp;quot;{1'b1, 1'b1}&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;b&amp;quot;, &amp;quot;2'b00&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;c&amp;quot;, &amp;quot;2'b01&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
    ValueTable df ;&lt;br /&gt;
&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    const char *id_name ;&lt;br /&gt;
    const char *val_str ;&lt;br /&gt;
    FOREACH_MAP_ITEM(&amp;amp;known_values, mi, &amp;amp;id_name, &amp;amp;val_str) {&lt;br /&gt;
        if (!id_name || !val_str) continue ;&lt;br /&gt;
&lt;br /&gt;
        // Find the identifier:&lt;br /&gt;
        VeriIdDef *id = mod-&amp;gt;FindDeclared(id_name) ;&lt;br /&gt;
        if (!id) return 3 ; &lt;br /&gt;
&lt;br /&gt;
        // Create the expression:&lt;br /&gt;
        VeriExpression *expr = veri_file::AnalyzeExpr(val_str, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
        if (!expr) return 4 ;&lt;br /&gt;
&lt;br /&gt;
        // Evaluate the expression:&lt;br /&gt;
        // If this is a literal expression, we do not need the value value or Resolve() call or else we need both:&lt;br /&gt;
        VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, 0 /* value table */) ;&lt;br /&gt;
        delete expr ;&lt;br /&gt;
        if (!val) return 5 ; &lt;br /&gt;
&lt;br /&gt;
        // Insert into the table to be used later:&lt;br /&gt;
        if (!df.Insert(id, val)) {&lt;br /&gt;
            delete val ;&lt;br /&gt;
            return 6 ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Now create the expression for to be evaluated:&lt;br /&gt;
    VeriExpression *expr = veri_file::AnalyzeExpr(expr_string, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
    if (!expr) return 7 ;&lt;br /&gt;
&lt;br /&gt;
    // Resolve the expression so that the id-refs are resolved:&lt;br /&gt;
    expr-&amp;gt;Resolve(mod-&amp;gt;GetScope(), VeriTreeNode::VERI_UNDEF_ENV) ;&lt;br /&gt;
&lt;br /&gt;
    VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, &amp;amp;df /* use this table with the known values */) ;&lt;br /&gt;
    delete expr ;&lt;br /&gt;
    if (!val) return 8 ; // Failed to evaluate&lt;br /&gt;
&lt;br /&gt;
    char *image = val-&amp;gt;Image() ;&lt;br /&gt;
    int result = val-&amp;gt;GetIntegerValue() ;&lt;br /&gt;
    mod-&amp;gt;Info(&amp;quot;Evaluated value: %s (%d)&amp;quot;, ((image)?image:&amp;quot;&amp;quot;), result) ;&lt;br /&gt;
    Strings::free(image) ;&lt;br /&gt;
    delete val ;&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;
Verilog testcase:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module test_module;&lt;br /&gt;
    wire a [1:0];&lt;br /&gt;
    wire [1:0] b;&lt;br /&gt;
    wire [1:0] c;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'test.v' (VERI-1482)&lt;br /&gt;
test.v(5): INFO: Evaluated value: 2'b10 (2)&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=933</id>
		<title>How to evaluate a Verilog expression</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=How_to_evaluate_a_Verilog_expression&amp;diff=933"/>
				<updated>2025-02-20T17:20:55Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: Created page with &amp;quot;This applicatione example shows how to evaluate a Verilog expression. Note that it requires 'Static Elaboration' feature.  C++:  &amp;lt;nowiki&amp;gt; #include &amp;quot;veri_file.h&amp;quot; #include &amp;quot;Veri...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This applicatione example shows how to evaluate a Verilog expression. Note that it requires 'Static Elaboration' feature.&lt;br /&gt;
&lt;br /&gt;
C++:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;veri_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriModule.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriBaseValue_Stat.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Strings.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Array.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Map.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;
int main(int argc, const char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = (argc &amp;gt; 1) ? argv[1] : &amp;quot;test.v&amp;quot; ;&lt;br /&gt;
    const char *module_name = (argc &amp;gt; 2) ? argv[2] : &amp;quot;test_module&amp;quot; ;&lt;br /&gt;
&lt;br /&gt;
    Array files(1) ;&lt;br /&gt;
    files.Insert(file_name) ;&lt;br /&gt;
    if (!veri_file::AnalyzeMultipleFiles(&amp;amp;files, veri_file::SYSTEM_VERILOG)) return 1 ; &lt;br /&gt;
&lt;br /&gt;
    const VeriModule *mod = veri_file::GetModule(module_name) ;&lt;br /&gt;
    if (!mod) return 2 ; &lt;br /&gt;
&lt;br /&gt;
    // Apply following known values to evaluate &amp;quot;a[b] + c&amp;quot;: &lt;br /&gt;
    //   a = {1'b1, 1'b1}&lt;br /&gt;
    //   b = 2'b00&lt;br /&gt;
    //   c = 2'b01  &lt;br /&gt;
&lt;br /&gt;
    const char *expr_string = &amp;quot;a[b] + c&amp;quot; ;&lt;br /&gt;
    Map known_values(STRING_HASH) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;a&amp;quot;, &amp;quot;{1'b1, 1'b1}&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;b&amp;quot;, &amp;quot;2'b00&amp;quot;) ;&lt;br /&gt;
    (void) known_values.Insert(&amp;quot;c&amp;quot;, &amp;quot;2'b01&amp;quot;) ;&lt;br /&gt;
&lt;br /&gt;
    ValueTable df ;&lt;br /&gt;
&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    const char *id_name ;&lt;br /&gt;
    const char *val_str ;&lt;br /&gt;
    FOREACH_MAP_ITEM(&amp;amp;known_values, mi, &amp;amp;id_name, &amp;amp;val_str) {&lt;br /&gt;
        if (!id_name || !val_str) continue ;&lt;br /&gt;
&lt;br /&gt;
        // Find the identifier:&lt;br /&gt;
        VeriIdDef *id = mod-&amp;gt;FindDeclared(id_name) ;&lt;br /&gt;
        if (!id) return 3 ; &lt;br /&gt;
&lt;br /&gt;
        // Create the expression:&lt;br /&gt;
        VeriExpression *expr = veri_file::AnalyzeExpr(val_str, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
        if (!expr) return 4 ;&lt;br /&gt;
&lt;br /&gt;
        // Evaluate the expression:&lt;br /&gt;
        // If this is a literal expression, we do not need the value value or Resolve() call or else we need both:&lt;br /&gt;
        VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, 0 /* value table */) ;&lt;br /&gt;
        delete expr ;&lt;br /&gt;
        if (!val) return 5 ; &lt;br /&gt;
&lt;br /&gt;
        // Insert into the table to be used later:&lt;br /&gt;
        if (!df.Insert(id, val)) {&lt;br /&gt;
            delete val ;&lt;br /&gt;
            return 6 ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Now create the expression for to be evaluated:&lt;br /&gt;
    VeriExpression *expr = veri_file::AnalyzeExpr(expr_string, veri_file::SYSTEM_VERILOG) ;&lt;br /&gt;
    if (!expr) return 7 ;&lt;br /&gt;
&lt;br /&gt;
    // Resolve the expression so that the id-refs are resolved:&lt;br /&gt;
    expr-&amp;gt;Resolve(mod-&amp;gt;GetScope(), VeriTreeNode::VERI_UNDEF_ENV) ;&lt;br /&gt;
&lt;br /&gt;
    VeriBaseValue *val = expr-&amp;gt;StaticEvaluate(0 /* self context */, &amp;amp;df /* use this table with the known values */) ;&lt;br /&gt;
    delete expr ;&lt;br /&gt;
    if (!val) return 8 ; // Failed to evaluate&lt;br /&gt;
&lt;br /&gt;
    char *image = val-&amp;gt;Image() ;&lt;br /&gt;
    int result = val-&amp;gt;GetIntegerValue() ;&lt;br /&gt;
    mod-&amp;gt;Info(&amp;quot;Evaluated value: %s (%d)&amp;quot;, ((image)?image:&amp;quot;&amp;quot;), result) ;&lt;br /&gt;
    Strings::free(image) ;&lt;br /&gt;
    delete val ;&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;
&lt;br /&gt;
Run:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'test.v' (VERI-1482)&lt;br /&gt;
test.v(5): INFO: Evaluated value: 2'b10 (2)&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Main_Page&amp;diff=932</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Main_Page&amp;diff=932"/>
				<updated>2025-02-20T17:15:46Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''General'''&lt;br /&gt;
* [[How to get best support from Verific | '''''How to get best support from Verific''''']]&lt;br /&gt;
* [[Source code customization &amp;amp; Stable release services | Source code customization &amp;amp; Stable release services]]&lt;br /&gt;
* [[How to save computer resources | How to save computer resources (memory consumption &amp;amp; runtime)]]&lt;br /&gt;
* [[Original RTL language | How do I know what language a Netlist in the netlist database comes from?]]&lt;br /&gt;
* [[Verific data structures | What are the data structures in Verific?]]&lt;br /&gt;
* [[Remove Verific data structures | How do I remove all Verific data structures in memory?]]&lt;br /&gt;
* [[Does Verific build CDFG? | Does Verific build control and data flow graph (CDFG)?]]&lt;br /&gt;
* [[Does Verific support XMR?| Does Verific support cross module references (XMR)?]]&lt;br /&gt;
* [[Compile-time/run-time flags | Are there options to control Verific software's behavior? Compile-time &amp;amp; run-time flags.]]&lt;br /&gt;
* [[Message handling | How do I downgrade/upgrade messages from Verific? How do I get messages with more details?]]&lt;br /&gt;
* [[Release version | How do I tell the version of a Verific software release? ]]&lt;br /&gt;
* [[Simulation models for Verific primitives | Where do I find simulation models for Verific primitives (VERIFIC_XOR, VERIFIC_DFFRS, ....)? ]]&lt;br /&gt;
* [[Tcl library path| How to correct building (linking) issue &amp;quot;/usr/bin/ld: cannot find -ltcl&amp;quot;]]&lt;br /&gt;
* [[LineFile data from input files | LineFile data from input files]]&lt;br /&gt;
* [[Difference between RTL and gate-level simulations - Flipflop with async set and async reset | Difference between RTL and gate-level simulations - Flipflop with async set and async reset]]&lt;br /&gt;
* [[Preserving user nets - preventing nets from being optimized away | Preserving user nets - preventing nets from being optimized away]]&lt;br /&gt;
* [[Python pretty-printer for gdb | Python pretty-printer for gdb]]&lt;br /&gt;
* [[Yosys-Verific Integration | Yosys-Verific integration]]&lt;br /&gt;
* [[How to enable long paths on Windows? | How to enable long paths on Windows?]]&lt;br /&gt;
&lt;br /&gt;
'''Input: VHDL, Verilog (and SystemVerilog), Liberty, EDIF'''&lt;br /&gt;
* [[How to get all Verilog files being analyzed | Verilog: I'm using -v, -y, .... After Verific is done with the analysis, how do I get a list of all the files being analyzed?]]&lt;br /&gt;
* [[Included files associated with a Verilog source file | Verilog: How do I get the list of included files associated with a Verilog source file?]]&lt;br /&gt;
* [[How to get type/initial value of parameters | Verilog: How to get type/initial value of parameters.]]&lt;br /&gt;
* [[Verilog ports being renamed | Verilog: Port Expressions]]&lt;br /&gt;
* [[Design with System Verilog and Verilog 2001 files | Verilog: For a design consisting of a mixture of Verilog 2001 and SystemVerilog input files, should I parse all the files as SystemVerilog?]]&lt;br /&gt;
* [[How to get module ports from Verilog parsetree | Verilog: From the Verilog parsetree, how can I get the ports of a module?]]&lt;br /&gt;
* [[How to change name of id in Verilog parsetree | Verilog: How do I change the name of an id (VeriidDef) in Verilog parsetree?]]&lt;br /&gt;
* [[How to get library containing nested module | Verilog: How do I get nested modules and get the library that contains the nested module?]]&lt;br /&gt;
* [[How to get linefile information of macro definitions | Verilog: How do I get linefile information of macro definitions?]]&lt;br /&gt;
* [[How to find port dimensions | Verilog: How do I get port dimensions?]]&lt;br /&gt;
* [[Instance - Module binding order | Verilog: What is the order of binding modules to instances?]]&lt;br /&gt;
* [[How Verific elaborator handles blackboxes/unknown boxes | Verilog: How Verific elaborator handles blackboxes/unknown boxes]]&lt;br /&gt;
* [[Constant expression replacement | Verilog: Does Verific replace constant expressions with their respective values?]]&lt;br /&gt;
* [[Modules with '_1' '_2' suffix in their names | Verilog: After static elaboration, there are modules with &amp;quot;_1&amp;quot;, &amp;quot;_2&amp;quot;, ..., suffix in their names. Why?]]&lt;br /&gt;
* [[Defined macros become undefined - MFCU vs SFCU | SystemVerilog: Why does Verific complain about undefined macros for macros defined in a different file (Compilation Unit)?]]&lt;br /&gt;
* [[Notes on analysis | SystemVerilog: Notes on analysis]]&lt;br /&gt;
* [[How to get enums from Verilog parsetree | SystemVerilog: From the parsetree, how can I get the enums declared in a module?]]&lt;br /&gt;
* [[How to identify packages being imported into a module | SystemVerilog: How do I identify packages being imported into a module?]]&lt;br /&gt;
* [[SystemVerilog &amp;quot;std&amp;quot; package | SystemVerilog: Support for SystemVerilog semaphore/process/mailbox constructs.]]&lt;br /&gt;
* [[Top level module with interface ports | SystemVerilog: Support for SystemVerilog top level module with interface ports.]]&lt;br /&gt;
* [[Design with VHDL-1993 and VHDL-2008 files | VHDL: VHDL-1993 and VHDL-2008 each has its own IEEE library set. How do I analyze/elaborate a design with a mixture of files of different VHDL dialects (1993 and 2008)?]]&lt;br /&gt;
* [[Escaped identifiers in RTL files and in Verific data structures | Verilog/VHDL: Escaped identifiers in RTL files and in Verific data structures]]&lt;br /&gt;
* [[Prettyprint to a string | Verilog/VHDL: How to prettyprint a parsetree node to a string.]]&lt;br /&gt;
* [[Static elaboration | Verilog/VHDL: What does 'static elaboration' do?]]&lt;br /&gt;
* [[How to ignore a (not used) parameter/generic in elaboration. | Verilog/VHDL: How to ignore a (not used) parameter/generic in elaboration.]]&lt;br /&gt;
* [[What VeriModule* or VhdlPrimaryUnit* the Netlist comes from? | Verilog/VHDL: For a Netlist in the netlist database, is there a clean way to look back at what VeriModule* or VhdlPrimaryUnit* the Netlist was derived from?]]&lt;br /&gt;
* [[Cross-reference between the original RTL files and the elaborated netlist | Verilog/VHDL: Is there a way to cross-reference between the original RTL design files and the elaboration netlist?]]&lt;br /&gt;
* [[How to ignore parameters/generics in elaboration | Verilog/VHDL: Is there a way to tell the elaborator to ignore certain parameters/generics so that the unit/module is not uniquified?]]&lt;br /&gt;
* [[How to check for errors in analysis/elaboration | Verilog/VHDL: Is there a way to tell if the analysis/elaboration process has errors?]]&lt;br /&gt;
* [[Modules/design units with &amp;quot;_default&amp;quot; suffix in their names | Verilog/VHDL: After static elaboration, there are modules/design units/interfaces with &amp;quot;_default&amp;quot; or &amp;quot;or &amp;quot;_1, _2&amp;quot; suffix in their names. What are they?]]&lt;br /&gt;
* [[How to parse a string | Verilog/VHDL: How to parse a string - Example of adding a module to the parsetree]]&lt;br /&gt;
* [[Support IEEE 1735 encryption standard | Verilog/VHDL: Does Verific support IEEE 1735 encryption standard?]]&lt;br /&gt;
'''Netlist Database'''&lt;br /&gt;
* [[Logic optimization across hierarchy boundaries | Netlist Database: Does Verific perform logic optimization across hierarchy boundaries?]]&lt;br /&gt;
* [[Bit-blasting a multi-port RAM instance | Netlist Database: Bit-blasting a multi-port RAM instance]]&lt;br /&gt;
* [[System attributes | Netlist Database: System attributes]]&lt;br /&gt;
&lt;br /&gt;
'''Output'''&lt;br /&gt;
* [[Output file formats | What language formats does Verific support as output?]]&lt;br /&gt;
&lt;br /&gt;
'''Scripting languages: TCL, Perl, Python'''&lt;br /&gt;
* [[What languages can I use with Verific software? | What programming languages can I use with Verific software?]]&lt;br /&gt;
&lt;br /&gt;
'''Code examples'''&lt;br /&gt;
* [[How to use RegisterCallBackMsg() | Util/C++: How to use RegisterCallBackMsg()]]&lt;br /&gt;
* [[How to use MessageCallBackHandler Class | Util/C++: How to use MessageCallBackHandler Class]]&lt;br /&gt;
* [[How to use RegisterPragmaRefCallBack() | Util/C++: How to use RegisterPragmaRefCallBack()]]&lt;br /&gt;
* [[Write out an encrypted netlist | Database/C++: Write out an encrypted netlist]]&lt;br /&gt;
* [[Extract clock enable | Database/C++: Extract clock enable]]&lt;br /&gt;
* [[Black box, empty box, and unknown box | Database/C++: Black box, empty box, and unknown box]]&lt;br /&gt;
* [[Post processing port resolution of black boxes | Database/C++: Post processing port resolution of black boxes]]&lt;br /&gt;
* [[Finding hierarchical paths of a Netlist | Database/C++: Finding hierarchical paths of a Netlist]]&lt;br /&gt;
* [[Replacing Verific built-in primitives/operators with user implementations | Database/C++: Replacing Verific built-in primitives/operators with user implementations]]&lt;br /&gt;
* [[Hierarchy tree RTL elaboration | Database/Perl: Simple example of hierarchy tree elaboration]]&lt;br /&gt;
* [[Create a Netlist Database from scratch (not from RTL elaboration) | Database/Perl/TCL: Create a Netlist Database from scratch (not from RTL elaboration)]]&lt;br /&gt;
* [[Buffering signals and ungrouping | Database/Verilog: Buffering signals and ungrouping (flattening) in the Netlist Database]]&lt;br /&gt;
* [[Memory elements of a RamNet | Database/Verilog/C++: Memory elements of a RamNet]]&lt;br /&gt;
* [[Process -f file and explore the Netlist Database (C++)| Database/Verilog/C++: Process -f file and explore the Netlist Database]]&lt;br /&gt;
* [[Process -f file and explore the Netlist Database (py)| Database/Verilog/Python: Process -f file and explore the Netlist Database]]&lt;br /&gt;
* [[Fanout cone and grouping | Database/Verilog/Perl: Fanout cone and grouping in the Netlist Database]]&lt;br /&gt;
* [[Type Range example | Database/Verilog/C++: Type Range example  (simple)]]&lt;br /&gt;
* [[Type Range example with multi-dimensional arrays| Database/Verilog/C++/Perl: Type Range example with multi-dimensional arrays]]&lt;br /&gt;
* [[Using TypeRange table to retrieve the originating type-range for an id | Database/Verilog/C++: Using TypeRange table to retrieve the originating type-range for an id]]&lt;br /&gt;
* [[Simple example of visitor pattern | Verilog/C++: Simple examples of visitor pattern]]&lt;br /&gt;
* [[Statically elaborate with different values of parameters | Verilog/C++: Statically elaborate with different values of parameters]]&lt;br /&gt;
* [[Prettyprint all modules in the design hierarchy | Verilog/C++: Prettyprint all modules in the design hierarchy]]&lt;br /&gt;
* [[Getting instances' parameters | Verilog/C++: Getting instances' parameters]]&lt;br /&gt;
* [[Accessing and evaluating module's parameters | Verilog/C++: Accessing and evaluating module's parameters]]&lt;br /&gt;
* [[Visiting Hierarchical References (VeriSelectedName) | Verilog/C++: Visiting Hierarchical References (VeriSelectedName)]]&lt;br /&gt;
* [[Using stream input to ignore input file | Verilog/C++: Using stream input to ignore input file]]&lt;br /&gt;
* [[How to ignore certain modules while analyzing input RTL files | Verilog/C++: How to ignore certain modules while analyzing input RTL files]]&lt;br /&gt;
* [[How to tell if a module has encrypted contents | Verilog/C++: How to tell if a module has encrypted contents]]&lt;br /&gt;
* [[Comment out a line using text based design modification and parsetree modification | Verilog/C++: Comment out a line using text-based design modification and parsetree modification]] &lt;br /&gt;
* [[Verilog/C++: How to use IsUserDeclared() : Example for port associations]]&lt;br /&gt;
* [[How to create new module in Verilog parsetree | Verilog/C++: How to create new module in Verilog parsetree]]&lt;br /&gt;
* [[In Verilog parsetree adding names to unnamed instances | Verilog/C++: In Verilog parsetree adding names to unnamed instances]]&lt;br /&gt;
* [[How to get full hierarchy ID path | Verilog/C++: How to get full hierarchy ID path]]&lt;br /&gt;
* [[How to traverse scope hierarchy | Verilog/C++: How to traverse scope hierarchy]]&lt;br /&gt;
* [[Access attributes in parsetree | Verilog/C++: How to access attributes in parsetree]]&lt;br /&gt;
* [[How to detect multiple-clock-edge condition in Verilog parsetree | Verilog/C++: How to detect multiple-clock-edge condition in Verilog parsetree]]&lt;br /&gt;
* [[How to get driving net of an instance | Verilog/C++: How to get driving net of an instance]]&lt;br /&gt;
* [[Parse select modules only and ignore the rest | Verilog/C++: Parse select modules only and ignore the rest]]&lt;br /&gt;
* [[Create DOT diagram of parse tree | Verilog/C++: Create DOT diagram of a parse tree]]&lt;br /&gt;
* [[How to evaluate a Verilog expression | Verilog/C++: How to evaluate a Verilog expression]]&lt;br /&gt;
* [[How to get parameters creation-time initial expression/value after Static Elaboration | Verilog/C++: How to get parameters creation-time initial expression/value after Static Elaboration]]&lt;br /&gt;
* [[How to get linefile data of macros - Macro callback function | Verilog/C++/Perl/Python: How to get linefile data of macros - Macro callback function]]&lt;br /&gt;
* [[Where in RTL does it get assigned? | Verilog/C++/Perl/Python: Where in RTL does it get assigned?]]&lt;br /&gt;
* [[Access attributes of ports in parsetree | Verilog/Perl: Access attributes of ports in parsetree and from netlist]]&lt;br /&gt;
* [[Evaluate 'for-generate' loop | Verilog/C++: Evaluate 'for-generate' loop]]&lt;br /&gt;
* [[Retrieve package name for user-defined variable types | SystemVerilog/C++/Python: Retrieve package name for user-defined variable types]]&lt;br /&gt;
* [[Pretty-print a module and the packages imported by the module | SystemVerilog/C++: Pretty-print a module and the packages imported by the module]]&lt;br /&gt;
* [[How to get packed dimensions of enum | SystemVerilog/C++: How to get packed dimensions of enum]]&lt;br /&gt;
* [[How to replace a statement that has a label | SystemVerilog/C++: How to replace a statement that has a label]]&lt;br /&gt;
* [[How to insert/add a statement, or a module item, into a sequential block and a generate block | SystemVerilog/C++: How to insert/add a statement, or a module item, into a sequential block and a generate block]]&lt;br /&gt;
* [[Simple examples of VHDL visitor pattern | VHDL/C++: Simple examples of VHDL visitor pattern]]&lt;br /&gt;
* [[Traverse instances in parsetree | VHDL/C++: Traverse instances in parsetree]]&lt;br /&gt;
* [[Parsing from data in memory | Verilog/VHDL/C++: Parsing from data in memory]]&lt;br /&gt;
&lt;br /&gt;
'''INVIO Code examples'''&lt;br /&gt;
* [[Simple port modification | SystemVerilog/Python: Simple port modification]]&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Modules_with_%27_1%27_%27_2%27_suffix_in_their_names&amp;diff=917</id>
		<title>Modules with ' 1' ' 2' suffix in their names</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Modules_with_%27_1%27_%27_2%27_suffix_in_their_names&amp;diff=917"/>
				<updated>2024-10-19T01:41:15Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''&amp;gt;&amp;gt;&amp;gt; This article will be merged with [http://www.verific.com/faq/index.php?title=Modules/design_units_with_%22_default%22_suffix_in_their_names this article] &amp;lt;&amp;lt;&amp;lt;'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Static elaboration process adds the suffix &amp;quot;_&amp;lt;number&amp;gt;&amp;quot; to the module name when:&lt;br /&gt;
#Module contains hierarchical identifier(s), and&lt;br /&gt;
#Hierarchical identifier(s) in that module point(s) to different objects depending on the hierarchical position of that module instance.&lt;br /&gt;
&lt;br /&gt;
An example :&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module test ;&lt;br /&gt;
    parameter p = 12 ;&lt;br /&gt;
    mod I() ;&lt;br /&gt;
    foo I2() ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
module foo ;&lt;br /&gt;
    test1 test() ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
module test1 ;&lt;br /&gt;
    parameter p = 2 ;&lt;br /&gt;
    mod I3() ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
module mod ;&lt;br /&gt;
    initial $display(test.p) ; // This is hierarchical identifier&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The hierarchy is:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
test (top module)&lt;br /&gt;
    I (mod)&lt;br /&gt;
    I2 (foo)&lt;br /&gt;
        test (test1)&lt;br /&gt;
            I3 (mod)&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So here module 'mod' is instantiated twice in the hierarchy. The hierarchical identifier 'test.p' inside module 'mod', can refer to parameter 'p' inside top level module 'test' for the instance 'I' of module 'mod'; but it can also refer to parameter 'p' inside module 'test1' for the instance 'I3' of module 'mod'. In other words, the prefix 'test' can refer to module 'test' (top module) or instance 'top' inside module 'foo'.&lt;br /&gt;
&lt;br /&gt;
In the example above, one hierarchical name can refer to different objects in the hierarchy. In this situation static elaboration creates 2 different copies of module 'mod' and their names are differentiated by adding &amp;quot;_&amp;lt;number&amp;gt;&amp;quot; ('mod_2' and 'mod_3'). Hierarchical identifiers in these two modules are resolved with proper identifiers.&lt;br /&gt;
&lt;br /&gt;
The parsetree after static elaboration:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module test ;&lt;br /&gt;
    parameter p = 12 ;&lt;br /&gt;
    mod_2 I () ;&lt;br /&gt;
    foo I2 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
module foo ;&lt;br /&gt;
    test1 test () ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
module test1 ;&lt;br /&gt;
    parameter p = 2 ;&lt;br /&gt;
    mod_3 I3 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
module mod ;&lt;br /&gt;
    initial&lt;br /&gt;
        $display (test.p) ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
module mod_2 ;&lt;br /&gt;
    initial&lt;br /&gt;
        $display (test.p) ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
module mod_3 ;&lt;br /&gt;
    initial&lt;br /&gt;
        $display (test.p) ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The design hierarchy is:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
test (top module)&lt;br /&gt;
    I (mod_2)&lt;br /&gt;
    I2 (foo)&lt;br /&gt;
        test (test1)&lt;br /&gt;
            I3 (mod_3)&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The original module 'mod' is not instantiated.&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Remove_Verific_data_structures&amp;diff=916</id>
		<title>Remove Verific data structures</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Remove_Verific_data_structures&amp;diff=916"/>
				<updated>2024-10-19T01:15:21Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Q: How do I remove all Verific data structures in memory?'''&lt;br /&gt;
&lt;br /&gt;
To remove hdl file sorting data:&lt;br /&gt;
&lt;br /&gt;
    hdl_file_sort::Reset();&lt;br /&gt;
&lt;br /&gt;
To reset file system cache:&lt;br /&gt;
&lt;br /&gt;
    FileSystem::ResetDirectoryCache();&lt;br /&gt;
&lt;br /&gt;
To remove Verilog parsetree:&lt;br /&gt;
&lt;br /&gt;
    veri_file::Reset();&lt;br /&gt;
&lt;br /&gt;
To remove VHDL parsetree:&lt;br /&gt;
&lt;br /&gt;
    vhdl_file::Reset();&lt;br /&gt;
&lt;br /&gt;
To remove synlib parsetree:&lt;br /&gt;
&lt;br /&gt;
    synlib_file::Reset();&lt;br /&gt;
&lt;br /&gt;
To remove hierarchy tree:&lt;br /&gt;
&lt;br /&gt;
    hier_tree::DeleteHierarchicalTree() ;&lt;br /&gt;
&lt;br /&gt;
To remove UPF data structures:&lt;br /&gt;
&lt;br /&gt;
    upf_file::DeleteAll();&lt;br /&gt;
&lt;br /&gt;
To remove the netlist database:&lt;br /&gt;
&lt;br /&gt;
    Libset::Reset();&lt;br /&gt;
&lt;br /&gt;
To remove linefile data (make sure that you've removed all parsetrees and the netlist database):&lt;br /&gt;
&lt;br /&gt;
    LineFile::DeleteAllLineFiles();&lt;br /&gt;
    LineFile::ResetFileIdMaps();&lt;br /&gt;
&lt;br /&gt;
To remove message type settings:&lt;br /&gt;
&lt;br /&gt;
    Message::Reset();&lt;br /&gt;
&lt;br /&gt;
To reset run-time flags:&lt;br /&gt;
&lt;br /&gt;
    RuntimeFlags::DeleteAllFlags();&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Modules/design_units_with_%22_default%22_suffix_in_their_names&amp;diff=915</id>
		<title>Modules/design units with &quot; default&quot; suffix in their names</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Modules/design_units_with_%22_default%22_suffix_in_their_names&amp;diff=915"/>
				<updated>2024-10-19T01:11:23Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt; This article is currently under construction &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Q: After static elaboration, there are modules/design units with &amp;quot;_default&amp;quot; or &amp;quot;_1, _2&amp;quot; suffix in their names. Why? And what are they? '''&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_default&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Static elaboration process is a multiple-iteration process and modules/design units may be modified differently in each iteration.&lt;br /&gt;
&lt;br /&gt;
We need to keep original version of modules/design units as they are immediately after analysis so that they can be copied for different parameter/generic settings in each iteration and body of copied modules/design units can be elaborated (generate unroll, array instance processing, etc.) differently for each parameter/generic setting.&lt;br /&gt;
&lt;br /&gt;
Another reason to copy instantiated modules/design units with &amp;quot;_default&amp;quot; name is in mixed language elaboration. Here a Verilog module may instantiate a VHDL entity which has been elaborated earlier with different generic values. In that case during Verilog elaboration we will not get original contents of instantiated entity.&lt;br /&gt;
&lt;br /&gt;
Moreover, to support incremental elaboration we need to keep original modules/design units, as lower level units can be elaborated earlier.&lt;br /&gt;
&lt;br /&gt;
In Verilog, we have a runtime-flag &amp;quot;veri_remove_suffix_default_from_copied_module_names&amp;quot; to rename modules from &amp;quot;&amp;lt;orig_name&amp;gt;_default&amp;quot; to &amp;quot;&amp;lt;orig_name&amp;gt;&amp;quot;. This will work only when runtime-flag &amp;quot;veri_cleanup_base_modules&amp;quot; is set.&lt;br /&gt;
&lt;br /&gt;
==== Interfaces with &amp;quot;_default&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
SystemVerilog interfaces can be used in any of the following ways :&lt;br /&gt;
&lt;br /&gt;
*  As interface instantiations.&lt;br /&gt;
*  As interface ports.&lt;br /&gt;
*  As virtual interfaces.&lt;br /&gt;
*  As hierarchical names.&lt;br /&gt;
&lt;br /&gt;
Interface is always copied with '_default' suffix since we do not know for sure if there is a virtual interface in the hierarchy below which is yet to be processed.&lt;br /&gt;
&lt;br /&gt;
The copied interface (with '_default' suffix) will be the one that is elaborated and specified in the virtual interface declaration, interface instance, or top-level module port.  Every instantiated module containing interface type ports will also be copied during static elaboration since its interface port names may have been modified as well.&lt;br /&gt;
&lt;br /&gt;
Virtual interfaces can appear in many different parts of a design, and may or may not be associated with interface instances. Virtual interfaces are not stored in Verific's pseudo-tree, so after static elaboration we do not know whether an interface is used as a virtual interface or not, or where it is being used.  Without this knowledge, we cannot arbitrarily change all the references of an interface from  '&amp;lt;interface_name&amp;gt;_default'  to  '&amp;lt;interface_name&amp;gt; because the references may become invalid. Because of this, we do not have flags to remove the '_default' from the interface names as we do for modules.&lt;br /&gt;
&lt;br /&gt;
The '_default_&amp;lt;n&amp;gt;' suffix may also be added due to the presence of hierarchical references in an interface or bind statements containing interface instantiations.&lt;br /&gt;
&lt;br /&gt;
Verific VIPER #19809 has more details.&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_&amp;lt;N&amp;gt;&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Modules can be copied with _&amp;lt;N&amp;gt; suffix for hier-ref present/going via them.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module top ;&lt;br /&gt;
    test      t  () ;&lt;br /&gt;
    test #(0) t0 () ;&lt;br /&gt;
    test #(1) t1 () ;&lt;br /&gt;
    test #(2) t2 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module test ;&lt;br /&gt;
    parameter P = 0 ;&lt;br /&gt;
    wire [P:0] sig ;&lt;br /&gt;
    bot b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot ;&lt;br /&gt;
    initial $display(test.sig) ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here &amp;quot;bot&amp;quot; has to be copied 3 times with _&amp;lt;N&amp;gt; suffix so that they can point to 3 different &amp;quot;sig&amp;quot; of 3 different sizes.&lt;br /&gt;
The same can happen for bind statements as well. Different bind instances can be added to different instances of the same module.&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_copy&amp;lt;N&amp;gt;&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Modules can be copied with _copy&amp;lt;N&amp;gt; suffix when a module with _&amp;lt;N&amp;gt; is already present in the same library.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module top ;&lt;br /&gt;
    test      t  () ;&lt;br /&gt;
    test #(0) t0 () ;&lt;br /&gt;
    test #(1) t1 () ;&lt;br /&gt;
    test #(2) t2 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module test ;&lt;br /&gt;
    parameter P = 0 ;&lt;br /&gt;
    wire [P:0] sig ;&lt;br /&gt;
    bot b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot ;&lt;br /&gt;
    initial $display(test.sig) ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot_2 ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here &amp;quot;bot_2&amp;quot; already exists and hence the copied &amp;quot;bot&amp;quot; which we wanted to name &amp;quot;bot_2&amp;quot; is renamed to &amp;quot;bot_copy&amp;lt;N&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_&amp;lt;N&amp;gt;_&amp;lt;M&amp;gt;&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Modules can even be copied with _&amp;lt;N&amp;gt;_&amp;lt;M&amp;gt; suffix in some corner cases with name conflict as well as hier-refs.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module top ;&lt;br /&gt;
    test      t  () ;&lt;br /&gt;
    test #(0) t0 () ;&lt;br /&gt;
    test #(1) t1 () ;&lt;br /&gt;
    test #(2) t2 () ;&lt;br /&gt;
    bot_2 b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module test ;&lt;br /&gt;
    parameter P = 0 ;&lt;br /&gt;
    wire [P:0] sig ;&lt;br /&gt;
    bot b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot ;&lt;br /&gt;
    initial $display(test.sig) ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot_2 ;&lt;br /&gt;
    generate&lt;br /&gt;
        test #(2) t1 () ;&lt;br /&gt;
    endgenerate&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here instead of &amp;quot;bot_copy&amp;lt;N&amp;gt;&amp;quot;, one of the elaborated versions of &amp;quot;bot&amp;quot; which is to be renamed to &amp;quot;bot_2&amp;quot; is actually named as &amp;quot;bot_2_1&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== How to get the original name or the original module ====&lt;br /&gt;
&lt;br /&gt;
APIs to retrieve the original name of the module or to get the original module itself (only when the original module is available):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
VeriModule::GetOriginalModuleName()&lt;br /&gt;
VeriModule::GetOriginalModule()&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Modules_with_%27_1%27_%27_2%27_suffix_in_their_names&amp;diff=914</id>
		<title>Modules with ' 1' ' 2' suffix in their names</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Modules_with_%27_1%27_%27_2%27_suffix_in_their_names&amp;diff=914"/>
				<updated>2024-10-19T01:10:20Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt; This article will be merged with another article &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Static elaboration process adds the suffix &amp;quot;_&amp;lt;number&amp;gt;&amp;quot; to the module name when:&lt;br /&gt;
#Module contains hierarchical identifier(s), and&lt;br /&gt;
#Hierarchical identifier(s) in that module point(s) to different objects depending on the hierarchical position of that module instance.&lt;br /&gt;
&lt;br /&gt;
An example :&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module test ;&lt;br /&gt;
    parameter p = 12 ;&lt;br /&gt;
    mod I() ;&lt;br /&gt;
    foo I2() ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
module foo ;&lt;br /&gt;
    test1 test() ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
module test1 ;&lt;br /&gt;
    parameter p = 2 ;&lt;br /&gt;
    mod I3() ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
module mod ;&lt;br /&gt;
    initial $display(test.p) ; // This is hierarchical identifier&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The hierarchy is:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
test (top module)&lt;br /&gt;
    I (mod)&lt;br /&gt;
    I2 (foo)&lt;br /&gt;
        test (test1)&lt;br /&gt;
            I3 (mod)&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So here module 'mod' is instantiated twice in the hierarchy. The hierarchical identifier 'test.p' inside module 'mod', can refer to parameter 'p' inside top level module 'test' for the instance 'I' of module 'mod'; but it can also refer to parameter 'p' inside module 'test1' for the instance 'I3' of module 'mod'. In other words, the prefix 'test' can refer to module 'test' (top module) or instance 'top' inside module 'foo'.&lt;br /&gt;
&lt;br /&gt;
In the example above, one hierarchical name can refer to different objects in the hierarchy. In this situation static elaboration creates 2 different copies of module 'mod' and their names are differentiated by adding &amp;quot;_&amp;lt;number&amp;gt;&amp;quot; ('mod_2' and 'mod_3'). Hierarchical identifiers in these two modules are resolved with proper identifiers.&lt;br /&gt;
&lt;br /&gt;
The parsetree after static elaboration:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module test ;&lt;br /&gt;
    parameter p = 12 ;&lt;br /&gt;
    mod_2 I () ;&lt;br /&gt;
    foo I2 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
module foo ;&lt;br /&gt;
    test1 test () ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
module test1 ;&lt;br /&gt;
    parameter p = 2 ;&lt;br /&gt;
    mod_3 I3 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
module mod ;&lt;br /&gt;
    initial&lt;br /&gt;
        $display (test.p) ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
module mod_2 ;&lt;br /&gt;
    initial&lt;br /&gt;
        $display (test.p) ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
module mod_3 ;&lt;br /&gt;
    initial&lt;br /&gt;
        $display (test.p) ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The design hierarchy is:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
test (top module)&lt;br /&gt;
    I (mod_2)&lt;br /&gt;
    I2 (foo)&lt;br /&gt;
        test (test1)&lt;br /&gt;
            I3 (mod_3)&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The original module 'mod' is not instantiated.&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Main_Page&amp;diff=913</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Main_Page&amp;diff=913"/>
				<updated>2024-10-19T01:08:38Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''General'''&lt;br /&gt;
* [[How to get best support from Verific | '''''How to get best support from Verific''''']]&lt;br /&gt;
* [[Source code customization &amp;amp; Stable release services | Source code customization &amp;amp; Stable release services]]&lt;br /&gt;
* [[How to save computer resources | How to save computer resources (memory consumption &amp;amp; runtime)]]&lt;br /&gt;
* [[Original RTL language | How do I know what language a Netlist in the netlist database comes from?]]&lt;br /&gt;
* [[Verific data structures | What are the data structures in Verific?]]&lt;br /&gt;
* [[Remove Verific data structures | How do I remove all Verific data structures in memory?]]&lt;br /&gt;
* [[Does Verific build CDFG? | Does Verific build control and data flow graph (CDFG)?]]&lt;br /&gt;
* [[Does Verific support XMR?| Does Verific support cross module references (XMR)?]]&lt;br /&gt;
* [[Compile-time/run-time flags | Are there options to control Verific software's behavior? Compile-time &amp;amp; run-time flags.]]&lt;br /&gt;
* [[Message handling | How do I downgrade/upgrade messages from Verific? How do I get messages with more details?]]&lt;br /&gt;
* [[Release version | How do I tell the version of a Verific software release? ]]&lt;br /&gt;
* [[Simulation models for Verific primitives | Where do I find simulation models for Verific primitives (VERIFIC_XOR, VERIFIC_DFFRS, ....)? ]]&lt;br /&gt;
* [[Tcl library path| How to correct building (linking) issue &amp;quot;/usr/bin/ld: cannot find -ltcl&amp;quot;]]&lt;br /&gt;
* [[LineFile data from input files | LineFile data from input files]]&lt;br /&gt;
* [[Difference between RTL and gate-level simulations - Flipflop with async set and async reset | Difference between RTL and gate-level simulations - Flipflop with async set and async reset]]&lt;br /&gt;
* [[Preserving user nets - preventing nets from being optimized away | Preserving user nets - preventing nets from being optimized away]]&lt;br /&gt;
* [[Python pretty-printer for gdb | Python pretty-printer for gdb]]&lt;br /&gt;
* [[Yosys-Verific Integration | Yosys-Verific integration]]&lt;br /&gt;
&lt;br /&gt;
'''Input: VHDL, Verilog (and SystemVerilog), Liberty, EDIF'''&lt;br /&gt;
* [[How to get all Verilog files being analyzed | Verilog: I'm using -v, -y, .... After Verific is done with the analysis, how do I get a list of all the files being analyzed?]]&lt;br /&gt;
* [[Included files associated with a Verilog source file | Verilog: How do I get the list of included files associated with a Verilog source file?]]&lt;br /&gt;
* [[How to get type/initial value of parameters | Verilog: How to get type/initial value of parameters.]]&lt;br /&gt;
* [[Verilog ports being renamed | Verilog: Port Expressions]]&lt;br /&gt;
* [[Design with System Verilog and Verilog 2001 files | Verilog: For a design consisting of a mixture of Verilog 2001 and SystemVerilog input files, should I parse all the files as SystemVerilog?]]&lt;br /&gt;
* [[How to get module ports from Verilog parsetree | Verilog: From the Verilog parsetree, how can I get the ports of a module?]]&lt;br /&gt;
* [[How to change name of id in Verilog parsetree | Verilog: How do I change the name of an id (VeriidDef) in Verilog parsetree?]]&lt;br /&gt;
* [[How to get library containing nested module | Verilog: How do I get nested modules and get the library that contains the nested module?]]&lt;br /&gt;
* [[How to get linefile information of macro definitions | Verilog: How do I get linefile information of macro definitions?]]&lt;br /&gt;
* [[How to find port dimensions | Verilog: How do I get port dimensions?]]&lt;br /&gt;
* [[Instance - Module binding order | Verilog: What is the order of binding modules to instances?]]&lt;br /&gt;
* [[How Verific elaborator handles blackboxes/unknown boxes | Verilog: How Verific elaborator handles blackboxes/unknown boxes]]&lt;br /&gt;
* [[Constant expression replacement | Verilog: Does Verific replace constant expressions with their respective values?]]&lt;br /&gt;
* [[Modules with '_1' '_2' suffix in their names | Verilog: After static elaboration, there are modules with &amp;quot;_1&amp;quot;, &amp;quot;_2&amp;quot;, ..., suffix in their names. Why?]]&lt;br /&gt;
* [[Defined macros become undefined - MFCU vs SFCU | SystemVerilog: Why does Verific complain about undefined macros for macros defined in a different file (Compilation Unit)?]]&lt;br /&gt;
* [[Notes on analysis | SystemVerilog: Notes on analysis]]&lt;br /&gt;
* [[How to get enums from Verilog parsetree | SystemVerilog: From the parsetree, how can I get the enums declared in a module?]]&lt;br /&gt;
* [[How to identify packages being imported into a module | SystemVerilog: How do I identify packages being imported into a module?]]&lt;br /&gt;
* [[SystemVerilog &amp;quot;std&amp;quot; package | SystemVerilog: Support for SystemVerilog semaphore/process/mailbox constructs.]]&lt;br /&gt;
* [[Top level module with interface ports | SystemVerilog: Support for SystemVerilog top level module with interface ports.]]&lt;br /&gt;
* [[Design with VHDL-1993 and VHDL-2008 files | VHDL: VHDL-1993 and VHDL-2008 each has its own IEEE library set. How do I analyze/elaborate a design with a mixture of files of different VHDL dialects (1993 and 2008)?]]&lt;br /&gt;
* [[Escaped identifiers in RTL files and in Verific data structures | Verilog/VHDL: Escaped identifiers in RTL files and in Verific data structures]]&lt;br /&gt;
* [[Prettyprint to a string | Verilog/VHDL: How to prettyprint a parsetree node to a string.]]&lt;br /&gt;
* [[Static elaboration | Verilog/VHDL: What does 'static elaboration' do?]]&lt;br /&gt;
* [[How to ignore a (not used) parameter/generic in elaboration. | Verilog/VHDL: How to ignore a (not used) parameter/generic in elaboration.]]&lt;br /&gt;
* [[What VeriModule* or VhdlPrimaryUnit* the Netlist comes from? | Verilog/VHDL: For a Netlist in the netlist database, is there a clean way to look back at what VeriModule* or VhdlPrimaryUnit* the Netlist was derived from?]]&lt;br /&gt;
* [[Cross-reference between the original RTL files and the elaborated netlist | Verilog/VHDL: Is there a way to cross-reference between the original RTL design files and the elaboration netlist?]]&lt;br /&gt;
* [[How to ignore parameters/generics in elaboration | Verilog/VHDL: Is there a way to tell the elaborator to ignore certain parameters/generics so that the unit/module is not uniquified?]]&lt;br /&gt;
* [[How to check for errors in analysis/elaboration | Verilog/VHDL: Is there a way to tell if the analysis/elaboration process has errors?]]&lt;br /&gt;
* [[Modules/design units with &amp;quot;_default&amp;quot; suffix in their names | Verilog/VHDL: After static elaboration, there are modules/design units/interfaces with &amp;quot;_default&amp;quot; or &amp;quot;or &amp;quot;_1, _2&amp;quot; suffix in their names. What are they?]]&lt;br /&gt;
* [[How to parse a string | Verilog/VHDL: How to parse a string - Example of adding a module to the parsetree]]&lt;br /&gt;
* [[Support IEEE 1735 encryption standard | Verilog/VHDL: Does Verific support IEEE 1735 encryption standard?]]&lt;br /&gt;
'''Netlist Database'''&lt;br /&gt;
* [[Logic optimization across hierarchy boundaries | Netlist Database: Does Verific perform logic optimization across hierarchy boundaries?]]&lt;br /&gt;
* [[Bit-blasting a multi-port RAM instance | Netlist Database: Bit-blasting a multi-port RAM instance]]&lt;br /&gt;
* [[System attributes | Netlist Database: System attributes]]&lt;br /&gt;
&lt;br /&gt;
'''Output'''&lt;br /&gt;
* [[Output file formats | What language formats does Verific support as output?]]&lt;br /&gt;
&lt;br /&gt;
'''Scripting languages: TCL, Perl, Python'''&lt;br /&gt;
* [[What languages can I use with Verific software? | What programming languages can I use with Verific software?]]&lt;br /&gt;
&lt;br /&gt;
'''Code examples'''&lt;br /&gt;
* [[How to use RegisterCallBackMsg() | Util/C++: How to use RegisterCallBackMsg()]]&lt;br /&gt;
* [[How to use MessageCallBackHandler Class | Util/C++: How to use MessageCallBackHandler Class]]&lt;br /&gt;
* [[How to use RegisterPragmaRefCallBack() | Util/C++: How to use RegisterPragmaRefCallBack()]]&lt;br /&gt;
* [[Write out an encrypted netlist | Database/C++: Write out an encrypted netlist]]&lt;br /&gt;
* [[Extract clock enable | Database/C++: Extract clock enable]]&lt;br /&gt;
* [[Black box, empty box, and unknown box | Database/C++: Black box, empty box, and unknown box]]&lt;br /&gt;
* [[Post processing port resolution of black boxes | Database/C++: Post processing port resolution of black boxes]]&lt;br /&gt;
* [[Finding hierarchical paths of a Netlist | Database/C++: Finding hierarchical paths of a Netlist]]&lt;br /&gt;
* [[Replacing Verific built-in primitives/operators with user implementations | Database/C++: Replacing Verific built-in primitives/operators with user implementations]]&lt;br /&gt;
* [[Hierarchy tree RTL elaboration | Database/Perl: Simple example of hierarchy tree elaboration]]&lt;br /&gt;
* [[Create a Netlist Database from scratch (not from RTL elaboration) | Database/Perl/TCL: Create a Netlist Database from scratch (not from RTL elaboration)]]&lt;br /&gt;
* [[Buffering signals and ungrouping | Database/Verilog: Buffering signals and ungrouping (flattening) in the Netlist Database]]&lt;br /&gt;
* [[Memory elements of a RamNet | Database/Verilog/C++: Memory elements of a RamNet]]&lt;br /&gt;
* [[Process -f file and explore the Netlist Database (C++)| Database/Verilog/C++: Process -f file and explore the Netlist Database]]&lt;br /&gt;
* [[Process -f file and explore the Netlist Database (py)| Database/Verilog/Python: Process -f file and explore the Netlist Database]]&lt;br /&gt;
* [[Fanout cone and grouping | Database/Verilog/Perl: Fanout cone and grouping in the Netlist Database]]&lt;br /&gt;
* [[Type Range example | Database/Verilog/C++: Type Range example  (simple)]]&lt;br /&gt;
* [[Type Range example with multi-dimensional arrays| Database/Verilog/C++/Perl: Type Range example with multi-dimensional arrays]]&lt;br /&gt;
* [[Using TypeRange table to retrieve the originating type-range for an id | Database/Verilog/C++: Using TypeRange table to retrieve the originating type-range for an id]]&lt;br /&gt;
* [[Simple example of visitor pattern | Verilog/C++: Simple examples of visitor pattern]]&lt;br /&gt;
* [[Statically elaborate with different values of parameters | Verilog/C++: Statically elaborate with different values of parameters]]&lt;br /&gt;
* [[Prettyprint all modules in the design hierarchy | Verilog/C++: Prettyprint all modules in the design hierarchy]]&lt;br /&gt;
* [[Getting instances' parameters | Verilog/C++: Getting instances' parameters]]&lt;br /&gt;
* [[Accessing and evaluating module's parameters | Verilog/C++: Accessing and evaluating module's parameters]]&lt;br /&gt;
* [[Visiting Hierarchical References (VeriSelectedName) | Verilog/C++: Visiting Hierarchical References (VeriSelectedName)]]&lt;br /&gt;
* [[Using stream input to ignore input file | Verilog/C++: Using stream input to ignore input file]]&lt;br /&gt;
* [[How to ignore certain modules while analyzing input RTL files | Verilog/C++: How to ignore certain modules while analyzing input RTL files]]&lt;br /&gt;
* [[How to tell if a module has encrypted contents | Verilog/C++: How to tell if a module has encrypted contents]]&lt;br /&gt;
* [[Comment out a line using text based design modification and parsetree modification | Verilog/C++: Comment out a line using text-based design modification and parsetree modification]] &lt;br /&gt;
* [[Verilog/C++: How to use IsUserDeclared() : Example for port associations]]&lt;br /&gt;
* [[How to create new module in Verilog parsetree | Verilog/C++: How to create new module in Verilog parsetree]]&lt;br /&gt;
* [[In Verilog parsetree adding names to unnamed instances | Verilog/C++: In Verilog parsetree adding names to unnamed instances]]&lt;br /&gt;
* [[How to get full hierarchy ID path | Verilog/C++: How to get full hierarchy ID path]]&lt;br /&gt;
* [[How to traverse scope hierarchy | Verilog/C++: How to traverse scope hierarchy]]&lt;br /&gt;
* [[Access attributes in parsetree | Verilog/C++: How to access attributes in parsetree]]&lt;br /&gt;
* [[How to detect multiple-clock-edge condition in Verilog parsetree | Verilog/C++: How to detect multiple-clock-edge condition in Verilog parsetree]]&lt;br /&gt;
* [[How to get driving net of an instance | Verilog/C++: How to get driving net of an instance]]&lt;br /&gt;
* [[Parse select modules only and ignore the rest | Verilog/C++: Parse select modules only and ignore the rest]]&lt;br /&gt;
* [[Create DOT diagram of parse tree | Verilog/C++: Create DOT diagram of a parse tree]]&lt;br /&gt;
* [[How to get linefile data of macros - Macro callback function | Verilog/C++/Perl/Python: How to get linefile data of macros - Macro callback function]]&lt;br /&gt;
* [[Where in RTL does it get assigned? | Verilog/C++/Perl/Python: Where in RTL does it get assigned?]]&lt;br /&gt;
* [[Access attributes of ports in parsetree | Verilog/Perl: Access attributes of ports in parsetree and from netlist]]&lt;br /&gt;
* [[Evaluate 'for-generate' loop | Verilog/C++: Evaluate 'for-generate' loop]]&lt;br /&gt;
* [[Retrieve package name for user-defined variable types | SystemVerilog/C++/Python: Retrieve package name for user-defined variable types]]&lt;br /&gt;
* [[Pretty-print a module and the packages imported by the module | SystemVerilog/C++: Pretty-print a module and the packages imported by the module]]&lt;br /&gt;
* [[How to get packed dimensions of enum | SystemVerilog/C++: How to get packed dimensions of enum]]&lt;br /&gt;
* [[How to replace a statement that has a label | SystemVerilog/C++: How to replace a statement that has a label]]&lt;br /&gt;
* [[How to insert/add a statement, or a module item, into a sequential block and a generate block | SystemVerilog/C++: How to insert/add a statement, or a module item, into a sequential block and a generate block]]&lt;br /&gt;
* [[Simple examples of VHDL visitor pattern | VHDL/C++: Simple examples of VHDL visitor pattern]]&lt;br /&gt;
* [[Traverse instances in parsetree | VHDL/C++: Traverse instances in parsetree]]&lt;br /&gt;
* [[Parsing from data in memory | Verilog/VHDL/C++: Parsing from data in memory]]&lt;br /&gt;
&lt;br /&gt;
'''INVIO Code examples'''&lt;br /&gt;
* [[Simple port modification | SystemVerilog/Python: Simple port modification]]&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Modules/design_units_with_%22_default%22_suffix_in_their_names&amp;diff=912</id>
		<title>Modules/design units with &quot; default&quot; suffix in their names</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Modules/design_units_with_%22_default%22_suffix_in_their_names&amp;diff=912"/>
				<updated>2024-10-19T01:06:43Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pre style=&amp;quot;color: red&amp;quot;&amp;gt; This article is currently under construction &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Q: After static elaboration, there are modules/design units with &amp;quot;_default&amp;quot; or &amp;quot;_1, _2&amp;quot; suffix in their names. Why? And what are they? '''&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_default&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Static elaboration process is a multiple-iteration process and modules/design units may be modified differently in each iteration.&lt;br /&gt;
&lt;br /&gt;
We need to keep original version of modules/design units as they are immediately after analysis so that they can be copied for different parameter/generic settings in each iteration and body of copied modules/design units can be elaborated (generate unroll, array instance processing, etc.) differently for each parameter/generic setting.&lt;br /&gt;
&lt;br /&gt;
Another reason to copy instantiated modules/design units with &amp;quot;_default&amp;quot; name is in mixed language elaboration. Here a Verilog module may instantiate a VHDL entity which has been elaborated earlier with different generic values. In that case during Verilog elaboration we will not get original contents of instantiated entity.&lt;br /&gt;
&lt;br /&gt;
Moreover, to support incremental elaboration we need to keep original modules/design units, as lower level units can be elaborated earlier.&lt;br /&gt;
&lt;br /&gt;
In Verilog, we have a runtime-flag &amp;quot;veri_remove_suffix_default_from_copied_module_names&amp;quot; to rename modules from &amp;quot;&amp;lt;orig_name&amp;gt;_default&amp;quot; to &amp;quot;&amp;lt;orig_name&amp;gt;&amp;quot;. This will work only when runtime-flag &amp;quot;veri_cleanup_base_modules&amp;quot; is set.&lt;br /&gt;
&lt;br /&gt;
==== Interfaces with &amp;quot;_default&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
SystemVerilog interfaces can be used in any of the following ways :&lt;br /&gt;
&lt;br /&gt;
*  As interface instantiations.&lt;br /&gt;
*  As interface ports.&lt;br /&gt;
*  As virtual interfaces.&lt;br /&gt;
*  As hierarchical names.&lt;br /&gt;
&lt;br /&gt;
Interface is always copied with '_default' suffix since we do not know for sure if there is a virtual interface in the hierarchy below which is yet to be processed.&lt;br /&gt;
&lt;br /&gt;
The copied interface (with '_default' suffix) will be the one that is elaborated and specified in the virtual interface declaration, interface instance, or top-level module port.  Every instantiated module containing interface type ports will also be copied during static elaboration since its interface port names may have been modified as well.&lt;br /&gt;
&lt;br /&gt;
Virtual interfaces can appear in many different parts of a design, and may or may not be associated with interface instances. Virtual interfaces are not stored in Verific's pseudo-tree, so after static elaboration we do not know whether an interface is used as a virtual interface or not, or where it is being used.  Without this knowledge, we cannot arbitrarily change all the references of an interface from  '&amp;lt;interface_name&amp;gt;_default'  to  '&amp;lt;interface_name&amp;gt; because the references may become invalid. Because of this, we do not have flags to remove the '_default' from the interface names as we do for modules.&lt;br /&gt;
&lt;br /&gt;
The '_default_&amp;lt;n&amp;gt;' suffix may also be added due to the presence of hierarchical references in an interface or bind statements containing interface instantiations.&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_&amp;lt;N&amp;gt;&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Modules can be copied with _&amp;lt;N&amp;gt; suffix for hier-ref present/going via them.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module top ;&lt;br /&gt;
    test      t  () ;&lt;br /&gt;
    test #(0) t0 () ;&lt;br /&gt;
    test #(1) t1 () ;&lt;br /&gt;
    test #(2) t2 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module test ;&lt;br /&gt;
    parameter P = 0 ;&lt;br /&gt;
    wire [P:0] sig ;&lt;br /&gt;
    bot b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot ;&lt;br /&gt;
    initial $display(test.sig) ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here &amp;quot;bot&amp;quot; has to be copied 3 times with _&amp;lt;N&amp;gt; suffix so that they can point to 3 different &amp;quot;sig&amp;quot; of 3 different sizes.&lt;br /&gt;
The same can happen for bind statements as well. Different bind instances can be added to different instances of the same module.&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_copy&amp;lt;N&amp;gt;&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Modules can be copied with _copy&amp;lt;N&amp;gt; suffix when a module with _&amp;lt;N&amp;gt; is already present in the same library.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module top ;&lt;br /&gt;
    test      t  () ;&lt;br /&gt;
    test #(0) t0 () ;&lt;br /&gt;
    test #(1) t1 () ;&lt;br /&gt;
    test #(2) t2 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module test ;&lt;br /&gt;
    parameter P = 0 ;&lt;br /&gt;
    wire [P:0] sig ;&lt;br /&gt;
    bot b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot ;&lt;br /&gt;
    initial $display(test.sig) ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot_2 ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here &amp;quot;bot_2&amp;quot; already exists and hence the copied &amp;quot;bot&amp;quot; which we wanted to name &amp;quot;bot_2&amp;quot; is renamed to &amp;quot;bot_copy&amp;lt;N&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== Modules with &amp;quot;_&amp;lt;N&amp;gt;_&amp;lt;M&amp;gt;&amp;quot; suffix ====&lt;br /&gt;
&lt;br /&gt;
Modules can even be copied with _&amp;lt;N&amp;gt;_&amp;lt;M&amp;gt; suffix in some corner cases with name conflict as well as hier-refs.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
module top ;&lt;br /&gt;
    test      t  () ;&lt;br /&gt;
    test #(0) t0 () ;&lt;br /&gt;
    test #(1) t1 () ;&lt;br /&gt;
    test #(2) t2 () ;&lt;br /&gt;
    bot_2 b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module test ;&lt;br /&gt;
    parameter P = 0 ;&lt;br /&gt;
    wire [P:0] sig ;&lt;br /&gt;
    bot b1 () ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot ;&lt;br /&gt;
    initial $display(test.sig) ;&lt;br /&gt;
endmodule&lt;br /&gt;
 &lt;br /&gt;
module bot_2 ;&lt;br /&gt;
    generate&lt;br /&gt;
        test #(2) t1 () ;&lt;br /&gt;
    endgenerate&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here instead of &amp;quot;bot_copy&amp;lt;N&amp;gt;&amp;quot;, one of the elaborated versions of &amp;quot;bot&amp;quot; which is to be renamed to &amp;quot;bot_2&amp;quot; is actually named as &amp;quot;bot_2_1&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==== How to get the original name or the original module ====&lt;br /&gt;
&lt;br /&gt;
APIs to retrieve the original name of the module or to get the original module itself (only when the original module is available):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
VeriModule::GetOriginalModuleName()&lt;br /&gt;
VeriModule::GetOriginalModule()&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Simple_example_of_visitor_pattern&amp;diff=909</id>
		<title>Simple example of visitor pattern</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Simple_example_of_visitor_pattern&amp;diff=909"/>
				<updated>2024-09-06T23:04:57Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Example 1:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ cat test.cpp&lt;br /&gt;
#include &amp;lt;iostream&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;VeriVisitor.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriConstVal.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Map.h&amp;quot;&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;
class MyVisitor : public VeriVisitor&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
    MyVisitor() : VeriVisitor() { }&lt;br /&gt;
    virtual ~MyVisitor() { }&lt;br /&gt;
&lt;br /&gt;
    virtual void VERI_VISIT(VeriConst, node)&lt;br /&gt;
    {&lt;br /&gt;
        char *str = node.GetPrettyPrintedString() ;&lt;br /&gt;
        node.Info(&amp;quot;Got expression: %s&amp;quot;, str) ;&lt;br /&gt;
        Strings::free(str) ;&lt;br /&gt;
    }&lt;br /&gt;
} ;&lt;br /&gt;
&lt;br /&gt;
int main (int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
    const char *file_name = &amp;quot;test.sv&amp;quot; ; // defaulf input filename&lt;br /&gt;
    if (argc &amp;gt; 1) file_name = argv[1] ; // Set the file name as specified by the user&lt;br /&gt;
    // veri_file::Analyze(const char *file_name, unsigned verilog_mode=VERILOG_2K, const char *lib_name=&amp;quot;work&amp;quot;, unsigned cu_mode=NO_MODE) ;&lt;br /&gt;
    if (!veri_file::Analyze(file_name, veri_file::SYSTEM_VERILOG)) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    // if (!veri_file::ElaborateAllStatic()) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    MyVisitor mv ;&lt;br /&gt;
&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    VeriModule *mod ;&lt;br /&gt;
    FOREACH_VERILOG_MODULE(mi, mod) if (mod) mod-&amp;gt;Accept(mv) ;&lt;br /&gt;
&lt;br /&gt;
    return 0 ;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$ cat test.sv&lt;br /&gt;
module test ;&lt;br /&gt;
    (* a = 1, b = 2.6 *) wire w ;&lt;br /&gt;
    assign w = 2'b00 ;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
$ test-linux&lt;br /&gt;
-- Analyzing Verilog file 'test.sv' (VERI-1482)&lt;br /&gt;
test.sv(2): INFO: Got expression: 1&lt;br /&gt;
test.sv(2): INFO: Got expression: 2.6&lt;br /&gt;
test.sv(3): INFO: Got expression: 2'b0&lt;br /&gt;
$&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
Example 2:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ cat test.cpp&lt;br /&gt;
#include &amp;lt;iostream&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;VeriVisitor.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriId.h&amp;quot;&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;
class MyVisitor : public VeriVisitor&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
    MyVisitor() : VeriVisitor() { }&lt;br /&gt;
    virtual ~MyVisitor() { }&lt;br /&gt;
&lt;br /&gt;
    virtual void VERI_VISIT(VeriBindDirective, node)&lt;br /&gt;
    {&lt;br /&gt;
        char *str = node.GetPrettyPrintedString() ;&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; &amp;quot;    bind directive: &amp;quot; &amp;lt;&amp;lt; str;&lt;br /&gt;
        Strings::free(str) ;&lt;br /&gt;
        VeriModuleItem *verimoduleitem = node.GetInstantiation();&lt;br /&gt;
        if (verimoduleitem-&amp;gt;IsInstantiation()) {&lt;br /&gt;
            VeriModuleInstantiation *instantiation = static_cast &amp;lt;VeriModuleInstantiation *&amp;gt;(verimoduleitem);&lt;br /&gt;
            str = instantiation-&amp;gt;GetPrettyPrintedString() ;&lt;br /&gt;
            std::cout &amp;lt;&amp;lt; &amp;quot;        instantiation: &amp;quot; &amp;lt;&amp;lt; str ;&lt;br /&gt;
            VeriModule *mod = instantiation-&amp;gt;GetInstantiatedModule();&lt;br /&gt;
            if (mod) {&lt;br /&gt;
                std::cout &amp;lt;&amp;lt; &amp;quot;            instantiated module: &amp;quot; &amp;lt;&amp;lt; mod-&amp;gt;Name() &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;;&lt;br /&gt;
            }&lt;br /&gt;
            Array *ids = instantiation-&amp;gt;GetIds();&lt;br /&gt;
            unsigned i;&lt;br /&gt;
            VeriInstId *instid;&lt;br /&gt;
            FOREACH_ARRAY_ITEM (ids, i, instid) {&lt;br /&gt;
                std::cout &amp;lt;&amp;lt; &amp;quot;            instance name: &amp;quot; &amp;lt;&amp;lt; instid-&amp;gt;Name() &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;;&lt;br /&gt;
            }&lt;br /&gt;
            Strings::free(str) ;&lt;br /&gt;
        }&lt;br /&gt;
        Array *target_inst_list = node.GetTargetInstanceList();&lt;br /&gt;
        unsigned i;&lt;br /&gt;
        VeriExpression *target_instance ;&lt;br /&gt;
        FOREACH_ARRAY_ITEM(target_inst_list, i, target_instance) {&lt;br /&gt;
            if (!target_instance) continue ;&lt;br /&gt;
            char *str = target_instance-&amp;gt;GetPrettyPrintedString() ;&lt;br /&gt;
            std::cout &amp;lt;&amp;lt; &amp;quot;        target_instance: &amp;quot; &amp;lt;&amp;lt; str;&lt;br /&gt;
            Strings::free(str) ;&lt;br /&gt;
            std::cout &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
} ;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
    if (!veri_file::Analyze(&amp;quot;test.v&amp;quot;, veri_file::SYSTEM_VERILOG)) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    MyVisitor mv ;&lt;br /&gt;
&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    VeriModule *mod ;&lt;br /&gt;
    FOREACH_VERILOG_MODULE(mi, mod) if (mod) mod-&amp;gt;Accept(mv) ;&lt;br /&gt;
&lt;br /&gt;
    return 0 ;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$ cat test.v&lt;br /&gt;
module test;&lt;br /&gt;
  sub inst();&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
module foo;&lt;br /&gt;
endmodule&lt;br /&gt;
&lt;br /&gt;
bind test.inst foo i_foo(.*);&lt;br /&gt;
&lt;br /&gt;
$ test-linux&lt;br /&gt;
-- Analyzing Verilog file 'test.v' (VERI-1482)&lt;br /&gt;
    bind directive: bind test.inst foo i_foo (.* ) ;&lt;br /&gt;
        instantiation: foo i_foo (.* ) ;&lt;br /&gt;
            instantiated module: foo&lt;br /&gt;
            instance name: i_foo&lt;br /&gt;
        target_instance: test.inst&lt;br /&gt;
&lt;br /&gt;
$&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Support_IEEE_1735_encryption_standard&amp;diff=897</id>
		<title>Support IEEE 1735 encryption standard</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Support_IEEE_1735_encryption_standard&amp;diff=897"/>
				<updated>2024-07-25T05:27:36Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Q: Does Verific provide support for IEEE 1735 encryption standard?'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Note: This article mentions only &amp;quot;encryption/decryption '''algorithms''',&amp;quot; but the same arguments also apply to &amp;quot;decryption/encryption '''keys'''.&amp;quot;''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Verific provides APIs with which the licensees can plug in their proprietary encryption/decryption algorithms.&lt;br /&gt;
 &lt;br /&gt;
For technical details, please see:&lt;br /&gt;
 &lt;br /&gt;
[http://www.verific.com/docs/index.php?title=Parsing_Protected_and_IEEE_1735_Encrypted_RTL_Files Parsing Protected and IEEE 1735 Encrypted RTL Files]&lt;br /&gt;
(contact Verific Tech Support if you don't have credentials for Verific Documentation).&lt;br /&gt;
 &lt;br /&gt;
There are application examples in Verific distribution:&lt;br /&gt;
 &lt;br /&gt;
    examples/verilog/parse_encrypted_RTL&lt;br /&gt;
    examples/verilog/parse_encrypted_RTL_1735style&lt;br /&gt;
&lt;br /&gt;
Verific does not implement nor provide encryption/decryption algorithms for several reasons:&lt;br /&gt;
&lt;br /&gt;
* If Verific were to provide encryption algorithms, Verific would have to provide the decryption algorithms. Verific has always been shipping source code and is not set up to ship binaries. If Verific shipped the implementations of the encryption/decryption algorithms in the form of C++ source code, that would defeat the purpose of encryption in the first place.&lt;br /&gt;
&lt;br /&gt;
* If Verific provided encryption/decryption algorithms, it would ship the same implementations to all of its licensees. Many licensees of Verific are direct competitors. A company would not want its competitors to have access to its encryption/decryption algorithms.&lt;br /&gt;
&lt;br /&gt;
* As the provider of encryption/decryption algorithms, Verific would be responsible for providing measures to prevent security breaching. Since the encryption/decryption implementations were shipped to multiple licensees, there would be no guarantee that the algorithms would enjoy the same protection as the licensees' IPs would. It is not fair nor practical to expect Verific to bear the responsibility.&lt;br /&gt;
&lt;br /&gt;
So the task of encryption/decryption implementations is appropriately reserved to the licensee.&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=How_to_parse_a_string&amp;diff=894</id>
		<title>How to parse a string</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=How_to_parse_a_string&amp;diff=894"/>
				<updated>2024-06-18T17:10:19Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Let's say you want to add a node to the parse tree.&lt;br /&gt;
&lt;br /&gt;
One simple way to do so is to start with a text string, then &amp;quot;parse&amp;quot; that string to get a VHDL or Verilog construct. The construct can then be added to the parse tree.&lt;br /&gt;
&lt;br /&gt;
Below are the APIs to parse a string:&lt;br /&gt;
&lt;br /&gt;
'''Verilog:'''&lt;br /&gt;
* VeriExpression *veri_file::AnalyzeExpr(const char *expr, unsigned verilog_mode=VERILOG_2K, const linefile_type line_file = 0)&lt;br /&gt;
* VeriModuleItem *veri_file::AnalyzeModuleItem(const char *module_item, unsigned verilog_mode=VERILOG_2K, const linefile_type line_file = 0, VeriScope *container_scope = 0)&lt;br /&gt;
* VeriStatement *veri_file::AnalyzeStatement(const char *statement, unsigned verilog_mode=VERILOG_2K, const linefile_type line_file = 0, VeriScope *container_scope = 0)&lt;br /&gt;
Notes for Verilog :&lt;br /&gt;
:- appropriate scope information where the given string is valid should be passed to the APIs for them to work properly&lt;br /&gt;
:- need to call Resolve() on the returned parse tree nodes with proper scope where these items will be used&lt;br /&gt;
:- VeriTreeNode::VERI_UNDEF_ENV can be passed as the Resolve() environment&lt;br /&gt;
:- if required the nodes can be added to the existing parse tree using the appropriate APIs&lt;br /&gt;
&lt;br /&gt;
'''VHDL:'''&lt;br /&gt;
* VhdlExpression *vhdl_file::AnalyzeExpr(const char *expr, unsigned vhdl_mode=VHDL_93, const linefile_type line_file=0)&lt;br /&gt;
* VhdlStatement *vhdl_file::AnalyzeSequentialStatement(const char *statement, unsigned vhdl_mode = VHDL_93, const char *lib_name = &amp;quot;work&amp;quot;, const linefile_type line_file = 0, * VhdlScope *container_scope = 0)&lt;br /&gt;
* VhdlStatement *vhdl_file::AnalyzeConcurrentStatement(const char *statement, unsigned vhdl_mode = VHDL_93, const char *lib_name = &amp;quot;work&amp;quot;, const linefile_type line_file = 0, VhdlScope *container_scope = 0)&lt;br /&gt;
* VhdlDesignUnit *vhdl_file::AnalyzeUnit(const char *unit, unsigned vhdl_mode = VHDL_93, const char *lib_name = &amp;quot;work&amp;quot;, const linefile_type line_file = 0)&lt;br /&gt;
Notes for VHDL :&lt;br /&gt;
:- appropriate scope information where the given string is valid should be passed to the APIs for them to work properly&lt;br /&gt;
:- need vhdl_file::AnalyzeSequentialStatement() as well as vhdl_file::AnalyzeConcurrentStatement() to differentiate between the starting points of the two&lt;br /&gt;
:- Verilog AnalyzeModuleItem() = both VHDL AnalyzeConcurrentStatement() and VHDL AnalyzeUnit()&lt;br /&gt;
:- Verilog AnalyzeStatement() = VHDL AnalyzeSequentialStatement()&lt;br /&gt;
&lt;br /&gt;
An example excerpt of C++ code using AnalyzeExpr() is as follows :&lt;br /&gt;
    VeriExpression *expr = veri_file::AnalyzeExpr(expr_string, veri_file::SYSTEM_VERILOG);&lt;br /&gt;
    VeriScope *current_scope = module-&amp;gt;GetScope() ;&lt;br /&gt;
    if (expr) {&lt;br /&gt;
        expr-&amp;gt;Resolve(current_scope, VeriTreeNode::VERI_UNDEF_ENV);&lt;br /&gt;
        // plus anything else user may want to add&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Full designs can be analyzed from strings as well. Please use streams for that.&lt;br /&gt;
See [https://www.verific.com/docs/index.php?title=Analyzing_Stream_Inputs Analyzing Stream Inputs]&lt;br /&gt;
&lt;br /&gt;
Below is a C++ code example of using string parsing (veri_file::AnalyzeModuleItem()) to add a module to the parsetree.&lt;br /&gt;
&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;
#include &amp;quot;VeriModule.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriId.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriScope.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriLibrary.h&amp;quot;&lt;br /&gt;
#include &amp;quot;DataBase.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriWrite.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;Array.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;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    // Analyze the file:&lt;br /&gt;
    Array files(1) ;&lt;br /&gt;
    files.InsertLast(&amp;quot;test.v&amp;quot;) ;&lt;br /&gt;
    if (!veri_file::AnalyzeMultipleFiles(&amp;amp;files, veri_file::SYSTEM_VERILOG, &amp;quot;work&amp;quot;)) return 1 ;&lt;br /&gt;
&lt;br /&gt;
    // Get the 'top' module:&lt;br /&gt;
    VeriModule *top = veri_file::GetModule(&amp;quot;test&amp;quot;) ;&lt;br /&gt;
    if (!top) return 2 ;&lt;br /&gt;
&lt;br /&gt;
    // Get the library of the 'top' module:&lt;br /&gt;
    VeriLibrary *work_lib = top-&amp;gt;GetLibrary() ;&lt;br /&gt;
    if (!work_lib) return 4 ;&lt;br /&gt;
&lt;br /&gt;
    // Get the compilation unit of the 'top' module and then the compilation unit scope where the class is declared:&lt;br /&gt;
    VeriModule *root = top-&amp;gt;GetCompilationUnit() ;&lt;br /&gt;
    VeriScope *scope = (root) ? root-&amp;gt;GetScope() : 0 ;&lt;br /&gt;
&lt;br /&gt;
    // Analyze a new module under the scope of the compilation unit:&lt;br /&gt;
    linefile_type dummy_lf = LineFile::EncodeLineFile(&amp;quot;read-from-string&amp;quot;, 1) ;&lt;br /&gt;
    VeriModuleItem *mi = veri_file::AnalyzeRootItem(&amp;quot;module new_module ( RESET, SET, CLK, IN, O );parameter INIT = 1'b0;input RESET;input SET;input CLK;input IN;output reg O = INIT;endmodule&amp;quot;, veri_file::SYSTEM_VERILOG, dummy_lf, scope) ;&lt;br /&gt;
    if (!mi) return 5 ;&lt;br /&gt;
&lt;br /&gt;
    // Get the identifier of the module item:&lt;br /&gt;
    VeriIdDef *id = mi-&amp;gt;GetId() ;&lt;br /&gt;
    if (!id) return 6 ;&lt;br /&gt;
&lt;br /&gt;
    // Get the VeriModule * from the identifier of the module:&lt;br /&gt;
    // This will return NULL if it is not actually a module.&lt;br /&gt;
    VeriModule *mod = id-&amp;gt;GetModule() ;&lt;br /&gt;
    if (!mod) return 7 ;&lt;br /&gt;
&lt;br /&gt;
    // Add to user defined library:&lt;br /&gt;
    VeriLibrary *user_define_lib = veri_file::GetLibrary(&amp;quot;new_lib&amp;quot;, 1 /* create if needed */) ;&lt;br /&gt;
    VERIFIC_ASSERT(user_define_lib) ; // Must be there, should be created if it was not there&lt;br /&gt;
    if (!user_define_lib-&amp;gt;AddModule(mod)) return 8 ;&lt;br /&gt;
&lt;br /&gt;
    mod-&amp;gt;Resolve(scope, VeriTreeNode::VERI_UNDEF_ENV) ;&lt;br /&gt;
&lt;br /&gt;
    veri_file::PrettyPrint(&amp;quot;pp.v.golden.new&amp;quot;, 0) ;&lt;br /&gt;
&lt;br /&gt;
    // Finally, elaborate the top module:&lt;br /&gt;
    veri_file::AddLOption(&amp;quot;user_define_lib&amp;quot;) ;&lt;br /&gt;
    if (!veri_file::Elaborate(&amp;quot;test&amp;quot;)) return 9 ;&lt;br /&gt;
&lt;br /&gt;
    Netlist *top_nl = Netlist::PresentDesign() ;&lt;br /&gt;
    if (!top_nl) return 10 ;&lt;br /&gt;
&lt;br /&gt;
    VeriWrite vw ;&lt;br /&gt;
    vw.WriteFile (&amp;quot;netlist_out.v.golden.new&amp;quot;, top_nl) ;&lt;br /&gt;
&lt;br /&gt;
    return 0 ;&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Source_code_customization_%26_Stable_release_services&amp;diff=893</id>
		<title>Source code customization &amp; Stable release services</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Source_code_customization_%26_Stable_release_services&amp;diff=893"/>
				<updated>2024-05-08T17:23:51Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;On Verific's system, each of our licensees has a separate code branch. There are mechanisms in place to prevent cross-contamination among code branches, helping to ensure their privacy and security.  With this implementation Verific is able to offer two complimentary services to our licensees : ''Source Code Customization'' and ''Stable Release Maintenance''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''1. Source Code Customization&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
A licensee can send in custom code modifications to be merged into their branch maintained by Verific.  The customizations will be included in future source code releases so that the licensee will not need to merge them manually each time.  Please note the following :&lt;br /&gt;
&lt;br /&gt;
* The modified code should be complete and compilable on Verific's system.&lt;br /&gt;
&lt;br /&gt;
* Zip the modified code with the same password used for the monthly code releases.&lt;br /&gt;
&lt;br /&gt;
* Mention the Verific release version that the modifications are based upon.&lt;br /&gt;
&lt;br /&gt;
The licensee can include testcases that exercise the customized code. These testcases will be added to the regression testsuite of the licensee's code branch.&lt;br /&gt;
&lt;br /&gt;
The best way to initiate this process is for the licensee to file a VIPER issue with Type &amp;quot;Merge Request&amp;quot; and attach the zip file of the code modifications to the VIPER issue. This VIPER issue will be closed (not just &amp;quot;fixed&amp;quot;) when the code merge has been completed. The licensee will receive an email notice when the VIPER issue is closed.&lt;br /&gt;
&lt;br /&gt;
'''Important notes:''' Verific will maintain the code changes, but the ownership still lies with the customer and issues arising from it, if any, need to be corrected by the customer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''2. Stable Release Maintenance&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
A Stable release is a physically separate branch of a licensee's code on Verific's system.  It is treated as a distinct &amp;quot;customer&amp;quot; branch.  There are no connections between a Stable branch and the licensee's normal branch.  A Stable branch is usually requested by a licensee when a specific monthly normal branch has been extensively tested and integrated into the licensee's tool and there is a need to maintain this branch of code for a longer period of time than the regular monthly Verific releases.  Some notes to keep in mind about the Stable branch :&lt;br /&gt;
&lt;br /&gt;
*   After creation, Stable branch code can only be changed to fix Stable branch VIPER issues.  VIPER issues filed for a Stable branch are treated as &amp;quot;customer-specific&amp;quot;.  In other words, VIPER fixes in a Stable branch don't go into the normal branch and, likewise, VIPER fixes in the normal branch don't go into a Stable branch.&lt;br /&gt;
&lt;br /&gt;
*   To avoid having new issues introduced into a Stable branch, only defect (not enhancement) VIPERs are allowed for a Stable branch.&lt;br /&gt;
&lt;br /&gt;
*   If an issue needs to be fixed in both a Stable branch and in the normal branch, two separate VIPER issues will need to be filed : one for the Stable branch and one for the normal branch.&lt;br /&gt;
&lt;br /&gt;
*   Stable branch code can not be merged into normal branch code.&lt;br /&gt;
&lt;br /&gt;
*   When a Stable branch has served its purpose and is ready to be retired, the licensee should inform Verific about this decision as soon as possible.  We will then archive the branch and stop its maintenance, helping to free up our time and resources.&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Using_TypeRange_table_to_retrieve_the_originating_type-range_for_an_id&amp;diff=892</id>
		<title>Using TypeRange table to retrieve the originating type-range for an id</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Using_TypeRange_table_to_retrieve_the_originating_type-range_for_an_id&amp;diff=892"/>
				<updated>2024-04-23T18:35:47Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: Created page with &amp;quot;C++:  &amp;lt;nowiki&amp;gt; #include &amp;quot;veri_file.h&amp;quot; #include &amp;quot;DataBase.h&amp;quot; #include &amp;quot;Map.h&amp;quot; #include &amp;quot;Set.h&amp;quot;  #ifdef VERIFIC_NAMESPACE using namespace Verific ; #endif  int main() {     Runt...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;C++:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;quot;veri_file.h&amp;quot;&lt;br /&gt;
#include &amp;quot;DataBase.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Map.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Set.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;
int main()&lt;br /&gt;
{&lt;br /&gt;
    RuntimeFlags::SetVar(&amp;quot;db_preserve_user_nets&amp;quot;, 1) ;&lt;br /&gt;
&lt;br /&gt;
    // Need to set this flag&lt;br /&gt;
    RuntimeFlags::SetVar(&amp;quot;db_add_id_vs_netbus_map&amp;quot;, 1) ;&lt;br /&gt;
&lt;br /&gt;
    if (!veri_file::Analyze(&amp;quot;test.sv&amp;quot;, veri_file::SYSTEM_VERILOG)) return 1 ;&lt;br /&gt;
    if (!veri_file::ElaborateAll()) return 2 ;&lt;br /&gt;
&lt;br /&gt;
    Netlist *netlist = Netlist::PresentDesign() ;&lt;br /&gt;
    if (!netlist) return 3 ;&lt;br /&gt;
&lt;br /&gt;
    const char *id_name = 0 ;&lt;br /&gt;
    const TypeRange *type_range = 0 ;&lt;br /&gt;
    char *tr_str = 0 ;&lt;br /&gt;
&lt;br /&gt;
#if 1 // To get the originating type-range for an id (e.g. 'a[0].AW')&lt;br /&gt;
    id_name = &amp;quot;a[0].AW&amp;quot; ;&lt;br /&gt;
    type_range = netlist-&amp;gt;GetTypeRange(id_name, 1) ;&lt;br /&gt;
    tr_str = (type_range) ? type_range-&amp;gt;Dump() : 0 ;&lt;br /&gt;
    netlist-&amp;gt;Info(&amp;quot;'%s' is created from type '%s'&amp;quot;, id_name, tr_str) ;&lt;br /&gt;
    Strings::free(tr_str) ;&lt;br /&gt;
&lt;br /&gt;
#else // To get the originating type-ranges for all nets/buses&lt;br /&gt;
    const Map *type_ranges = netlist-&amp;gt;GetTypeRangeTable() ;&lt;br /&gt;
    if (!type_ranges) return 4 ;&lt;br /&gt;
&lt;br /&gt;
    const Map *id_vs_nets = netlist-&amp;gt;GetIdNetsTable() ;&lt;br /&gt;
    if (!id_vs_nets) return 5 ;&lt;br /&gt;
&lt;br /&gt;
    // Create a mapping of all nets/buses to Verilog id from where they are created:&lt;br /&gt;
    Map net_or_bus_2_id(POINTER_HASH) ;&lt;br /&gt;
    MapIter mi ;&lt;br /&gt;
    const Set *net_or_buses ;&lt;br /&gt;
    DesignObj *net_or_bus ;&lt;br /&gt;
    FOREACH_MAP_ITEM(id_vs_nets, mi, &amp;amp;id_name, &amp;amp;net_or_buses) {&lt;br /&gt;
        SetIter si ;&lt;br /&gt;
        FOREACH_SET_ITEM(net_or_buses, si, &amp;amp;net_or_bus) {&lt;br /&gt;
            (void) net_or_bus_2_id.Insert(net_or_bus, id_name) ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Now get the id-name of all nets/buses from the above mapping and find them from the type-range table.&lt;br /&gt;
    Set done_buses(POINTER_HASH) ;&lt;br /&gt;
    const Net *net ;&lt;br /&gt;
    const NetBus *bus ;&lt;br /&gt;
    FOREACH_NET_OF_NETLIST(netlist, mi, net) {&lt;br /&gt;
        if (!net || !net-&amp;gt;IsUserDeclared()) continue ;&lt;br /&gt;
        bus = net-&amp;gt;Bus() ;&lt;br /&gt;
        if (bus &amp;amp;&amp;amp; !done_buses.Insert(bus)) continue ;&lt;br /&gt;
        net_or_bus = (bus) ? (DesignObj*)bus : (DesignObj*)net ;&lt;br /&gt;
        id_name = (const char *)net_or_bus_2_id.GetValue(net_or_bus) ;&lt;br /&gt;
        if (!id_name) {&lt;br /&gt;
            net_or_bus-&amp;gt;Error(&amp;quot;'%s' does not have an associated id&amp;quot;, net_or_bus-&amp;gt;Name()) ;&lt;br /&gt;
            continue ;&lt;br /&gt;
        }&lt;br /&gt;
        type_range = (const TypeRange *)type_ranges-&amp;gt;GetValue(id_name) ;&lt;br /&gt;
        if (!type_range) {&lt;br /&gt;
            net_or_bus-&amp;gt;Error(&amp;quot;'%s' created from '%s' does not have an associated type-range info&amp;quot;, net_or_bus-&amp;gt;Name(), id_name) ;&lt;br /&gt;
            continue ;&lt;br /&gt;
        }&lt;br /&gt;
        tr_str = type_range-&amp;gt;Dump() ;&lt;br /&gt;
        net_or_bus-&amp;gt;Info(&amp;quot;'%s' is created from '%s' of type '%s'&amp;quot;, net_or_bus-&amp;gt;Name(), id_name, tr_str) ;&lt;br /&gt;
        Strings::free(tr_str) ;&lt;br /&gt;
    }&lt;br /&gt;
#endif&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;
pkg.sv:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
package pkg;&lt;br /&gt;
    typedef struct packed {&lt;br /&gt;
        reg [1:0] AA;&lt;br /&gt;
        reg [1:0] BB;&lt;br /&gt;
    } t1;&lt;br /&gt;
    typedef struct packed {&lt;br /&gt;
        reg [5:0] CC;&lt;br /&gt;
        reg DD;&lt;br /&gt;
    } t2;&lt;br /&gt;
    typedef struct packed {&lt;br /&gt;
        t1 AW;&lt;br /&gt;
        t2 BW;&lt;br /&gt;
    } mst;&lt;br /&gt;
endpackage // pkg&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
test.sv:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
`include &amp;quot;pkg.sv&amp;quot;&lt;br /&gt;
module top (&lt;br /&gt;
          input clk, rst,&lt;br /&gt;
          input [5:0] a_in,&lt;br /&gt;
          input [5:0] b_in&lt;br /&gt;
          );&lt;br /&gt;
    wire pkg::mst a[3:0];&lt;br /&gt;
    assign a[0].AW.AA = a_in[1:0];&lt;br /&gt;
    assign a[0].AW.BB = a_in[4:2];&lt;br /&gt;
    assign a[0].BW.CC = a_in | b_in;&lt;br /&gt;
    assign a[0].BW.DD = 1;&lt;br /&gt;
endmodule&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
$ test-linux &lt;br /&gt;
-- Analyzing Verilog file 'test.sv' (VERI-1482)&lt;br /&gt;
test.sv(1): INFO: analyzing included file 'pkg.sv' (VERI-1328)&lt;br /&gt;
test.sv(1): INFO: back to file 'test.sv' (VERI-2320)&lt;br /&gt;
test.sv(2): INFO: compiling module 'top' (VERI-1018)&lt;br /&gt;
test.sv(9): WARNING: expression size 3 truncated to fit in target size 2 (VERI-1209)&lt;br /&gt;
test.sv(2): INFO: 'a[0].AW' is created from type ' {struct packed &amp;lt;t1&amp;gt; {AA : [1:0] reg, BB : [1:0] reg}}'&lt;br /&gt;
$ &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Main_Page&amp;diff=891</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Main_Page&amp;diff=891"/>
				<updated>2024-04-23T18:30:13Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''General'''&lt;br /&gt;
* [[How to get best support from Verific | '''''How to get best support from Verific''''']]&lt;br /&gt;
* [[Source code customization &amp;amp; Stable release services | Source code customization &amp;amp; Stable release services]]&lt;br /&gt;
* [[How to save computer resources | How to save computer resources (memory consumption &amp;amp; runtime)]]&lt;br /&gt;
* [[Original RTL language | How do I know what language a Netlist in the netlist database comes from?]]&lt;br /&gt;
* [[Verific data structures | What are the data structures in Verific?]]&lt;br /&gt;
* [[Remove Verific data structures | How do I remove all Verific data structures in memory?]]&lt;br /&gt;
* [[Does Verific build CDFG? | Does Verific build control and data flow graph (CDFG)?]]&lt;br /&gt;
* [[Does Verific support XMR?| Does Verific support cross module references (XMR)?]]&lt;br /&gt;
* [[Compile-time/run-time flags | Are there options to control Verific software's behavior? Compile-time &amp;amp; run-time flags.]]&lt;br /&gt;
* [[Message handling | How do I downgrade/upgrade messages from Verific? How do I get messages with more details?]]&lt;br /&gt;
* [[Release version | How do I tell the version of a Verific software release? ]]&lt;br /&gt;
* [[Simulation models for Verific primitives | Where do I find simulation models for Verific primitives (VERIFIC_XOR, VERIFIC_DFFRS, ....)? ]]&lt;br /&gt;
* [[Tcl library path| How to correct building (linking) issue &amp;quot;/usr/bin/ld: cannot find -ltcl&amp;quot;]]&lt;br /&gt;
* [[LineFile data from input files | LineFile data from input files]]&lt;br /&gt;
* [[Difference between RTL and gate-level simulations - Flipflop with async set and async reset | Difference between RTL and gate-level simulations - Flipflop with async set and async reset]]&lt;br /&gt;
* [[Preserving user nets - preventing nets from being optimized away | Preserving user nets - preventing nets from being optimized away]]&lt;br /&gt;
* [[Python pretty-printer for gdb | Python pretty-printer for gdb]]&lt;br /&gt;
&lt;br /&gt;
'''Input: VHDL, Verilog (and SystemVerilog), Liberty, EDIF'''&lt;br /&gt;
* [[How to get all Verilog files being analyzed | Verilog: I'm using -v, -y, .... After Verific is done with the analysis, how do I get a list of all the files being analyzed?]]&lt;br /&gt;
* [[Included files associated with a Verilog source file | Verilog: How do I get the list of included files associated with a Verilog source file?]]&lt;br /&gt;
* [[How to get type/initial value of parameters | Verilog: How to get type/initial value of parameters.]]&lt;br /&gt;
* [[Verilog ports being renamed | Verilog: Port Expressions]]&lt;br /&gt;
* [[Design with System Verilog and Verilog 2001 files | Verilog: For a design consisting of a mixture of Verilog 2001 and SystemVerilog input files, should I parse all the files as SystemVerilog?]]&lt;br /&gt;
* [[How to get module ports from Verilog parsetree | Verilog: From the Verilog parsetree, how can I get the ports of a module?]]&lt;br /&gt;
* [[How to change name of id in Verilog parsetree | Verilog: How do I change the name of an id (VeriidDef) in Verilog parsetree?]]&lt;br /&gt;
* [[How to get library containing nested module | Verilog: How do I get nested modules and get the library that contains the nested module?]]&lt;br /&gt;
* [[How to get linefile information of macro definitions | Verilog: How do I get linefile information of macro definitions?]]&lt;br /&gt;
* [[How to find port dimensions | Verilog: How do I get port dimensions?]]&lt;br /&gt;
* [[Instance - Module binding order | Verilog: What is the order of binding modules to instances?]]&lt;br /&gt;
* [[How Verific elaborator handles blackboxes/unknown boxes | Verilog: How Verific elaborator handles blackboxes/unknown boxes]]&lt;br /&gt;
* [[Constant expression replacement | Verilog: Does Verific replace constant expressions with their respective values?]]&lt;br /&gt;
* [[Modules with '_1' '_2' suffix in their names | Verilog: After static elaboration, there are modules with &amp;quot;_1&amp;quot;, &amp;quot;_2&amp;quot;, ..., suffix in their names. Why?]]&lt;br /&gt;
* [[Defined macros become undefined - MFCU vs SFCU | SystemVerilog: Why does Verific complain about undefined macros for macros defined in a different file (Compilation Unit)?]]&lt;br /&gt;
* [[Notes on analysis | SystemVerilog: Notes on analysis]]&lt;br /&gt;
* [[How to get enums from Verilog parsetree | SystemVerilog: From the parsetree, how can I get the enums declared in a module?]]&lt;br /&gt;
* [[How to identify packages being imported into a module | SystemVerilog: How do I identify packages being imported into a module?]]&lt;br /&gt;
* [[SystemVerilog &amp;quot;std&amp;quot; package | SystemVerilog: Support for SystemVerilog semaphore/process/mailbox constructs.]]&lt;br /&gt;
* [[Top level module with interface ports | SystemVerilog: Support for SystemVerilog top level module with interface ports.]]&lt;br /&gt;
* [[Design with VHDL-1993 and VHDL-2008 files | VHDL: VHDL-1993 and VHDL-2008 each has its own IEEE library set. How do I analyze/elaborate a design with a mixture of files of different VHDL dialects (1993 and 2008)?]]&lt;br /&gt;
* [[Escaped identifiers in RTL files and in Verific data structures | Verilog/VHDL: Escaped identifiers in RTL files and in Verific data structures]]&lt;br /&gt;
* [[Prettyprint to a string | Verilog/VHDL: How to prettyprint a parsetree node to a string.]]&lt;br /&gt;
* [[Static elaboration | Verilog/VHDL: What does 'static elaboration' do?]]&lt;br /&gt;
* [[How to ignore a (not used) parameter/generic in elaboration. | Verilog/VHDL: How to ignore a (not used) parameter/generic in elaboration.]]&lt;br /&gt;
* [[What VeriModule* or VhdlPrimaryUnit* the Netlist comes from? | Verilog/VHDL: For a Netlist in the netlist database, is there a clean way to look back at what VeriModule* or VhdlPrimaryUnit* the Netlist was derived from?]]&lt;br /&gt;
* [[Cross-reference between the original RTL files and the elaborated netlist | Verilog/VHDL: Is there a way to cross-reference between the original RTL design files and the elaboration netlist?]]&lt;br /&gt;
* [[How to ignore parameters/generics in elaboration | Verilog/VHDL: Is there a way to tell the elaborator to ignore certain parameters/generics so that the unit/module is not uniquified?]]&lt;br /&gt;
* [[How to check for errors in analysis/elaboration | Verilog/VHDL: Is there a way to tell if the analysis/elaboration process has errors?]]&lt;br /&gt;
* [[Modules/design units with &amp;quot;_default&amp;quot; suffix in their names | Verilog/VHDL: After static elaboration, there are modules/design units/interfaces with &amp;quot;_default&amp;quot; suffix in their names. Why? And what are they?]]&lt;br /&gt;
* [[How to parse a string | Verilog/VHDL: How to parse a string - Example of adding a module to the parsetree]]&lt;br /&gt;
* [[Support IEEE 1735 encryption standard | Verilog/VHDL: Does Verific support IEEE 1735 encryption standard?]]&lt;br /&gt;
'''Netlist Database'''&lt;br /&gt;
* [[Logic optimization across hierarchy boundaries | Netlist Database: Does Verific perform logic optimization across hierarchy boundaries?]]&lt;br /&gt;
* [[Bit-blasting a multi-port RAM instance | Netlist Database: Bit-blasting a multi-port RAM instance]]&lt;br /&gt;
* [[System attributes | Netlist Database: System attributes]]&lt;br /&gt;
&lt;br /&gt;
'''Output'''&lt;br /&gt;
* [[Output file formats | What language formats does Verific support as output?]]&lt;br /&gt;
&lt;br /&gt;
'''Scripting languages: TCL, Perl, Python'''&lt;br /&gt;
* [[What languages can I use with Verific software? | What programming languages can I use with Verific software?]]&lt;br /&gt;
&lt;br /&gt;
'''Code examples'''&lt;br /&gt;
* [[How to use RegisterCallBackMsg() | Util/C++: How to use RegisterCallBackMsg()]]&lt;br /&gt;
* [[How to use MessageCallBackHandler Class | Util/C++: How to use MessageCallBackHandler Class]]&lt;br /&gt;
* [[How to use RegisterPragmaRefCallBack() | Util/C++: How to use RegisterPragmaRefCallBack()]]&lt;br /&gt;
* [[Write out an encrypted netlist | Database/C++: Write out an encrypted netlist]]&lt;br /&gt;
* [[Extract clock enable | Database/C++: Extract clock enable]]&lt;br /&gt;
* [[Black box, empty box, and unknown box | Database/C++: Black box, empty box, and unknown box]]&lt;br /&gt;
* [[Post processing port resolution of black boxes | Database/C++: Post processing port resolution of black boxes]]&lt;br /&gt;
* [[Finding hierarchical paths of a Netlist | Database/C++: Finding hierarchical paths of a Netlist]]&lt;br /&gt;
* [[Replacing Verific built-in primitives/operators with user implementations | Database/C++: Replacing Verific built-in primitives/operators with user implementations]]&lt;br /&gt;
* [[Hierarchy tree RTL elaboration | Database/Perl: Simple example of hierarchy tree elaboration]]&lt;br /&gt;
* [[Create a Netlist Database from scratch (not from RTL elaboration) | Database/Perl/TCL: Create a Netlist Database from scratch (not from RTL elaboration)]]&lt;br /&gt;
* [[Buffering signals and ungrouping | Database/Verilog: Buffering signals and ungrouping (flattening) in the Netlist Database]]&lt;br /&gt;
* [[Memory elements of a RamNet | Database/Verilog/C++: Memory elements of a RamNet]]&lt;br /&gt;
* [[Process -f file and explore the Netlist Database (C++)| Database/Verilog/C++: Process -f file and explore the Netlist Database]]&lt;br /&gt;
* [[Process -f file and explore the Netlist Database (py)| Database/Verilog/Python: Process -f file and explore the Netlist Database]]&lt;br /&gt;
* [[Fanout cone and grouping | Database/Verilog/Perl: Fanout cone and grouping in the Netlist Database]]&lt;br /&gt;
* [[Type Range example | Database/Verilog/C++: Type Range example  (simple)]]&lt;br /&gt;
* [[Type Range example with multi-dimensional arrays| Database/Verilog/C++/Perl: Type Range example with multi-dimensional arrays]]&lt;br /&gt;
* [[Using TypeRange table to retrieve the originating type-range for an id | Database/Verilog/C++: Using TypeRange table to retrieve the originating type-range for an id]]&lt;br /&gt;
* [[Simple example of visitor pattern | Verilog/C++: Simple examples of visitor pattern]]&lt;br /&gt;
* [[Statically elaborate with different values of parameters | Verilog/C++: Statically elaborate with different values of parameters]]&lt;br /&gt;
* [[Prettyprint all modules in the design hierarchy | Verilog/C++: Prettyprint all modules in the design hierarchy]]&lt;br /&gt;
* [[Getting instances' parameters | Verilog/C++: Getting instances' parameters]]&lt;br /&gt;
* [[Accessing and evaluating module's parameters | Verilog/C++: Accessing and evaluating module's parameters]]&lt;br /&gt;
* [[Visiting Hierarchical References (VeriSelectedName) | Verilog/C++: Visiting Hierarchical References (VeriSelectedName)]]&lt;br /&gt;
* [[Using stream input to ignore input file | Verilog/C++: Using stream input to ignore input file]]&lt;br /&gt;
* [[How to ignore certain modules while analyzing input RTL files | Verilog/C++: How to ignore certain modules while analyzing input RTL files]]&lt;br /&gt;
* [[How to tell if a module has encrypted contents | Verilog/C++: How to tell if a module has encrypted contents]]&lt;br /&gt;
* [[Comment out a line using text based design modification and parsetree modification | Verilog/C++: Comment out a line using text-based design modification and parsetree modification]] &lt;br /&gt;
* [[Verilog/C++: How to use IsUserDeclared() : Example for port associations]]&lt;br /&gt;
* [[How to create new module in Verilog parsetree | Verilog/C++: How to create new module in Verilog parsetree]]&lt;br /&gt;
* [[In Verilog parsetree adding names to unnamed instances | Verilog/C++: In Verilog parsetree adding names to unnamed instances]]&lt;br /&gt;
* [[How to get full hierarchy ID path | Verilog/C++: How to get full hierarchy ID path]]&lt;br /&gt;
* [[How to traverse scope hierarchy | Verilog/C++: How to traverse scope hierarchy]]&lt;br /&gt;
* [[Access attributes in parsetree | Verilog/C++: How to access attributes in parsetree]]&lt;br /&gt;
* [[How to detect multiple-clock-edge condition in Verilog parsetree | Verilog/C++: How to detect multiple-clock-edge condition in Verilog parsetree]]&lt;br /&gt;
* [[How to get driving net of an instance | Verilog/C++: How to get driving net of an instance]]&lt;br /&gt;
* [[Parse select modules only and ignore the rest | Verilog/C++: Parse select modules only and ignore the rest]]&lt;br /&gt;
* [[Create DOT diagram of parse tree | Verilog/C++: Create DOT diagram of a parse tree]]&lt;br /&gt;
* [[How to get linefile data of macros - Macro callback function | Verilog/C++/Perl/Python: How to get linefile data of macros - Macro callback function]]&lt;br /&gt;
* [[Where in RTL does it get assigned? | Verilog/C++/Perl/Python: Where in RTL does it get assigned?]]&lt;br /&gt;
* [[Access attributes of ports in parsetree | Verilog/Perl: Access attributes of ports in parsetree and from netlist]]&lt;br /&gt;
* [[Evaluate 'for-generate' loop | Verilog/C++: Evaluate 'for-generate' loop]]&lt;br /&gt;
* [[Retrieve package name for user-defined variable types | SystemVerilog/C++/Python: Retrieve package name for user-defined variable types]]&lt;br /&gt;
* [[Pretty-print a module and the packages imported by the module | SystemVerilog/C++: Pretty-print a module and the packages imported by the module]]&lt;br /&gt;
* [[How to get packed dimensions of enum | SystemVerilog/C++: How to get packed dimensions of enum]]&lt;br /&gt;
* [[Simple examples of VHDL visitor pattern | VHDL/C++: Simple examples of VHDL visitor pattern]]&lt;br /&gt;
* [[Traverse instances in parsetree | VHDL/C++: Traverse instances in parsetree]]&lt;br /&gt;
* [[Parsing from data in memory | Verilog/VHDL/C++: Parsing from data in memory]]&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=In_Verilog_parsetree_adding_names_to_unnamed_instances&amp;diff=890</id>
		<title>In Verilog parsetree adding names to unnamed instances</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=In_Verilog_parsetree_adding_names_to_unnamed_instances&amp;diff=890"/>
				<updated>2024-04-04T02:52:10Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In Verilog, each module instantiation should have a name. But name is optional for UDP instantiation and Verilog primitive instantiation.&lt;br /&gt;
&lt;br /&gt;
Verific issues a warning for unnamed module instantiation:&lt;br /&gt;
&lt;br /&gt;
  test.v(16): WARNING: instantiating unknown module 'foo' (VERI-1063)&lt;br /&gt;
&lt;br /&gt;
The warning is issued during elaboration because in analysis, it is not known whether the instantiated construct is a module, a UDP, or a primitive.&lt;br /&gt;
&lt;br /&gt;
This application adds a name to each unnamed module instantiation. Note that this application has facilities to keep track of the scope of the instantiation statement.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&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;VeriId.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriExpression.h&amp;quot;&lt;br /&gt;
#include &amp;quot;VeriScope.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Map.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
using namespace std ;&lt;br /&gt;
#ifdef VERIFIC_NAMESPACE&lt;br /&gt;
using namespace Verific ;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
class MyVisitor : public VeriVisitor&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
    MyVisitor() : VeriVisitor(), _scope_stack(0) { }&lt;br /&gt;
    virtual ~MyVisitor() { }&lt;br /&gt;
&lt;br /&gt;
    virtual void VERI_VISIT(VeriModuleInstantiation, node)&lt;br /&gt;
    {&lt;br /&gt;
        VeriScope *current_scope = GetCurrentScope() ;&lt;br /&gt;
        Array *inst_ids ;&lt;br /&gt;
        inst_ids = node.GetIds() ;&lt;br /&gt;
        unsigned i ;&lt;br /&gt;
        VeriInstId *inst_id ;&lt;br /&gt;
        FOREACH_ARRAY_ITEM(inst_ids, i, inst_id) {&lt;br /&gt;
            if (!inst_id) continue ;&lt;br /&gt;
            const char *inst_name = inst_id-&amp;gt;InstName() ;&lt;br /&gt;
            char *allocated_inst_name = 0 ;&lt;br /&gt;
            if (!inst_name &amp;amp;&amp;amp; current_scope) {&lt;br /&gt;
                VeriIdDef *scope_id = current_scope-&amp;gt;GetOwner();&lt;br /&gt;
                unsigned uniq_no = 0 ;&lt;br /&gt;
                char *suffix = Strings::itoa((int)(uniq_no)) ;&lt;br /&gt;
                char *prefix = (scope_id &amp;amp;&amp;amp; scope_id-&amp;gt;Name()) ? Strings::save(&amp;quot;unnamed_inst_&amp;quot;, scope_id-&amp;gt;Name(), &amp;quot;_&amp;quot;) : Strings::save(&amp;quot;unnamed_inst_&amp;quot;) ;&lt;br /&gt;
                allocated_inst_name = Strings::save(prefix, suffix) ;&lt;br /&gt;
                while (current_scope-&amp;gt;FindLocal(allocated_inst_name) &amp;amp;&amp;amp; (uniq_no &amp;lt; 1000)) {&lt;br /&gt;
                    Strings::free(allocated_inst_name) ;&lt;br /&gt;
                    Strings::free(suffix) ;&lt;br /&gt;
                    suffix = Strings::itoa((int)(uniq_no)) ;&lt;br /&gt;
                    allocated_inst_name = Strings::save(prefix, suffix) ;&lt;br /&gt;
                    uniq_no++ ;&lt;br /&gt;
                }&lt;br /&gt;
                current_scope-&amp;gt;Undeclare(inst_id) ;&lt;br /&gt;
                inst_id-&amp;gt;SetName(allocated_inst_name) ;&lt;br /&gt;
                current_scope-&amp;gt;Declare(inst_id, 0, 0) ;&lt;br /&gt;
                Strings::free(allocated_inst_name) ;&lt;br /&gt;
                Strings::free(suffix) ;&lt;br /&gt;
                Strings::free(prefix) ;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    virtual void PreAction(VeriTreeNode &amp;amp;node)&lt;br /&gt;
    {&lt;br /&gt;
        // Push the scope of the current node into the stack:&lt;br /&gt;
        const VeriModuleItem *item = dynamic_cast&amp;lt;VeriModuleItem *&amp;gt;(&amp;amp;node) ;&lt;br /&gt;
        VeriScope *scope = (item) ? item-&amp;gt;GetScope() : 0 ;&lt;br /&gt;
        if (scope) _scope_stack.InsertLast(scope) ;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    virtual void PostAction(VeriTreeNode &amp;amp;node)&lt;br /&gt;
    {&lt;br /&gt;
        // Pop the scope of the current node from the stack:&lt;br /&gt;
        const VeriModuleItem *item = dynamic_cast&amp;lt;VeriModuleItem *&amp;gt;(&amp;amp;node) ;&lt;br /&gt;
        VeriScope *scope = (item) ? item-&amp;gt;GetScope() : 0 ;&lt;br /&gt;
        if (scope) (void) _scope_stack.RemoveLast() ;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Get the current/active scope for the parse tree we are visiting:&lt;br /&gt;
    VeriScope *GetCurrentScope() const { return (_scope_stack.Size()) ? (VeriScope *)_scope_stack.GetLast() : 0 ; }&lt;br /&gt;
&lt;br /&gt;
private:&lt;br /&gt;
    Array _scope_stack ;&lt;br /&gt;
} ;&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
    if (!veri_file::Analyze(&amp;quot;test.v&amp;quot;, veri_file::SYSTEM_VERILOG)) return 1 ;&lt;br /&gt;
    veri_file::PrettyPrint (&amp;quot;pp_out_before.v.golden.new&amp;quot;, 0) ;&lt;br /&gt;
    MyVisitor mv ;&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;
        mod-&amp;gt;Accept(mv) ;&lt;br /&gt;
    }&lt;br /&gt;
    veri_file::PrettyPrint (&amp;quot;pp_out_after.v.golden.new&amp;quot;, 0) ;&lt;br /&gt;
    return 0 ;&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=SystemVerilog_%22std%22_package&amp;diff=889</id>
		<title>SystemVerilog &quot;std&quot; package</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=SystemVerilog_%22std%22_package&amp;diff=889"/>
				<updated>2024-02-29T00:05:06Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Q: Support for SystemVerilog semaphore/process/mailbox.'''&lt;br /&gt;
&lt;br /&gt;
When I analyzed my SystemVerilog file, Verific issued error message:&lt;br /&gt;
&lt;br /&gt;
 test.sv(4): ERROR: process is not declared (VERI-1128)&lt;br /&gt;
&lt;br /&gt;
(similarly for &amp;quot;mailbox&amp;quot; and &amp;quot;semaphore&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Does Verific support those SystemVerilog constructs?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
According to SystemVerilog LRM, &amp;quot;process&amp;quot;, &amp;quot;mailbox&amp;quot;, and &amp;quot;semaphore&amp;quot; are classes defined in package &amp;quot;std&amp;quot; in library &amp;quot;std&amp;quot;. Before analyzing the file using these classes, you need to load the &amp;quot;std&amp;quot; package. You can use either of the following ways:&lt;br /&gt;
&lt;br /&gt;
* Analyze the package before loading the design:&lt;br /&gt;
 veri_file::Analyze(&amp;quot;verilog_packages/std.sv&amp;quot;, veri_file::SYSTEM_VERILOG, &amp;quot;std&amp;quot;) ;&lt;br /&gt;
* or load the library on demand using binary/restore method:&lt;br /&gt;
 veri_file::AddLibraryPath(&amp;quot;std&amp;quot;, &amp;quot;verilog_packages/sdbs/std&amp;quot;) ;&lt;br /&gt;
The binary dump file &amp;quot;std.sdb&amp;quot; should be in &amp;quot;verilog_packages/sdbs/std&amp;quot; directory.&lt;br /&gt;
&lt;br /&gt;
* tcl commands:&lt;br /&gt;
&lt;br /&gt;
 setveriloglibrarypath -default ../sdbs&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
 &lt;br /&gt;
 setveriloglibrarypath -associate std=../sdbs/std&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Instance_-_Module_binding_order&amp;diff=883</id>
		<title>Instance - Module binding order</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Instance_-_Module_binding_order&amp;diff=883"/>
				<updated>2024-01-26T00:41:36Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Q: Verilog has many ways to find modules not in the file being directly read: -L, -v, -y, .... There may be more than one module of the same name. What is the order of binding?'''&lt;br /&gt;
&lt;br /&gt;
The order of searching for modules is:&lt;br /&gt;
&lt;br /&gt;
# While parsing:&lt;br /&gt;
## `uselib&lt;br /&gt;
## -L&lt;br /&gt;
## (present working library)&lt;br /&gt;
## -y/-v (their order in an f-file is considered)&lt;br /&gt;
# While elaborating:&lt;br /&gt;
## configurations&lt;br /&gt;
## already resolved module from analysis, ie, order of parsing (above)&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Constant_expression_replacement&amp;diff=867</id>
		<title>Constant expression replacement</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Constant_expression_replacement&amp;diff=867"/>
				<updated>2023-11-17T16:51:38Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Q: Does Verific replace constant expressions with their respective values?'''&lt;br /&gt;
&lt;br /&gt;
I have in my Verilog code:&lt;br /&gt;
    parameter size = 8;&lt;br /&gt;
    reg [size-1:0] foo;&lt;br /&gt;
I expect the range of &amp;quot;foo&amp;quot; to be [7:0]. How do I get the range [7:0]?&lt;br /&gt;
&lt;br /&gt;
If run-time flag &amp;quot;veri_replace_const_exprs&amp;quot; is set, during static elaboration, Verific will replace the following constant expressions with their respective values:&lt;br /&gt;
# Bounds of packed and unpacked ranges in all data declarations.&lt;br /&gt;
# Default values of all declared objects if those are constant.&lt;br /&gt;
# Delay values.&lt;br /&gt;
# Reject and error limits of VeriPathPulse values.&lt;br /&gt;
# Indexed expressions only if the indexed expression is a bit-select on the LHS of a continuous assignment or output/inout port of module or gate instantiation.&lt;br /&gt;
&lt;br /&gt;
Above specific replacements are not done on un-elaborated modules because the parameter values they depend on might be changed later by other applications.&lt;br /&gt;
&lt;br /&gt;
In C++:&lt;br /&gt;
 RuntimeFlags::SetVar(&amp;quot;veri_replace_const_exprs&amp;quot;, 1) ;&lt;br /&gt;
&lt;br /&gt;
In Tcl:&lt;br /&gt;
 set_runtime_flag &amp;quot;veri_replace_const_exprs&amp;quot; 1&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Notes_on_analysis&amp;diff=865</id>
		<title>Notes on analysis</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Notes_on_analysis&amp;diff=865"/>
				<updated>2023-11-01T04:53:25Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;First, please read this article: [[Defined macros become undefined - MFCU vs SFCU]].&lt;br /&gt;
&lt;br /&gt;
'''Q: Can I use 'veri_file::Analyze()' to read SystemVerilog input files one by one, all of them belonging to one compilation unit?'''&lt;br /&gt;
 &lt;br /&gt;
Yes. But if you have multiple files, it’s better to use 'veri_file::AnalyzeMultipleFiles()'.&lt;br /&gt;
 &lt;br /&gt;
'veri_file::AnalyzeMultipleFiles()', besides analyzing each file, also:&lt;br /&gt;
 &lt;br /&gt;
* opens and ends the compilation unit&lt;br /&gt;
* processes –v and –y options&lt;br /&gt;
* removes include directories&lt;br /&gt;
* processes root module&lt;br /&gt;
* undefines user-defined macros, including command-line macros&lt;br /&gt;
* resets compile directives (e.g. `default_nettype, `timescale)&lt;br /&gt;
 &lt;br /&gt;
If you use 'veri_file::Analyze()' to analyze each file one by one, after all the calls to 'veri_file::Analyze(), depending on the application, you may want to run veri_file::RemoveAllIncludeDirs() and veri_file::EndCompilationUnit().&lt;br /&gt;
&lt;br /&gt;
If the application calls any elaboration API (e.g. veri_file::Elaborate()), there is no need to call veri_file::RemoveAllIncludeDirs() and veri_file::EndCompilationUnit() because the elaboration API will call those APIs before actual elaboration.&lt;br /&gt;
&lt;br /&gt;
The TCL command 'analyze' uses the API 'veri_file::AnalyzeMultipleFiles()'. In other words, it assumes a complete compilation unit for each execution.&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Notes_on_analysis&amp;diff=864</id>
		<title>Notes on analysis</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Notes_on_analysis&amp;diff=864"/>
				<updated>2023-11-01T04:52:10Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;First, please read this article: [[Defined macros become undefined - MFCU vs SFCU]].&lt;br /&gt;
&lt;br /&gt;
'''Q: Can I use 'veri_file::Analyze()' to read SystemVerilog input files one by one, all of them belonging to one compilation unit?'''&lt;br /&gt;
 &lt;br /&gt;
Yes. But if you have multiple files, it’s better to use 'veri_file::AnalyzeMultipleFiles()'.&lt;br /&gt;
 &lt;br /&gt;
'veri_file::AnalyzeMultipleFiles()', besides analyzing each file, also:&lt;br /&gt;
 &lt;br /&gt;
* opens and ends the compilation unit&lt;br /&gt;
* processes –v and –y options&lt;br /&gt;
* removes include directories&lt;br /&gt;
* processes root module&lt;br /&gt;
* undefines user-defined macros, including command-line macros&lt;br /&gt;
* resets compile directives (e.g. `default_nettype, `timescale)&lt;br /&gt;
 &lt;br /&gt;
If you use 'veri_file::Analyze()' to analyze each file one by one, after all the calls to 'veri_file::Analyze(), depending on the application, you may also want to run veri_file::RemoveAllIncludeDirs() and veri_file::EndCompilationUnit().&lt;br /&gt;
&lt;br /&gt;
If the application calls any elaboration API (e.g. veri_file::Elaborate()), there is no need to call veri_file::RemoveAllIncludeDirs() and veri_file::EndCompilationUnit() because the elaboration API will call those APIs before actual elaboration.&lt;br /&gt;
&lt;br /&gt;
The TCL command 'analyze' uses the API 'veri_file::AnalyzeMultipleFiles()'. In other words, it assumes a complete compilation unit for each execution.&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Notes_on_analysis&amp;diff=860</id>
		<title>Notes on analysis</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Notes_on_analysis&amp;diff=860"/>
				<updated>2023-10-20T19:13:07Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;First, please read this article: [[Defined macros become undefined - MFCU vs SFCU]].&lt;br /&gt;
&lt;br /&gt;
'''Q: Can I use 'veri_file::Analyze()' to read SystemVerilog input files one by one, all of them belonging to one compilation unit?'''&lt;br /&gt;
 &lt;br /&gt;
Yes. But if you have multiple files, it’s better to use 'veri_file::AnalyzeMultipleFiles()'.&lt;br /&gt;
 &lt;br /&gt;
'veri_file::AnalyzeMultipleFiles()', besides analyzing each file, also:&lt;br /&gt;
 &lt;br /&gt;
* opens and ends the compilation unit&lt;br /&gt;
* processes –v and –y options&lt;br /&gt;
* removes include directories&lt;br /&gt;
* processes root module&lt;br /&gt;
* undefines user-defined macros, including command-line macros&lt;br /&gt;
* resets compile directives (e.g. `default_nettype, `timescale)&lt;br /&gt;
 &lt;br /&gt;
If you use 'veri_file::Analyze()' to analyze each file one by one, after all the calls to 'veri_file::Analyze()', you’ll need to call 'veri_file::AnalyzeFull()' to complete the analysis before starting any other operation. Depending on the application, you may also want to run veri_file::RemoveAllIncludeDirs() and veri_file::EndCompilationUnit().&lt;br /&gt;
&lt;br /&gt;
The TCL command 'analyze' uses the API 'veri_file::AnalyzeMultipleFiles()'. In other words, it assumes a complete compilation unit for each execution.&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=Notes_on_analysis&amp;diff=859</id>
		<title>Notes on analysis</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=Notes_on_analysis&amp;diff=859"/>
				<updated>2023-10-20T16:32:52Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;First, please read this article: [[Defined macros become undefined - MFCU vs SFCU]].&lt;br /&gt;
&lt;br /&gt;
'''Q: Can I use 'veri_file::Analyze()' to read SystemVerilog input files one by one, all of them belonging to one compilation unit?'''&lt;br /&gt;
 &lt;br /&gt;
Yes. But if you have multiple files, it’s better to use 'veri_file::AnalyzeMultipleFiles()'.&lt;br /&gt;
 &lt;br /&gt;
'veri_file::AnalyzeMultipleFiles()', besides analyzing each file, also:&lt;br /&gt;
 &lt;br /&gt;
* opens and ends the compilation unit&lt;br /&gt;
* processes –v and –y options&lt;br /&gt;
* removes include directories&lt;br /&gt;
* processes root module&lt;br /&gt;
* undefines user-defined macros, including command-line macros&lt;br /&gt;
* resets compile directives (e.g. `default_nettype, `timescale)&lt;br /&gt;
 &lt;br /&gt;
If you use 'veri_file::Analyze()' to analyze each file one by one, after all the calls to 'veri_file::Analyze()'. you’ll need to call 'veri_file::AnalyzeFull()' to complete the analysis before starting any other operation. Depending on the application, you may also want to run veri_file::RemoveAllIncludeDirs() and veri_file::EndCompilationUnit().&lt;br /&gt;
&lt;br /&gt;
The TCL command 'analyze' uses the API 'veri_file::AnalyzeMultipleFiles()'. In other words, it assumes a complete compilation unit for each execution.&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	<entry>
		<id>https://www.verific.com/faq/index.php?title=How_to_get_best_support_from_Verific&amp;diff=858</id>
		<title>How to get best support from Verific</title>
		<link rel="alternate" type="text/html" href="https://www.verific.com/faq/index.php?title=How_to_get_best_support_from_Verific&amp;diff=858"/>
				<updated>2023-10-12T00:25:36Z</updated>
		
		<summary type="html">&lt;p&gt;Hoa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We here at Verific strive to provide you with the best customer service.&lt;br /&gt;
&lt;br /&gt;
But we need help from you. Please:&lt;br /&gt;
&lt;br /&gt;
* Identify your company and your group/business unit. Many of our customers have multiple Verific licenses, each with a different product configuration.&amp;lt;br /&amp;gt;On our file system, each of the licensees has a dedicated code branch, and code cross-contamination is an absolute no-no. Identifying your company and your business unit will help us to use the appropriate code branch.&amp;lt;br /&amp;gt; - The API &amp;quot;Message::CustomerName()&amp;quot; returns your company name.&amp;lt;br /&amp;gt; - Another way is to tell us the name/email address of the person in your company that frequently deal with Verific.&amp;lt;br /&amp;gt; - Please use an email address associated with your company; do not use an email address from a generic email service provider (e.g. JohnSmith@gmail.com).&lt;br /&gt;
&lt;br /&gt;
* Tell us what Verific release you are using: &amp;lt;br /&amp;gt;  - The API &amp;quot;Message::ReleaseString()&amp;quot; returns something like &amp;quot;Jul17_SW_Release.&amp;quot;&amp;lt;br /&amp;gt;   - Or you can just search for &amp;quot;ReleaseString&amp;quot; in util/Message.cpp. &amp;lt;br /&amp;gt;   - If you are evaluating Verific software, tell us the exact name of the zip file containing the library package. &amp;lt;br /&amp;gt;   - Or you can run tclmain application with &amp;quot;-v&amp;quot; option:&lt;br /&gt;
    $ tclmain-linux-O -v&lt;br /&gt;
     -- (c) Copyright 1999 - 2020 Verific Design Automation Inc. All rights reserved&lt;br /&gt;
     -- Verific release: Mar20_SW_Release, to: Company, release date: Tue Apr 28 09:13:38 2020&lt;br /&gt;
     Hello, init.tcl has been executed&lt;br /&gt;
     %&lt;br /&gt;
&lt;br /&gt;
* Be clear and precise about the issue. Send us the log file if available; if not, a description of the symptom and the exact error/warning messages will help tremendously.&amp;lt;br /&amp;gt;If it is at all possible, send us a testcase that we can use to re-create the symptom. If there is a problem, that testcase can be used to verify that the problem has been fixed. By the way, the testcase you provide will be added to the regression testsuite for your code branch. It will not be shared with anyone/organization outside of Verific.&amp;lt;br /&amp;gt;The testcase should include Verilog/VHDL files, a TCL/Perl/Python script, or a C++ application exhibiting the symptom (current output), and the expected output.&amp;lt;br /&amp;gt;''In sending the testcase, '''do not send screenshots'''. Rather, please send text files, or put them in the body of the email message so that we can save the files or cut and paste the text to create the testcase on our file system. If you send screenshots, we will have to type the files in, which takes time and is error-prone.''&lt;br /&gt;
&lt;br /&gt;
* The C++ application or the TCL/Perl/Python modules used to recreate the symptoms should be built with '''''the C++ source code as shipped from Verific'''''. Otherwise please let us know any modifications, including compile-time flags and run-time flags, that have been done on the source code.&lt;br /&gt;
&lt;br /&gt;
* If you send a log file, please do not suppress any messages from Verific; they are essential in debugging. &amp;lt;br /&amp;gt;To clear message suppressions, please use Message::ClearAllMessageTypes().&lt;br /&gt;
&lt;br /&gt;
* If any of the older releases of Verific has a different behavior, and you are reporting a regression, tell us what release(s) of Verific you are comparing to. This will save us some time checking the old releases.&lt;br /&gt;
&lt;br /&gt;
* If there are other EDA tools that run &amp;quot;correctly,&amp;quot; provide the names and the versions of the tools and their &amp;quot;correct&amp;quot; output. Do not just say, &amp;quot;Other tools accept the design&amp;quot; (then we will need to ask you the names of the tools).&lt;br /&gt;
* Send email to support@verific.com. If you want to send email to an individual Verific engineer, add support@verific.com to the cc list.&amp;lt;br /&amp;gt;We have an internal procedure to prevent tech support requests from falling through the cracks. This procedure works only for email messages sent to, or cc'ed, support@verific.com.&amp;lt;br /&amp;gt;''If your questions are related to Verific's Invio product, please send email to invio@verific.com.''&lt;br /&gt;
* Initiate a new email thread (new subject line) for a new issue. Do not 'reply' to an old email thread to report a new issue. Our internal procedure depends on the subject line of the email message. Reusing an old subject line may result in a delay in response time.&lt;br /&gt;
&lt;br /&gt;
* If the problem is resolved at your end, inform us so we can close the issue.&lt;br /&gt;
&lt;br /&gt;
Thank you very much.&lt;/div&gt;</summary>
		<author><name>Hoa</name></author>	</entry>

	</feed>