The output of my IP is zeros when executed in the same notebook cell, Why?

Hello

I have an algorithm that I am trying to accelerate using multiple IPs. The issue is the following. When I try to read the buffer from the same notebook cell the output is zeros. However, when I print it in the next cell it gives me the correct results. The algorithm looks like follows:

Variable initialization
for I = 0 to 100:
   IP_1
   # some code
   IP_2 
  # some other code
end for 

I am almost sure my IPs are fast enough to finish before printing the results. I even tried to read the control register and it gives me 3 = b11 meaning ap_done = 1

If I try to run my algorithm in .py file instead of a notebook will I encounter the same issue? How can I solve this issue ?
Thank you

If the correct values are read later, it does seem like a race condition. Waiting for ap_done should protect against this, so I’m not sure what else to suggest.
Can you try adding a sleep delay into your first cell before you read the results?

Cathal

1 Like

Hi @cathalmccabe
I honestly don’t see how this looks like a race condition. I made a screenshot of the notebook to further explain my issue. Please have a look:

Why do you NOT think this is a race condition?
This is what it looks like to me.
Can you add a check for AP_DONE after you call run_dg_kernel()?

Cathal

First, my apologies, you are right about the racing condition. I was a little bit confused.
Second, I figure out what is going on. The IP takes I think 1 sec to process and send the data to the memory. When I try to run the cells fast I get AP_DONE is 0 after 1 sec it turns to 1. meaning my IP is slow.

One solution is assumed to be setting a higher PL_clk frequency that meets the timing constraints. Or optimize more my design. Still, any advice would be more than welcome for me.

1 Like

Yes, you can try and optimize your design.
You could add a check after you call your hardware function.
E.g.

while ap_done == 0:
  pass

You could try add interrupts, but interrupts are complicated. If you don’t need interrupts, polling on ap_done is much simpler.

Cathal

2 Likes