use ispec and ospec in FPNormaliseModSingle
[ieee754fpu.git] / src / add / nmigen_add_experiment.py
index 0d2f9ae05bd261954b01cece41623cb30a9a8b65..5d5a9933250434778592112bfa7bed17c5ed96f1 100644 (file)
@@ -711,13 +711,10 @@ class FPAddAlignSingleAdd(FPState, FPID):
         self.o = self.mod.ospec()
 
         self.a0mod = FPAddStage0Mod(width)
-        self.a0_out_z = FPNumBase(width, False)
-        self.out_tot = Signal(self.a0_out_z.m_width + 4, reset_less=True)
-        self.a0_out_z = FPNumBase(width, False)
+        self.a0o = self.a0mod.ospec()
 
         self.a1mod = FPAddStage1Mod(width)
-        self.out_z = FPNumBase(width, False)
-        self.out_of = Overflow()
+        self.a1o = self.a1mod.ospec()
 
     def setup(self, m, in_a, in_b, in_mid):
         """ links module to inputs and outputs
@@ -726,18 +723,16 @@ class FPAddAlignSingleAdd(FPState, FPID):
         m.d.comb += self.o.eq(self.mod.o)
 
         self.a0mod.setup(m, self.o.a, self.o.b)
-        m.d.comb += self.a0_out_z.eq(self.a0mod.o.z)
-        m.d.comb += self.out_tot.eq(self.a0mod.o.tot)
+        m.d.comb += self.a0o.eq(self.a0mod.o)
 
-        self.a1mod.setup(m, self.out_tot, self.a0_out_z)
+        self.a1mod.setup(m, self.a0o.tot, self.a0o.z)
 
         if self.in_mid is not None:
             m.d.comb += self.in_mid.eq(in_mid)
 
     def action(self, m):
         self.idsync(m)
-        m.d.sync += self.out_of.eq(self.a1mod.o.of)
-        m.d.sync += self.out_z.eq(self.a1mod.o.z)
+        m.d.sync += self.a1o.eq(self.a1mod.o)
         m.next = "normalise_1"
 
 
@@ -933,8 +928,14 @@ class FPNormaliseModSingle:
 
     def __init__(self, width):
         self.width = width
-        self.in_z = FPNumBase(width, False)
-        self.out_z = FPNumBase(width, False)
+        self.in_z = self.ispec()
+        self.out_z = self.ospec()
+
+    def ispec(self):
+        return FPNumBase(self.width, False)
+
+    def ospec(self):
+        return FPNumBase(self.width, False)
 
     def setup(self, m, in_z, out_z, modname):
         """ links module to inputs and outputs
@@ -968,7 +969,7 @@ class FPNormaliseModSingle:
         # initialise out from in (overridden below)
         m.d.comb += self.out_z.eq(in_z)
         m.d.comb += self.out_of.eq(in_of)
-        # normalisation increase/decrease conditions
+        # normalisation decrease condition
         decrease = Signal(reset_less=True)
         m.d.comb += decrease.eq(in_z.m_msbzero)
         # decrease exponent
@@ -1096,7 +1097,6 @@ class FPNorm1ModMulti:
     def __init__(self, width, single_cycle=True):
         self.width = width
         self.in_select = Signal(reset_less=True)
-        self.out_norm = Signal(reset_less=True)
         self.in_z = FPNumBase(width, False)
         self.in_of = Overflow()
         self.temp_z = FPNumBase(width, False)
@@ -1567,7 +1567,7 @@ class FPADDBaseMod(FPID):
         alm.setup(m, sc.o.a, sc.o.b, sc.in_mid)
 
         n1 = self.add_state(FPNormToPack(self.width, self.id_wid))
-        n1.setup(m, alm.out_z, alm.out_of, alm.in_mid)
+        n1.setup(m, alm.a1o.z, alm.a1o.of, alm.in_mid)
 
         ppz = self.add_state(FPPutZ("pack_put_z", n1.out_z, self.out_z,
                                     n1.in_mid, self.out_mid))