HDL libraries are a very powerful feature of the HDL languages. Sigasi Visual HDL (SVH) makes it easy to configure and use them. We’re assuming that you understand the basic concepts of HDL libraries, and so this section focuses on how they are implemented in SVH.

As with any HDL tool, SVH needs to know where the libraries are located on your file system. Below, we describe how the library configuration can be examined and modified using the GUI.

We’ve also presented a use case about how to set up libraries with SVH to organize your projects.

Examining the Library Configuration

You can examine the library configuration in the Sigasi Projects view, which shows how VHDL or SystemVerilog files are mapped.

Each physical file or folder is annotated with the library it belongs to between square brackets.

Library Configuration in VS Code

In the image above, you can see a mixed-language project called Sigasi-Demo, with a folder named Common Libraries. In that folder, you see the typical standard libraries (std and ieee) upon which all VHDL projects depend.

Lower down, you can see other folders, most of which are mapped to the library work. One of the folders (verilog) is mapped to the library verilog.

Modifying the Library Configuration

You can modify library mapping for project files right in the Sigasi Projects view.

Select a file or a folder in the view and right-click.

Modifying the Library Configuration in VS Code

Once you select Set Library in the menu, you will get the library configuration options, as you can see in the image below.

Set Library in VS Code
  • Select Exclude from Build to exclude a file or folder from any library
  • Select New Library… to define a new library and map a file or folder to it
  • If you select one or more folders, SVH automatically suggests the folder name as a library - in this case, the includes folder
  • Select the name of an existing library to map a file or folder to that library

When you map a file into a library, only that file is affected. However, if you map a folder into a library, then everything in that folder will be mapped into that library. Any previous library mapping configurations applied to files or folders in the given folder will be overridden. When you are defining the library mapping for a new project, you should map from top to bottom.

So, in the case of our Sigasi-Demo project, if work is not a good default, you would change the top folder’s mapping first and then override the mapping in the sub-folders.

To exclude any file from all libraries, you can select the Exclude from build option. SVH will then assume that the corresponding resource is not part of the project and will not include that resource in a project build. This is typically useful when you have stale copies of HDL files or folders lying around that you simply want to ignore.

SystemVerilog Include Files

SystemVerilog include files are always excluded from the build. Any file that is included in another design file gets excluded from the build, even if it has an extension that would normally identify it as a design file, e.g. .v or .sv. It often doesn’t make sense to compile include files by themselves. Instead, include files are compiled in the context of the file in which they are included.

Configuration File

All library configuration information is stored in the .library_mapping.xml file in the root of your project. If you edit this file, the affected HDL files in your project will be rebuilt automatically. Note that .library_mapping.xml should be checked into your version control system.

SVH only writes changes to this configuration file when you make changes to the library configuration. When you do make changes, SVH first checks that all paths in the library configuration still exist. If a path no longer exists, it will be removed from the configuration file. Note that the library configuration file is case-sensitive, even on Windows.

Common Libraries

Each project has a folder called Common Libraries. This is where reusable libraries go: whether vendor libraries, third-party IP libraries, or your own reusable libraries. By default, the VHDL STD and IEEE libraries are added to this folder. The Common Libraries folder behaves like any other folder. You can delete it, rename it, or apply a different library mapping. In most cases, however, the default configuration is just what you need.

How To Add Files To Common Libraries

In any newly created Sigasi project, the Common Libraries folder contains the VHDL files of the IEEE and STD libraries.

To add files, right-click the Common Libraries folder and select the New Linked Folder to create a Linked Folder pointing to the actual folder location that contains the files you wish to add to the Common Libraries.

How Is “Common Libraries” Different From Other Folders?

  • Common Libraries by default is a virtual folder. This means that it is not a real folder in the project directory and it can only contain references to folders on your file system.
  • Files in Common Libraries are supposed to be error free. SVH will not mark errors or warnings in these files.
  • Aside from these, a few other libraries’ errors and warnings are never marked, regardless of their location. These libraries are: std, ieee, altera_mf, altera, XilinxCoreLib, unisim, mentor, lpm, simprim, std_developerskit, unimacro, and modelsim_lib.
  • While you work on your project, you don’t want to edit the files in the Common Libraries, but you do need them to compile your project.

Using Common Libraries is recommended for files that are supposed to be error free. This increases SVH’s performance by preventing it from analyzing files that don’t need to be analyzed.

Adding Third-Party Libraries to a Project

If your project uses libraries from Quartus or Vivado or standalone libraries (e.g. UVM), SVH provides a mechanism that makes it easier to add such libraries to a project and to switch between versions of libraries and toolchains.

First, SVH needs to know the location of the toolchains and standalone libraries on your system. SVH can automatically detect Quartus and Vivado installations:

  • in default installation locations: /opt, /tools, C:\, <home>, and <home>/Documents.
  • via environment variables that point to installation or bin directories of these tools (e.g. QUARTUS_ROOTDIR, XILINX_VIVADO, PATH, etc.).

Note: You can run the Reload Toolchain Libraries command to see what toolchains were detected (they would have a (detected) mark).

You can override detected toolchains or add additional toolchain installations and external libraries in the extension settings:

  • When adding a toolchain, you’ll have to specify:
    • the installation path,
    • the Kind (Quartus or Vivado), and
    • an alias that would be used in a project to reference this installation.
  • When adding a library, you’ll have to specify:
    • the library path,
    • the library name, that would be used to map HDL files,
    • the layout, which would configure how to link this library (at the moment, only two layouts are supported: a UVM library layout or a Default one that would simply link, map, and add a specified directory to include paths), and
    • an alias that would be used in a project to reference this library path

Once you’ve added all required toolchains (or are happy with detected toolchains) you have to extract their libraries with the Reload Toolchain Libraries command. This would allow using these libraries in your project. You can choose whether to extract only family-independent libraries or all libraries.

Now you can run the Manage Linked Libraries command and select what libraries you want to use in your project (if you don’t need them later on, you can unselect them here as well). After pressing the OK button (or Enter), the selected libraries will be linked to your project in the Common Libraries folder (while unselected libraries will be removed). To the right of the library name in a wizard you can see what library or toolchain version is used.

Note: If the project configuration for a linked library is out-of-sync with an intended library layout (e.g. library files mapping was manually changed), this library will be marked as (out-of-sync) on this wizard page. Pressing the OK button (or Enter) will fix the configuration of all linked libraries that are out-of-sync.

If you have multiple toolchain installations or library versions and would like to use a different one, you can run the Set Active Toolchain or Set Active Library command and set a desired version as active.

A Reset Active Toolchains and Libraries command removes active toolchain and library aliases from project configuration files if those are not used by currently linked libraries. It can make configuration cleaner without affecting libraries linked to a project.

Note: When you link libraries this way, your project file and project settings will contain only aliases of toolchains and libraries, not their absolute paths on your system. This way, when multiple people work on a project, it’s sufficient to add a toolchain or library with the same alias in workspace settings (or use the same environment variable to point to the library or toolchain installation path).