I want to add a binary trigger signal for measurements to my vivado HLS IP. The code looks as follows:
void subfunction1(const int a[10], const int b[10], int out[10]){
for(int i=0;i<10;i++){
out[i] = a[i] + b[i];
}
}
void subfunction2(const int a[10], const int b[10], int out[10]){
for(int i=0;i<10;i++){
out[i] = a[i] + b[i];
}
}
void function(const int a[10], const int b[10], int out[10], bool *trigger){
subfunction1(a, b, out);
*trigger = true;
subfunction2(out, b, out);
*trigger = false
}
uint8_t top_level_fun(const int a[10], const int b[10], int out[10], bool *trigger){
#pragma HLS INTERFACE ap_memory port = a
#pragma HLS INTERFACE ap_memory port = b
#pragma HLS INTERFACE ap_memory port = out
#pragma HLS INTERFACE ap_fifo register port = trigger
#pragma HLS RESOURCE variable=a core=ROM_1P_BRAM
#pragma HLS RESOURCE variable=b core=ROM_1P_BRAM
#pragma HLS RESOURCE variable=out core=RAM_1P_BROM
function(a,b,out,trigger);
return 0x01; // success
}
I want the trigger variable to be 0 normally and 1 during the execution of subfunction2. When I compile/co-simulate the code and view the results in the full wave viewer I see that the value of trigger never changes. How can I control the value of trigger during the execution of my code so that I can see this on the top level of my IP.
You need to make your trigger variable volatile:
Otherwise the compiler will optimize away previous calls as it thinks they are unnecessary.
Please note the section on multi-access pointers in UG902 / UG1399: