diff --git a/liteeth/common.py b/liteeth/common.py index 84ad436..3f80637 100644 --- a/liteeth/common.py +++ b/liteeth/common.py @@ -146,11 +146,14 @@ def _remove_from_layout(layout, *args): return r def convert_ip(s): - ip = 0 - for e in s.split("."): - ip = ip << 8 - ip += int(e) - return ip + if isinstance(s, str): + ip = 0 + for e in s.split("."): + ip = ip << 8 + ip += int(e) + return ip + else: + return s # Stream Layouts ----------------------------------------------------------------------------------- diff --git a/liteeth/core/__init__.py b/liteeth/core/__init__.py index 7dcb8e2..26fc9f1 100644 --- a/liteeth/core/__init__.py +++ b/liteeth/core/__init__.py @@ -15,8 +15,7 @@ from liteeth.core.icmp import LiteEthICMP class LiteEthIPCore(Module, AutoCSR): def __init__(self, phy, mac_address, ip_address, clk_freq, with_icmp=True, dw=8): - if isinstance(ip_address, str): - ip_address = convert_ip(ip_address) + ip_address = convert_ip(ip_address) self.submodules.mac = LiteEthMAC(phy, dw, interface="crossbar", with_preamble_crc=True) self.submodules.arp = LiteEthARP(self.mac, mac_address, ip_address, clk_freq, dw=dw) self.submodules.ip = LiteEthIP(self.mac, mac_address, ip_address, self.arp.table, dw=dw) @@ -27,8 +26,7 @@ class LiteEthIPCore(Module, AutoCSR): class LiteEthUDPIPCore(LiteEthIPCore): def __init__(self, phy, mac_address, ip_address, clk_freq, with_icmp=True, dw=8): - if isinstance(ip_address, str): - ip_address = convert_ip(ip_address) + ip_address = convert_ip(ip_address) LiteEthIPCore.__init__(self, phy, mac_address, ip_address, clk_freq, dw=dw, with_icmp=with_icmp) self.submodules.udp = LiteEthUDP(self.ip, ip_address, dw=dw)