mirror of
https://github.com/DrasLorus/CORDIC_Rotate_APFX.git
synced 2024-11-24 05:33:16 +01:00
Merge pull request #3 from DrasLorus/msvc-support-experimental
MSVC++ Support
This commit is contained in:
commit
b789105732
6 changed files with 133 additions and 80 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -12,3 +12,6 @@ sources/CCordicRotateRom/CCordicRotateRom_*.?pp
|
||||||
sources/CordicRoms/cordic_rom_*.?pp
|
sources/CordicRoms/cordic_rom_*.?pp
|
||||||
sources/tb/catchy/cordic_rom_tb_??*_*.?pp
|
sources/tb/catchy/cordic_rom_tb_??*_*.?pp
|
||||||
sources/tb/catch_less/cordic_rom_aptypes_tb_??*_*.?pp
|
sources/tb/catch_less/cordic_rom_aptypes_tb_??*_*.?pp
|
||||||
|
|
||||||
|
CMakeSettings.json
|
||||||
|
.vs
|
|
@ -24,7 +24,24 @@ project (
|
||||||
VERSION 0.1
|
VERSION 0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.2))
|
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.2))
|
||||||
|
# message ( FATAL_ERROR "This project require a GNU compiler version greater than 6.2." "\nNote:
|
||||||
|
# If you tried to use g++-4.6.3 as provided by Xilinx Vivado v2019.1, use directly the TCL script
|
||||||
|
# " "in the folder `hls_files/cordicabs_16_4_6`." )
|
||||||
|
set (IS_GNU_LEGACY ON)
|
||||||
|
else ()
|
||||||
|
set (IS_GNU_LEGACY OFF)
|
||||||
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
add_compile_options (/Zc:__cplusplus)
|
||||||
|
if (CMAKE_BUILD_TYPE STREQUAL Release OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
|
||||||
|
add_compile_options (/Ob0) # Disable inlining, that makes CL.EXE crash.
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
|
if (IS_GNU_LEGACY)
|
||||||
set (CMAKE_CXX_STANDARD 11)
|
set (CMAKE_CXX_STANDARD 11)
|
||||||
else ()
|
else ()
|
||||||
set (CMAKE_CXX_STANDARD 14)
|
set (CMAKE_CXX_STANDARD 14)
|
||||||
|
@ -50,16 +67,26 @@ option (ENABLE_SOFTWARE
|
||||||
|
|
||||||
option (PEDANTIC "use -Wall and -pedantic." ON)
|
option (PEDANTIC "use -Wall and -pedantic." ON)
|
||||||
|
|
||||||
|
option (ENABLE_DEPFETCH "Allow to fetch dependency from external sources." OFF)
|
||||||
|
|
||||||
# ##################################################################################################
|
# ##################################################################################################
|
||||||
|
|
||||||
if (PEDANTIC)
|
if (PEDANTIC)
|
||||||
add_compile_options (-Wall -pedantic)
|
add_compile_options (-Wall)
|
||||||
|
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
add_compile_options (-pedantic)
|
||||||
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (EXPORT_COMMANDS)
|
if (EXPORT_COMMANDS)
|
||||||
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if (ENABLE_DEPFETCH)
|
||||||
|
include (FetchContent)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
if (ENABLE_XILINX)
|
if (ENABLE_XILINX)
|
||||||
set (
|
set (
|
||||||
XILINX_HOME
|
XILINX_HOME
|
||||||
|
@ -78,6 +105,20 @@ if (ENABLE_XILINX)
|
||||||
set (AP_INCLUDE_DIR ${XILINX_HOME}/Vivado/${XILINX_VER}/include)
|
set (AP_INCLUDE_DIR ${XILINX_HOME}/Vivado/${XILINX_VER}/include)
|
||||||
endif ()
|
endif ()
|
||||||
message (STATUS "AP headers must lie under ${AP_INCLUDE_DIR}")
|
message (STATUS "AP headers must lie under ${AP_INCLUDE_DIR}")
|
||||||
|
else ()
|
||||||
|
if (ENABLE_DEPFETCH)
|
||||||
|
FetchContent_Declare (
|
||||||
|
hlsaptypes
|
||||||
|
GIT_REPOSITORY https://github.com/DrasLorus/HLS_arbitrary_Precision_Types.git
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_MakeAvailable (hlsaptypes)
|
||||||
|
|
||||||
|
find_file (
|
||||||
|
AP_FIXED ap_fixed.h
|
||||||
|
HINTS ${hlsaptypes_SOURCE_DIR}
|
||||||
|
PATH_SUFFIXES "include"
|
||||||
|
)
|
||||||
else ()
|
else ()
|
||||||
set (
|
set (
|
||||||
AP_TYPES_HINT
|
AP_TYPES_HINT
|
||||||
|
@ -90,7 +131,7 @@ else ()
|
||||||
HINTS ${AP_TYPES_HINT}
|
HINTS ${AP_TYPES_HINT}
|
||||||
PATH_SUFFIXES ap_types hls_ap_types/include REQUIRED
|
PATH_SUFFIXES ap_types hls_ap_types/include REQUIRED
|
||||||
)
|
)
|
||||||
|
endif ()
|
||||||
get_filename_component (AP_INCLUDE_DIR ${AP_FIXED} DIRECTORY)
|
get_filename_component (AP_INCLUDE_DIR ${AP_FIXED} DIRECTORY)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
@ -189,7 +230,7 @@ target_link_libraries (cordic PUBLIC romgen cordic_rom_gen)
|
||||||
|
|
||||||
if (ENABLE_TESTING)
|
if (ENABLE_TESTING)
|
||||||
include (CTest)
|
include (CTest)
|
||||||
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.2))
|
if (IS_GNU_LEGACY)
|
||||||
string (
|
string (
|
||||||
CONFIGURE
|
CONFIGURE
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/sources/tb/catch_less/cordic_rom_aptypes_tb_${ROM_TYPE}_${CORDIC_W}_${CORDIC_STAGES}_${CORDIC_Q}_${CORDIC_DIVIDER}.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/sources/tb/catch_less/cordic_rom_aptypes_tb_${ROM_TYPE}_${CORDIC_W}_${CORDIC_STAGES}_${CORDIC_Q}_${CORDIC_DIVIDER}.cpp
|
||||||
|
@ -222,8 +263,19 @@ if (ENABLE_TESTING)
|
||||||
)
|
)
|
||||||
endforeach ()
|
endforeach ()
|
||||||
|
|
||||||
|
else ()
|
||||||
|
if (ENABLE_DEPFETCH)
|
||||||
|
FetchContent_Declare (
|
||||||
|
Catch2
|
||||||
|
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||||
|
GIT_TAG v2.13.9
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_MakeAvailable (Catch2)
|
||||||
|
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/contrib)
|
||||||
else ()
|
else ()
|
||||||
find_package (Catch2 REQUIRED)
|
find_package (Catch2 REQUIRED)
|
||||||
|
endif ()
|
||||||
|
|
||||||
string (
|
string (
|
||||||
CONFIGURE
|
CONFIGURE
|
||||||
|
|
|
@ -104,7 +104,7 @@ private:
|
||||||
|
|
||||||
R = beta < 0 ? R | mask : R & nmask;
|
R = beta < 0 ? R | mask : R & nmask;
|
||||||
|
|
||||||
const double factor = sigma / double(1U << (u - 1));
|
const double factor = sigma / double(1LU << (u - 1));
|
||||||
|
|
||||||
const double I = A + B * factor;
|
const double I = A + B * factor;
|
||||||
B = B - A * factor;
|
B = B - A * factor;
|
||||||
|
|
|
@ -90,8 +90,8 @@ public:
|
||||||
|
|
||||||
const int64_t Ri = (R & mask) == mask ? 1 : -1;
|
const int64_t Ri = (R & mask) == mask ? 1 : -1;
|
||||||
|
|
||||||
const int64_t I = A + Ri * (B / int64_t(1U << (u - 1)));
|
const int64_t I = A + Ri * (B / int64_t(1LU << (u - 1)));
|
||||||
B = B - Ri * (A / int64_t(1U << (u - 1)));
|
B = B - Ri * (A / int64_t(1LU << (u - 1)));
|
||||||
A = I;
|
A = I;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,10 @@ TEST_CASE("ROM-based Cordic (TPL @ROM_TYPE@, @CORDIC_W@, @CORDIC_STAGES@, @CORDI
|
||||||
|
|
||||||
constexpr unsigned n_lines = 100000;
|
constexpr unsigned n_lines = 100000;
|
||||||
|
|
||||||
complex<double> values_in[n_lines];
|
vector<complex<double>> values_in(n_lines);
|
||||||
complex<double> values_out[n_lines];
|
vector<complex<double>> values_out(n_lines);
|
||||||
|
|
||||||
complex<double> results[n_lines];
|
vector<complex<double>> results(n_lines);
|
||||||
|
|
||||||
ifstream INPUT(input_fn);
|
ifstream INPUT(input_fn);
|
||||||
|
|
||||||
|
@ -93,13 +93,13 @@ TEST_CASE("ROM-based Cordic (TPL @ROM_TYPE@, @CORDIC_W@, @CORDIC_STAGES@, @CORDI
|
||||||
constexpr unsigned Out_W = cordic_rom::Out_W;
|
constexpr unsigned Out_W = cordic_rom::Out_W;
|
||||||
constexpr unsigned In_W = cordic_rom::In_W;
|
constexpr unsigned In_W = cordic_rom::In_W;
|
||||||
|
|
||||||
ap_int<In_W> values_re_in[n_lines];
|
vector<ap_int<In_W>> values_re_in(n_lines);
|
||||||
ap_int<In_W> values_im_in[n_lines];
|
vector<ap_int<In_W>> values_im_in(n_lines);
|
||||||
ap_int<Out_W> values_re_out[n_lines];
|
vector<ap_int<Out_W>> values_re_out(n_lines);
|
||||||
ap_int<Out_W> values_im_out[n_lines];
|
vector<ap_int<Out_W>> values_im_out(n_lines);
|
||||||
|
|
||||||
double results_re[n_lines];
|
vector<double> results_re(n_lines);
|
||||||
double results_im[n_lines];
|
vector<double> results_im(n_lines);
|
||||||
|
|
||||||
FILE * INPUT = fopen(input_fn.c_str(), "r");
|
FILE * INPUT = fopen(input_fn.c_str(), "r");
|
||||||
|
|
||||||
|
@ -148,13 +148,13 @@ TEST_CASE("ROM-based Cordic (TPL @ROM_TYPE@, @CORDIC_W@, @CORDIC_STAGES@, @CORDI
|
||||||
constexpr unsigned Out_W = cordic_rom::Out_W;
|
constexpr unsigned Out_W = cordic_rom::Out_W;
|
||||||
constexpr unsigned In_W = cordic_rom::In_W;
|
constexpr unsigned In_W = cordic_rom::In_W;
|
||||||
|
|
||||||
ap_int<In_W> values_re_in[n_lines];
|
vector<ap_int<In_W>> values_re_in(n_lines);
|
||||||
ap_int<In_W> values_im_in[n_lines];
|
vector<ap_int<In_W>> values_im_in(n_lines);
|
||||||
ap_int<Out_W> values_re_out[n_lines];
|
vector<ap_int<Out_W>> values_re_out(n_lines);
|
||||||
ap_int<Out_W> values_im_out[n_lines];
|
vector<ap_int<Out_W>> values_im_out(n_lines);
|
||||||
|
|
||||||
double results_re[n_lines];
|
vector<double> results_re(n_lines);
|
||||||
double results_im[n_lines];
|
vector<double> results_im(n_lines);
|
||||||
|
|
||||||
FILE * INPUT = fopen(input_fn.c_str(), "r");
|
FILE * INPUT = fopen(input_fn.c_str(), "r");
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,10 @@
|
||||||
|
|
||||||
#include "CCordicRotateConstexpr/CCordicRotateConstexpr.hpp"
|
#include "CCordicRotateConstexpr/CCordicRotateConstexpr.hpp"
|
||||||
#include "CCordicRotateSmart/CCordicRotateSmart.hpp"
|
#include "CCordicRotateSmart/CCordicRotateSmart.hpp"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <catch2/catch.hpp>
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
|
@ -36,14 +38,14 @@ TEST_CASE("Adaptive CORDIC work as intended", "[!mayfail][!hide][WIP]") {
|
||||||
string output_fn = "../data/output.dat"; // _8_14_4_17_5_19_7_12
|
string output_fn = "../data/output.dat"; // _8_14_4_17_5_19_7_12
|
||||||
|
|
||||||
constexpr unsigned n_lines = 100000;
|
constexpr unsigned n_lines = 100000;
|
||||||
ap_fixed<17, 5> values_re_in[n_lines];
|
vector<ap_fixed<17, 5>> values_re_in(n_lines);
|
||||||
ap_fixed<17, 5> values_im_in[n_lines];
|
vector<ap_fixed<17, 5>> values_im_in(n_lines);
|
||||||
ap_fixed<14, 4> angles_in[n_lines];
|
vector<ap_fixed<14, 4>> angles_in(n_lines);
|
||||||
ap_fixed<19, 7> values_re_out[n_lines];
|
vector<ap_fixed<19, 7>> values_re_out(n_lines);
|
||||||
ap_fixed<19, 7> values_im_out[n_lines];
|
vector<ap_fixed<19, 7>> values_im_out(n_lines);
|
||||||
|
|
||||||
double exp_re_out[n_lines];
|
vector<double> exp_re_out(n_lines);
|
||||||
double exp_im_out[n_lines];
|
vector<double> exp_im_out(n_lines);
|
||||||
|
|
||||||
FILE * INPUT = fopen(input_fn.c_str(), "r");
|
FILE * INPUT = fopen(input_fn.c_str(), "r");
|
||||||
FILE * RESULTS = fopen(output_fn.c_str(), "r");
|
FILE * RESULTS = fopen(output_fn.c_str(), "r");
|
||||||
|
@ -104,10 +106,10 @@ TEST_CASE("ROM-based Cordic works with C-Types", "[CORDIC]") {
|
||||||
|
|
||||||
constexpr unsigned n_lines = 100000;
|
constexpr unsigned n_lines = 100000;
|
||||||
|
|
||||||
complex<double> values_in[n_lines];
|
vector<complex<double>> values_in(n_lines);
|
||||||
complex<double> values_out[n_lines];
|
vector<complex<double>> values_out(n_lines);
|
||||||
|
|
||||||
complex<double> results[n_lines];
|
vector<complex<double>> results(n_lines);
|
||||||
|
|
||||||
// ofstream FILE;
|
// ofstream FILE;
|
||||||
|
|
||||||
|
@ -165,7 +167,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
SECTION("W:16 - I:4 - Stages:6 - q:64") {
|
SECTION("W:16 - I:4 - Stages:6 - q:64") {
|
||||||
typedef CCordicRotateConstexpr<16, 4, 6, 64> cordic_rom;
|
typedef CCordicRotateConstexpr<16, 4, 6, 64> cordic_rom;
|
||||||
|
|
||||||
static constexpr cordic_rom cordic {};
|
//static constexpr cordic_rom cordic {};
|
||||||
|
|
||||||
string input_fn = "../data/input.dat";
|
string input_fn = "../data/input.dat";
|
||||||
|
|
||||||
|
@ -176,13 +178,13 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
constexpr unsigned Out_W = cordic_rom::Out_W;
|
constexpr unsigned Out_W = cordic_rom::Out_W;
|
||||||
constexpr unsigned In_W = cordic_rom::In_W;
|
constexpr unsigned In_W = cordic_rom::In_W;
|
||||||
|
|
||||||
ap_int<In_W> values_re_in[n_lines];
|
vector<ap_int<In_W>> values_re_in(n_lines);
|
||||||
ap_int<In_W> values_im_in[n_lines];
|
vector<ap_int<In_W>> values_im_in(n_lines);
|
||||||
ap_int<Out_W> values_re_out[n_lines];
|
vector<ap_int<Out_W>> values_re_out(n_lines);
|
||||||
ap_int<Out_W> values_im_out[n_lines];
|
vector<ap_int<Out_W>> values_im_out(n_lines);
|
||||||
|
|
||||||
double results_re[n_lines];
|
vector<double> results_re(n_lines);
|
||||||
double results_im[n_lines];
|
vector<double> results_im(n_lines);
|
||||||
|
|
||||||
// ofstream out_stream;
|
// ofstream out_stream;
|
||||||
|
|
||||||
|
@ -197,7 +199,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
values_re_in[i] = int64_t(a * double(cordic_rom::in_scale_factor));
|
values_re_in[i] = int64_t(a * double(cordic_rom::in_scale_factor));
|
||||||
values_im_in[i] = int64_t(b * double(cordic_rom::in_scale_factor));
|
values_im_in[i] = int64_t(b * double(cordic_rom::in_scale_factor));
|
||||||
|
|
||||||
const complex<double> e = c * exp(complex<double>(0., rotation / q * (i & cnt_mask)));
|
const complex<double> e = c * exp(complex<double>(0., rotation / q * double(i & cnt_mask)));
|
||||||
results_re[i] = e.real();
|
results_re[i] = e.real();
|
||||||
results_im[i] = e.imag();
|
results_im[i] = e.imag();
|
||||||
}
|
}
|
||||||
|
@ -208,7 +210,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
// ofstream out_stream("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_rom::Out_I - 1)) * 2. / 100.;
|
||||||
|
|
||||||
// Executing the encoder
|
// Executing the encoder
|
||||||
for (unsigned iter = 0; iter < n_lines; iter++) {
|
for (unsigned iter = 0; iter < n_lines; iter++) {
|
||||||
|
@ -242,7 +244,6 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
|
|
||||||
SECTION("W:16 - I:4 - Stages:6 - q:64 - internal scaling") {
|
SECTION("W:16 - I:4 - Stages:6 - q:64 - internal scaling") {
|
||||||
typedef CCordicRotateConstexpr<16, 4, 6, 64> cordic_rom;
|
typedef CCordicRotateConstexpr<16, 4, 6, 64> cordic_rom;
|
||||||
static constexpr cordic_rom cordic {};
|
|
||||||
|
|
||||||
string input_fn = "../data/input.dat";
|
string input_fn = "../data/input.dat";
|
||||||
|
|
||||||
|
@ -253,13 +254,13 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
constexpr unsigned Out_W = cordic_rom::Out_W;
|
constexpr unsigned Out_W = cordic_rom::Out_W;
|
||||||
constexpr unsigned In_W = cordic_rom::In_W;
|
constexpr unsigned In_W = cordic_rom::In_W;
|
||||||
|
|
||||||
ap_int<In_W> values_re_in[n_lines];
|
vector<ap_int<In_W>> values_re_in(n_lines);
|
||||||
ap_int<In_W> values_im_in[n_lines];
|
vector<ap_int<In_W>> values_im_in(n_lines);
|
||||||
ap_int<Out_W> values_re_out[n_lines];
|
vector<ap_int<Out_W>> values_re_out(n_lines);
|
||||||
ap_int<Out_W> values_im_out[n_lines];
|
vector<ap_int<Out_W>> values_im_out(n_lines);
|
||||||
|
|
||||||
double results_re[n_lines];
|
vector<double> results_re(n_lines);
|
||||||
double results_im[n_lines];
|
vector<double> results_im(n_lines);
|
||||||
|
|
||||||
// ofstream out_stream;
|
// ofstream out_stream;
|
||||||
|
|
||||||
|
@ -274,7 +275,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
values_re_in[i] = int64_t(a * double(cordic_rom::in_scale_factor));
|
values_re_in[i] = int64_t(a * double(cordic_rom::in_scale_factor));
|
||||||
values_im_in[i] = int64_t(b * double(cordic_rom::in_scale_factor));
|
values_im_in[i] = int64_t(b * double(cordic_rom::in_scale_factor));
|
||||||
|
|
||||||
const complex<double> e = c * exp(complex<double>(0., rotation / q * (i & cnt_mask)));
|
const complex<double> e = c * exp(complex<double>(0., rotation / q * double(i & cnt_mask)));
|
||||||
results_re[i] = e.real();
|
results_re[i] = e.real();
|
||||||
results_im[i] = e.imag();
|
results_im[i] = e.imag();
|
||||||
}
|
}
|
||||||
|
@ -285,7 +286,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
// 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 double abs_margin = double(1 << (cordic.Out_I - 1)) * 3. / 100.; // Internal scaling create noise
|
constexpr double abs_margin = double(1 << (cordic_rom::Out_I - 1)) * 3. / 100.; // Internal scaling create noise
|
||||||
|
|
||||||
// Executing the encoder
|
// Executing the encoder
|
||||||
for (unsigned iter = 0; iter < n_lines; iter++) {
|
for (unsigned iter = 0; iter < n_lines; iter++) {
|
||||||
|
@ -324,8 +325,6 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
SECTION("W:16 - I:4 - Stages:6 - q:64 - divider:4") {
|
SECTION("W:16 - I:4 - Stages:6 - q:64 - divider:4") {
|
||||||
typedef CCordicRotateConstexpr<16, 4, 6, 64, 4> cordic_rom;
|
typedef CCordicRotateConstexpr<16, 4, 6, 64, 4> cordic_rom;
|
||||||
|
|
||||||
static constexpr cordic_rom cordic {};
|
|
||||||
|
|
||||||
string input_fn = "../data/input.dat";
|
string input_fn = "../data/input.dat";
|
||||||
|
|
||||||
constexpr double rotation = cordic_rom::rotation;
|
constexpr double rotation = cordic_rom::rotation;
|
||||||
|
@ -335,13 +334,13 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
constexpr unsigned Out_W = cordic_rom::Out_W;
|
constexpr unsigned Out_W = cordic_rom::Out_W;
|
||||||
constexpr unsigned In_W = cordic_rom::In_W;
|
constexpr unsigned In_W = cordic_rom::In_W;
|
||||||
|
|
||||||
ap_int<In_W> values_re_in[n_lines];
|
vector<ap_int<In_W>> values_re_in(n_lines);
|
||||||
ap_int<In_W> values_im_in[n_lines];
|
vector<ap_int<In_W>> values_im_in(n_lines);
|
||||||
ap_int<Out_W> values_re_out[n_lines];
|
vector<ap_int<Out_W>> values_re_out(n_lines);
|
||||||
ap_int<Out_W> values_im_out[n_lines];
|
vector<ap_int<Out_W>> values_im_out(n_lines);
|
||||||
|
|
||||||
double results_re[n_lines];
|
vector<double> results_re(n_lines);
|
||||||
double results_im[n_lines];
|
vector<double> results_im(n_lines);
|
||||||
|
|
||||||
// ofstream out_stream;
|
// ofstream out_stream;
|
||||||
|
|
||||||
|
@ -356,7 +355,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
values_re_in[i] = int64_t(a * double(cordic_rom::in_scale_factor));
|
values_re_in[i] = int64_t(a * double(cordic_rom::in_scale_factor));
|
||||||
values_im_in[i] = int64_t(b * double(cordic_rom::in_scale_factor));
|
values_im_in[i] = int64_t(b * double(cordic_rom::in_scale_factor));
|
||||||
|
|
||||||
const complex<double> e = c * exp(complex<double>(0., rotation / q * (i & cnt_mask)));
|
const complex<double> e = c * exp(complex<double>(0., rotation / q * double(i & cnt_mask)));
|
||||||
results_re[i] = e.real();
|
results_re[i] = e.real();
|
||||||
results_im[i] = e.imag();
|
results_im[i] = e.imag();
|
||||||
}
|
}
|
||||||
|
@ -367,7 +366,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
// 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 double abs_margin = double(1 << (cordic.Out_I - 1)) * 2. / 100.;
|
constexpr double abs_margin = double(1 << (cordic_rom::Out_I - 1)) * 2. / 100.;
|
||||||
|
|
||||||
// Executing the encoder
|
// Executing the encoder
|
||||||
for (unsigned iter = 0; iter < n_lines; iter++) {
|
for (unsigned iter = 0; iter < n_lines; iter++) {
|
||||||
|
@ -401,7 +400,6 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
|
|
||||||
SECTION("W:16 - I:4 - Stages:6 - q:64 - divider:4 - internal scaling") {
|
SECTION("W:16 - I:4 - Stages:6 - q:64 - divider:4 - internal scaling") {
|
||||||
typedef CCordicRotateConstexpr<16, 4, 7, 64, 4> cordic_rom;
|
typedef CCordicRotateConstexpr<16, 4, 7, 64, 4> cordic_rom;
|
||||||
static constexpr cordic_rom cordic {};
|
|
||||||
|
|
||||||
string input_fn = "../data/input.dat";
|
string input_fn = "../data/input.dat";
|
||||||
|
|
||||||
|
@ -412,13 +410,13 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
constexpr unsigned Out_W = cordic_rom::Out_W;
|
constexpr unsigned Out_W = cordic_rom::Out_W;
|
||||||
constexpr unsigned In_W = cordic_rom::In_W;
|
constexpr unsigned In_W = cordic_rom::In_W;
|
||||||
|
|
||||||
ap_int<In_W> values_re_in[n_lines];
|
vector<ap_int<In_W>> values_re_in(n_lines);
|
||||||
ap_int<In_W> values_im_in[n_lines];
|
vector<ap_int<In_W>> values_im_in(n_lines);
|
||||||
ap_int<Out_W> values_re_out[n_lines];
|
vector<ap_int<Out_W>> values_re_out(n_lines);
|
||||||
ap_int<Out_W> values_im_out[n_lines];
|
vector<ap_int<Out_W>> values_im_out(n_lines);
|
||||||
|
|
||||||
double results_re[n_lines];
|
vector<double> results_re(n_lines);
|
||||||
double results_im[n_lines];
|
vector<double> results_im(n_lines);
|
||||||
|
|
||||||
ofstream out_stream;
|
ofstream out_stream;
|
||||||
|
|
||||||
|
@ -444,7 +442,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
// 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 double abs_margin = double(1 << (cordic.Out_I - 1)) * 3. / 100.; // Internal scaling creates noise
|
constexpr double abs_margin = double(1 << (cordic_rom::Out_I - 1)) * 3. / 100.; // Internal scaling creates noise
|
||||||
|
|
||||||
// Executing the encoder
|
// Executing the encoder
|
||||||
for (unsigned iter = 0; iter < n_lines; iter++) {
|
for (unsigned iter = 0; iter < n_lines; iter++) {
|
||||||
|
|
Loading…
Reference in a new issue