Revert "Use higher precision arithmetic when calculating the atan2 table"
authorMichael Nolan <mtnolan2640@gmail.com>
Fri, 17 Apr 2020 15:22:24 +0000 (11:22 -0400)
committerMichael Nolan <mtnolan2640@gmail.com>
Fri, 17 Apr 2020 17:27:57 +0000 (13:27 -0400)
This reverts commit 7aea44d471226db693ee99fd272504248d57375b.

setup.py
src/ieee754/cordic/fpsin_cos.py

index c5bf5cf02cacb34274123f02f5dbfac9ee440059..95367ed01906d4179a76e14e7c9ad9594e739871 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -11,7 +11,6 @@ version = '0.0.1'
 install_requires = [
     'nmutil',
 #    'sfpy',  # XXX temporarily disabled
-    'gmpy2'
 ]
 
 test_requires = [
index 3c96cafa952a5ab33452eef2e28c7271c93fbce7..c61e6bf2648bfe530855e54fb8ae110e4eb7fb72 100644 (file)
@@ -8,10 +8,6 @@ import math
 from enum import Enum, unique
 from ieee754.fpcommon.fpbase import FPNumBaseRecord, FPNumDecode
 
-import gmpy2
-from gmpy2 import mpfr
-
-
 
 @unique
 class CordicState(Enum):
@@ -29,14 +25,8 @@ class CordicROM(Elaboratable):
         self.addr = Signal(range(iterations))
         self.data = Signal(range(-M, M-1))
 
-        angles = []
-        gmpy2.get_context().precision = 150
-        for i in range(self.iterations):
-            x = mpfr(2) ** -i
-            x = gmpy2.atan(x)
-            x = x/(gmpy2.const_pi()/mpfr(2))
-            x = x * mpfr(M)
-            angles.append(int(round(x)))
+        angles = [int(round(M*math.atan(2**(-i))/(math.pi/2)))
+                  for i in range(self.iterations)]
 
         self.mem = Memory(width=self.data.width,
                           depth=self.iterations,