We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

Showing results for 
Search instead for 
Did you mean: 

Adam Taylor’s MicroZed Chronicles, Part 132: LabVIEW FPGA, NI RIO, and Eclipse

Xilinx Employee
Xilinx Employee
0 0 39.2K


By Adam Taylor


Last time, we looked at getting the first NI (National Instruments) RIO eval kit example up and running using the traditional LabVIEW environment. This week we are going to look at how we run the same pre-complied FPGA bit file coupled with a C application on the NI Real Time Operating System. For this we will use the Eclipse environment we set up last week.






Rather helpfully, the first example comes with all the source files we need. All we need to do is import them into the Eclipse environment. These files consist of:


  • cpp - The main application
  • h – Header file which details the FPGA interfaces and information on the FPGA
  • c – Contains the functions to use the FPGA bit file within the software
  • h – Declares the functions for NiFpga.c
  • lvbitx – The bit file we will use


Software developed in Eclipse is designed to run on the NI Real Time Operating System, a Linux-based operating system. The software runs on the Zynq SoC’s dual-core ARM Cortex-A9 cores.


The main function in the example does the following:


  1. Sets up the task, memory and stack
  2. Load the FPGA
  3. Executes the flashing of the LEDs for a fixed time period
  4. Closes down the task and exits the application


Written out like that, it seems to be pretty simple. As with all things, it is a little more complicated than we might think.  However the environment and API’s make it pretty straightforward.


NI provides an FPGA Interface C API Generator that creates the necessary files to access and use the FPGA bit file within the application. The first of these is NiFPGA_LEDPWMFPGA.h, which contains the information on the specific bit file to be loaded into the Zynq SoC’s PL (programmable logic). The NiFpga.h and NiFpga.c files provide more generic functions needed to support any FPGA operation.


Within NiFPGA_LEDPWMFPGA.h, you will find the name of the bit file the program will use along with a signature of the bit file to be loaded. If the .lvbitx file does not contain the same signature, the program will generate an error when we attempt to load it.


This file also contains the type definitions needed to interface with the FPGA design. In this case, it defines the number of LEDs controlled by the bit file and the LED intensity. However, we also need methods to read and write from the FPGA bit file from within our program.


This is achieved using the NiFpga_MergeStatus() function to initially open the bit file and then to read and write from it. To do this, the merge function will also include other functions such as the NIFPGA_Open and NI_WriteArrayU8 functions. All of these functions are provided by the generic NiFpga.c and NiFpga.h files generated by the API.

When we run this example on the hardware, we will see the LEDs flashing as before and the console within the Eclipse environment will display the results shown below. There is no GUI, so we cannot change the intensity or operation of the LED’s as in the initial example.





Once we have the example up and running we can easily change the function from flashing the LEDs to outputting a constant illumination on the LEDs. We can also increase the time the demonstration runs simply by changing a few constants and re compiling it.


Next week we will look at how we can create the bit file we wish to use in more detail.




The code is available on Github as always.


If you want E book or hardback versions of previous MicroZed chronicle blogs, you can get them below.




  • First Year E Book here
  • First Year Hardback here.




MicroZed Chronicles hardcopy.jpg




  • Second Year E Book here
  • Second Year Hardback here



 MicroZed Chronicles Second Year.jpg




You also can find links to all the previous MicroZed Chronicles blogs on my own Web site, here.






Tags (2)