Skip to content

Commit

Permalink
Merge pull request #35 from Xiretza/standalone-customization
Browse files Browse the repository at this point in the history
Allow changing all SoC options through YAML config
  • Loading branch information
enjoy-digital authored Mar 17, 2020
2 parents 32d4af1 + 2e9121d commit 693a6b1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
5 changes: 3 additions & 2 deletions examples/wishbone_mii.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ clk_freq: 100e6
core: wishbone
endianness: big

mem_map:
ethmac: 0x50000000
soc:
mem_map:
ethmac: 0x50000000
27 changes: 20 additions & 7 deletions liteeth/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,26 @@
# PHY Core -----------------------------------------------------------------------------------------

class PHYCore(SoCMini):
def __init__(self, phy, clk_freq, platform):
SoCMini.__init__(self, platform, clk_freq=clk_freq)
def __init__(self, platform, core_config):
for deprecated in ("csr_map", "mem_map"):
if deprecated in core_config:
raise RuntimeWarning("Config option {!r} is now a sub-option of 'soc'".format(deprecated))

soc_args = {}
if "soc" in core_config:
soc_config = core_config["soc"]

for arg in soc_config:
if arg in ("csr_map", "interrupt_map", "mem_map"):
getattr(self, arg).update(soc_config[arg])
else:
soc_args[arg] = soc_config[arg]

SoCMini.__init__(self, platform, clk_freq=core_config["clk_freq"], **soc_args)
self.submodules.crg = CRG(platform.request("sys_clock"),
platform.request("sys_reset"))
phy = core_config["phy"]

# ethernet
if phy in [liteeth_phys.LiteEthPHYMII]:
ethphy = phy(
Expand All @@ -196,10 +212,7 @@ def __init__(self, phy, clk_freq, platform):

class MACCore(PHYCore):
def __init__(self, platform, core_config):
self.mem_map.update(core_config.get("mem_map", {}))
self.csr_map.update(core_config.get("csr_map", {}))

PHYCore.__init__(self, core_config["phy"], core_config["clk_freq"], platform)
PHYCore.__init__(self, platform, core_config)

self.submodules.ethmac = LiteEthMAC(phy=self.ethphy, dw=32, interface="wishbone", endianness=core_config["endianness"])
self.add_wb_slave(self.mem_map["ethmac"], self.ethmac.bus)
Expand All @@ -221,7 +234,7 @@ def __init__(self, interface):

class UDPCore(PHYCore):
def __init__(self, platform, core_config):
PHYCore.__init__(self, core_config["phy"], core_config["clk_freq"], platform)
PHYCore.__init__(self, platform, core_config)

self.submodules.core = LiteEthUDPIPCore(self.ethphy, core_config["mac_address"], convert_ip(core_config["ip_address"]), core_config["clk_freq"])
udp_port = self.core.udp.crossbar.get_port(core_config["port"], 8)
Expand Down

0 comments on commit 693a6b1

Please sign in to comment.