cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Mentor
Mentor
402 Views
Registered: ‎06-09-2011

Can't read a file data in Vivado HLS testbench

Jump to solution

Hi all,

I am going to use a file which contains samples(16 bits, so short data type in C++) of a generated Sin signal as the input of my testbench in HLS. All my efforts were failed. I read all data as zero!. I see the file has non zero values.

fscanf (FpRd, "%hi\n", &Signal);
printf("\n Read with fscanf: %d", Signal);

Above code returns non zero values in a C++ application. But, here it only returns 0 value in Signal. I have to read values from the file to feed my Synthesis C code with that and make sure the C verification stage passes successfully.

Thanks in advance,

Hossein

Thanks,
Hossein
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Scholar
Scholar
282 Views
Registered: ‎03-28-2016

@embedded ,

By chance have you added the text file to your HLS project? 

It needs to be added explicitly to the "Simulation" files in your HLS project.  All of the files get copied to the ..../solution/csim/build directory.  If the file is not present in that directory, you will get zeros if you try to read from it.

Ted Booth | Tech. Lead FPGA Design Engineer | DesignLinx Solutions
https://www.designlinxhs.com

View solution in original post

0 Kudos
6 Replies
Highlighted
Voyager
Voyager
374 Views
Registered: ‎06-20-2012

I assume you have verified that FpRd is a valid descriptor.

== If this was helpful, please feel free to give Kudos, and close if it answers your question ==
0 Kudos
Highlighted
Mentor
Mentor
367 Views
Registered: ‎06-09-2011
Could you please explain more? I did not understand.
Thanks,
Hossein
0 Kudos
Highlighted
Mentor
Mentor
366 Views
Registered: ‎06-09-2011

Could you please explain more? I did not understand.

Thanks,
Hossein
Tags (2)
0 Kudos
Highlighted
Voyager
Voyager
356 Views
Registered: ‎06-20-2012

I suppose that your code is like that:

  FILE * FpRd;
  FpRd= fopen ("myfile.txt","r");

 Have you checked if FpRd is != NULL.

== If this was helpful, please feel free to give Kudos, and close if it answers your question ==
Highlighted
Scholar
Scholar
283 Views
Registered: ‎03-28-2016

@embedded ,

By chance have you added the text file to your HLS project? 

It needs to be added explicitly to the "Simulation" files in your HLS project.  All of the files get copied to the ..../solution/csim/build directory.  If the file is not present in that directory, you will get zeros if you try to read from it.

Ted Booth | Tech. Lead FPGA Design Engineer | DesignLinx Solutions
https://www.designlinxhs.com

View solution in original post

0 Kudos
Highlighted
Mentor
Mentor
258 Views
Registered: ‎06-09-2011

Hi @tedbooth ,

Thanks. I forgot to add it to the project.

Thanks,
Hossein
0 Kudos