From 3188fdefa5574e83ac86270e0b9088e1bfb838d5 Mon Sep 17 00:00:00 2001 From: saji Date: Sat, 21 Sep 2024 22:33:47 -0500 Subject: [PATCH] wip: test works, bypass amaranth-boards not working --- .../platforms/colorlight_5a75b_v8_2.py | 38 ++++++++++--------- tests/test_platform.py | 26 +++++++++++++ 2 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 tests/test_platform.py diff --git a/src/groovylight/platforms/colorlight_5a75b_v8_2.py b/src/groovylight/platforms/colorlight_5a75b_v8_2.py index f992258..d22a7e2 100644 --- a/src/groovylight/platforms/colorlight_5a75b_v8_2.py +++ b/src/groovylight/platforms/colorlight_5a75b_v8_2.py @@ -2,7 +2,7 @@ import os import subprocess from amaranth.vendor import LatticeECP5Platform from amaranth.build import Resource, Pins, Attrs, Clock, Subsignal, PinsN, Connector -from amaranth_boards.resources import SDRAMResource +# from amaranth_boards.resources import SDRAMResource, LEDResources, ButtonResources class Colorlight_5A75B_R82Platform(LatticeECP5Platform): @@ -23,23 +23,25 @@ class Colorlight_5A75B_R82Platform(LatticeECP5Platform): Subsignal("copi", Pins("T8", dir="o")), Attrs(IO_TYPE="LVCMOS33"), ), - Resource("usr_btn", 0, Pins("R7", dir="i"), Attrs(IO_TYPE="LVCMOS33")), - Resource("usr_led", 0, Pins("T6", dir="o"), Attrs(IO_TYPE="LVCMOS33")), - SDRAMResource( - 0, - clk="C8", - we_n="B5", - cas_n="A6", - ras_n="B6", - ba="B7 A8", - a="A9 B9 B10 C10 D9 C9 E9 D8 E8 C7 B8", - dq="B2 A2 C3 A3 B3 A4 B4 A5 E7 C6 D7 D6 " - "E6 D5 C5 E5 A11 B11 B12 A13 B13 A14 B14 D14 D13 " - "E11 C13 D11 C12 D10 C11 D10", - attrs=Attrs( - PULLMODE="NONE", DRIVE="4", SLEWRATE="FAST", IO_TYPE="LVCMOS33" - ), - ), + Resource("led", 0, PinsN("T6", dir="o"), Attrs(IO_TYPE="LVCMOS33")), + # *ButtonResources( + # pins="R7", invert=True, attrs=Attrs(IO_TYPE="LVCMOS33", PULLMODE="UP") + # ), + # SDRAMResource( + # 0, + # clk="C8", + # we_n="B5", + # cas_n="A6", + # ras_n="B6", + # ba="B7 A8", + # a="A9 B9 B10 C10 D9 C9 E9 D8 E8 C7 B8", + # dq="B2 A2 C3 A3 B3 A4 B4 A5 E7 C6 D7 D6 " + # "E6 D5 C5 E5 A11 B11 B12 A13 B13 A14 B14 D14 D13 " + # "E11 C13 D11 C12 D10 C11 D10", + # attrs=Attrs( + # PULLMODE="NONE", DRIVE="4", SLEWRATE="FAST", IO_TYPE="LVCMOS33" + # ), + # ), Resource( "eth_rgmii", 0, diff --git a/tests/test_platform.py b/tests/test_platform.py new file mode 100644 index 0000000..cfd74aa --- /dev/null +++ b/tests/test_platform.py @@ -0,0 +1,26 @@ +from amaranth import Elaboratable, Module, Signal +from amaranth.lib.io import Buffer +from groovylight.platforms.colorlight_5a75b_v8_2 import Colorlight_5A75B_R82Platform + + +class Blinky(Elaboratable): + def elaborate(self, platform): + m = Module() + + m.submodules.led = led = Buffer("o", platform.request("led", dir="-")) + state = Signal() + counter = Signal(24) + + with m.If(counter == 0): + m.d.sync += [counter.eq(~0), state.eq(~state)] + with m.Else(): + m.d.sync += counter.eq(counter - 1) + + m.d.comb += led.o.eq(state) + + return m + + +def test_platform(): + plat = Colorlight_5A75B_R82Platform() + plat.build(Blinky())