Trenz Electronic GmbH Support Forum

Trenz Electronic Products => Trenz Electronic FPGA Modules => Topic started by: Deepak on November 19, 2021, 01:21:39 AM

Title: C++ Program using Function Pointer not running in Microblaze
Post by: Deepak on November 19, 2021, 01:21:39 AM
Hello,

I am writing a simple program with templates and function pointer in Vitis 2019.2 to run on the Microblaze. I instantiated a Microblaze and BRAM in the hardware.
The program is compiling without any errors but result is not stored on the memory. I ran the same program on my local desktop and it is running as expected.

Can someone please help me on how to debug this issue?

I have posted the program below.

Thanks for your time and consideration.

#include "xil_io.h"
#include "xparameters.h"
#include <functional>

int AddFunc(int a, int b, int c){
     int ans = a + b + c;
     return ans;
}

template <typename T, typename... ArgTypes>
class FuncExec{
     const std::function<T(ArgTypes...)> f_;
     T value;

public:
     FuncExec(const std::function<T(ArgTypes...)> f) : f_(f) {}

     void FuncInput(ArgTypes... args){
          value = f_(args...);
          Xil_Out64(XPAR_AXI_BRAM_CTRL_1_S_AXI_BASEADDR + sizeof(double) + sizeof(double), value);
     }
};

int main() {
     FuncExec <int, int, int, int> func1(AddFunc);
     func1.FuncInput(3, 3, 3);
     return 0;
}
Title: Re: C++ Program using Function Pointer not running in Microblaze
Post by: JH on November 23, 2021, 07:30:21 AM
Hi,
I didn't work with C++ and Xilinx vitis. So I can't help much on this problem.
Maybe you should write one time to Xilinx forum because this is a more general question and xilinx community is much bigger .

br
John