Forum Discussion
Sample project with RTL module library not working
- 4 years ago
The issue is in my expHBU.h file. I put
uint8_t expHBU(uint8_t input);Rather than the CORRECT
extern "C" { uint8_t expHBU(uint8_t input); }This extern is extremely esoteric and should be included in the reference manual.
Here are the source files I am using. I am trying to model the basic rtl library tutorial the best I can (which compiles fine in my environment). I'm sure its some easy syntax error that none of the compilers or packagers is catching.
I cannot upload the .cpp and .h files because this site rejects them. Here is the source
expHBU.h
#include <stdint.h> #include "HLS/math.h" uint8_t expHBU(uint8_t input);
expHBU.cpp
#include "expHBU.h" uint8_t expHBU(uint8_t input){ return (uint8_t)exp(input); }
component_testbench.cpp
#include "HLS/hls.h" #include "HLS/stdio.h" #include "HLS/math.h" #include "expHBU.h" component uint8_t executeexp(uint8_t exponent) { return expHBU(exponent); } component uint8_t executeexp_basic(uint8_t exponent) { return exp(exponent); } int main() { uint8_t exponent = 3; uint8_t result = executeexp(exponent); printf("result %d \n", result); return 0; }
Reminder: the x86 simulation works, but the FPGA compile does NOT
Thanks,
messn036
The issue is in my expHBU.h file. I put
uint8_t expHBU(uint8_t input);
Rather than the CORRECT
extern "C" { uint8_t expHBU(uint8_t input); }
This extern is extremely esoteric and should be included in the reference manual.
- YoshiakiS_Altera4 years ago
Occasional Contributor
Hello messn036,
Thank you for the update.
Basically, you need to add the extern “C” to call a function from C++ to C. This is general rule of C++.
C++ Language adds a prefix to a function name to support the class feature.
But, this feature is disabled when you add extern “C”.
So many C/C++ headers include:
#ifdef __cplusplus extern "C" { #endif rtl_inet_uint16 rtl_htons(rtl_inet_uint16 hostshort); rtl_inet_uint16 rtl_ntohs(rtl_inet_uint16 netshort); rtl_inet_uint32 rtl_htonl(rtl_inet_uint32 hostlong); rtl_inet_uint32 rtl_ntohl(rtl_inet_uint32 netlong); #ifdef __cplusplus } #endifBest regards,
Yoshiaki Saito
- YoshiakiS_Altera4 years ago
Occasional Contributor
Hello messn036,
I will close this thread if no further questions from you.
Best regards,
Yoshiaki Saito