experimenting
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 22 Jul 2019 11:19:58 +0000 (12:19 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 22 Jul 2019 11:19:58 +0000 (12:19 +0100)
src/ieee754/fpcommon/test/fpmux.py
src/ieee754/fpdiv/div0.py
src/ieee754/fpdiv/div2.py

index 181e57a2dac5e8c9e9cfeb338968c1330726fb30..631f2fc2af5cde1e95de7d5a1890f9a113e4f3fd 100644 (file)
@@ -167,6 +167,9 @@ def create_random(num_rows, width, single_op=False, n_vals=10):
             else:
                 op1 = randint(0, (1<<width)-1)
                 op2 = randint(0, (1<<width)-1)
+
+                op1 = 0x4000
+                op2 = 0x4000
                 vals.append((op1, op2,))
     return vals
 
index 4bd12cb273b47bea8c24ceae71e2b8f40c6c0eef..763d0be6ea92f30bdad48dae91a73f5b1ff856b8 100644 (file)
@@ -66,7 +66,9 @@ class FPDivStage0Mod(Elaboratable):
             bm0 = Signal(len(self.i.b.m)+3, reset_less=True)
             m.d.comb += [
                          am0.eq(Cat(0, 0, self.i.a.m, 0)),
-                         bm0.eq(Cat(0, 0, self.i.b.m, 0))
+                         bm0.eq(Cat(0, 0, self.i.b.m, 0)),
+                         #am0.eq(0x392),
+                         #bm0.eq(0x1110),
                         ]
 
             m.d.comb += [self.o.z.e.eq(self.i.a.e - self.i.b.e + 1),
index 61c7fa4ca79aceff6b0c957ee37f1ef5aaa8d20e..8fb5b8c27f0aa1e9ff4e25bf1dee4e352a7176a9 100644 (file)
@@ -65,24 +65,26 @@ class FPDivStage2Mod(FPState, Elaboratable):
         with m.If(~self.i.out_do_z):
             mw = self.o.z.m_width
             # TODO: compensate for answer being in range 0.49999 to 1.99998
-            p = Signal(len(self.i.quotient_root), reset_less=True)
+            pl = len(self.i.quotient_root) + len(self.i.remainder)
+            pt = Signal(pl, reset_less=True)
+            m.d.comb += pt.eq(Cat(self.i.remainder, self.i.quotient_root))
+            p = Signal(pl, reset_less=True)
             with m.If(self.i.quotient_root[-1]):
-                m.d.comb += p.eq(self.i.quotient_root)
+                m.d.comb += p.eq(pt)
             with m.Else():
                 # get 1 bit of extra accuracy if the mantissa top bit is zero
-                m.d.comb += p.eq(self.i.quotient_root<<1)
+                m.d.comb += p.eq(pt << 1)
                 m.d.comb += self.o.z.e.eq(self.i.z.e-1)
 
             # TODO: use p here instead of quotient_root, direct.
             # XXX what to do about remainder? shift that as well?
             # hmm, how about concatenate remainder and quotient...
             m.d.comb += [
-                self.o.z.m.eq(self.i.quotient_root[mw+2:]),
-                self.o.of.m0.eq(self.i.quotient_root[mw+2]), # copy of LSB
-                self.o.of.guard.eq(self.i.quotient_root[mw+1]),
-                self.o.of.round_bit.eq(self.i.quotient_root[mw]),
-                self.o.of.sticky.eq(Cat(self.i.remainder,
-                                        self.i.quotient_root[:mw]).bool())
+                self.o.z.m.eq(p[-mw-2:]),
+                self.o.of.m0.eq(p[-mw-2]), # copy of LSB
+                self.o.of.guard.eq(p[-mw-1]),
+                self.o.of.round_bit.eq(p[-mw]),
+                self.o.of.sticky.eq(p[:-mw].bool())
             ]
 
         m.d.comb += self.o.out_do_z.eq(self.i.out_do_z)