litex/misoclib/com/liteeth/core/ip/crossbar.py

35 lines
1.0 KiB
Python
Raw Normal View History

from misoclib.com.liteeth.common import *
from misoclib.com.liteeth.generic import *
from misoclib.com.liteeth.generic.crossbar import LiteEthCrossbar
2015-02-11 19:30:17 -05:00
2015-04-13 04:20:02 -04:00
2015-02-11 19:30:17 -05:00
class LiteEthIPV4MasterPort:
def __init__(self, dw):
self.dw = dw
self.source = Source(eth_ipv4_user_description(dw))
self.sink = Sink(eth_ipv4_user_description(dw))
2015-02-11 19:30:17 -05:00
2015-04-13 04:20:02 -04:00
2015-02-11 19:30:17 -05:00
class LiteEthIPV4SlavePort:
def __init__(self, dw):
self.dw = dw
self.sink = Sink(eth_ipv4_user_description(dw))
self.source = Source(eth_ipv4_user_description(dw))
2015-02-11 19:30:17 -05:00
2015-04-13 04:20:02 -04:00
2015-02-11 19:30:17 -05:00
class LiteEthIPV4UserPort(LiteEthIPV4SlavePort):
def __init__(self, dw):
LiteEthIPV4SlavePort.__init__(self, dw)
2015-02-11 19:30:17 -05:00
2015-04-13 04:20:02 -04:00
2015-02-11 19:30:17 -05:00
class LiteEthIPV4Crossbar(LiteEthCrossbar):
def __init__(self):
LiteEthCrossbar.__init__(self, LiteEthIPV4MasterPort, "protocol")
2015-02-11 19:30:17 -05:00
def get_port(self, protocol):
if protocol in self.users.keys():
raise ValueError("Protocol {0:#x} already assigned".format(protocol))
port = LiteEthIPV4UserPort(8)
self.users[protocol] = port
return port