06-26-2016 04:36 PM
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.
06-26-2016 11:00 PM
06-27-2016 02:42 AM
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.
06-27-2016 09:25 AM
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.