mirror of
https://github.com/DrasLorus/CORDIC_Rotate_APFX.git
synced 2024-11-22 04:33:17 +01:00
Clang works, not GCC
This commit is contained in:
parent
f2a7c0c886
commit
cbd04f1a3e
5 changed files with 23 additions and 25 deletions
|
@ -19,7 +19,6 @@ if (EXPORT_COMMANDS)
|
||||||
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
option (ENABLE_XILINX "use Xilinx provided and proprietary headers." ON)
|
option (ENABLE_XILINX "use Xilinx provided and proprietary headers." ON)
|
||||||
if (ENABLE_XILINX)
|
if (ENABLE_XILINX)
|
||||||
set (
|
set (
|
||||||
|
@ -54,8 +53,7 @@ if ((NOT EXISTS ${AP_INCLUDE_DIR}/ap_int.h) OR (NOT EXISTS
|
||||||
message (
|
message (
|
||||||
FATAL_ERROR
|
FATAL_ERROR
|
||||||
"Arbitrary precision headers not found in ${AP_INCLUDE_DIR}.\n"
|
"Arbitrary precision headers not found in ${AP_INCLUDE_DIR}.\n"
|
||||||
"Consider disabling the ap_int feature using `-DENABLE_AP_INT=OFF`"
|
"Please provide a suitable path to the headers."
|
||||||
" or provide a suitable path to the headers."
|
|
||||||
)
|
)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ private:
|
||||||
public:
|
public:
|
||||||
uint8_t rom[max_length];
|
uint8_t rom[max_length];
|
||||||
|
|
||||||
constexpr CRomGeneratorConst() {
|
constexpr CRomGeneratorConst() : rom() {
|
||||||
for (unsigned n = 0; n < max_length; n++) {
|
for (unsigned n = 0; n < max_length; n++) {
|
||||||
const double chip_rotation = rotation / double(q) * double(n);
|
const double chip_rotation = rotation / double(q) * double(n);
|
||||||
rom[n] = cordic_rom_gen(chip_rotation);
|
rom[n] = cordic_rom_gen(chip_rotation);
|
||||||
|
@ -106,7 +106,7 @@ public:
|
||||||
|
|
||||||
template <unsigned In_W, unsigned NStages, unsigned Tq>
|
template <unsigned In_W, unsigned NStages, unsigned Tq>
|
||||||
void generate_rom_header_const(const char * filename = "rom_cordic.h") {
|
void generate_rom_header_const(const char * filename = "rom_cordic.h") {
|
||||||
constexpr CRomGeneratorConst<In_W, NStages, Tq> rom;
|
constexpr CRomGeneratorConst<In_W, NStages, Tq> rom{};
|
||||||
|
|
||||||
FILE * rom_file = fopen(filename, "w");
|
FILE * rom_file = fopen(filename, "w");
|
||||||
if (!bool(rom_file)) {
|
if (!bool(rom_file)) {
|
||||||
|
@ -130,7 +130,7 @@ void generate_rom_header_const(const char * filename = "rom_cordic.h") {
|
||||||
|
|
||||||
template <unsigned In_W, unsigned NStages, unsigned Tq>
|
template <unsigned In_W, unsigned NStages, unsigned Tq>
|
||||||
void generate_rom_header_const_raw(const char * filename = "rom_cordic.txt") {
|
void generate_rom_header_const_raw(const char * filename = "rom_cordic.txt") {
|
||||||
constexpr CRomGeneratorConst<In_W, NStages, Tq> rom;
|
constexpr CRomGeneratorConst<In_W, NStages, Tq> rom{};
|
||||||
|
|
||||||
FILE * rom_file = fopen(filename, "w");
|
FILE * rom_file = fopen(filename, "w");
|
||||||
if (!bool(rom_file)) {
|
if (!bool(rom_file)) {
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
const double re_x = floor(double(scale_factor - 1) * cos(-rotation / double(q) * double(n)));
|
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 double im_x = floor(double(scale_factor - 1) * sin(-rotation / double(q) * double(n)));
|
||||||
|
|
||||||
const std::complex<int64_t> x {re_x, im_x};
|
const std::complex<int64_t> x {int64_t(re_x), int64_t(im_x)};
|
||||||
|
|
||||||
double error = 1000.;
|
double error = 1000.;
|
||||||
uint8_t rom_v = 0x0;
|
uint8_t rom_v = 0x0;
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
#include <ap_fixed.h>
|
#include <ap_fixed.h>
|
||||||
#include <ap_int.h>
|
#include <ap_int.h>
|
||||||
|
|
||||||
|
template <uint8_t N_STAGES,
|
||||||
|
class T,
|
||||||
|
uint8_t ATAN_I>
|
||||||
|
struct CAtanLUT {
|
||||||
static constexpr double atanDbl[28] {
|
static constexpr double atanDbl[28] {
|
||||||
0.78539816339745, 0.46364760900081, 0.24497866312686, 0.12435499454676,
|
0.78539816339745, 0.46364760900081, 0.24497866312686, 0.12435499454676,
|
||||||
0.06241880999596, 0.03123983343027, 0.01562372862048, 0.00781234106010,
|
0.06241880999596, 0.03123983343027, 0.01562372862048, 0.00781234106010,
|
||||||
|
@ -20,10 +24,6 @@ static constexpr double atanDbl[28] {
|
||||||
0.00000095367432, 0.00000047683716, 0.00000023841858, 0.00000011920929,
|
0.00000095367432, 0.00000047683716, 0.00000023841858, 0.00000011920929,
|
||||||
0.00000005960464, 0.00000002980232, 0.00000001490116, 0.00000000745058};
|
0.00000005960464, 0.00000002980232, 0.00000001490116, 0.00000000745058};
|
||||||
|
|
||||||
template <uint8_t N_STAGES,
|
|
||||||
class T,
|
|
||||||
uint8_t ATAN_I>
|
|
||||||
struct CAtanLUT {
|
|
||||||
static_assert(N_STAGES < 28, "Not enough arctan available.");
|
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(N_STAGES <= ATAN_I, "ATAN_I can't be less than N_STAGES.");
|
||||||
static_assert(std::__is_standard_integer<T>(), "Must be a standard C++ integer type.");
|
static_assert(std::__is_standard_integer<T>(), "Must be a standard C++ integer type.");
|
||||||
|
|
|
@ -182,7 +182,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
|
|
||||||
// Save the results to a file
|
// Save the results to a file
|
||||||
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 cordic_rom cordic {};
|
constexpr cordic_rom cordic {};
|
||||||
|
|
||||||
|
@ -193,8 +193,8 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
// Execute
|
// Execute
|
||||||
const uint8_t counter = uint8_t(iter & cnt_mask);
|
const uint8_t counter = uint8_t(iter & cnt_mask);
|
||||||
|
|
||||||
if (iter < cnt_mask + 1)
|
// if (iter < cnt_mask + 1)
|
||||||
fprintf(romf, "%03d\n", (uint16_t) cordic.rom_cordic.rom[counter]);
|
// fprintf(romf, "%03d\n", (uint16_t) cordic.rom_cordic.rom[counter]);
|
||||||
|
|
||||||
cordic.cordic(
|
cordic.cordic(
|
||||||
values_re_in[iter], values_im_in[iter],
|
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));
|
REQUIRE_THAT(values_im_out[iter].to_double() * 5. / 8. / cordic_rom::out_scale_factor, WithinAbsMatcher(results_im[iter], abs_margin));
|
||||||
}
|
}
|
||||||
out_stream.close();
|
out_stream.close();
|
||||||
fclose(romf);
|
// fclose(romf);
|
||||||
|
|
||||||
// Compare the results file with the golden results
|
// Compare the results file with the golden results
|
||||||
// int retval = 0;
|
// int retval = 0;
|
||||||
|
@ -260,7 +260,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
|
|
||||||
// Save the results to a file
|
// Save the results to a file
|
||||||
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 cordic_rom cordic {};
|
constexpr cordic_rom cordic {};
|
||||||
|
|
||||||
|
@ -271,8 +271,8 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
// Execute
|
// Execute
|
||||||
const uint8_t counter = uint8_t(iter & cnt_mask);
|
const uint8_t counter = uint8_t(iter & cnt_mask);
|
||||||
|
|
||||||
if (iter < cnt_mask + 1)
|
// if (iter < cnt_mask + 1)
|
||||||
fprintf(romf, "%03d\n", (uint16_t) cordic.rom_cordic.rom[counter]);
|
// fprintf(romf, "%03d\n", (uint16_t) cordic.rom_cordic.rom[counter]);
|
||||||
|
|
||||||
cordic.cordic(
|
cordic.cordic(
|
||||||
values_re_in[iter], values_im_in[iter],
|
values_re_in[iter], values_im_in[iter],
|
||||||
|
@ -293,7 +293,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
||||||
abs_margin));
|
abs_margin));
|
||||||
}
|
}
|
||||||
out_stream.close();
|
out_stream.close();
|
||||||
fclose(romf);
|
// fclose(romf);
|
||||||
|
|
||||||
// Compare the results file with the golden results
|
// Compare the results file with the golden results
|
||||||
// int retval = 0;
|
// int retval = 0;
|
||||||
|
|
Loading…
Reference in a new issue