1 from nmigen
import Signal
, Const
2 from nmutil
.dynamicpipe
import SimpleHandshakeRedir
3 from ieee754
.fpcommon
.fpbase
import Overflow
, FPNumBaseRecord
4 from ieee754
.fpcommon
.getop
import FPPipeContext
8 class CordicInitialData
:
10 def __init__(self
, pspec
):
12 self
.z0
= Signal(range(-ZMAX
, ZMAX
), name
="z") # denormed result
13 self
.ctx
= FPPipeContext(pspec
)
14 self
.muxid
= self
.ctx
.muxid
21 return [self
.z0
.eq(i
.z0
), self
.ctx
.eq(i
.ctx
)]
24 class CordicOutputData
:
26 def __init__(self
, pspec
, e_extra
=False):
28 self
.x
= Signal(width
)
29 self
.y
= Signal(width
)
30 self
.ctx
= FPPipeContext(pspec
)
31 self
.muxid
= self
.ctx
.muxid
39 return [self
.x
.eq(i
.x
), self
.y
.eq(i
.y
),
45 def __init__(self
, pspec
):
49 self
.x
= Signal(range(-M
, M
+1), name
="x") # operand a
50 self
.y
= Signal(range(-M
, M
+1), name
="y") # operand b
51 self
.z
= Signal(range(-ZMAX
, ZMAX
), name
="z") # denormed result
52 self
.ctx
= FPPipeContext(pspec
)
53 self
.muxid
= self
.ctx
.muxid
62 ret
= [self
.z
.eq(i
.z
), self
.x
.eq(i
.x
), self
.y
.eq(i
.y
),
68 def __init__(self
, fracbits
, rounds_per_stage
):
69 self
.fracbits
= fracbits
70 # Number of cordic operations per pipeline stage
71 self
.rounds_per_stage
= rounds_per_stage
72 self
.M
= (1 << fracbits
)
73 self
.ZMAX
= int(round(self
.M
* math
.pi
/2))
74 zm
= Const(-self
.ZMAX
)
75 self
.iterations
= zm
.width
- 1
77 self
.pipekls
= SimpleHandshakeRedir