DVT SystemVerilog IDE User Guide
Rev. 21.1.18, 28 April 2021
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:
+dvt_pverilog_map+<(p) file path>=<(g) file path>
You may specify this directive multiple times for several file pairs.
+dvt_pverilog_ext_map+<(p) files extension>=<(g) files extension>
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.
+dvt_pverilog_pattern_tag_map+<(p) pattern1>=<(g) pattern2>
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.
+dvt_pverilog_path_map+<path prefix of (p) files>=<path prefix of (g) files>
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.
+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:
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.
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:
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:
Tip For convenience you can also use a custom toolbar button to quickly apply preprocessing.