UPGRADE YOUR BROWSER

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!

cancel
Showing results for 
Search instead for 
Did you mean: 
267 Views
Registered: ‎07-08-2019

Executing an algorithm in FPGA and host PC in SDK

Hello,

 

I'm using the SDK to program an algorithm, which has a textfile input. My idea is to download the textfile into the board (I used dow -data command and it worked) so later the FPGA will scan it (scanf) faster than my PC would and all the program would be executed in my ZCU102-ES2.

However, I couldn't find any way to scan my textfile in the board, so I've thought about scanning the text input in my PC (it would work as a host) and then, when I reach the algorithm function calling, the algorithm (previously installed in the FPGA) would be executed in the board.

I'd like to ask you which one of the two ways you would choose and how to keep advancing. I've been stuck for some days.

Thanks and cheers.

0 Kudos
10 Replies
256 Views
Registered: ‎07-23-2019

Re: Executing an algorithm in FPGA and host PC in SDK

@jorge_barredo 

"so later the FPGA will scan it (scanf) faster than my PC would"

A couple of potential misconceptions:

1 - what is "the FPGA"? You have a PS and a PL that both can do things independently.

2 - scanf being faster. Why? Because it's an FPGA and everyone says they are fast? Look, scanf is a standard C function that is compiled to assembler code and executed by a CPU, either your laptop one or the Cortex in your FPGA board. for the fastest access, you read your text (assumed ASCII) into a byte array and index it. If you want even a faster access, load it into the PL BRAM and stream it with a DMA and axi stream.

 

0 Kudos
253 Views
Registered: ‎07-08-2019

Re: Executing an algorithm in FPGA and host PC in SDK

Sorry, I didn't express myself too good.

When I said "scan faster" I meant to have everything together in the FPGA in several codes I have already programmed. My question is that as my board doesn't allow fscanf, fprintf, fopen, etc, if there's a solution to this in the way of having a host PC that loads the textfile (a graph with many nodes) and when I reach the algorithm calling it's executed in the board.

I know that in Vivado HLS you can select one top function (the algorithm) and a testbench (where I would read the file). But I ask if there's something like this in SDK.

0 Kudos
242 Views
Registered: ‎07-23-2019

Re: Executing an algorithm in FPGA and host PC in SDK

 

scanf reads from stdin, your keyboard in a PC. Fscanf reads files so you need a file tree. Maybe is fscanf what you need.

Keeping things together doesn't ensure speed. A hundred snails in a box won't outrun a cheetah.

Accessing data is usually what consumes the least time. If you are concerned about speed you should focus on speeding up your process, not your data grabbing. Most of the times, data is read and buffered while the previous batch is being processed.

something like testbenches for software? I think there is something like that for things like avionics software, etc. but is probably not meant for what you want it. Testbenches create an artificial world around the bit you are testing, but eventually, your bit will go into a board without the testbench so you solved nothing. If you need your software to read a file, you need a solution in the real world, a testbench is like getting drunk and forgetting the problem until tomorrow. Then the problem wakes you up again.

you need a real connection in your software, a serial port, a VCP, a USB host or device, ethernet... then decide a protocol and let your software read your data through that channel, forget testbenches.

 

0 Kudos
207 Views
Registered: ‎07-08-2019

Re: Executing an algorithm in FPGA and host PC in SDK

Thanks so much @archangel-lightworks , I've thinking a lot about what you said.

I'll use the textfile graph as an input and fscanf. I've tested it and seems to work. One last question: in which folder do i have to paste the textfile? My FPGA doesn't find it and I've tried several directories, doesn't read it.

0 Kudos
194 Views
Registered: ‎07-23-2019

Re: Executing an algorithm in FPGA and host PC in SDK

It shouldn't matter where the file is. The /home should work.

If your processor can't find it, most probably is because it isn't there. No need to try directories.

0 Kudos
187 Views
Registered: ‎07-08-2019

Re: Executing an algorithm in FPGA and host PC in SDK

You mean /home directory in a Linux project of the SDK?

0 Kudos
Highlighted
174 Views
Registered: ‎07-23-2019

Re: Executing an algorithm in FPGA and host PC in SDK

 

/home directory in the file tree in your board's RAM memory (loaded from the SD card) and is accessible by the PS in your FPGA.

164 Views
Registered: ‎07-08-2019

Re: Executing an algorithm in FPGA and host PC in SDK

I didn't use a SD card, I thought I could sent it directly to the board and through a pragma or something I'd store the file in the BRAM. This isn't the easy issue i believed.

0 Kudos
149 Views
Registered: ‎07-23-2019

Re: Executing an algorithm in FPGA and host PC in SDK

You probably can send all the config + software + file tree via jtag, I prefer the SD card.

What I'm pretty sure you cannot do is having Linux based on BRAM. If you can, you would be the first Linux without external RAM in the World, I guess. The main reason is the size. Also, your on-chip processor has dedicated pins to the external RAM, that's a sign.

There is no problem for having data in BRAM (on top of Linux using RAM). You can if you like, but you will need an interface to the processor, like an AXI interconnect, etc. It doesn't make much sense because having Linux you already have lots of space in the RAM and is already accessible by the processor. It's not using something free.

 

0 Kudos
144 Views
Registered: ‎07-08-2019

Re: Executing an algorithm in FPGA and host PC in SDK

Thanks again.

Do you know any step-by-step guide for both jtag and sd card methods?

Cheers

0 Kudos