Simple python script to find HDL file dependencies.
git clone https://github.com/pevhall/hdldepends.git
cd hdldepends
pip install .Dependency to run the script is Python >=3.8
hdldepends path/to/config/fileFor more information about available command line parameters refer to the built-in help (hdldepends -h) or see sections below.
Create a toml file in the root of your project with specify all the library VHDL files.
cat hdldepends.toml
'vhdl_files_glob' = ['./fw/lib/vhdl/**.vhd]
Now from a sub directory dump the VHDL work library compile order for a top level testbench
hdldepends hdldepends.toml --top-file ../vhdl/example_tb.vhd --compile-order-vhdl-lib work:compile_order.txt
Contain the project information include which files are include and from which libraries. These can be written in json or toml. The configuration files are broken into key value pairs. Where the keys are all the possible configuration file options.
There are a number of ways to add different source files to the "project". Source File keys/options are made up of the following first:
- language first, then
- an input type, and finally
- an optional custom tag They are combined as follows _<input_type>@<custom_tag>
All current possible _<input_type> options are:
vhdl_filesvhdl_files_filevhdl_files_globverilog_filesverilog_files_fileverilog_files_globx_xci_filesx_xci_files_filex_xci_files_globx_bd_filesx_bd_files_filex_bd_files_globother_filesother_files_fileother_files_globext_filesext_files_fileext_files_glob
At the end of a configuration file key/option a custom file tag can be added. The custom tag can be used to separate different sets of the same file type. The custom tag will be exported with the --compile-order.
The custom tags to distinguish the difference between VHDL93 and VHDL2008. This was required because currently Vivado can only add VHDL93 files (and not VHDL2008) to block diagrams.
Supported input types are.
*_files*_files_file*_files_glob
All these types relate to file paths.
- The file paths can be absolute or relative to the current containing the path.
- Paths can also contain shell environment variables by placing the environment variable within {} (curly brackets)
This is simply a single path to a file or a list of paths to files.
This is a single path to a file or a list of paths to files containing lists of paths to files.
This is a single glob or a list of globs. Note the globs happens in order. Special characters are:
*Matches anything in a directory**Searches directories recursively!Must to the first character. This inverses the match so this pattern removes matches Note the glob happen in order. Hence an inverse!match as the first line in the glob list does nothing.
Examples:
- "*.vhd", # Include all VHDL files
- "src/**/*.vhd", # Include all VHDL files in src directory and subdirectories The Xilinx tool version is used when passing the XCI and BD files. It will try and get the correct tool version.
- "!src/temp/*", # Exclude everything in the temp directory
- "!**/*_test.py" # Exclude all test files
Supported languages are
vhdl_*verilog_*x_xci_*x_bd_*other_*ext_*
VHDL is the only language where libraries are supported.
So for the VHDL options instead of just having a list the vhdl_files, vhdl_files_file and vhdl_files_glob support directories where the key is the library to add the VHDL files into. This can also be a directories to a list if you want to add multiple elements to the same directory. If the library is not specified then the default library is used.
Verilog files currently have a limitation that header files are currently not scanned
Xilinx LogiCORE IP (XCI) files are currently scanned for VHDL, Verilog and or nested BD dependencies.
The Vivado version and Xilinx part number will be extracted from the file. If multiple files with the same entity are found the program will try to filter out the correct version using the command line options --x-tool-version and --x-device.
Note: this is currently only tested on Vivado 2022.2
Xilinx Block Diagrams (BD) files are currently scanned for VHDL, Verilog and or nested BD dependencies.
The Vivado version and Xilinx part number will be extracted from the file. If multiple files with the same entity are found the program will try to filter out the correct version using the command line options --x-tool-version and --x-device.
Note: XCI inside the BD can be regenerated by the BD and so are not a dependency of the BD.
Note: this is currently only tested on Vivado 2022.2
Other files are not scanned by the name minus the extension (eg name.extension) is assumed to be the module name.
The was originally used for XCI files until the x_xci_* option was added.
Ext is short for external. These files will not be scanned and are "external to"/"not used in" the compile order. These files can be extracted from the project using the --ext-file-list and --ext-file-list-tag command line options.
The is currently used for Vivado constant files (XDC)
If you want to generate the compile order you will need to have the top level file set. This can be set in the configuration file using one of these options or set in the command line options.
Note: A configuration containing a top file setting cannot be reference by another configuration through the sub option.
Set the passed VHDL file as the top level file
Set the passed Verilog file as the top level file
Set the passed Xilinx BD file as the top level file
This is the top entity to create the compile order from. This entity must be included in the file options.
This options are about telling the compile order processing to ignore things.
For options that accept a library dictionary, then the dictionary key is the library name. The dictionary value can be a list to contain more then one item to connect to the library. If no dictionary is not specified then the default work library is assumed.
Ignore libraries key indicates libraries which the design will ignore not add to the compile order.
This option accepts a list or single value.
Ignore packages key indicates VHDL packages which the design will ignore not add to the compile order.
This option accepts a library dictionary list or single value.
Ignore entities key indicates entities which the design will ignore not add to the compile order.
This ken accepts a library dictionary list or single value.
Ignore components key indicates components which the design will ignore not add to the compile order.
NOTE: you do not indicate which library the component comes from.
This key accepts a list or single value.
Package file skip order key added the package to the project but will ignore the package and all components in the package when creating the compile order.
This key accepts a library dictionary list or single value.
Other options
Pre-commands are commands to run before other keys are processed.
This key accepts a list or a single value.
The major purpose of this is to automatically update files referenced by key file_list_files. An example of pre_cmds could be.
git ls_files ./fw | grep ".vhd$" > fw_files_work.txt
This will place all .vhd files paths into fw-files_work.txt.
The sub key adds other configuration files to the project. Which will be searched after the current configuration file. This can be a path relative to the directory containing this file or a file name contained in a parent directory of this file.
This key accepts a list or a single value.
Below are the command line options for the hdldepnds.py command line program
Command line flag options
Print help message and exit
Selected the verbose level.
- Nothing is warning
-vis info, and-vvis debug.
Do not load anything from a pickle cache
Do not load anything from a pickle cache and do not write any pickle caches
The top file command line option specifies the project's top level file to create the compile order from. This works the same as the configuration file key top_file.
The top file command line option specifies the project's top level file to create the compile order from. This works the same as the configuration file key top_entity.
This is a bit of a hack. It will give the work library the passed name.
NOTE: If it changes it will evaluate every cached file referenced.
The file list command line option accepts a location to a file not yet created. This will save a list of all added to the hdldepends project. Each line contains:
- file type,
- library, and
- absolute path to file under question.
The file list type command line option accepts :. Type can be:
- vhdl
- verilog
- x_bd
- other This will save a list to of all files of added to the hdldepends project. If is vhdl each file in the file contains:
- library, and
- absolute path to file under question. If it is any other type each line is only:
- absolute path to file under question.
The file list VHDL library option exports the file list for one particular library. The option accepts lib:file where lib is the library to export and file is the location to export the file list to. Each line of the created file will contain the absolute path to a file.
The compile order command line option accepts a location to a file not yet created. The project compile order will be exported to this file. Each line containing:
- file type,
- library, and
- absolute path to file under question.
The compile order type command line option accepts :. Type can be:
- vhdl
- verilog
- x_bd
- other This will save the compile order to of all files of which are required to be compiled by the project. If is vhdl each file in the file contains:
- library, and
- absolute path to file under question. If it is any other type each line is only:
- absolute path to file under question.
- library, and
- absolute path to file under question.
The compile order VHDL library option exports the compile order for one particular VHDL library. The option accepts lib:file where lib is the library to export and file is the location to export the compile order. Each line of the created file will contain the absolute path to a file.
This option specifies the Vivado version, it is used when passing the Xilinx XCI and BD files. It will try and get the correct tool version.
This option specifies the Xilinx device is used when passing the Xilinx XCI and BD files. It will try and get the Xilinx device.
Note --x-tool-version will take priority over --x-device so if it can only match one it will match the tool version.
This program has only one positional argument type.
This can be a direct path to a configuration file or just the file name. If only the file name is specified the program will look in parent directories for the file.
More then one configuration file can be specified. If more then one file is specified use the --top-lib command line option and not top_file configuration file key.
File paths can be relative to the file that contains the paths or relative to the current directory if passed by the command line.