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.
This commit is contained in:
DrasLorus 2022-04-20 19:44:52 +02:00
parent 0dc041b840
commit a8433e0188
Signed by: moniere
GPG key ID: 14C4DE44B8DD6F35
3 changed files with 9 additions and 9 deletions

View file

@ -189,18 +189,18 @@ if (ENABLE_TESTING)
) )
configure_file (sources/tb/cordic_rom_tb.cpp.in ${TB_SOURCE} @ONLY) configure_file (sources/tb/cordic_rom_tb.cpp.in ${TB_SOURCE} @ONLY)
add_library (catch_common OBJECT sources/tb/main_catch2.cpp) add_library (catch_common_${PROJECT_NAME} OBJECT sources/tb/main_catch2.cpp)
target_link_libraries (catch_common PUBLIC Catch2::Catch2) target_link_libraries (catch_common_${PROJECT_NAME} PUBLIC Catch2::Catch2)
file (GLOB ALL_ROM_TB_SOURCES sources/tb/cordic_rom_*.cpp) file (GLOB ALL_ROM_TB_SOURCES sources/tb/cordic_rom_*.cpp)
list (REMOVE_ITEM ALL_ROM_TB_SOURCES ${TB_SOURCE}) list (REMOVE_ITEM ALL_ROM_TB_SOURCES ${TB_SOURCE})
add_executable (cordic_tb sources/tb/cordic_tb.cpp ${TB_SOURCE} ${ALL_ROM_TB_SOURCES}) 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 (CTest)
include (Catch) include (Catch)
catch_discover_tests (cordic_tb) catch_discover_tests (cordic_tb WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data)
endif () endif ()
file (GLOB ALL_ROM_HEADERS sources/CordicRoms/cordic_rom_*.hpp) file (GLOB ALL_ROM_HEADERS sources/CordicRoms/cordic_rom_*.hpp)

View file

@ -65,6 +65,10 @@ public:
return in * kn_i / 16U; return in * kn_i / 16U;
} }
static constexpr double scale_cordic(double in) {
return in * kn_values[nb_stages - 1];
}
#if !defined(__SYNTHESIS__) && defined(SOFTWARE) #if !defined(__SYNTHESIS__) && defined(SOFTWARE)
static constexpr std::complex<int64_t> cordic(std::complex<int64_t> x_in, static constexpr std::complex<int64_t> cordic(std::complex<int64_t> x_in,
uint64_t counter) { uint64_t counter) {
@ -92,10 +96,6 @@ public:
return {(A), (B)}; return {(A), (B)};
} }
static constexpr double scale_cordic(double in) {
return in * kn_values[nb_stages - 1];
}
static constexpr std::complex<double> cordic(std::complex<double> x_in, static constexpr std::complex<double> cordic(std::complex<double> x_in,
uint64_t counter) { uint64_t counter) {
const std::complex<int64_t> fx_x_in(int64_t(x_in.real() * double(in_scale_factor)), const std::complex<int64_t> fx_x_in(int64_t(x_in.real() * double(in_scale_factor)),

View file

@ -206,7 +206,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
fclose(INPUT); fclose(INPUT);
// Save the results to a file // Save the results to a file
// out_stream.open("results_ap.dat"); // ofstream out_stream("results_ap.dat");
// FILE * romf = fopen("rom.dat", "w"); // FILE * romf = fopen("rom.dat", "w");
constexpr double abs_margin = double(1 << (cordic.Out_I - 1)) * 2. / 100.; constexpr double abs_margin = double(1 << (cordic.Out_I - 1)) * 2. / 100.;