.. _UVM Components Diagrams:

UVM Components Diagrams
=======================


**UVM Components Diagrams** help you inspect and document the structure of a verification environment.

You can create a component diagram in one of the following ways:

-  :kbd:`Right-Click` in the :ref:`Verification Hierarchy View` and select **Show Diagram**. This way is faster, but the generated diagram might not be completely accurate because it's missing the runtime information.
-  Generate the diagram using the simulator and open it in DVT. This way requires to run the simulation with some additional files compiled, but the generated diagram will be complete.

The following operations are available in the :kbd:`Right-Click` context menu:

-  **Go to Create Call** Jump to the create call for the selected instance.
-  **Go to Type** Jump to the declaration of the selected element's type. It is available for nodes and labeled edges.

Component Diagrams from Verification Hierarchy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To generate the Component Diagrams from the :ref:`Verification Hierarchy View`, :kbd:`Right-Click` on an entry in the view and select **Show Diagram**.

.. figure:: ../../images/sv_VHView_component_diagram.png
	:align: center

Component Diagrams from Simulation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To generate the Component Diagrams from simulation, some additional arguments must be added to the build directives, depending on the simulator.

-  IUS: "-f $DVT_HOME/libs/dvt_chs/dvt_chs.top.ius.f". When using -makelib/-endlib add "-f $DVT_HOME/libs/dvt_chs/dvt_chs.ius.f" inside the library and "-top dvt_chs_module" outside of it.
-  VCS: "-f $DVT_HOME/libs/dvt_chs/dvt_chs.vcs.f"
-  Questa: "-f $DVT_HOME/libs/dvt_chs/dvt_chs.questa.f"

.. note:: 
	
	To generate diagrams for OVM environments, use the appropriate filelist from $DVT_HOME/libs/dvt_chs/ovm

When the simulation starts, a **component_hierarchy_of_<test_name>.chd** will be generated in the working directory.
Open the generated file in DVT to inspect the diagram.

The location of the diagram can be changed by setting the **DVT_CHS_FILE** environment variable before running the simulation.
 
.. code-block:: console

 export DVT_CHS_FILE=/path/to/a/components_diagram.chd # sh, bash
 setenv DVT_CHS_FILE /path/to/a/components_diagram.chd # csh, tcsh

You can stop the test immediately after the diagram has been generated by setting the **DVT_CHS_STOP_TEST** environment variable before running the simulation.
 
.. code-block:: console
 
 export DVT_CHS_STOP_TEST=true # sh, bash
 setenv DVT_CHS_STOP_TEST=true # csh, tcsh

.. figure:: ../../images/sv_simulator_component_diagram.png
	:align: center

Diagram Filters
~~~~~~~~~~~~~~~

You can customize the diagram using the *Filters* button  in the diagram editor toolbar.

.. figure:: ../../images/common/filters-dialog-drv-mon.png

Use the drop-down menu at the top of the dialog to select from available filters.

Use the buttons in the top-right corner of the dialog to create, duplicate, or delete the current filter.

Use the checkboxes at the bottom of the dialog to further clean up the diagram.

A filter is defined using filter rules (one per line). The general form of a filter rule is:

*command* *element_kinds* **matching** *regex* [**using** *color_name_or_code*]

-  *command* is one of **hide**, **show**, or **color**
-  *element_kinds* is a comma-separated list of kinds. The available kinds are **instances**, **types**, **ports**, **port types** and **transaction types**
-  *regex* is a regular expression that matches the relevant diagram element labels
-  *color_name_or_code* is a color specified by `name <https://www.w3.org/wiki/CSS3/Color/Extended_color_keywords>`_, *6- or 3-digit hexadecimal code*, *comma-separated decimal RGB code* or the keyword *random*. This is relevant only for **color** rules.

.. tip::
	
	You can use content assist to write the filters (*CTRL + Space*).

To apply a filter rule only to elements under a specific instance, you must provide the relevant path in the *regex* section of the rule:

-  a *path* must always begin with the name of the top instance in the diagram (if *instance* is under *top_instance*, then **top_instance/instance/...** is valid, while **instance/...** is not)
-  a *path* consists only of names of instances and "**/**"
-  each level is separated from the previous using "**/**" (valid: **top_instance/inst1/inst2/...**; not valid: **top_instance.inst1.inst2...**)
-  regular expressions may be used in the *path* section of a rule (for example, **top_instance/.*/some_instance**)
-  if the *regex* contains "**/**", everything before the last "/" is the *path*, the rest is used to match the relevant diagram elements (in the following example, the bolded text is the path: **top_instance/.*/inst1/**.*drv.*)
-  if the *regex* does not contain "**/**", it applies to all elements of the appropriate *element_kinds*

.. tip::
	
	You can hide the hierarchy under an instance with the filter "hide instances matching **path/to/instance/.***".

With the predefined filter in the image above, the resulting diagram will be similar to the following:

.. figure:: ../../images/common/component-diagram-filter-drv-mon.png





