From db15e626f368745d0b337f887a2c317d5d3c4516 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 28 Mar 2019 16:46:17 +0000 Subject: [PATCH] make FPGet2Ops conform to Stage API, use in compact StageChain --- src/add/nmigen_add_experiment.py | 34 ++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/add/nmigen_add_experiment.py b/src/add/nmigen_add_experiment.py index 77c03f80..ae4fb2a6 100644 --- a/src/add/nmigen_add_experiment.py +++ b/src/add/nmigen_add_experiment.py @@ -144,20 +144,33 @@ class FPGet2Op(FPState): FPState.__init__(self, in_state) self.out_state = out_state self.mod = FPGet2OpMod(width, id_wid) - self.o = self.mod.ospec() + self.o = self.ospec() self.in_stb = Signal(reset_less=True) self.out_ack = Signal(reset_less=True) self.out_decode = Signal(reset_less=True) - def setup(self, m, i, in_stb, in_ack): + def ispec(self): + return self.mod.ispec() + + def ospec(self): + return self.mod.ospec() + + def trigger_setup(self, m, in_stb, in_ack): + """ links stb/ack + """ + m.d.comb += self.mod.stb.eq(in_stb) + m.d.comb += in_ack.eq(self.mod.ack) + + def setup(self, m, i): """ links module to inputs and outputs """ m.submodules.get_ops = self.mod m.d.comb += self.mod.i.eq(i) - m.d.comb += self.mod.stb.eq(in_stb) m.d.comb += self.out_ack.eq(self.mod.ack) m.d.comb += self.out_decode.eq(self.mod.trigger) - m.d.comb += in_ack.eq(self.mod.ack) + + def process(self, i): + return self.o def action(self, m): with m.If(self.out_decode): @@ -1587,9 +1600,10 @@ class FPADDBaseMod: get = self.add_state(FPGet2Op("get_ops", "special_cases", self.width)) - get.setup(m, self.i, self.in_t.stb, self.in_t.ack) + get.setup(m, self.i) a = get.out_op1 b = get.out_op2 + get.trigger_setup(m, self.in_t.stb, self.in_t.ack) sc = self.add_state(FPAddSpecialCases(self.width, self.id_wid)) sc.setup(m, a, b, self.in_mid) @@ -1634,17 +1648,17 @@ class FPADDBaseMod: def get_compact_fragment(self, m, platform=None): - get = self.add_state(FPGet2Op("get_ops", "special_cases", - self.width, self.id_wid)) - get.setup(m, self.i, self.in_t.stb, self.in_t.ack) + get = FPGet2Op("get_ops", "special_cases", self.width, self.id_wid) sc = FPAddSpecialCasesDeNorm(self.width, self.id_wid) alm = FPAddAlignSingleAdd(self.width, self.id_wid) n1 = FPNormToPack(self.width, self.id_wid) - chainlist = [sc, alm, n1] + get.trigger_setup(m, self.in_t.stb, self.in_t.ack) + + chainlist = [get, sc, alm, n1] chain = StageChain(chainlist, specallocate=True) - chain.setup(m, get.o) + chain.setup(m, self.i) for mod in chainlist: sc = self.add_state(mod) -- 2.30.2