2011-12-04 18:16:44 -05:00
|
|
|
from migen.fhdl import structure as f
|
2011-12-08 12:47:32 -05:00
|
|
|
from .simple import Simple
|
2011-12-04 18:16:44 -05:00
|
|
|
|
2011-12-08 12:47:32 -05:00
|
|
|
_desc = [
|
|
|
|
(True, "a", 16),
|
|
|
|
(True, "we", 1),
|
|
|
|
(True, "d", 32),
|
|
|
|
(False, "d", 32)
|
|
|
|
]
|
|
|
|
|
|
|
|
class Master(Simple):
|
2011-12-08 13:16:08 -05:00
|
|
|
def __init__(self, name=""):
|
|
|
|
Simple.__init__(self, _desc, False, name)
|
2011-12-04 18:16:44 -05:00
|
|
|
|
2011-12-08 12:47:32 -05:00
|
|
|
class Slave(Simple):
|
2011-12-08 13:16:08 -05:00
|
|
|
def __init__(self, name=""):
|
|
|
|
Simple.__init__(self, _desc, True, name)
|
2011-12-04 18:16:44 -05:00
|
|
|
|
|
|
|
class Interconnect:
|
|
|
|
def __init__(self, master, slaves):
|
|
|
|
self.master = master
|
|
|
|
self.slaves = slaves
|
|
|
|
|
|
|
|
def GetFragment(self):
|
|
|
|
a = f.Assign
|
|
|
|
comb = []
|
|
|
|
rb = f.Constant(0, f.BV(32))
|
|
|
|
for slave in self.slaves:
|
|
|
|
comb.append(a(slave.a_i, self.master.a_o))
|
|
|
|
comb.append(a(slave.we_i, self.master.we_o))
|
|
|
|
comb.append(a(slave.d_i, self.master.d_o))
|
|
|
|
rb = rb | slave.d_o
|
|
|
|
comb.append(a(master.d_i, rb))
|
2011-12-08 12:47:32 -05:00
|
|
|
return f.Fragment(comb)
|