Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/nmigen-boards
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 50403d6846ed
Choose a base ref
...
head repository: m-labs/nmigen-boards
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ecda2a1d08af
Choose a head ref
  • 1 commit
  • 4 files changed
  • 1 contributor

Commits on Jun 4, 2019

  1. Copy the full SHA
    ecda2a1 View commit details
Showing with 50 additions and 0 deletions.
  1. +35 −0 nmigen_boards/_blinky.py
  2. +5 −0 nmigen_boards/ice40_hx1k_blink_evn.py
  3. +5 −0 nmigen_boards/icestick.py
  4. +5 −0 nmigen_boards/tinyfpga_bx.py
35 changes: 35 additions & 0 deletions nmigen_boards/_blinky.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import itertools

from nmigen import *
from nmigen.build import ConstraintError


class Blinky(Elaboratable):
def elaborate(self, platform):
m = Module()

clk_name, clk_freq = next(iter(platform.clocks.items()))
clk = platform.request(*clk_name)
m.domains.sync = ClockDomain()
m.d.comb += ClockSignal().eq(clk.i)

leds = []
for n in itertools.count():
try:
leds.append(platform.request("user_led", n))
except ConstraintError:
break
leds = Cat(led.o for led in leds)

ctr = Signal(max=int(clk_freq//2), reset=int(clk_freq//2) - 1)
with m.If(ctr == 0):
m.d.sync += ctr.eq(ctr.reset)
m.d.sync += leds.eq(~leds)
with m.Else():
m.d.sync += ctr.eq(ctr - 1)

return m


def build_and_program(platform_cls, **kwargs):
platform_cls().build(Blinky(), do_program=True, **kwargs)
5 changes: 5 additions & 0 deletions nmigen_boards/ice40_hx1k_blink_evn.py
Original file line number Diff line number Diff line change
@@ -40,3 +40,8 @@ def toolchain_program(self, products, name):
iceburn = os.environ.get("ICEBURN", "iCEburn")
with products.extract("{}.bin".format(name)) as bitstream_filename:
subprocess.run([iceburn, "-evw", bitstream_filename], check=True)


if __name__ == "__main__":
from ._blinky import build_and_program
build_and_program(ICE40HX1KBlinkEVNPlatform)
5 changes: 5 additions & 0 deletions nmigen_boards/icestick.py
Original file line number Diff line number Diff line change
@@ -61,3 +61,8 @@ def toolchain_program(self, products, name):
iceprog = os.environ.get("ICEPROG", "iceprog")
with products.extract("{}.bin".format(name)) as bitstream_filename:
subprocess.run([iceprog, bitstream_filename], check=True)


if __name__ == "__main__":
from ._blinky import build_and_program
build_and_program(ICEStickPlatform)
5 changes: 5 additions & 0 deletions nmigen_boards/tinyfpga_bx.py
Original file line number Diff line number Diff line change
@@ -61,3 +61,8 @@ def toolchain_program(self, products, name):
tinyprog = os.environ.get("TINYPROG", "tinyprog")
with products.extract("{}.bin".format(name)) as bitstream_filename:
subprocess.run([tinyprog, "-p", bitstream_filename], check=True)


if __name__ == "__main__":
from ._blinky import build_and_program
build_and_program(TinyFPGABXPlatform)