.. _Auto-config:

Auto-config
===========

.. rst-class:: lead

   
Particularly for small projects, in order to simplify project configuration, instead of explicitly specifying lists of files, incdirs etc., you can use one or more +dvt_init_auto directives in default.build. 

For example:

.. code-block::
    :emphasize-text: +dvt_init_auto

    # Identify and compile sources from the project directory
    +dvt_init_auto

    # Identify and compile sources from some other path
    +dvt_init_auto
    +dvt_compilation_root+/some/other/path

DVT scans the specified directories and automatically detects how to compile the source code files.

For each ``+dvt_init_auto`` directive, a corresponding **default.build.auto.#** file is created.

The **.build.auto.#** files contain compilation directives like incdirs, top files, libraries, UVM libraries, Xilinx libraries, etc. resulting from the auto-configuration algorithm.

After scanning, DVT compiles the code using the directives in generated auto files.

.. tip::
    
    You can specify multiple scan roots using **+dvt_autoconfig_scan_root_add+<root>**, for example when sources reside in multiple independent locations:

    .. code-block::
        :emphasize-text: +dvt_init_auto

        # Specify scan roots in addition to the compilation root
        +dvt_init_auto
        +dvt_compilation_root+/some/other/path
        +dvt_autoconfig_scan_root_add+/additional/scan/root1
        +dvt_autoconfig_scan_root_add+/additional/scan/root2

.. note::
    
    The compilation root is by default an auto-config scan root. To override this behavior, specify the **+dvt_autoconfig_scan_root_clear** directive first:

    .. code-block::
        :emphasize-text: +dvt_init_auto
    
        # Don't scan the default compilation root, only the specified scan roots
        +dvt_init_auto
        +dvt_autoconfig_scan_root_clear
        +dvt_autoconfig_scan_root_add+/scan/root1
        +dvt_autoconfig_scan_root_add+/scan/root2

DVT automatically detects and analyzes existing Intel(Altera) Quartus or Xilinx ISE/Vivado projects in the compilation root directory of a ``+dvt_init_auto`` directive.

.. note:: 
    
    Auto files are overwritten on every full build.

You can specify additional directives in ``+dvt_init_auto`` sections. They are copied as is in the corresponding .build.auto.# file. For example:

.. code-block::
    :emphasize-text: +dvt_init_auto

    +dvt_init_auto
    +define+RTL
    +define+ADDR_SIZE=32
    +incdir+$UVM_RGM_HOME/src
    +dvt_skip_compile+*/some/path*

You can specify a compatibility mode and use simulator specific directives:

.. code-block::
    :emphasize-text: +dvt_init_auto

    +dvt_init_auto+ius.irun
    -v93

The available compatibility modes are: dvt, ius.irun, vcs.vlogan and vcs.vhdlan. If a compatibility mode is not specified, it defaults to dvt. See :ref:`Compatibility Modes` for a detailed description.

.. tip:: 
    
    When working with large filesystem hierarchies or slow network drives, the scan phase might time out, by default after 40 seconds.
    
    To increase the timeout for a particular **+dvt_init_auto section**, use **+dvt_autoconfig_timeout** build config directive.
    
    For example to set timeout to 2 minutes:

    .. code-block::
        :emphasize-text: +dvt_init_auto

        +dvt_init_auto
        +dvt_autoconfig_timeout+120
        [...]


.. tip:: 
    
    Use the **+dvt_autoconfig_debug+SCAN** build configuration directive to see detailed scanning progress reported in the :guilabel:`Console View`.



