From: Michael Nolan Date: Thu, 16 Apr 2020 19:18:07 +0000 (-0400) Subject: Run the cordic for the proper number of iterations X-Git-Tag: ls180-24jan2020~87 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=39dab2a91f22458a221da5cd83480552844cfa54;p=ieee754fpu.git Run the cordic for the proper number of iterations --- diff --git a/src/ieee754/cordic/fpsin_cos.py b/src/ieee754/cordic/fpsin_cos.py index 382082be..c61e6bf2 100644 --- a/src/ieee754/cordic/fpsin_cos.py +++ b/src/ieee754/cordic/fpsin_cos.py @@ -61,7 +61,7 @@ class CORDIC(Elaboratable): self.ready = Signal(reset=True) self.width = self.z0.width - self.iterations = self.width - 1 + self.iterations = self.fracbits - 1 def elaborate(self, platform): m = Module() diff --git a/src/ieee754/cordic/test/test_fpsin_cos.py b/src/ieee754/cordic/test/test_fpsin_cos.py index 091b7ecc..c793fdd9 100644 --- a/src/ieee754/cordic/test/test_fpsin_cos.py +++ b/src/ieee754/cordic/test/test_fpsin_cos.py @@ -42,7 +42,7 @@ class SinCosTestCase(FHDLTestCase): yield yield start.eq(0) yield - for i in range(fracbits * 3): + for i in range(dut.fracbits+1): rdy = yield ready zo = yield dut.z_out if rdy and not asserted: @@ -56,6 +56,11 @@ class SinCosTestCase(FHDLTestCase): diff = abs(real_sin - expected_sin) print(f"{real_sin} {expected_sin} {diff}") self.assertTrue(diff < 0.001) + real_cos = yield dut.cos + real_cos = self.get_frac(real_cos, dut.cos.width - 2) + diff = abs(real_cos - expected_cos) + print(f"{real_cos} {expected_cos} {diff}") + self.assertTrue(diff < 0.001) yield