-
Notifications
You must be signed in to change notification settings - Fork 190
Description
I am encountering a issue with the expf() function from <math.h> when running c code on FPGA. The function is returning a small negative number(-4.40810382e-39) instead of the expected small positive number(0.000049) for ac0 similarly for all other variables, which suggests a problem in the floating-point library implementation. Im checking the values on gdb
Project Context & Environment
SDK: V1 branch of git
c code :
#include <stdio.h>
#include <math.h>
int main() {
float ac0 =29.020918;
float ac1 = 35.507084;
float ac2 = 31.198545;
float ac3 = 32.586067;
float result;
float sum = 0.0f;
float max_val = ac0;
if (ac1 > max_val) max_val = ac1;
if (ac2 > max_val) max_val = ac2;
if (ac3 > max_val) max_val = ac3;
ac0 = expf(ac0 - max_val);
sum += ac0;
ac1 = expf(ac1 - max_val);
sum += ac1;
ac2 = expf(ac2 - max_val);
sum += ac2;
ac3 = expf(ac3 - max_val);
sum += ac3;
return 0;
}
Make file : PULP_APP = test
PULP_APP_FC_SRCS = test.c
PULP_APP_HOST_SRCS = test.c
PULP_CFLAGS = -O0 -g
PULP_LDFLAGS += -lm # For math functions
include $(PULP_SDK_HOME)/install/rules/pulp_rt.mk