Communicating with FPGA Devices from Linux Applications Using the FPGA Interface C API

Updated Sep 13, 2022

Environment

Software

  • LabVIEW FPGA Module

Driver

  • NI-RIO (Legacy)
  • FPGA Interface C API

Operating System

  • Linux

You can communicate with NI FPGA devices from Linux® using the NI-RIO driver and FPGA Interface C API. This document explains how to program your NI FPGA hardware using the LabVIEW FPGA Module (Windows), how to install needed FPGA Interface C API and NI-RIO driver software, and how to use the FPGA Interface C API to communicate with your FPGA device from C applications on Linux.

Programming NI FPGA-Based Hardware Devices

To program an FPGA bitfile for NI FPGA-based devices (e.g. R-Series modules), you must use the LabVIEW  development environment along with the LabVIEW FPGA Module on a Windows system. It is not currently possible to program FPGA bitfiles for NI FPGA-based devices from the LabVIEW development on Linux.

Once you have generated an FPGA bitfile, you can download it to a NI FPGA device installed in a Linux system. You do this from a host application written in C; continue reading for instructions on how to do this.
 

Installing the NI-RIO Driver and FPGA Interface C API Software and NI-RIO Driver on Your Windows Development Machine

After programming a bitfile for your FPGA-based device, you will need to generate a custom C API on your Windows development machine based on the inputs and outputs to your FPGA application. 
 

To do this, you need two pieces of software on your Windows development machine:
 

Installing the NI-RIO Driver on Your Linux System 

To communicate with your NI FPGA-based device from applications on Linux, you need to install the NI-RIO driver on your Linux system. This driver is currently supported with the following distributions:
 

  • Red Hat Enterprise Linux 5.x i386

  • Red Hat Enterprise Linux 5.x x86_64

  • Red Hat Enterprise Linux 6.x i386

  • Red Hat Enterprise Linux 6.x x86_64

  • Scientific Linux 5.x i386

  • Scientific Linux 5.x x86_64

  • Scientific Linux 6.x i386

  • Scientific Linux 6.x x86_64
     

You can download and install the NI-RIO 4.1.0 driver for Linux from ni.com/updates. Installation instructions are provided in the README.txt file noted on the download page.

Using the FPGA Interface C API to Communicate with NI FPGA-Based Devices from C Applications on Linux

A tutorial is available to help guide you through the process of generating a C interface to your LabVIEW FPGA application, and then using that interface in your C application on Linux. Essentially, you will take the following steps:
 

  1. Transfer your compiled LabVIEW FPGA bitfile from your Windows development machine to your Linux system

  2. Generate a custom C API for your LabVIEW FPGA application from the LabVIEW development environment on your Windows machine

  3. Develop a C host application for your Linux system that uses the custom C API that you generated in step 2. Your host application will connect to the NI FPGA-based device, download your bitfile from step 1, and then send and receive data as needed.
     

To read the detailed tutorial, visit the document: Building an R Series FPGA Interface Host Application in C . Note that the FPGA Interface C API can be used to generate custom C APIs for use on Windows or Linux. Therefore, some Windows examples given in the tutorial may need to be slightly adjusted when developing a Linux host application.
 

The registered trademark Linux® is used pursuant to a sublicense from LMI, the exclusive licensee of Linus Torvalds, owner of the mark on a worldwide basis.