+
+
+class FPCordicConvertFixed(PipeModBase):
+ def __init__(self, pspec):
+ super().__init__(pspec, "tofixed")
+
+ def ispec(self):
+ return FPSCData(self.pspec, False)
+
+ def ospec(self):
+ return CordicInitialData(self.pspec)
+
+ def elaborate(self, platform):
+ m = Module()
+ comb = m.d.comb
+
+ shifter = Signal(self.i.a.e.width)
+ comb += shifter.eq(-self.i.a.e)
+
+ z_intermed = Signal(unsigned(self.o.z0.width))
+ z_shifted = Signal(signed(self.o.z0.width))
+ comb += z_intermed.eq(Cat(Repl(0, self.pspec.fracbits -
+ self.i.a.rmw),
+ self.i.a.m))
+ comb += z_shifted.eq(z_intermed >> shifter)
+ comb += self.o.z0.eq(Mux(self.i.a.s,
+ ~z_shifted + 1,
+ z_shifted))
+
+ return m
+