Author Topic: C++ Program using Function Pointer not running in Microblaze  (Read 335 times)

Deepak

  • Active Member
  • *
  • Posts: 15
C++ Program using Function Pointer not running in Microblaze
« 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;
}

JH

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1835
Re: C++ Program using Function Pointer not running in Microblaze
« Reply #1 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