cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
nanson
Explorer
Explorer
758 Views
Registered: ‎08-31-2017

ap_unit operation and cout issue

Jump to solution

Hi, dear elites,

I wrote a simple test code to test arithmetic operation over 64 bits as shown below. However, somehow the output of basic small number test via cout is 0 in HLS 2017.02. After some trial, I still cannot resolve it. Maybe you can provide me some guidance to out of this issue.

Thanks

 

 

#include "ap_int.h"

typedef ap_uint<124> in1_t;
typedef ap_uint<124> in2_t;
typedef ap_uint<125> out_t;

void arith_over_65bits(in1_t inA, in2_t inB, out_t sumAB);
 
#include "arith_over_65bits.h"

void arith_over_65bits(in1_t inA, in2_t inB, out_t sumAB) {

sumAB = inA + inB;

}
 


#include <stdio.h>
#include "arith_over_65bits.h"

int main()
{
in1_t inA;
in2_t inB;
out_t sumAB;

//inA = "2";//"18446744073709551557111";
//inB = "1";

inA = 2;
inB = 1;

arith_over_65bits(inA,inB,sumAB);

std::cout << "cout of sumAB : " << sumAB;

}
 
INFO: [SIM 2] *************** CSIM start ***************
INFO: [SIM 4] CSIM will launch GCC as the compiler.
Compiling ../../../../../phd_sdu_dk/plan4act/HLS_templates/arith_over_65bits/src/tb_arith_over_65bits.cpp in debug mode
Compiling ../../../../../phd_sdu_dk/plan4act/HLS_templates/arith_over_65bits/src/arith_over_65bits.cpp in debug mode
Generating csim.exe
cout of sumAB : 0
INFO: [SIM 1] CSim done with 0 errors.
INFO: [SIM 3] *************** CSIM finish ***************
0 Kudos
1 Solution

Accepted Solutions
u4223374
Advisor
Advisor
746 Views
Registered: ‎04-26-2015

You're passing sumAB by value, so it cannot be changed by the arith_over_65bit function. Research "pass by value", "pass by reference", and "pass by address".

View solution in original post

0 Kudos
2 Replies
u4223374
Advisor
Advisor
747 Views
Registered: ‎04-26-2015

You're passing sumAB by value, so it cannot be changed by the arith_over_65bit function. Research "pass by value", "pass by reference", and "pass by address".

View solution in original post

0 Kudos
nanson
Explorer
Explorer
730 Views
Registered: ‎08-31-2017

Thanks for the hint. After modifying as call by reference, it's resolved.

0 Kudos