Intel® High Level Design
Support for Intel® High Level Synthesis Compiler, DSP Builder, OneAPI for Intel® FPGAs, Intel® FPGA SDK for OpenCL™
697 Discussions

Sample project with RTL module library not working

messn036
Novice
2,243 Views

Hello Intel Support,

I am attempting to compile a library of RTL components to use in my HLS project.

The HLS project compiles when testing for x86-64 simulation, but the compiler complains about the desired RTL function being "undefined" when attempting to compile for test-fpga.

I have included the relevant files .v and .xml files, but cannot upload the .cpp or .h file though they are included when I compile the library

I am curious as to which file likely has the issue since I can do simulation but not compilation.

Thank you in advance

0 Kudos
1 Solution
messn036
Novice
2,090 Views

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.

View solution in original post

0 Kudos
8 Replies
YoshiakiS_Intel
Employee
2,223 Views

Hello messn036,

 

For investigation, could you please upload your failure log?

 

Best regards,

 Yoshiaki Saito

0 Kudos
messn036
Novice
2,202 Views
i++ component_testbench.cpp expHBU.a -v --dont-error-if-large-area-est -march=Cyclone10GX -o test-fpga
Target FPGA part name: 10CX220YF780I5G
Target FPGA family name: Cyclone10GX
Target FPGA speed grade: -5
Resolved expHBU.a to /home/grads/messn036/OpenCL-HUBERT/OpenCL-HUBERT/component_ip/expHBU.a
Analyzing component_testbench.cpp for testbench generation
Creating x86-64 testbench
Analyzing component_testbench.cpp for hardware generation
Verifying version information in the included files.
Expecting version 21.2.0.67.4 for all included files.
Included files passed version check. Checked: /home/grads/messn036/OpenCL-HUBERT/OpenCL-HUBERT/component_ip/expHBU.a
Preprocessing FPGA Libraries
Optimizing component(s) and generating Verilog files
component_testbench.cpp:9: Compiler Error: undefined reference to 'expHBU(unsigned char)'
HLS Main Optimizer FAILED.
make: *** [test-fpga] Error 1

I have done some basic troubleshooting in the meantime an narrowed down my error a bit. To compile the RTL library, I am using the following commands

fpga_crossgen exp_wrapper.xml --target hls --emulation_model expHBU.cpp -o expHBU.o
fpga_libtool --target hls --create expHBU.a expHBU.o

But It seems like I need to use different flags to get the xml and verilog to compile for NOT the x86-64 simulation but for the test-fpga version. Am I right here? When should I expect to compile the xml and verilog?

0 Kudos
messn036
Novice
2,197 Views

Additional information: If I compile the library with just the fpga_crossgen command (exclude the expHBU.a step)

fpga_crossgen exp_wrapper.xml --target hls --emulation_model expHBU.cpp -o expHBU.o

And then attempt a -march=Cyclone10GX compile

i++ component_testbench.cpp expHBU.o  -v --dont-error-if-large-area-est -march=Cyclone10GX -o test-fpga

I get the following error

Compiler Error: Cannot find Library file ./test-fpga.prj/spec.xml
0 Kudos
YoshiakiS_Intel
Employee
2,163 Views

Hello messn036,

 

Thank you for sharing the failure log with us.

I think the simple design is necessary to investigate it for us.

So could you share simple full design which can duplicate the error with us?

 

Best regards,

 Yoshiaki Saito

0 Kudos
messn036
Novice
2,144 Views

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

 

0 Kudos
messn036
Novice
2,091 Views

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.

0 Kudos
YoshiakiS_Intel
Employee
2,058 Views

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
}
#endif

 

Best regards,

 Yoshiaki Saito

0 Kudos
YoshiakiS_Intel
Employee
1,842 Views

Hello messn036,

 

I will close this thread if no further questions from you.

 

Best regards,

 Yoshiaki Saito

0 Kudos
Reply