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))
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))