Skip to content

Commit

Permalink
tools/litex_sim: Cleanup ethernet local/ip address handling and do +1…
Browse files Browse the repository at this point in the history
… when both ethernet/etherbone are enabled.

Allow Etherbone to be by default at 192.168.1.50 when no Ethernet and 192.168.1.51 when also with Ethernet.
  • Loading branch information
enjoy-digital committed Jan 3, 2025
1 parent b9cc5c5 commit 0d58da0
Showing 1 changed file with 42 additions and 30 deletions.
72 changes: 42 additions & 30 deletions litex/tools/litex_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,32 +159,36 @@ def __init__(self):

class SimSoC(SoCCore):
def __init__(self,
with_sdram = False,
with_sdram_bist = False,
with_ethernet = False,
ethernet_phy_model = "sim",
with_etherbone = False,
etherbone_mac_address = 0x10e2d5000001,
etherbone_ip_address = "192.168.1.51",
with_analyzer = False,
sdram_module = "MT48LC16M16",
sdram_init = [],
sdram_data_width = 32,
sdram_spd_data = None,
sdram_verbosity = 0,
with_i2c = False,
with_sdcard = False,
with_spi_flash = False,
spi_flash_init = [],
with_gpio = False,
with_sdram = False,
with_sdram_bist = False,
with_ethernet = False,
ethernet_phy_model = "sim",
ethernet_local_ip = "192.168.1.50",
ethernet_remote_ip = "192.168.1.100",
with_etherbone = False,
with_analyzer = False,
sdram_module = "MT48LC16M16",
sdram_init = [],
sdram_data_width = 32,
sdram_spd_data = None,
sdram_verbosity = 0,
with_i2c = False,
with_sdcard = False,
with_spi_flash = False,
spi_flash_init = [],
with_gpio = False,
with_video_framebuffer = False,
with_video_terminal = False,
with_video_colorbars = False,
sim_debug = False,
trace_reset_on = False,
with_jtag = False,
with_video_terminal = False,
with_video_colorbars = False,
sim_debug = False,
trace_reset_on = False,
with_jtag = False,
**kwargs):
platform = Platform()

# Platform ---------------------------------------------------------------------------------
platform = Platform()

# Parameters -------------------------------------------------------------------------------
sys_clk_freq = int(1e6)

# CRG --------------------------------------------------------------------------------------
Expand Down Expand Up @@ -248,12 +252,18 @@ def __init__(self,
# Etherbone with optional Ethernet ---------------------------------------------------------
if with_etherbone:
self.add_etherbone(
phy = self.ethphy,
ip_address = etherbone_ip_address,
mac_address = etherbone_mac_address,
data_width = 8,
with_ethmac = with_ethernet,
phy = self.ethphy,
# Etherbone Parameters.
ip_address = convert_ip(ethernet_local_ip) + int(with_ethernet), # +1 when both to avoid conflict.
mac_address = 0x10e2d5000001,
data_width = 8,
# Ethernet Parameters.
with_ethmac = with_ethernet,
ethmac_address = 0x10e2d5000000,
ethmac_local_ip = ethernet_local_ip,
ethmac_remote_ip = ethernet_remote_ip,
)

# Ethernet only ----------------------------------------------------------------------------
elif with_ethernet:
# Ethernet MAC
Expand Down Expand Up @@ -546,6 +556,8 @@ def main():
with_sdram_bist = args.with_sdram_bist,
with_ethernet = args.with_ethernet,
ethernet_phy_model = args.ethernet_phy_model,
ethernet_local_ip = args.local_ip,
ethernet_remote_ip = args.remote_ip,
with_etherbone = args.with_etherbone,
with_analyzer = args.with_analyzer,
with_i2c = args.with_i2c,
Expand All @@ -564,7 +576,7 @@ def main():
if ram_boot_address == 0:
ram_boot_address = conf_soc.mem_map["main_ram"]
soc.add_constant("ROM_BOOT_ADDRESS", ram_boot_address)
if args.with_ethernet:
if args.with_ethernet and (not args.with_etherbone): # FIXME: Remove.
for i in range(4):
soc.add_constant("LOCALIP{}".format(i+1), int(args.local_ip.split(".")[i]))
for i in range(4):
Expand Down

0 comments on commit 0d58da0

Please sign in to comment.