Skip to content

About

Simple python script to find VHDL file dependencies. I intend to cover Verilog as well at a latter date

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

84 Commits

Folders and files

Repository files navigation

hdldepends

Simple python script to find HDL file dependencies.

Install

git clone https://github.com/pevhall/hdldepends.git
cd hdldepends
pip install .

Dependency to run the script is Python >=3.8

Running hdldepends

hdldepends path/to/config/file

For more information about available command line parameters refer to the built-in help (hdldepends -h) or see sections below.

Basic VHDL Example

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

Configuration file Keys/Options

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.

Source 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_files
  • vhdl_files_file
  • vhdl_files_glob
  • verilog_files
  • verilog_files_file
  • verilog_files_glob
  • x_xci_files
  • x_xci_files_file
  • x_xci_files_glob
  • x_bd_files
  • x_bd_files_file
  • x_bd_files_glob
  • other_files
  • other_files_file
  • other_files_glob
  • ext_files
  • ext_files_file
  • ext_files_glob

Custom Tag

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.

Input types

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)

*_files

This is simply a single path to a file or a list of paths to files.

*_files_file

This is a single path to a file or a list of paths to files containing lists of paths to files.

*_files_glob

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

Languages

Supported languages are

  • vhdl_*
  • verilog_*
  • x_xci_*
  • x_bd_*
  • other_*
  • ext_*

vhdl_*

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_*

Verilog files currently have a limitation that header files are currently not scanned

x_xci_*

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

x_bd_*

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_*

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_*

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)

Top level file

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.

top_vhdl_file

Set the passed VHDL file as the top level file

top_verilog_file

Set the passed Verilog file as the top level file

top_x_bd_file

Set the passed Xilinx BD file as the top level file

top_entity

This is the top entity to create the compile order from. This entity must be included in the file options.

Files to ignore

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_libs

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

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

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

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.

vhdl_package_skip_order

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

Other options

pre_cmds

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.

sub

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.

Command line

Below are the command line options for the hdldepnds.py command line program

Options

Command line flag options

-h --help

Print help message and exit

-v --verbose

Selected the verbose level.

  • Nothing is warning
  • -v is info, and
  • -vv is debug.

-c --clear-pickle

Do not load anything from a pickle cache

--no-pickle

Do not load anything from a pickle cache and do not write any pickle caches

--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_file.

--top-entity

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.

--top-lib

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.

--file-list

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.

--file-list-type

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.

--file-list-vhdl-lib

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.

--compile-order

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.

--compile-order-type

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.

--compile-order-vhdl-lib

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.

--x-tool-version

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.

--x-device

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.

Positional Arguments

This program has only one positional argument type.

config_file

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.

Paths

File paths can be relative to the file that contains the paths or relative to the current directory if passed by the command line.

About

Simple python script to find VHDL file dependencies. I intend to cover Verilog as well at a latter date

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages