Clang works, not GCC

This commit is contained in:
Camille Monière 2022-02-11 19:17:11 +01:00
parent f2a7c0c886
commit cbd04f1a3e
Signed by: moniere
GPG key ID: 188DD5B072181C0F
5 changed files with 23 additions and 25 deletions

View file

@ -19,7 +19,6 @@ if (EXPORT_COMMANDS)
set (CMAKE_EXPORT_COMPILE_COMMANDS ON) set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
endif () endif ()
option (ENABLE_XILINX "use Xilinx provided and proprietary headers." ON) option (ENABLE_XILINX "use Xilinx provided and proprietary headers." ON)
if (ENABLE_XILINX) if (ENABLE_XILINX)
set ( set (
@ -54,8 +53,7 @@ if ((NOT EXISTS ${AP_INCLUDE_DIR}/ap_int.h) OR (NOT EXISTS
message ( message (
FATAL_ERROR FATAL_ERROR
"Arbitrary precision headers not found in ${AP_INCLUDE_DIR}.\n" "Arbitrary precision headers not found in ${AP_INCLUDE_DIR}.\n"
"Consider disabling the ap_int feature using `-DENABLE_AP_INT=OFF`" "Please provide a suitable path to the headers."
" or provide a suitable path to the headers."
) )
endif () endif ()

View file

@ -96,7 +96,7 @@ private:
public: public:
uint8_t rom[max_length]; uint8_t rom[max_length];
constexpr CRomGeneratorConst() { constexpr CRomGeneratorConst() : rom() {
for (unsigned n = 0; n < max_length; n++) { for (unsigned n = 0; n < max_length; n++) {
const double chip_rotation = rotation / double(q) * double(n); const double chip_rotation = rotation / double(q) * double(n);
rom[n] = cordic_rom_gen(chip_rotation); rom[n] = cordic_rom_gen(chip_rotation);
@ -106,7 +106,7 @@ public:
template <unsigned In_W, unsigned NStages, unsigned Tq> template <unsigned In_W, unsigned NStages, unsigned Tq>
void generate_rom_header_const(const char * filename = "rom_cordic.h") { void generate_rom_header_const(const char * filename = "rom_cordic.h") {
constexpr CRomGeneratorConst<In_W, NStages, Tq> rom; constexpr CRomGeneratorConst<In_W, NStages, Tq> rom{};
FILE * rom_file = fopen(filename, "w"); FILE * rom_file = fopen(filename, "w");
if (!bool(rom_file)) { if (!bool(rom_file)) {
@ -130,7 +130,7 @@ void generate_rom_header_const(const char * filename = "rom_cordic.h") {
template <unsigned In_W, unsigned NStages, unsigned Tq> template <unsigned In_W, unsigned NStages, unsigned Tq>
void generate_rom_header_const_raw(const char * filename = "rom_cordic.txt") { void generate_rom_header_const_raw(const char * filename = "rom_cordic.txt") {
constexpr CRomGeneratorConst<In_W, NStages, Tq> rom; constexpr CRomGeneratorConst<In_W, NStages, Tq> rom{};
FILE * rom_file = fopen(filename, "w"); FILE * rom_file = fopen(filename, "w");
if (!bool(rom_file)) { if (!bool(rom_file)) {

View file

@ -54,7 +54,7 @@ public:
const double re_x = floor(double(scale_factor - 1) * cos(-rotation / double(q) * double(n))); const double re_x = floor(double(scale_factor - 1) * cos(-rotation / double(q) * double(n)));
const double im_x = floor(double(scale_factor - 1) * sin(-rotation / double(q) * double(n))); const double im_x = floor(double(scale_factor - 1) * sin(-rotation / double(q) * double(n)));
const std::complex<int64_t> x {re_x, im_x}; const std::complex<int64_t> x {int64_t(re_x), int64_t(im_x)};
double error = 1000.; double error = 1000.;
uint8_t rom_v = 0x0; uint8_t rom_v = 0x0;

View file

@ -11,19 +11,19 @@
#include <ap_fixed.h> #include <ap_fixed.h>
#include <ap_int.h> #include <ap_int.h>
static constexpr double atanDbl[28] {
0.78539816339745, 0.46364760900081, 0.24497866312686, 0.12435499454676,
0.06241880999596, 0.03123983343027, 0.01562372862048, 0.00781234106010,
0.00390623013197, 0.00195312251648, 0.00097656218956, 0.00048828121119,
0.00024414062015, 0.00012207031189, 0.00006103515617, 0.00003051757812,
0.00001525878906, 0.00000762939453, 0.00000381469727, 0.00000190734863,
0.00000095367432, 0.00000047683716, 0.00000023841858, 0.00000011920929,
0.00000005960464, 0.00000002980232, 0.00000001490116, 0.00000000745058};
template <uint8_t N_STAGES, template <uint8_t N_STAGES,
class T, class T,
uint8_t ATAN_I> uint8_t ATAN_I>
struct CAtanLUT { struct CAtanLUT {
static constexpr double atanDbl[28] {
0.78539816339745, 0.46364760900081, 0.24497866312686, 0.12435499454676,
0.06241880999596, 0.03123983343027, 0.01562372862048, 0.00781234106010,
0.00390623013197, 0.00195312251648, 0.00097656218956, 0.00048828121119,
0.00024414062015, 0.00012207031189, 0.00006103515617, 0.00003051757812,
0.00001525878906, 0.00000762939453, 0.00000381469727, 0.00000190734863,
0.00000095367432, 0.00000047683716, 0.00000023841858, 0.00000011920929,
0.00000005960464, 0.00000002980232, 0.00000001490116, 0.00000000745058};
static_assert(N_STAGES < 28, "Not enough arctan available."); static_assert(N_STAGES < 28, "Not enough arctan available.");
static_assert(N_STAGES <= ATAN_I, "ATAN_I can't be less than N_STAGES."); static_assert(N_STAGES <= ATAN_I, "ATAN_I can't be less than N_STAGES.");
static_assert(std::__is_standard_integer<T>(), "Must be a standard C++ integer type."); static_assert(std::__is_standard_integer<T>(), "Must be a standard C++ integer type.");

View file

@ -8,7 +8,7 @@
using namespace std; using namespace std;
using Catch::Matchers::Floating::WithinAbsMatcher; using Catch::Matchers::Floating::WithinAbsMatcher;
TEST_CASE("Adaptive CORDIC work as intended", "[!hide][WIP]") { TEST_CASE("Adaptive CORDIC work as intended", "[!hide][WIP]") {
typedef CCordicRotate<8, 14, 4, 17, 5, 19, 7, 12> cordic_legacy; typedef CCordicRotate<8, 14, 4, 17, 5, 19, 7, 12> cordic_legacy;
@ -182,7 +182,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
// Save the results to a file // Save the results to a file
out_stream.open("results_ap.dat"); out_stream.open("results_ap.dat");
FILE * romf = fopen("rom.dat", "w"); // FILE * romf = fopen("rom.dat", "w");
constexpr cordic_rom cordic {}; constexpr cordic_rom cordic {};
@ -193,8 +193,8 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
// Execute // Execute
const uint8_t counter = uint8_t(iter & cnt_mask); const uint8_t counter = uint8_t(iter & cnt_mask);
if (iter < cnt_mask + 1) // if (iter < cnt_mask + 1)
fprintf(romf, "%03d\n", (uint16_t) cordic.rom_cordic.rom[counter]); // fprintf(romf, "%03d\n", (uint16_t) cordic.rom_cordic.rom[counter]);
cordic.cordic( cordic.cordic(
values_re_in[iter], values_im_in[iter], values_re_in[iter], values_im_in[iter],
@ -211,7 +211,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
REQUIRE_THAT(values_im_out[iter].to_double() * 5. / 8. / cordic_rom::out_scale_factor, WithinAbsMatcher(results_im[iter], abs_margin)); REQUIRE_THAT(values_im_out[iter].to_double() * 5. / 8. / cordic_rom::out_scale_factor, WithinAbsMatcher(results_im[iter], abs_margin));
} }
out_stream.close(); out_stream.close();
fclose(romf); // fclose(romf);
// Compare the results file with the golden results // Compare the results file with the golden results
// int retval = 0; // int retval = 0;
@ -260,7 +260,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
// Save the results to a file // Save the results to a file
out_stream.open("results_ap.dat"); out_stream.open("results_ap.dat");
FILE * romf = fopen("rom.dat", "w"); // FILE * romf = fopen("rom.dat", "w");
constexpr cordic_rom cordic {}; constexpr cordic_rom cordic {};
@ -271,8 +271,8 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
// Execute // Execute
const uint8_t counter = uint8_t(iter & cnt_mask); const uint8_t counter = uint8_t(iter & cnt_mask);
if (iter < cnt_mask + 1) // if (iter < cnt_mask + 1)
fprintf(romf, "%03d\n", (uint16_t) cordic.rom_cordic.rom[counter]); // fprintf(romf, "%03d\n", (uint16_t) cordic.rom_cordic.rom[counter]);
cordic.cordic( cordic.cordic(
values_re_in[iter], values_im_in[iter], values_re_in[iter], values_im_in[iter],
@ -293,7 +293,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
abs_margin)); abs_margin));
} }
out_stream.close(); out_stream.close();
fclose(romf); // fclose(romf);
// Compare the results file with the golden results // Compare the results file with the golden results
// int retval = 0; // int retval = 0;