2011-12-16 15:30:14 -05:00
|
|
|
from migen.fhdl.structure import *
|
2011-12-08 12:47:32 -05:00
|
|
|
|
2011-12-16 10:02:55 -05:00
|
|
|
def get_sig_name(signal, slave):
|
2011-12-08 17:06:04 -05:00
|
|
|
if signal[0] ^ slave:
|
|
|
|
suffix = "_o"
|
|
|
|
else:
|
|
|
|
suffix = "_i"
|
|
|
|
return signal[1] + suffix
|
|
|
|
|
2011-12-08 12:47:32 -05:00
|
|
|
# desc is a list of tuples, each made up of:
|
|
|
|
# 0) boolean: "master to slave"
|
|
|
|
# 1) string: name
|
|
|
|
# 2) int: width
|
|
|
|
class Simple():
|
2012-01-27 16:20:57 -05:00
|
|
|
def __init__(self, desc, slave):
|
2011-12-08 12:47:32 -05:00
|
|
|
for signal in desc:
|
2012-02-14 07:12:43 -05:00
|
|
|
modules = self.__module__.split(".")
|
2011-12-08 12:47:32 -05:00
|
|
|
busname = modules[len(modules)-1]
|
2011-12-16 10:02:55 -05:00
|
|
|
signame = get_sig_name(signal, slave)
|
2011-12-16 15:30:14 -05:00
|
|
|
setattr(self, signame, Signal(BV(signal[2]), busname + "_" + signame))
|
2012-01-15 09:48:51 -05:00
|
|
|
|
|
|
|
def signals(self):
|
|
|
|
return [self.__dict__[k]
|
|
|
|
for k in self.__dict__
|
|
|
|
if isinstance(self.__dict__[k], Signal)]
|