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: 
Highlighted
Visitor piflodrops
Visitor
297 Views
Registered: ‎04-25-2017

Read ap_int data from CSV file created via ILA export.

Jump to solution

Hi,

In vivado HLS simulation (2017.4), I need to read data from a csv file created via the export ila in the hardaware manager on Vivado.

One of the data that I must read is an ap_int<256> and here is the shape of the csv file I want to read :

 

Sample in Buffer,Sample in Window,TRIGGER,data_i_need_to_read[255:0]
0,0,0,05d14cc4af723fbc2bd24259000000000284f73bcf7efffffffff9cf26d7c4f9
1,1,0,06d0c0eff7833fa2d5a5b8e2ffffffffff49b3f4b019fffffffff7e7e2506f24
2,2,0,07cfc774be3a3f857fa9c1b9fffffffffbab904566a1fffffffff91fcf9bb6da

My main goal is to ba able to read data_i_need_to_read. To do so I have tried to use classic C function like fscanf :

 

int s_in_buffer, s_in_window, trigger;
ap_int<256>  d_exp_im_fifo_0;

 fscanf(ptr_fid, "%d,%d,%d,%064x",s_in_buffer, s_in_window, trigger, d_exp_im_fifo_0);

I've also tried to use c++ like : csv_file >> s_in_buffer >>  s_in_window >> trigger >> d_exp_im_fifo_0;

 

But the compilator always send me an error :

error: cannot pass objects of non-trivially-copyable type 'class ap_int<256>' through '...'

So my question is, what is the good way to read this kind of data ?

My question had already been asked here, but nobody could answer I guess.

https://forums.xilinx.com/t5/Vivado-High-Level-Synthesis-HLS/A-question-about-reading-data-from-an-external-file/m-p/726301#M7426

 

Thank you for helping me.

 

See You,
Pierre

 

 

0 Kudos
1 Solution

Accepted Solutions
Explorer
Explorer
248 Views
Registered: ‎07-18-2018

Re: Read ap_int data from CSV file created via ILA export.

Jump to solution

Are you using this for a test bench?

i think the issue you are having is that fscanf doesn't understand the HLS ap_ints.

You likely should read it in as a string, and then write a function to convert the string into a 256bit integer,

 

I would do something where I would convert the string to a decimal value between 0-15 starting at the MSB, and each time I see a new char shift it over by 4 bits and add the previous value.

char text[64];

int val_2_add;

for (i=0; i <64; i++) {

if(text[i] >= 48 | val_2_add[i] <= 57) {

     val_2_add = (text[i]  -48);

} else if ( <Same but for a - f >) {

}

d_exp_im_fifo_0 = (d_exp_im_fifo_0 << 4) + val_2_add ;

}

I believe that should get some arbitrary sized bit vector from a file. There might be an HLS function to do this, but I didn't see it so this should work instead.

0 Kudos
2 Replies
Explorer
Explorer
249 Views
Registered: ‎07-18-2018

Re: Read ap_int data from CSV file created via ILA export.

Jump to solution

Are you using this for a test bench?

i think the issue you are having is that fscanf doesn't understand the HLS ap_ints.

You likely should read it in as a string, and then write a function to convert the string into a 256bit integer,

 

I would do something where I would convert the string to a decimal value between 0-15 starting at the MSB, and each time I see a new char shift it over by 4 bits and add the previous value.

char text[64];

int val_2_add;

for (i=0; i <64; i++) {

if(text[i] >= 48 | val_2_add[i] <= 57) {

     val_2_add = (text[i]  -48);

} else if ( <Same but for a - f >) {

}

d_exp_im_fifo_0 = (d_exp_im_fifo_0 << 4) + val_2_add ;

}

I believe that should get some arbitrary sized bit vector from a file. There might be an HLS function to do this, but I didn't see it so this should work instead.

0 Kudos
Visitor piflodrops
Visitor
232 Views
Registered: ‎04-25-2017

Re: Read ap_int data from CSV file created via ILA export.

Jump to solution

Yes I am using it for a Test Bench.

In deed your solution seems to be the best one since there is no HLS function available to read ap_int bigger than 64bits.

If you here about it, let me know :)

Thank you!