Skip to content

Commit afd531c

Browse files
committed
soc_linux.py: make setting IP address constants more readable
1 parent 5d896c4 commit afd531c

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

soc_linux.py

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from litex.soc.cores.pwm import PWM
2121

2222
from litex.tools.litex_json2dts_linux import generate_dts
23+
from litex.soc.integration.soc import add_ip_address_constants
2324

2425
# SoCLinux -----------------------------------------------------------------------------------------
2526

@@ -58,32 +59,8 @@ def add_i2c(self):
5859
# Ethernet configuration -------------------------------------------------------------------
5960

6061
def configure_ethernet(self, remote_ip, local_ip):
61-
remote_ip = remote_ip.split(".")
62-
local_ip = local_ip.split(".")
63-
64-
try: # FIXME: Improve.
65-
self.constants.pop("REMOTEIP1")
66-
self.constants.pop("REMOTEIP2")
67-
self.constants.pop("REMOTEIP3")
68-
self.constants.pop("REMOTEIP4")
69-
except:
70-
pass
71-
self.add_constant("REMOTEIP1", int(remote_ip[0]))
72-
self.add_constant("REMOTEIP2", int(remote_ip[1]))
73-
self.add_constant("REMOTEIP3", int(remote_ip[2]))
74-
self.add_constant("REMOTEIP4", int(remote_ip[3]))
75-
76-
try: # FIXME: Improve.
77-
self.constants.pop("LOCALIP1")
78-
self.constants.pop("LOCALIP2")
79-
self.constants.pop("LOCALIP3")
80-
self.constants.pop("LOCALIP4")
81-
except:
82-
pass
83-
self.add_constant("LOCALIP1", int(local_ip[0]))
84-
self.add_constant("LOCALIP2", int(local_ip[1]))
85-
self.add_constant("LOCALIP3", int(local_ip[2]))
86-
self.add_constant("LOCALIP4", int(local_ip[3]))
62+
add_ip_address_constants(self, "REMOTEIP", remote_ip, check_duplicate=False)
63+
add_ip_address_constants(self, "LOCALIP", local_ip, check_duplicate=False)
8764

8865
# DTS generation ---------------------------------------------------------------------------
8966

0 commit comments

Comments
 (0)