Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
All support for Intel NUC 7 - 13 systems has transitioned to ASUS. Read latest update.
20593 Discussions

Reading data from FPGA on HPS with Linux - what's the best way to do it?

jackhab
New Contributor I
782 Views

I have a Cyclone V with Linux application on ARM.

 

The application accesses FPGA directly by mapping HW light- and heavy-weight bridges into virtual memory space (without kernel driver).

 

Currently, I have a working application which does all access via alt_read_word() and alt_write_word().

 

I recall from NIOS documentation that this is the proper way to access HW memory to avoid caching issues but I couldn't find anything about it with regards to ARM. So I'd like to ask the following:

 

  1. Should FPGA memory be accessed by HPS only via SoCAL Memory Read/Write Utilities or it can be used as normal HPS RAM including calling memcopy() to move data between FPGA and HPS?
  2. Is there a document for SW developers which describes how HPS should access FPGA memory space?

 

Thanks.

0 Kudos
4 Replies
Jeet14
Employee
751 Views

Hi,


If you use the HPS and FPFA on chip RAM, then this can be accessed using the mmap() function in linux. 


You can refer the Cyclone V GSRD on below link. https://www.rocketboards.org/foswiki/Documentation/CycloneVSoCGSRD


Cyclone V, FPGA-to-HPS Bridges Design Example

https://www.intel.com/content/www/us/en/support/programmable/support-resources/design-examples/horizontal/fpga-to-hps-bridges-design-example.html


Regards

Tiwari


0 Kudos
jackhab
New Contributor I
711 Views

Hi Tiwari

 

I, indeed, use mmap() to gain access to FPGA memory space. But my question was about what happens during actual read and write.

 

Should I read the memory word-by-word using alt_read_word() function or reading big memory chunks using standard memcpy() also OK?

 

I am asking it because I'm not sure how ARM's data caching will behave during mempcpy() and I'm afraid caching can cause data corruption.

0 Kudos
Jeet14
Employee
676 Views

Hi,


Cross-compiler vendors generally include a precompiled set of standard class libraries, including a basic implementation of memcpy() . Unfortunately, since this same code must run on hardware with a variety of processors and memory architectures, it can't be optimized for any specific architecture. 


A variety of hardware and software factors might affect your decision about a memcpy() algorithm. These include the speed of your processor, the width of your memory bus, the availability and features of a data cache, and the size and alignment of the memory transfers your application will make.


An intimate knowledge of your target hardware and memory-transfer needs can help you write a much more efficient implementation of custom memcpy() functions.

You can also refer below link on memcpy and custom memcpy functions-

https://www.intel.com/content/www/us/en/developer/articles/technical/performance-optimization-of-memcpy-in-dpdk.html


I suggest you to use the data reading using driver APIs i.e. alt_read_word();


Regards

Jeetesh



0 Kudos
Jeet14
Employee
600 Views

Hi,

 

If you have any other question on the matter, please let me know.

 

Regards

Jeetesh


0 Kudos
Reply