mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
bus: add interconnect statements function
This commit is contained in:
parent
f995e8b92e
commit
92dfbb92dd
2 changed files with 19 additions and 15 deletions
|
@ -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))
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue