generated from saji/ecp5-template
38 lines
983 B
Python
38 lines
983 B
Python
import shutil
|
|
import pytest
|
|
from amaranth import Elaboratable, Module, Signal
|
|
from amaranth.lib.io import Buffer
|
|
from groovylight.platforms.colorlight_5a75b_v8_2 import Colorlight_5A75B_R82Platform
|
|
|
|
|
|
def progs_exist(programs) -> bool:
|
|
for p in programs:
|
|
if shutil.which(p) is None:
|
|
return False
|
|
return True
|
|
|
|
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():
|
|
if not progs_exist(["yosys", "nextpnr-ecp5", "openFPGALoader"]):
|
|
pytest.skip("missing toolchain programs")
|
|
plat = Colorlight_5A75B_R82Platform()
|
|
|
|
plat.build(Blinky())
|