From 92dfbb92dd3b5bdb53d4aef4cc11cdf71f7fbdf5 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 17 Feb 2012 23:51:32 +0100 Subject: [PATCH] bus: add interconnect statements function --- migen/bus/dfi.py | 12 +++++++----- migen/bus/simple.py | 22 ++++++++++++---------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/migen/bus/dfi.py b/migen/bus/dfi.py index 5fb2a044..b2137cb3 100644 --- a/migen/bus/dfi.py +++ b/migen/bus/dfi.py @@ -42,14 +42,16 @@ class Interface: r.append(("dfi_" + signal[1] + suffix, getattr(phase, signal[1]))) return r +def interconnect_stmts(master, slave): + r = [] + for pm, ps in zip(master.phases, slave.phases): + r += simple_interconnect_stmts(master.pdesc, pm, [ps]) + return r + class Interconnect: def __init__(self, master, slave): self.master = master self.slave = slave def get_fragment(self): - f = Fragment() - for pm, ps in zip(self.master.phases, self.slave.phases): - ic = SimpleInterconnect(pm, [ps]) - f += ic.get_fragment() - return f + return Fragment(interconnect_stmts(self.master, self.slave)) diff --git a/migen/bus/simple.py b/migen/bus/simple.py index f0f10490..348e510c 100644 --- a/migen/bus/simple.py +++ b/migen/bus/simple.py @@ -27,19 +27,21 @@ class SimpleInterface: signame = signal[1] setattr(self, signame, Signal(BV(signal[2]), busname + "_" + signame)) +def simple_interconnect_stmts(desc, master, slaves): + s2m = desc.get_names(S_TO_M) + m2s = desc.get_names(M_TO_S) + sl = [getattr(slave, name).eq(getattr(master, name)) + for name in m2s for slave in slaves] + sl += [getattr(master, name).eq( + optree("|", [getattr(slave, name) for slave in slaves]) + ) + for name in s2m] + return sl + class SimpleInterconnect: def __init__(self, master, slaves): self.master = master self.slaves = slaves def get_fragment(self): - desc = self.master.desc - s2m = desc.get_names(S_TO_M) - m2s = desc.get_names(M_TO_S) - comb = [getattr(slave, name).eq(getattr(self.master, name)) - for name in m2s for slave in self.slaves] - comb += [getattr(self.master, name).eq( - optree("|", [getattr(slave, name) for slave in self.slaves]) - ) - for name in s2m] - return Fragment(comb) + return Fragment(simple_interconnect_stmts(self.master.desc, self.master, self.slaves)) -- 2.30.2