From cbd04f1a3ecfe662a9d04ae512f1b625ee90210c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camille=20Moni=C3=A8re?= Date: Fri, 11 Feb 2022 19:17:11 +0100 Subject: [PATCH] Clang works, not GCC --- CMakeLists.txt | 4 +--- .../RomGeneratorConst/RomGeneratorConst.hpp | 6 +++--- .../RomGeneratorMCHalfPi.hpp | 2 +- sources/CCordicRotate/CCordicRotate.hpp | 18 +++++++++--------- sources/tb/cordic_tb.cpp | 18 +++++++++--------- 5 files changed, 23 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c976aeb..5850ad9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,6 @@ if (EXPORT_COMMANDS) set (CMAKE_EXPORT_COMPILE_COMMANDS ON) endif () - option (ENABLE_XILINX "use Xilinx provided and proprietary headers." ON) if (ENABLE_XILINX) set ( @@ -54,8 +53,7 @@ if ((NOT EXISTS ${AP_INCLUDE_DIR}/ap_int.h) OR (NOT EXISTS message ( FATAL_ERROR "Arbitrary precision headers not found in ${AP_INCLUDE_DIR}.\n" - "Consider disabling the ap_int feature using `-DENABLE_AP_INT=OFF`" - " or provide a suitable path to the headers." + "Please provide a suitable path to the headers." ) endif () diff --git a/RomGenerators/sources/RomGeneratorConst/RomGeneratorConst.hpp b/RomGenerators/sources/RomGeneratorConst/RomGeneratorConst.hpp index 79c4260..4839e3c 100644 --- a/RomGenerators/sources/RomGeneratorConst/RomGeneratorConst.hpp +++ b/RomGenerators/sources/RomGeneratorConst/RomGeneratorConst.hpp @@ -96,7 +96,7 @@ private: public: uint8_t rom[max_length]; - constexpr CRomGeneratorConst() { + constexpr CRomGeneratorConst() : rom() { for (unsigned n = 0; n < max_length; n++) { const double chip_rotation = rotation / double(q) * double(n); rom[n] = cordic_rom_gen(chip_rotation); @@ -106,7 +106,7 @@ public: template void generate_rom_header_const(const char * filename = "rom_cordic.h") { - constexpr CRomGeneratorConst rom; + constexpr CRomGeneratorConst rom{}; FILE * rom_file = fopen(filename, "w"); if (!bool(rom_file)) { @@ -130,7 +130,7 @@ void generate_rom_header_const(const char * filename = "rom_cordic.h") { template void generate_rom_header_const_raw(const char * filename = "rom_cordic.txt") { - constexpr CRomGeneratorConst rom; + constexpr CRomGeneratorConst rom{}; FILE * rom_file = fopen(filename, "w"); if (!bool(rom_file)) { diff --git a/RomGenerators/sources/RomGeneratorMCHalfPi/RomGeneratorMCHalfPi.hpp b/RomGenerators/sources/RomGeneratorMCHalfPi/RomGeneratorMCHalfPi.hpp index acb47f7..a8b6753 100644 --- a/RomGenerators/sources/RomGeneratorMCHalfPi/RomGeneratorMCHalfPi.hpp +++ b/RomGenerators/sources/RomGeneratorMCHalfPi/RomGeneratorMCHalfPi.hpp @@ -54,7 +54,7 @@ public: 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 std::complex x {re_x, im_x}; + const std::complex x {int64_t(re_x), int64_t(im_x)}; double error = 1000.; uint8_t rom_v = 0x0; diff --git a/sources/CCordicRotate/CCordicRotate.hpp b/sources/CCordicRotate/CCordicRotate.hpp index be3bf7f..3a52a7f 100644 --- a/sources/CCordicRotate/CCordicRotate.hpp +++ b/sources/CCordicRotate/CCordicRotate.hpp @@ -11,19 +11,19 @@ #include #include -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 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 <= ATAN_I, "ATAN_I can't be less than N_STAGES."); static_assert(std::__is_standard_integer(), "Must be a standard C++ integer type."); diff --git a/sources/tb/cordic_tb.cpp b/sources/tb/cordic_tb.cpp index 98cbe5c..9bba857 100644 --- a/sources/tb/cordic_tb.cpp +++ b/sources/tb/cordic_tb.cpp @@ -8,7 +8,7 @@ using namespace std; using Catch::Matchers::Floating::WithinAbsMatcher; - + TEST_CASE("Adaptive CORDIC work as intended", "[!hide][WIP]") { 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 out_stream.open("results_ap.dat"); - FILE * romf = fopen("rom.dat", "w"); + // FILE * romf = fopen("rom.dat", "w"); constexpr cordic_rom cordic {}; @@ -193,8 +193,8 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") { // Execute const uint8_t counter = uint8_t(iter & cnt_mask); - if (iter < cnt_mask + 1) - fprintf(romf, "%03d\n", (uint16_t) cordic.rom_cordic.rom[counter]); + // if (iter < cnt_mask + 1) + // fprintf(romf, "%03d\n", (uint16_t) cordic.rom_cordic.rom[counter]); cordic.cordic( 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)); } out_stream.close(); - fclose(romf); + // fclose(romf); // Compare the results file with the golden results // int retval = 0; @@ -260,7 +260,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") { // Save the results to a file out_stream.open("results_ap.dat"); - FILE * romf = fopen("rom.dat", "w"); + // FILE * romf = fopen("rom.dat", "w"); constexpr cordic_rom cordic {}; @@ -271,8 +271,8 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") { // Execute const uint8_t counter = uint8_t(iter & cnt_mask); - if (iter < cnt_mask + 1) - fprintf(romf, "%03d\n", (uint16_t) cordic.rom_cordic.rom[counter]); + // if (iter < cnt_mask + 1) + // fprintf(romf, "%03d\n", (uint16_t) cordic.rom_cordic.rom[counter]); cordic.cordic( values_re_in[iter], values_im_in[iter], @@ -293,7 +293,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") { abs_margin)); } out_stream.close(); - fclose(romf); + // fclose(romf); // Compare the results file with the golden results // int retval = 0;