A template to implement a CORDIC-based rotation with bit accurate fixed-point number representation.
Find a file
Camille Monière f0035238bf
Correct the name and improve widely
- Fix the MC (Monte-Carlo) to the proper algoritm name, ML (maximum
  likelyhood) and remove HalfPi since the use of divider allow to
  theoretically support any pi / 2^k, k an integer. In reality, a too
  low rotation would require more stages than 7 but it is for futur
  improvements.
- Make use of `divider` template to provide rotation grain finer than pi
  / 2. Validated (unit-tested) with pi / 4 with the same margins than pi
  / 2 (2% of error with floating scaling, 3% with fixed scaling).
- Fix rom size which now use N_STAGES+1 bits instead of 8 regardless of
  N_STAGES. Simplify the cordic method implementation, which
  unexpectedly (and fortunately) improved its performance.
2022-03-14 14:07:10 +01:00
.github Tentative of action 2022-02-14 15:55:30 +01:00
data Working AP template cordic 2022-02-11 18:17:13 +01:00
RomGenerators Correct the name and improve widely 2022-03-14 14:07:10 +01:00
sources Correct the name and improve widely 2022-03-14 14:07:10 +01:00
.clang-format Fix for GCC 9.4 support, formatting, and license addition. 2022-02-17 20:22:12 +01:00
.gitignore Correct the name and improve widely 2022-03-14 14:07:10 +01:00
cmake_format_conf.py Fix CMakeLists and add a constexpr test 2022-02-14 10:44:22 +01:00
CMakeLists.txt Correct the name and improve widely 2022-03-14 14:07:10 +01:00
lgpl-3.0.md Fix for GCC 9.4 support, formatting, and license addition. 2022-02-17 20:22:12 +01:00
LICENSE Fix for GCC 9.4 support, formatting, and license addition. 2022-02-17 20:22:12 +01:00
README.md Update CMakeLists and add GCC 6.2 and 6.5 to the supported compiler lists 2022-02-21 11:39:33 +01:00

CORDIC Rotate APFX

A free way to implement a CORDIC-based rotation using HLS, with bit-accurate precision.

Goal

CORDIC (COordinate Rotation DIgital Computer) is an efficient way to implement hardware complex rotations (e.g. z * exp(jw), with z = x + jy a complex and w a real angle). It is also useful for microcontrollers or microprocessors lacking floating-point units, as such multiplications can consume a noticeable amount of CPU cycles.

This implementation in C++14 (-std=c++14) is suitable for hardware simulation and (with the right headers and maybe a few tweaks) for synthesis.

This repository defines two working CORDIC-based rotation units classes, CCordicRotateRom and CCordicRotateConstexpr, which both rely on a ROM. They differ by the way the ROM is generated:

  • CCordicRotateRom depends on ROM headers generated by the build system (i.e. CMake) using configure files and build-time dependencies,
  • CCordicRotateConstexpr ROM is completely compiled using C++14 constexpr mechanism, which constraint the ROM type but allow cleaner build dependencies.

Currently, They can have from 2 to 7 stages, and the word length is a template. ROM tables contain control signals for each CORDIC stage, the input angle being the address. There are two kinds of generators:

  • A true constexpr one, that is entirely processed by the compiler.
  • A Monte-Carlo one, that is evaluated at runtime.

Both can be used to produced ROM headers but only the first one can be used for CCordicRotateConstexpr.

Only rotations of pi and pi/2 are currently supported, but support for any pi/2^k might be added later.

CCordicRotateSmart is an unfinished template that would implement a "smart" CORDIC, which would not need a ROM.

Test suite and dependencies

The Catch2 test framework has been used in conjunction with CTest to provides unit tests. The GitHub mirror of the repository also make use of GitHub Actions and Docker as a CI/CD solution.

  • Has been tested successfully compiled with:
    • GNU GCC 6.2 (Xilinx bundled version), 6.5, 9.4, 10.1, 10.2 and 11.2,
    • LLVM Clang 12.0 and 13.0,
  • Uses Catch v2.13.7,
  • Depends on Xilinx HLS arbitrary precision types, available as FOSS here provided by Xilinx or here patched by myself. Note: Xilinx also provides proprietary versions of those headers, suitable for synthesis and implementation, bundled with their products.

Copyright 2022 Camille "DrasLorus" Monière.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

A copy of the license is available here in Markdown or here in plain text.