cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jothiadityan
Visitor
Visitor
805 Views
Registered: ‎12-13-2019

Using a static/persistent variable in Vivado HLS

I am trying to design a HLS Fifo IP which records the number of times the IP has been called. I tried using a static variable which needs to start at 0 and increment by 1 each time it gets called or each time a new fifo of 2048 is generated. I used the following code but the variable gets reset to 0 each time the function is called when checking on the Simulation in HLS:

 

void generate_fifo(unsigned char d_out[2048]){
#pragma HLS INTERFACE ap_fifo port=d_out bundle=CRTL_BUS
#pragma HLS INTERFACE s_axilite port=return bundle=CRTL_BUS

static unsigned char counter=0;
//#pragma HLS RESET variable=counter off
for (int i=0;i<2048;i++){

 d_out=...;

}

counter++;

 

I tried with the reset pragma set to off still doesn't work out. Is there anything I am missing? How can I implement this logic in HLS ?

0 Kudos
3 Replies
nithink
Xilinx Employee
Xilinx Employee
802 Views
Registered: ‎09-04-2017

@jothiadityan  Do you see the expected behavior when you run c simulation?

Thanks,

Nithin

0 Kudos
jothiadityan
Visitor
Visitor
721 Views
Registered: ‎12-13-2019

@nithink nope the variable is zero at each call. It keeps getting reset. 

0 Kudos
nithink
Xilinx Employee
Xilinx Employee
712 Views
Registered: ‎09-04-2017

@jothiadityan so you need to first fix the behaviour at c simulation. I guess gcc would give the same behaviour. You should review your code once

Thanks,

Nithin

0 Kudos