From d92d11e3e78c8040360e4e430abc2da45feb58c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camille=20Moni=C3=A8re?= Date: Fri, 11 Feb 2022 20:17:10 +0100 Subject: [PATCH] GCC now works. --- CMakeLists.txt | 1 + sources/CCordicRotate/CCordicRotate.hpp | 5 ++--- .../CCordicRotateHalfPiRom.hpp | 3 +-- sources/tb/cordic_tb.cpp | 22 +++++++++---------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5850ad9..fc42af4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required (VERSION 3.16.0 FATAL_ERROR) # setting this is required set (CMAKE_CXX_STANDARD 14) +set (CMAKE_CXX_EXTENSIONS OFF) set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib) set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib) set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin) diff --git a/sources/CCordicRotate/CCordicRotate.hpp b/sources/CCordicRotate/CCordicRotate.hpp index 3a52a7f..a3b8455 100644 --- a/sources/CCordicRotate/CCordicRotate.hpp +++ b/sources/CCordicRotate/CCordicRotate.hpp @@ -45,10 +45,9 @@ template class CCordicRotate { -private: - static constexpr auto atanLUT = CAtanLUT(); - public: + static constexpr const CAtanLUT & atanLUT = CAtanLUT(); + static void process( const ap_fixed & fx_angle, const ap_fixed & fx_re_in, diff --git a/sources/CCordicRotateHalfPiRom/CCordicRotateHalfPiRom.hpp b/sources/CCordicRotateHalfPiRom/CCordicRotateHalfPiRom.hpp index baa1e19..b995e0c 100644 --- a/sources/CCordicRotateHalfPiRom/CCordicRotateHalfPiRom.hpp +++ b/sources/CCordicRotateHalfPiRom/CCordicRotateHalfPiRom.hpp @@ -25,7 +25,7 @@ class CCordicRotateRomHalfPi { static_assert(TNStages > 1, "2 stages of CORDIC is the minimum."); public: - static constexpr CRomGeneratorConst rom_cordic {}; + static constexpr const CRomGeneratorConst & rom_cordic = CRomGeneratorConst(); static constexpr unsigned In_W = TIn_W; static constexpr unsigned In_I = TIn_I; @@ -129,7 +129,6 @@ public: } }; - #if 0 template <> inline void CCordicRotateRomHalfPi<16, 4, 6, 64>::cordic( diff --git a/sources/tb/cordic_tb.cpp b/sources/tb/cordic_tb.cpp index 9bba857..9c09003 100644 --- a/sources/tb/cordic_tb.cpp +++ b/sources/tb/cordic_tb.cpp @@ -8,9 +8,10 @@ using namespace std; using Catch::Matchers::Floating::WithinAbsMatcher; - + +typedef CCordicRotate<8, 14, 4, 17, 5, 19, 7, 12> cordic_legacy; + TEST_CASE("Adaptive CORDIC work as intended", "[!hide][WIP]") { - typedef CCordicRotate<8, 14, 4, 17, 5, 19, 7, 12> cordic_legacy; string input_fn = "../data/input.dat"; // _8_14_4_17_5_19_7_12 string output_fn = "../data/output.dat"; // _8_14_4_17_5_19_7_12 @@ -72,9 +73,11 @@ TEST_CASE("Adaptive CORDIC work as intended", "[!hide][WIP]") { // Return 0 if the test passed } +typedef CCordicRotateRomHalfPi<16, 4, 6, 64> cordic_rom; + TEST_CASE("ROM-based Cordic works with C-Types", "[CORDIC]") { SECTION("W:16 - I:4 - Stages:6 - q:64") { - typedef CCordicRotateRomHalfPi<16, 4, 6, 64> cordic_rom; + static constexpr cordic_rom cordic {}; string input_fn = "../data/input.dat"; // _8_14_4_17_5_19_7_12 string output_fn = "../data/output.dat"; // _8_14_4_17_5_19_7_12 @@ -110,8 +113,6 @@ TEST_CASE("ROM-based Cordic works with C-Types", "[CORDIC]") { // Save the results to a file FILE.open("results.dat"); - constexpr cordic_rom cordic {}; - constexpr double abs_margin = double(1 << cordic.Out_I) * 2. / 100.; // Executing the encoder @@ -141,7 +142,8 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") { constexpr unsigned n_lines = 100000; SECTION("W:16 - I:4 - Stages:6 - q:64") { - typedef CCordicRotateRomHalfPi<16, 4, 6, 64> cordic_rom; + + static constexpr cordic_rom cordic {}; string input_fn = "../data/input.dat"; @@ -184,7 +186,6 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") { out_stream.open("results_ap.dat"); // FILE * romf = fopen("rom.dat", "w"); - constexpr cordic_rom cordic {}; constexpr double abs_margin = double(1 << cordic.Out_I) * 2. / 100.; @@ -219,8 +220,9 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") { } SECTION("W:16 - I:4 - Stages:6 - q:64 - internal scaling") { - typedef CCordicRotateRomHalfPi<16, 4, 6, 64> cordic_rom; - + // typedef CCordicRotateRomHalfPi<16, 4, 6, 64> cordic_rom; + static constexpr cordic_rom cordic {}; + string input_fn = "../data/input.dat"; constexpr double rotation = cordic_rom::rom_cordic.rotation; @@ -262,8 +264,6 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") { out_stream.open("results_ap.dat"); // FILE * romf = fopen("rom.dat", "w"); - constexpr cordic_rom cordic {}; - constexpr double abs_margin = double(1 << cordic.Out_I) * 2. / 100.; // Executing the encoder