cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
embedded
Advisor
Advisor
977 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
tedbooth
Scholar
Scholar
857 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
calibra
Scholar
Scholar
949 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
embedded
Advisor
Advisor
942 Views
Registered: ‎06-09-2011
Could you please explain more? I did not understand.
Thanks,
Hossein
0 Kudos
embedded
Advisor
Advisor
941 Views
Registered: ‎06-09-2011

Could you please explain more? I did not understand.

Thanks,
Hossein
Tags (2)
0 Kudos
calibra
Scholar
Scholar
931 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 ==
tedbooth
Scholar
Scholar
858 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
embedded
Advisor
Advisor
833 Views
Registered: ‎06-09-2011

Hi @tedbooth ,

Thanks. I forgot to add it to the project.

Thanks,
Hossein
0 Kudos