[libre-riscv-dev] div/mod algorithm written in python

Luke Kenneth Casson Leighton lkcl at lkcl.net
Sun Jul 21 15:40:26 BST 2019


so, this is the first bit.  bear in mind that at this stage, both
self.i.a and self.i.b have been "denormalised".  they're 1 bit longer
than a "normal" FPnum, and the top mantissa bit in each of a and b
have been set to 1:

diff --git a/src/ieee754/fpdiv/div0.py b/src/ieee754/fpdiv/div0.py
 from ieee754.fpcommon.fpbase import FPState
 from ieee754.fpcommon.denorm import FPSCData
 from ieee754.fpcommon.getop import FPPipeContext
+from ieee754.div_rem_sqrt_rsqrt.div_pipe import DivPipeInputData

        with m.If(~self.i.out_do_z):
            # do conversion here, of both self.i.a and self.i.b,
            # into DivPipeCoreInputData dividend and divisor.

+            m.d.comb += [self.o.z.e.eq(self.i.a.e - self.i.b.e + 1),
+                         self.o.z.s.eq(self.i.a.s ^ self.i.b.s)
+                         self.o.dividend.eq(self.i.a.m), # TODO: check
+                         self.o.divisor_radicand.eq(self.i.b.m), # TODO: check
+                         self.o.operation.eq(Const(0)) # TODO (set from ctx.op)
+                ]

that's basically... errr.... job done.  (except for setting up the operation).

l.



More information about the libre-riscv-dev mailing list