0

I'm new to FPGA and nios2. I want to add two integers using niosII. When I going to add two integers I wrote a C code like this.

#include "stdio.h"
#include "io.h"
#include "system.h"
int main()
{
    unsigned int a = 24,b=56,c,ans;

    c=a+b;
    printf("%d\n",c);

    while(1);
    return 0;
}

this code gave me correct answer. Now my question is which processor did the a+b operation? computer or FPGA board?. and is here essential to use custom component to do this operation? are there any inbuilt arithmetic operations in niosII?. Please anyone can give me answer. Thanks in advance.

Tricky
  • 3,791
  • 3
  • 10
  • 23
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Nov 01 '21 at 09:40
  • I would expect that to depend on optimisation level. On `-O0` the target CPU, i.e. Nios2 is going to add it, on `-O1` or above, the compiler will just push the constant 80 to stack for printf. – Aki Suihkonen Nov 01 '21 at 09:45

1 Answers1

0

Now my question is which processor did the a+b operation?

FPGA is not the processor. FPGA chip is just large set of logical units. Those units when programmed using NIOS logic form the processor. Now FPGA chip is the NIOS processor.

0___________
  • 60,014
  • 4
  • 34
  • 74