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)
|
||||
endif ()
|
||||
|
||||
|
||||
option (ENABLE_XILINX "use Xilinx provided and proprietary headers." ON)
|
||||
if (ENABLE_XILINX)
|
||||
set (
|
||||
|
@ -54,8 +53,7 @@ if ((NOT EXISTS ${AP_INCLUDE_DIR}/ap_int.h) OR (NOT EXISTS
|
|||
message (
|
||||
FATAL_ERROR
|
||||
"Arbitrary precision headers not found in ${AP_INCLUDE_DIR}.\n"
|
||||
"Consider disabling the ap_int feature using `-DENABLE_AP_INT=OFF`"
|
||||
" or provide a suitable path to the headers."
|
||||
"Please provide a suitable path to the headers."
|
||||
)
|
||||
endif ()
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ private:
|
|||
public:
|
||||
uint8_t rom[max_length];
|
||||
|
||||
constexpr CRomGeneratorConst() {
|
||||
constexpr CRomGeneratorConst() : rom() {
|
||||
for (unsigned n = 0; n < max_length; n++) {
|
||||
const double chip_rotation = rotation / double(q) * double(n);
|
||||
rom[n] = cordic_rom_gen(chip_rotation);
|
||||
|
@ -106,7 +106,7 @@ public:
|
|||
|
||||
template <unsigned In_W, unsigned NStages, unsigned Tq>
|
||||
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");
|
||||
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>
|
||||
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");
|
||||
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 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.;
|
||||
uint8_t rom_v = 0x0;
|
||||
|
|
|
@ -11,19 +11,19 @@
|
|||
#include <ap_fixed.h>
|
||||
#include <ap_int.h>
|
||||
|
||||
static constexpr double atanDbl[28] {
|
||||
0.78539816339745, 0.46364760900081, 0.24497866312686, 0.12435499454676,
|
||||
0.06241880999596, 0.03123983343027, 0.01562372862048, 0.00781234106010,
|
||||
0.00390623013197, 0.00195312251648, 0.00097656218956, 0.00048828121119,
|
||||
0.00024414062015, 0.00012207031189, 0.00006103515617, 0.00003051757812,
|
||||
0.00001525878906, 0.00000762939453, 0.00000381469727, 0.00000190734863,
|
||||
0.00000095367432, 0.00000047683716, 0.00000023841858, 0.00000011920929,
|
||||
0.00000005960464, 0.00000002980232, 0.00000001490116, 0.00000000745058};
|
||||
|
||||
template <uint8_t N_STAGES,
|
||||
class T,
|
||||
uint8_t ATAN_I>
|
||||
struct CAtanLUT {
|
||||
static constexpr double atanDbl[28] {
|
||||
0.78539816339745, 0.46364760900081, 0.24497866312686, 0.12435499454676,
|
||||
0.06241880999596, 0.03123983343027, 0.01562372862048, 0.00781234106010,
|
||||
0.00390623013197, 0.00195312251648, 0.00097656218956, 0.00048828121119,
|
||||
0.00024414062015, 0.00012207031189, 0.00006103515617, 0.00003051757812,
|
||||
0.00001525878906, 0.00000762939453, 0.00000381469727, 0.00000190734863,
|
||||
0.00000095367432, 0.00000047683716, 0.00000023841858, 0.00000011920929,
|
||||
0.00000005960464, 0.00000002980232, 0.00000001490116, 0.00000000745058};
|
||||
|
||||
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(std::__is_standard_integer<T>(), "Must be a standard C++ integer type.");
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
using namespace std;
|
||||
|
||||
using Catch::Matchers::Floating::WithinAbsMatcher;
|
||||
|
||||
|
||||
TEST_CASE("Adaptive CORDIC work as intended", "[!hide][WIP]") {
|
||||
typedef CCordicRotate<8, 14, 4, 17, 5, 19, 7, 12> cordic_legacy;
|
||||
|
||||
|
@ -182,7 +182,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
|||
|
||||
// Save the results to a file
|
||||
out_stream.open("results_ap.dat");
|
||||
FILE * romf = fopen("rom.dat", "w");
|
||||
// FILE * romf = fopen("rom.dat", "w");
|
||||
|
||||
constexpr cordic_rom cordic {};
|
||||
|
||||
|
@ -193,8 +193,8 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
|||
// Execute
|
||||
const uint8_t counter = uint8_t(iter & cnt_mask);
|
||||
|
||||
if (iter < cnt_mask + 1)
|
||||
fprintf(romf, "%03d\n", (uint16_t) cordic.rom_cordic.rom[counter]);
|
||||
// if (iter < cnt_mask + 1)
|
||||
// fprintf(romf, "%03d\n", (uint16_t) cordic.rom_cordic.rom[counter]);
|
||||
|
||||
cordic.cordic(
|
||||
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));
|
||||
}
|
||||
out_stream.close();
|
||||
fclose(romf);
|
||||
// fclose(romf);
|
||||
|
||||
// Compare the results file with the golden results
|
||||
// int retval = 0;
|
||||
|
@ -260,7 +260,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
|||
|
||||
// Save the results to a file
|
||||
out_stream.open("results_ap.dat");
|
||||
FILE * romf = fopen("rom.dat", "w");
|
||||
// FILE * romf = fopen("rom.dat", "w");
|
||||
|
||||
constexpr cordic_rom cordic {};
|
||||
|
||||
|
@ -271,8 +271,8 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
|||
// Execute
|
||||
const uint8_t counter = uint8_t(iter & cnt_mask);
|
||||
|
||||
if (iter < cnt_mask + 1)
|
||||
fprintf(romf, "%03d\n", (uint16_t) cordic.rom_cordic.rom[counter]);
|
||||
// if (iter < cnt_mask + 1)
|
||||
// fprintf(romf, "%03d\n", (uint16_t) cordic.rom_cordic.rom[counter]);
|
||||
|
||||
cordic.cordic(
|
||||
values_re_in[iter], values_im_in[iter],
|
||||
|
@ -293,7 +293,7 @@ TEST_CASE("ROM-based Cordic works with AP-Types", "[CORDIC]") {
|
|||
abs_margin));
|
||||
}
|
||||
out_stream.close();
|
||||
fclose(romf);
|
||||
// fclose(romf);
|
||||
|
||||
// Compare the results file with the golden results
|
||||
// int retval = 0;
|
||||
|
|
Loading…
Reference in a new issue