create Port class and remove connect method of mac/ip/udp Ports
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 10 Feb 2015 14:37:29 +0000 (15:37 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Tue, 10 Feb 2015 14:37:29 +0000 (15:37 +0100)
liteeth/common.py
liteeth/core/ip/common.py
liteeth/core/udp/common.py
liteeth/mac/__init__.py
liteeth/mac/common.py

index ce7e0d6334f62f9c73a4b20257cd9405ea262a76..6ac03099ca5489c6103beae1c632ce3dfd50fd36 100644 (file)
@@ -252,6 +252,15 @@ def eth_etherbone_user_description(dw):
        return EndpointDescription(payload_layout, param_layout, packetized=True)
 
 
+# Generic classes
+class Port:
+       def connect(self, port):
+               r = [
+                       Record.connect(self.source, port.sink),
+                       Record.connect(port.source, self.sink)
+               ]
+               return r
+
 # Generic modules
 @DecorateModule(InsertReset)
 @DecorateModule(InsertCE)
index 338033ea6b4e5246799fead2f3ed71d3f3b86cb1..17102767dbbf734a86735be59c5af7081b6344d0 100644 (file)
@@ -25,24 +25,12 @@ class LiteEthIPV4MasterPort:
                self.source = Source(eth_ipv4_user_description(dw))
                self.sink = Sink(eth_ipv4_user_description(dw))
 
-       def connect(self, slave):
-               return [
-                       Record.connect(self.source, slave.sink),
-                       Record.connect(slave.source, self.sink)
-               ]
-
 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))
 
-       def connect(self, master):
-               return [
-                       Record.connect(self.sink, master.source),
-                       Record.connect(master.sink, self.source)
-               ]
-
 class LiteEthIPV4UserPort(LiteEthIPV4SlavePort):
        def __init__(self, dw):
                LiteEthIPV4SlavePort.__init__(self, dw)
index 98fe9be361cdd3297e7aa07151a40b9658fb10d6..187b829e441ff9945829efb7f59dc3bccbc295df 100644 (file)
@@ -25,24 +25,12 @@ class LiteEthUDPMasterPort:
                self.source = Source(eth_udp_user_description(dw))
                self.sink = Sink(eth_udp_user_description(dw))
 
-       def connect(self, slave):
-               return [
-                       Record.connect(self.source, slave.sink),
-                       Record.connect(slave.source, self.sink)
-               ]
-
 class LiteEthUDPSlavePort:
        def __init__(self, dw):
                self.dw =dw
                self.sink = Sink(eth_udp_user_description(dw))
                self.source = Source(eth_udp_user_description(dw))
 
-       def connect(self, master):
-               return [
-                       Record.connect(self.sink, master.source),
-                       Record.connect(master.sink, self.source)
-               ]
-
 class LiteEthUDPUserPort(LiteEthUDPSlavePort):
        def __init__(self, dw):
                LiteEthUDPSlavePort.__init__(self, dw)
index e7bf6d66c91da164ee1ec3224098727bf3bccbf3..2346584e402fde9e3a62761338f4f79060276255 100644 (file)
@@ -20,10 +20,7 @@ class LiteEthMAC(Module, AutoCSR):
                        ]
                elif interface == "wishbone":
                        self.submodules.interface = LiteEthMACWishboneInterface(dw, 2, 2)
-                       self.comb += [
-                               Record.connect(self.interface.source, self.core.sink),
-                               Record.connect(self.core.source, self.interface.sink)
-                       ]
+                       self.comb += Port.connect(self.interface, self.core)
                        self.ev, self.bus = self.interface.sram.ev, self.interface.bus
                        self.csrs = self.interface.get_csrs()
                elif interface == "dma":
index f82faecb9e595140107dc2dd37e6366ee8f5da04..128d8f17cf18a039ff424fffe6d9c07dca036e47 100644 (file)
@@ -24,23 +24,11 @@ class LiteEthMACMasterPort:
                self.source = Source(eth_mac_description(dw))
                self.sink = Sink(eth_mac_description(dw))
 
-       def connect(self, slave):
-               return [
-                       Record.connect(self.source, slave.sink),
-                       Record.connect(slave.source, self.sink)
-               ]
-
 class LiteEthMACSlavePort:
        def __init__(self, dw):
                self.sink = Sink(eth_mac_description(dw))
                self.source = Source(eth_mac_description(dw))
 
-       def connect(self, master):
-               return [
-                       Record.connect(self.sink, master.source),
-                       Record.connect(master.sink, self.source)
-               ]
-
 class LiteEthMACUserPort(LiteEthMACSlavePort):
        def __init__(self, dw):
                LiteEthMACSlavePort.__init__(self, dw)