Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:22:35

0001 #ifndef CordicXilinx_H
0002 #define CordicXilinx_H
0003 
0004 #include <vector>
0005 #include <array>
0006 #include <cstdint>
0007 
0008 class CordicXilinx {
0009 public:
0010   CordicXilinx(int inputBits, int outputBits, bool debug = false);
0011 
0012   // Fills aPhi and aMagnitude with result scaled to 2^outputBits
0013   // input must be signed and in the range [ -2^(inputBits-1), 2^(inputBits-1) )
0014   void operator()(int32_t xInput, int32_t yInput, int32_t& aPhi, uint32_t& aMagnitude) const;
0015 
0016   // Returns angle in fixed point according to internalBits_ precision
0017   // The integer part is 3 bits (i.e. -4 to 3)
0018   // Valid input is -pi < angle < pi
0019   int encodeAngle(const double angleFloat) const;
0020 
0021 private:
0022   const int inputBits_;
0023   const int outputBits_;
0024   const bool debug_;
0025 
0026   std::vector<int> rotations_;
0027   // For (probably unnecessary) optimization
0028   std::array<int, 3> encodedAngles_;
0029   enum { Pi, HalfPi, NHalfPi };
0030   int iterations_;
0031   int internalBits_;
0032   int scaleFactor_;
0033 };
0034 
0035 #endif