litex/migen/bus/simple.py

23 lines
581 B
Python
Raw Normal View History

2011-12-08 12:47:32 -05:00
from migen.fhdl import structure as f
2011-12-08 17:06:04 -05:00
def GetSigName(signal, slave):
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():
2011-12-08 13:16:08 -05:00
def __init__(self, desc, slave, name):
2011-12-08 12:47:32 -05:00
for signal in desc:
modules = self.__module__.split('.')
busname = modules[len(modules)-1]
2011-12-08 13:16:08 -05:00
if name:
busname += "_" + name
2011-12-08 17:06:04 -05:00
signame = GetSigName(signal, slave)
2011-12-08 13:16:08 -05:00
setattr(self, signame, f.Signal(f.BV(signal[2]), busname + "_" + signame))