DVT SystemVerilog IDE User Guide
Rev. 23.1.21, 12 September 2023

41.8 Preprocessed Files Support

This application note describes how to use DVT with source files which contain preprocessing code in a general-purpose scripting language like perl, python, ruby or php.

A tool applies preprocessing and the resulting SystemVerilog files are actually compiled and simulated.

For simplicity, files containing preprocessing code are referred to as (p) files while generated files are referred to as (g) files.

Configure DVT to compile the generated (g) files

In order to provide advanced functionality (like hyperlinks, autocomplete, design and class hierarchy, error signaling, etc.) DVT must analyze the generated (g) source code files.

If the preprocessing (p) files are provided for analysis instead, DVT will trigger syntax errors, since the files do not have a valid SystemVerilog syntax, and functionality within these files (and possibly others) might be broken.

Map preprocessing (p) to generated (g) files

You must specify how (p) files are mapped to (g) files using one of the following build configuration directives in .dvt/default.build:

  • Direct mapping

   +dvt_pverilog_map+<(p) file path>=<(g) file path>

For example:


You may specify this directive multiple times for several file pairs.

  • Map by extension

   +dvt_pverilog_ext_map+<(p) files extension>=<(g) files extension>

For example:


A (p) file is mapped to a (g) file if they have the same basename and mapped extensions, regardless of their location inside the project. If multiple such files exist, there is no guarantee on the chosen pair.

You may specify this directive multiple times for different extension pairs.

  • Map by pattern tag

   +dvt_pverilog_pattern_tag_map+<(p) pattern1>=<(g) pattern2>

For example:


A (p) file is mapped to a (g) file if their names match the specified patterns, regardless of their location inside the project. A pattern is defined by an alternation of constant fragments and tags.

You may specify this directive multiple times for different pattern pairs.

  • Map by path prefix

   +dvt_pverilog_path_map+<path prefix of (p) files>=<path prefix of (g) files>

for example:


A (p) file is mapped to a (g) file if they have the same subpath relative to the (p) path prefix respectively to the (g) path prefix.

You may specify this directive multiple times for different path prefix pairs.

  • Map by comment


For example:

   +dvt_pverilog_comment_map+"Source file: (?<PFILE>\S+)"

The mapping is inferred from the (g) file, assuming it contains a comment pointing to the corresponding (p) source file.

Specify a regular expression pattern containing a named capturing group called PFILE. The pattern is applied to all comments at full build time.

To debug use:


Debug information will be printed in the DVT Build Console.

Using the PVerilog editor

Whenever you open a (p) or (g) file (from any view, or by jumping into it with a hyperlink) it gets opened using the PVerilog editor.

It's a multi-page editor which provides a convenient way to work with preprocessed/generated code. It has 3 tabs:

  • (p) - Shows the preprocessing file with syntax highlighting.

Hyperlink navigation options are available (Open Declaration, Show Usages, etc).

DVT detects the element under cursor by advanced analysis of the diff between the (p) and the (g) files, however in certain situations (for example in case of massive diffs) several hyperlink candidates might be available.

To see the full list, click on Show more....

From the pop-up dialog, choose the hyperlink navigation option and the element for which it should be applied.

  • (g) - Shows the generated code in a regular SystemVerilog editor. All of the advanced navigation and editing features of DVT are available (hyperlinks, autocomplete, erros as you type etc). Whenever you edit this file, a visual indicator reminds you that the file is generated.

  • Compare - A compare viewer of the (p) and (g) files. It is editable and allows you to move pieces of code between the two files. The (p) and (g) editors are synchronously scrolled.

A possible usage flow is to edit/debug code in the (g) tab of the PVerilog editor, and thus benefit from all the advanced DVT functionality. When done, quickly bring (p) and (g) files into sync using the compare viewer's "Copy from ..." buttons.

Integration of the preprocessing tool

You can define a DVT Generic Run Configuration to invoke the preprocessing tool.

You can instruct DVT to run this configuration every time you save the preprocessing file either in the (p) or © tab of the PVerilog editor. Use this directive in the .dvt/default.build build configuration file:

   +dvt_pverilog_run_on_save+"run configuration name"

Note that you need to enclose the run configuration name in quotes if it contains whitespace characters.

The run configuration script or command can use the following environment variables:


path to the generated (g) file


path to the preprocessing (p) file

Tip For convenience you can also use a custom toolbar button to quickly apply preprocessing.