Hi,
You can refer following code and i have not optimized it.
#include "HLS/hls.h"
# include <stdio.h>
# include "HLS/ac_int.h"
# include "HLS/ac_fixed.h"
# include "HLS/extendedmath.h"
# include "HLS/math.h"
typedef ac_fixed<11, 1, false> fixed_11_1_t;
typedef ac_fixed<28,8,false> fixed_28_8_t;
typedef ac_fixed<12,2,true> fixed_12_2_t;
typedef ac_fixed<21,1,false> fixed_21_1_t;
# define N 2
component void dut(fixed_11_1_t a, fixed_11_1_t b, fixed_28_8_t *dout)
{
unsigned int i;
fixed_28_8_t acc= 0;
fixed_11_1_t a_reg, b_reg;
fixed_12_2_t sub;
fixed_21_1_t sub2;
for(i=0; i<N; i++)
{
a_reg = a;
b_reg = b;
sub = a_reg - b_reg;
sub2 = sub*sub;
acc += sub2;
}
*dout = acc;
}
int main() {
fixed_28_8_t z;
fixed_28_8_t ip = &z;
fixed_11_1_t x={128.1,128.1};
fixed_11_1_t y={128.1,128.1};
dut(x,y,&z);
printf("Test ecxecuted\n");
getchar();
return 0;
}
Let me know if this has helped resolve the issue you are facing or if you need any further assistance.
Best Regards,
Anand Raj Shankar
(This message was posted on behalf of Intel Corporation)