cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Observer
Observer
5,961 Views
Registered: ‎07-17-2014

sdsoc hardware function global array access between functions

Hi, 

I have a problem as the following: in sdsoc, I have two hardware functions, the first one is passing a big junk of integer array from arm to pl (a global int array of 15k elements). This function is called only once in the beginning of the program.

I have another hardware function that takes another array (150 elements) as input and does comparisons with the larger array. The sw only version works fine but the hw/sw version does not work. It seems like the second function reads zeroes from the global array that is previously filled with the first hardware func. The second hardware function is called many times from the arm side.

My question is that can hardware functions share data like the scenario I described? What is the common way of doing this? Thanks. 

0 Kudos
Reply
3 Replies
Teacher
Teacher
5,937 Views
Registered: ‎03-31-2012

From a design perspective that's certainly possible. What you need is create storage in PL for the 15K integers and generate a read interface to that array with an offset/address so that the second pl block can use it. I am not sure if you can do that pl block design through sdsoc.
Also to debug, make sure you can write & read the 15K array to make sure that pl design of that portion really works.
- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos
Reply
Anonymous
Not applicable
5,927 Views

I also want to do some thing similar and one of the solution that came to my mind is to create a top level function which calls the other two functions. You declare the 15K array in this top level function. This top level functions calls one of the two functions based on an input argument input from SW. Something on the following lines:

 

#define FUNC1 (1)
#define FUNC2 (2)

template<typename T1, typename T2>
int MyTopHW(T1 smallArray, T2 largeArray, int condition)
{
    T1 smallArray[];
    T2 largeArray[15K];

    switch condition: {
    case FUNC1:
        function1(largeArray);
        break;
    case FUNC2:
        function2(smallArray, largeArray);
        break;
    }
}

Now how does the synthesis results are effected by this switch condition is something you should test.

Xilinx Employee
Xilinx Employee
5,899 Views
Registered: ‎06-29-2015

Hi gorker,

 

Please be aware that globals are generally to be avoided when passing them to/from hardware functions.

 

According to UG1027 page 33 (2016.1 version) it says:

 

It is an error to refer to a global variable within a hardware function or any of its sub-functions when this global variable is also referenced by other functions running in software.

 

Please try something similar to the code posted by imranashraf where the 15K array is local inside of some wrapper function (or main) and not global.

0 Kudos
Reply