From 04be2b56c14245a286db176946c9111866107bd1 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 22 Mar 2019 10:27:07 +0000 Subject: [PATCH] replace hand-chained module linkage with StageChain --- src/add/nmigen_add_experiment.py | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/add/nmigen_add_experiment.py b/src/add/nmigen_add_experiment.py index 662f1fb8..dd7b43d4 100644 --- a/src/add/nmigen_add_experiment.py +++ b/src/add/nmigen_add_experiment.py @@ -9,6 +9,7 @@ from math import log from fpbase import FPNumIn, FPNumOut, FPOp, Overflow, FPBase, FPNumBase from fpbase import MultiShiftRMerge, Trigger +from example_buf_pipe import StageChain #from fpbase import FPNumShiftMultiRight @@ -1255,31 +1256,17 @@ class FPNormToPack(FPState): """ links module to inputs and outputs """ - # Normalisation (chained to input in_z+in_of) + # Normalisation, Rounding Corrections, Pack - in a chain nmod = FPNorm1ModSingle(self.width, self.id_wid) - nmod.setup(m, i) - n_out = nmod.ospec() - m.d.comb += n_out.eq(nmod.o) - - # Rounding (chained to normalisation) rmod = FPRoundMod(self.width, self.id_wid) - rmod.setup(m, n_out) - r_out_z = rmod.ospec() - m.d.comb += r_out_z.eq(rmod.out_z) - - # Corrections (chained to rounding) cmod = FPCorrectionsMod(self.width, self.id_wid) - cmod.setup(m, r_out_z) - c_out_z = cmod.ospec() - m.d.comb += c_out_z.eq(cmod.out_z) - - # Pack (chained to corrections) - self.pmod = FPPackMod(self.width, self.id_wid) - self.pmod.setup(m, c_out_z) - self.out_z = self.pmod.ospec() + pmod = FPPackMod(self.width, self.id_wid) + chain = StageChain([nmod, rmod, cmod, pmod]) + chain.setup(m, i) + self.out_z = pmod.ospec() - m.d.sync += self.out_z.mid.eq(self.pmod.o.mid) - m.d.sync += self.out_z.z.v.eq(self.pmod.o.z.v) # outputs packed result + m.d.sync += self.out_z.mid.eq(pmod.o.mid) + m.d.sync += self.out_z.z.v.eq(pmod.o.z.v) # outputs packed result def action(self, m): m.next = "pack_put_z" -- 2.30.2