From a8433e01887055afaef9af405d2bac27a08c2ad3 Mon Sep 17 00:00:00 2001 From: DrasLorus Date: Wed, 20 Apr 2022 19:44:52 +0200 Subject: [PATCH] Fix synthesis and includes bugs - `catch_common` target renamed `catch_common_${PROJECT_NAME}` to avoid conflict with other `catch_common` target when included in a top cmake project. - `scale_cordic(double)` moved outside of the SOFTWARE region, as it can be useful in Xilinx testbench and is not synthetized anyway. - A little modification for debbuging purpose, out_stream can be used to dump results in a file if not commented out. --- CMakeLists.txt | 8 ++++---- sources/CCordicRotateConstexpr/CCordicRotateConstexpr.hpp | 8 ++++---- sources/tb/cordic_tb.cpp | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab5f75f..27af801 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -189,18 +189,18 @@ if (ENABLE_TESTING) ) configure_file (sources/tb/cordic_rom_tb.cpp.in ${TB_SOURCE} @ONLY) - add_library (catch_common OBJECT sources/tb/main_catch2.cpp) - target_link_libraries (catch_common PUBLIC Catch2::Catch2) + add_library (catch_common_${PROJECT_NAME} OBJECT sources/tb/main_catch2.cpp) + target_link_libraries (catch_common_${PROJECT_NAME} PUBLIC Catch2::Catch2) file (GLOB ALL_ROM_TB_SOURCES sources/tb/cordic_rom_*.cpp) list (REMOVE_ITEM ALL_ROM_TB_SOURCES ${TB_SOURCE}) add_executable (cordic_tb sources/tb/cordic_tb.cpp ${TB_SOURCE} ${ALL_ROM_TB_SOURCES}) - target_link_libraries (cordic_tb PUBLIC cordic catch_common) + target_link_libraries (cordic_tb PRIVATE cordic catch_common_${PROJECT_NAME}) include (CTest) include (Catch) - catch_discover_tests (cordic_tb) + catch_discover_tests (cordic_tb WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data) endif () file (GLOB ALL_ROM_HEADERS sources/CordicRoms/cordic_rom_*.hpp) diff --git a/sources/CCordicRotateConstexpr/CCordicRotateConstexpr.hpp b/sources/CCordicRotateConstexpr/CCordicRotateConstexpr.hpp index ac65840..4b9ad36 100644 --- a/sources/CCordicRotateConstexpr/CCordicRotateConstexpr.hpp +++ b/sources/CCordicRotateConstexpr/CCordicRotateConstexpr.hpp @@ -65,6 +65,10 @@ public: return in * kn_i / 16U; } + static constexpr double scale_cordic(double in) { + return in * kn_values[nb_stages - 1]; + } + #if !defined(__SYNTHESIS__) && defined(SOFTWARE) static constexpr std::complex cordic(std::complex x_in, uint64_t counter) { @@ -92,10 +96,6 @@ public: return {(A), (B)}; } - static constexpr double scale_cordic(double in) { - return in * kn_values[nb_stages - 1]; - } - static constexpr std::complex cordic(std::complex x_in, uint64_t counter) { const std::complex fx_x_in(int64_t(x_in.real() * double(in_scale_factor)), diff --git a/sources/tb/cordic_tb.cpp b/sources/tb/cordic_tb.cpp index a1314b5..58f1926 100644 --- a/sources/tb/cordic_tb.cpp +++ b/sources/tb/cordic_tb.cpp @@ -206,7 +206,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") { fclose(INPUT); // Save the results to a file - // out_stream.open("results_ap.dat"); + // ofstream out_stream("results_ap.dat"); // FILE * romf = fopen("rom.dat", "w"); constexpr double abs_margin = double(1 << (cordic.Out_I - 1)) * 2. / 100.;