use negative slice (now works)
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 14 Feb 2019 11:22:46 +0000 (11:22 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 14 Feb 2019 11:22:46 +0000 (11:22 +0000)
src/add/nmigen_add_experiment.py

index 92157d41f8addb8a3811ae2f7ed0b11af332036a..2db9c27ba0a4886ec4a64d9e2aac6fe7a998f14c 100644 (file)
@@ -9,9 +9,8 @@ from nmigen.cli import main
 class FPNum:
     def __init__(self, width, m_width=None):
         self.width = width
-        self.mw = 23 # TODO
         if m_width is None:
-            m_width = width + 3 # extra accuracy bits
+            m_width = width - 5 # mantissa extra bits (top,guard,round)
         self.v = Signal(width)      # Latched copy of value
         self.m = Signal(m_width)    # Mantissa
         self.e = Signal((10, True)) # Exponent: 10 bits, signed
@@ -34,7 +33,7 @@ class FPNum:
     def shift_down(self):
         return self.create(self.s,
                            self.e + 1,
-                           Cat(self.m[0] | self.m[1], self.m[1:self.mw-1], 0))
+                           Cat(self.m[0] | self.m[1], self.m[1:-5], 0))
 
     def nan(self, s):
         return self.create(s, 0xff, 1<<22)