FPGA Interface C API Reference

Content Type
Programming Language
Current manual
Product DocumentationFPGA Interface C API ReferenceGenerating a C API for a LabVIEW FPGA ApplicationCurrent page
Table of Contents

Generating a C API for a LabVIEW FPGA Application

Generating a C API for a LabVIEW FPGA Application

You can generate a C API for a LabVIEW FPGA application from the LabVIEW Project Explorer window, from the Windows Start menu, or from a Windows command line. The generated C API consists of the files needed to build and run a C/C++ application.

The FPGA Interface C API Generator works only on .lvbitx files created with LabVIEW 2009 or later. It does not work on .lvbit files created with older versions of LabVIEW, or on .lvbitx files created with the pioneer NI Labs version of the FPGA Interface C API.

With any of the following generation methods, you can specify a custom prefix for generated files and for the constants in the generated .h file. If you do not specify a custom prefix, the FPGA Interface C API Generator names files and constants based on the name of the FPGA VI from which the application bitfile was compiled.

Generating a C API from the LabVIEW Project Explorer Window

Complete the following steps to generate a C API for a compiled bitfile from the LabVIEW Project Explorer window.

  1. Right-click the FPGA VI and select Create Build Specification from the shortcut menu.
  2. Under Build Specifications, right-click the new build specification for the example FPGA VI, select Build, and wait for the build to complete.
    Note Note  For versions of LabVIEW earlier than 2010, right-click the example FPGA VI, select Compile, and wait for the compilation to complete.
  3. Right-click the compiled FPGA VI item and select Launch C API Generator from the shortcut menu.
  4. On the FPGA Interface C API Generator dialog box that appears, ensure that the right compiled FPGA bitfile is selected. You can browse to the right bitfile or type an absolute path to it.
  5. Select an output directory for the C API. If you do not select an output directory, the C API files will be created in the directory that contains the bitfile. You can browse to a directory or type an absolute path to it.
  6. Optionally, you can change the prefix for the generated files and for the constants in the generated .h file.
  7. If you are using LabWindows/CVI to develop your C application, place a check beside Exclude NiFpga.h/NiFpga.c because the FPGA Interface C API installs header and library files with LabWindows/CVI support.

Generating a C API from LabWindows/CVI 2010 or Later

Complete the following steps to generate a C API for a compiled bitfile from LabWindows/CVI 2010 or later.

  1. Select Tools»Launch FPGA Interface C API Generator.
  2. On the FPGA Interface C API Generator dialog box that appears, browse to the compiled FPGA bitfile or type an absolute path to it.
  3. Select an output directory for the C API. If you do not select an output directory, the C API files will be created in the directory that contains the bitfile. You can browse to a directory or type an absolute path to it.
  4. Optionally, you can change the prefix for the generated files and for the constants in the generated .h file. Note that Exclude NiFpga.h/NiFpga.c is checked because the FPGA Interface C API installs header and library files with LabWindows/CVI support.

Generating a C API from the Windows Start Menu

Complete the following steps to generate a C API for a compiled bitfile from the Windows Start menu.

  1. Select Start»All Programs»National Instruments»FPGA Interface C API»FPGA Interface C API Generator.
  2. On the FPGA Interface C API Generator dialog box that appears, browse to the compiled FPGA bitfile or type an absolute path to it.
  3. Select an output directory for the C API. If you do not select an output directory, the C API files will be created in the directory that contains the bitfile. You can browse to a directory or type an absolute path to it.
  4. Optionally, you can change the prefix for the generated files and for the constants in the generated .h file.
  5. If you are using LabWindows/CVI to develop your C application, place a check beside Exclude NiFpga.h/NiFpga.c because the FPGA Interface C API installs header and library files with LabWindows/CVI support.

Generating a C API from a Windows Command Line

Use the following syntax to generate a C API for a compiled bitfile from a Windows command line. Note that the second and third arguments, the path to output directory and prefix override, are optional.

capigen.exe "<absolute path to .lvbitx file>" ["<absolute path to output directory>" [<prefix override>]]

If you are using LabWindows/CVI to develop your C application, use the following syntax to exclude NiFpga.h and NiFpga.h because the FPGA Interface C API installs header and library files with LabWindows/CVI support:

capigen.exe -e "<absolute path to .lvbitx file>" ["<absolute path to output directory>" [<prefix override>]]

Using Absolute Paths to Specify File and Directory Locations

You must use an absolute path to specify the .lvbitx file. If you specify an output directory, you must also use an absolute path. However, if you do not specify an output directory, the FPGA Interface C API Generator creates the C API files in the directory containing the.lvbitx file. If a path contains spaces and you are specifying it from a Windows command line, you must enclose the path in double quotation marks. The following is an example with absolute paths.

capigen.exe "C:\Documents and Settings\<user-name>\My Documents\LabVIEW Data\FPGA Bitfiles\MyBitfile.lvbitx" "C:\Documents and Settings\<user-name>\Desktop" MyPrefix

Was this information helpful?