NI Home > Community > NI Discussion Forums

NI Labs

Reply
Member
captain_only
Posts: 10

C Interface to LabVIEW FPGA

[ Edited ]

Welcome to NI Labs C Interface to LabVIEW FPGA


Welcome to the C Interface to LabVIEW FPGA forum. This thread is intended to foster discussion about the project, so please post any questions, comments, bug reports, and other relevant information here.
Of particular interest is feedback on how easily the C Interface to LabVIEW FPGA integrates into the application build process. The C Interface to LabVIEW FPGA is provided by C code that must be compiled into the final application. Some of this code is specific to a particular FPGA VI and must be generated once the FPGA VI is complied into a bitfile. We would like to hear about any difficulties this causes and any recommendations for improving it.

Message Edited by Support on 01-16-2009 12:08 PM
NI Software Engineer - RIO
Member
koutnym
Posts: 17
0 Kudos

Re: C Interface to LabVIEW FPGA

Hello,

 

mentioned C interface to LV FPGA is nice feature coming right in time. I was already thinking how to integrate my C code subroutines with the LabVIEW FPGA and this is it. Before I run some performance testing, could you please tell me when will be available access to the either array elements or FPGA memory (and or including DMA)? My goal is to read/write data blocks (~1KB) from/to cross LabVIEW FPGA target to my specific hardware. I am currently working with sbRIO 9612 and the performance of data exchange between FPGA target <-> RT host written purely in LabVIEW is not satisfying me. This is because of complexity of used algorithms.

 

Thank you for response in advance.

Member
kentyman
Posts: 33
0 Kudos

Re: C Interface to LabVIEW FPGA

koutnym,

Glad to hear you're as excited as we are!

We are currently working on both read/write of array indicators/controls, as well as read/write of DMA FIFOs. We are hoping to have another iteration of the NI Labs release with these features sometime in the March timeframe, though we cannot promise anything.

As for performance, the actual function calls themselves should not be any faster than the current nodes on the FPGA Interface palette in LabVIEW. However, if your speed issue is related to your LabVIEW RT code itself, you could very well see a speedup by reimplementing it in C/C++.

I should warn you that the NI Labs implementation of DMA FIFOs will likely be slower than LabVIEW for technical reasons, so that will definitely effect any benchmarks you do. The goal of our NI Labs release is to get customers to try to tools/API/etc., so we hope that you'll still find benefit in using it. Don't worry, DMA FIFOs will no longer be slow when this feature releases.
Member
iled09
Posts: 2
0 Kudos

Re: C Interface to LabVIEW FPGA

Could you explain the purpose of this C / C++ interface? Does this allow one to run C / C++ programs on the FPGA, or does it just allow C / C++ programs to communicate with the FPGA from a computer or compactRIO.
Member
koutnym
Posts: 17
0 Kudos

Re: C Interface to LabVIEW FPGA

The second thought is right. C Interface to LabVIEW FPGA allows you to communicate with the code running on LabVIEW FPGA. As far as I know there is no other choice to program FPGA that use LabVIEW.
Member
kentyman
Posts: 33
0 Kudos

Re: C Interface to LabVIEW FPGA

iled09,

 

koutnym is right. This feature provides the ability to write programs in C/C++ which interface with LabVIEW FPGA code running on an FPGA target, such as an NI-RIO device. Previously, the only way to accomplish this was to write "host VIs" using the FPGA Interface palette.

Member
koutnym
Posts: 17

Re: C Interface to LabVIEW FPGA

Hello again!

 

I am satisfied with the functionality of  C Interface to LabVIEW FPGA. It works fine. I have had only some troubles to compile it using Wind River Workbench version: 3.0 (vxworks-6.6). Include file "stdint.h" provided with vxworks-6.6 is not "compatible" with the include file from the NI gccdist package (downloaded from NI FTP). So I've copied the "stdint.h" library provided by NI to my project directory and then the compilation went ok. So far so good.

 

I am pretty eager to use either DMA channel, or arrays to exchange the data. Could you please provide me with NiFpga.out library, where is enabled function "NiFpgaDll_WriteArrayU8, NiFpgaDll_ReadArrayU8", at least? It will help I suppose with the data exchange speed. If not possible, I can wait for next release of C Interface to LabVIEW FPGA.

 

Anyway, good work, thanks for it ;o)

Member
kentyman
Posts: 33
0 Kudos

Re: C Interface to LabVIEW FPGA

I'm happy to announce that a new version of the C Interface to LabVIEW FPGA!

This release adds support for DMA FIFOs, interrupts, and arrays. Additionally, there is now an executable named capigen.exe which generates your API instead of a VI, which can even be run from the command-line.

Just re-download the installer, unzip it, and run setup.exe. You shouldn't need to uninstall the previous version. As usual, we'd love to hear any and all feedback you have!

And as I mentioned before: The NI Labs implementation of DMA FIFOs will be slower than LabVIEW for technical reasons, so keep that in mind while benchmarking. The goal of our NI Labs release is to get customers to try to tools/API/etc., so we hope that you'll still find benefit in using it. Don't worry, DMA FIFOs will no longer be slow when this feature officially releases.

Also, note that the NI Labs website has yet to be updated, so please disregard the "does not currently support DMA" wording.
Member
koutnym
Posts: 17
0 Kudos

New version of C Interface to LabVIEW FPGA observations

Hello all,

After downloading latest version of C FPGA Interface I tried to rebuild delivered example code using gcc distribution downloaded from NI. I did the build from command line using my own makefile. Previous version of C FPGA Interface passed ok, new version of C FPGA Interface caused syntax error in "NiFpga.h" file. Error is caused when keyword "inline" is used. New version of C FPGA Interface has for some reason conditionally excluded definition of "inline" keyword which might be problem for above mentioned particular version of GCC. I would propose to change keyword "inline" with keyword "__inline__". Then all will work fine same way as before (http://developer.apple.com/documentation/developertools/gcc-4.0.1/gcc/Inline.html). Maybe someone could suggest other solution if this one is not for some reason good.

 

--- 

 

Back to the provided VxWorks sample code installed in the "\Program Files\National Instruments\NI Labs C FPGA Interface\Example". I have compiled "Example (CompactRIO).vi" for my sbRIO-9612 and then did the rebuild of that example using distributed GCC. I have also used "capigen.exe" utility. All works fine. So far so good.

 

Then I took my existing project, already working fine with previous version of C Interface to LabVIEW FPGA. Used again "capigen.exe" to be able create "lvbitx" file and did rebuild of using distributed GCC. When I loaded new files to the cRIO, my application is no longer working. From debug console I got something like this:

 

LOG:
Bitfile::EmptyElemTag
Bitfile::smileyfrustrated:TAG
Bitfile::Content::smileyfrustrated:EQ::BitfileVersion::EmptyElemTag
.
.
.
Bitfile::Content::smileyfrustrated:EQ::VI
Bitfile::Content::smileyfrustrated:EQ
Bitfile::Content
Bitfile


Above displayed LOG is shortened. Then function "NiFpga_Open" returned following error: -52005 (A memory allocation failed).

 

I've seen that structure of bitfile is somehow changed... I can't go deeper with the investigation. Could you give me any hint or technical support with this? 

Member
kentyman
Posts: 33
0 Kudos

Re: New version of C Interface to LabVIEW FPGA observations

koutnym,

 

Thanks for the feedback regarding inline. What version of GCC are you using?

 

Sorry to hear you're having problems in your existing project. Please ensure the following:

 

1. You're building with the latest versions of NiFpga.h and NiFpga.c (with whatever inline tweaks you need to satisfy GCC).

2. You're building with the newly created version of NiFpga_*.h from capigen.exe.

3. You're installing the .lvbitx file created from capigen.exe, rather than the old .bin file or the original .lvbit file.

4. You're passing the path to the .lvbitx file into NiFpga_Open, rather than the old .bin file or the original .lvbit file.

 

I suspect that #4 is the problem you're having. If that doesn't fix it, please include a bit more of the error output (about a dozen lines from the top and a dozen from the bottom).

 

As always, thanks for the feedback!