Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20706 Discussions

(CycloneV) Writing 128bits to FPGA at once using linux kernel module

Altera_Forum
Honored Contributor II
1,021 Views

Hi, 

 

I'm trying to write a kernel module that writes 128bits of data to the FPGA using the HPS-to-FPGA bridge. The bridge width is configured as 128 Bits in Qsys and I'm using memcpy_toio() to write data onto the bus. Using the SignalTap anaylzer I can see that the transfer happens in 32bit chunks every 10 cycles or so. What am I doing wrong? Is there a way to write 128bits at once and thereby increase the throughput? 

 

Thanks in advance for your help! 

 

EDIT: Some additional information: I'm working with a De0-Nano-SoC Development board using a Linux 4.1 kernel and an Angström rootfs.
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
294 Views

As the ARM is a 32-bit processor, as well as all the peripheral bridges, that's a really good question. The fast bridge is itself tied to a 64-bit bus to the main L3 switch. I could imagine the bridge AXI management unit can pack data together if configured for it, but I'd think that would require custom instructions? 

 

Check out page 8-18 in the HPS TRM: 

 

"The master issuing capability can be adjusted, through the fn_mod register, to allow one or multiple transactions to be outstanding in the FPGA fabric. The master bypass merge feature can also be enabled, through the bypass_merge bit in the fn_mod2 register. This feature ensures that the upsizing and downsizing logic does not alter any transactions when the FPGA master interface is configured to be 32 or 128 bits wide." 

 

This seems to say that it is worth looking at those two registers to see what their settings are. I'd think you'd WANT the merging to happen, which might not be on by default? That's a U-boot/preloader question, right there. I'd love to hear more, though. instead of a memcpy_toio(), have you tried a 64-bit transaction in a loop or direct?
0 Kudos
Altera_Forum
Honored Contributor II
294 Views

A colleague of mine was able write 64bits at once using the HWLib and the Socal.h library from userspace, but I those seem to be designed for userspace only. I'll try to manipulate the fn_mod registers, though from the documentation I gathered that the merging should be enabled by default.

0 Kudos
Altera_Forum
Honored Contributor II
294 Views

 

--- Quote Start ---  

A colleague of mine was able write 64bits at once using the HWLib and the Socal.h library from userspace, but I those seem to be designed for userspace only. I'll try to manipulate the fn_mod registers, though from the documentation I gathered that the merging should be enabled by default. 

--- Quote End ---  

 

 

Here's a question-- is memcpy_toio limited to 32-bits due to it's interaction with the AXI bus? Why not try abstracting as a long int and doing a direct memory write to test? 

 

EDIT: fixed type
0 Kudos
Altera_Forum
Honored Contributor II
294 Views

Given that the ARM is a 32 bit processor, the only way you will be able to write more than that is with a cache line write, or DMA.

0 Kudos
Reply