2015-02-28 03:02:28 -05:00
|
|
|
from misoclib.com.liteeth.common import *
|
2015-04-28 12:51:40 -04:00
|
|
|
from misoclib.com.liteeth.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:
|
2015-04-13 03:53:43 -04:00
|
|
|
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:
|
2015-04-13 03:53:43 -04:00
|
|
|
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):
|
2015-04-13 03:53:43 -04:00
|
|
|
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):
|
2015-04-13 03:53:43 -04:00
|
|
|
def __init__(self):
|
|
|
|
LiteEthCrossbar.__init__(self, LiteEthIPV4MasterPort, "protocol")
|
2015-02-11 19:30:17 -05:00
|
|
|
|
2015-04-13 03:53:43 -04: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
|