Skip to content

Commit

Permalink
Merge pull request #12 from antoinevg/antoinevg/move-platform-definit…
Browse files Browse the repository at this point in the history
…ions

gateware: bring moondancer-soc up to date with the cynthion platform definitions move
  • Loading branch information
antoinevg authored Sep 26, 2023
2 parents 78f0c12 + 6c7515c commit 4300bbf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 37 deletions.
2 changes: 1 addition & 1 deletion device/firmware/memory.x
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Automatically generated by LUNA; edits will be discarded on rebuild.
* (Most header files phrase this 'Do not edit.'; be warned accordingly.)
*
* Generated: 2023-09-14 14:26:11.879801.
* Generated: 2023-09-26 17:41:24.468929.
*/

MEMORY {
Expand Down
53 changes: 17 additions & 36 deletions device/gateware/moondancer_soc/top.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,24 @@ def elaborate(self, platform):
]

# wire up the cpu external reset signal
if isinstance(platform, CynthionPlatformRev0D4):
user1_io = platform.request("user_io", 1)
m.d.comb += user1_io.oe.eq(1)
elif isinstance(platform, CynthionPlatformRev0D7):
try:
user1_io = platform.request("button_user")
m.d.comb += self.soc.cpu.ext_reset.eq(user1_io.i)
else:
logging.error("Unsupported platform: {}".format(platform))
sys.exit(1)
except:
logging.warn("Platform does not support a user button for cpu reset")

# create our USB devices, connect device controllers and add eptri endpoint handlers
ulpi0 = platform.request(platform.default_usb_connection) # target_phy

# target_phy
ulpi0 = platform.request(platform.default_usb_connection)
usb0_device = USBDevice(bus=ulpi0)
usb0_device.add_endpoint(self.usb0_ep_control)
usb0_device.add_endpoint(self.usb0_ep_in)
usb0_device.add_endpoint(self.usb0_ep_out)
m.d.comb += self.usb0.attach(usb0_device)
m.submodules.usb0_device = usb0_device

# aux_phy
try:
ulpi1 = platform.request("aux_phy")
except:
Expand All @@ -131,6 +131,7 @@ def elaborate(self, platform):
m.d.comb += self.usb1.attach(usb1_device)
m.submodules.usb1_device = usb1_device

# control_phy
try:
ulpi2 = platform.request("control_phy")
except:
Expand All @@ -148,17 +149,11 @@ def elaborate(self, platform):
# - main ----------------------------------------------------------------------

import luna
from luna.gateware.platform.ulx3s import ULX3S_85F_Platform
try:
from luna.gateware.platform import CynthionPlatformRev0D4, CynthionPlatformRev0D7
except:
from luna.gateware.platform.luna_r0_4 import LUNAPlatformRev0D4 as CynthionPlatformRev0D4

from lambdasoc.sim.platform import CXXRTLPlatform
from luna.gateware.platform import get_appropriate_platform
from luna_soc.generate import Generate

if __name__ == "__main__":
from luna_soc.generate import Generate

# Disable UnusedElaborable warnings
from amaranth._unused import MustUse
MustUse._MustUse__silence = True
Expand All @@ -170,29 +165,15 @@ def elaborate(self, platform):
logging.getLogger().setLevel(logging.DEBUG)

# select platform
platform = luna.gateware.platform.get_appropriate_platform()
#platform = CynthionPlatformRev0D7()
#platform = ULX3S_85F_Platform()
#platform = CXXRTLPlatform()
platform = get_appropriate_platform()
if platform is None:
logging.error("Failed to identify a supported platform")
sys.exit(1)

# configure platform
# configure clock frequency
clock_frequency = int(platform.default_clk_frequency)

if isinstance(platform, CynthionPlatformRev0D4):
logging.info("Building for Cynthion revision 0.4")
elif isinstance(platform, CynthionPlatformRev0D7):
logging.info("Building for Cynthion revision 0.7")
elif isinstance(platform, ULX3S_85F_Platform):
logging.info("Building for ULX3s")
clock_frequency=int(48e6)
elif isinstance(platform, CXXRTLPlatform):
logging.info("Building for CXXRTLPlatform")
clock_frequency=int(1e6)
else:
logging.error("Unsupported platform: {}".format(platform))
sys.exit(1)

logging.info(f"Platform clock frequency: {clock_frequency}")
logging.info(f"Building for {platform} with clock frequency: {clock_frequency}")

# create design
design = MoondancerSoc(clock_frequency=clock_frequency)
Expand Down

0 comments on commit 4300bbf

Please sign in to comment.