From 04260dcb7a06ffab9b6131a292eac6cf89d2db29 Mon Sep 17 00:00:00 2001 From: Michael Nolan Date: Tue, 5 May 2020 14:08:58 -0400 Subject: [PATCH] Add in FPPipeContext to the cordic pipeline --- src/ieee754/cordic/fp_pipe_init_stages.py | 2 +- src/ieee754/cordic/pipe_data.py | 11 +++++++++-- src/ieee754/cordic/renormalize.py | 3 ++- src/ieee754/cordic/sin_cos_pipe_stage.py | 4 ++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/ieee754/cordic/fp_pipe_init_stages.py b/src/ieee754/cordic/fp_pipe_init_stages.py index 2d538713..f03e3731 100644 --- a/src/ieee754/cordic/fp_pipe_init_stages.py +++ b/src/ieee754/cordic/fp_pipe_init_stages.py @@ -65,5 +65,5 @@ class FPCordicConvertFixed(PipeModBase): ~z_shifted + 1, z_shifted)) + comb += self.o.ctx.eq(self.i.ctx) return m - diff --git a/src/ieee754/cordic/pipe_data.py b/src/ieee754/cordic/pipe_data.py index d83dbe7b..c9b24bcd 100644 --- a/src/ieee754/cordic/pipe_data.py +++ b/src/ieee754/cordic/pipe_data.py @@ -10,12 +10,15 @@ class CordicInitialData: def __init__(self, pspec): ZMAX = pspec.ZMAX self.z0 = Signal(range(-ZMAX, ZMAX), name="z") # denormed result + self.ctx = FPPipeContext(pspec) + self.muxid = self.ctx.muxid def __iter__(self): yield self.z0 + yield from self.ctx def eq(self, i): - return [self.z0.eq(i.z0)] + return [self.z0.eq(i.z0), self.ctx.eq(i.ctx)] class CordicOutputData: @@ -46,14 +49,18 @@ class CordicData: self.x = Signal(range(-M, M+1), name="x") # operand a self.y = Signal(range(-M, M+1), name="y") # operand b self.z = Signal(range(-ZMAX, ZMAX), name="z") # denormed result + self.ctx = FPPipeContext(pspec) + self.muxid = self.ctx.muxid def __iter__(self): yield self.x yield self.y yield self.z + yield from self.ctx def eq(self, i): - ret = [self.z.eq(i.z), self.x.eq(i.x), self.y.eq(i.y)] + ret = [self.z.eq(i.z), self.x.eq(i.x), self.y.eq(i.y), + self.ctx.eq(i.ctx)] return ret diff --git a/src/ieee754/cordic/renormalize.py b/src/ieee754/cordic/renormalize.py index e799d234..0a784074 100644 --- a/src/ieee754/cordic/renormalize.py +++ b/src/ieee754/cordic/renormalize.py @@ -38,7 +38,7 @@ class Norm(Elaboratable): comb += numrec.m.eq(normalized[-(numrec.m_width+1):-1]) comb += numrec.s.eq(sign) comb += numrec.e.eq(-count+1) - + comb += self.sig_out.eq(numrec.create2(numrec.s, numrec.e, numrec.m)) return m @@ -67,4 +67,5 @@ class CordicRenormalize(PipeModBase): comb += self.o.x.eq(normx.sig_out) comb += self.o.y.eq(normy.sig_out) + comb += self.o.ctx.eq(self.i.ctx) return m diff --git a/src/ieee754/cordic/sin_cos_pipe_stage.py b/src/ieee754/cordic/sin_cos_pipe_stage.py index 94916abf..35af6e28 100644 --- a/src/ieee754/cordic/sin_cos_pipe_stage.py +++ b/src/ieee754/cordic/sin_cos_pipe_stage.py @@ -28,6 +28,8 @@ class CordicInitialStage(PipeModBase): comb += self.o.x.eq(X0) comb += self.o.y.eq(0) comb += self.o.z.eq(self.i.z0) + + comb += self.o.ctx.eq(self.i.ctx) return m @@ -68,4 +70,6 @@ class CordicStage(PipeModBase): comb += self.o.y.eq(self.i.y - dy) comb += self.o.z.eq(self.i.z + dz) + + comb += self.o.ctx.eq(self.i.ctx) return m -- 2.30.2