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: c6e28e8cd43b
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: d21c2e2e964d
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Jun 6, 2019

  1. Add icebreaker platform.

    cr1901 authored and whitequark committed Jun 6, 2019
    Copy the full SHA
    d21c2e2 View commit details
Showing with 86 additions and 0 deletions.
  1. +86 −0 nmigen_boards/icebreaker.py
86 changes: 86 additions & 0 deletions nmigen_boards/icebreaker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import os
import subprocess

from nmigen.build import *
from nmigen.vendor.lattice_ice40 import *


__all__ = ["ICEBreakerPlatform"]


class ICEBreakerPlatform(LatticeICE40Platform):
device = "iCE40UP5K"
package = "SG48"
resources = [
Resource("clk12", 0, Pins("35", dir="i"),
Clock(12e6), Attrs(GLOBAL="1", IO_STANDARD="SB_LVCMOS33")),

Resource("user_led_n", 0, Pins("11", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS33")),
Resource("user_led_n", 1, Pins("37", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS33")),
# Color-specific aliases
Resource("user_ledr_n", 0, Pins("11", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS33")),
Resource("user_ledg_n", 0, Pins("37", dir="o"), Attrs(IO_STANDARD="SB_LVCMOS33")),
Resource("user_btn_n", 4, Pins("10", dir="i"), Attrs(IO_STANDARD="SB_LVCMOS33")),

Resource("serial", 0,
Subsignal("rx", Pins("6", dir="i")),
Subsignal("tx", Pins("9", dir="o"), Attrs(PULLUP="1")),
Attrs(IO_STANDARD="SB_LVTTL")
),

Resource("spiflash", 0,
Subsignal("cs_n", Pins("16", dir="o")),
Subsignal("clk", Pins("15", dir="o")),
Subsignal("mosi", Pins("14", dir="o")),
Subsignal("miso", Pins("17", dir="i")),
Subsignal("wp", Pins("12", dir="o")),
Subsignal("hold", Pins("13", dir="o")),
Attrs(IO_STANDARD="SB_LVCMOS33")
),

Resource("spiflash4x", 0,
Subsignal("cs_n", Pins("16", dir="o")),
Subsignal("clk", Pins("15", dir="o")),
Subsignal("dq", Pins("14 17 12 13", dir="io")),
Attrs(IO_STANDARD="SB_LVCMOS33")
),
]
connectors = [
Connector("pmod", 0, "4 2 47 45 - - 3 48 46 44 - -"), # PMOD1A
Connector("pmod", 1, "43 38 34 31 - - 42 36 32 28 - -"), # PMOD1B
Connector("pmod", 2, "27 25 21 19 - - 26 23 20 18 - -"), # PMOD2
]
# The attached LED/button section can be either used standalone or as a PMOD.
# Attach to platform using:
# p.add_resources(p.break_off_pmod)
# pmod_btn = plat.request("user_btn")
break_off_pmod = [
Resource("user_btn", 0, Pins("9", dir="i", conn=("pmod", 2)), Attrs(IO_STANDARD="SB_LVCMOS33")),
Resource("user_btn", 1, Pins("4", dir="i", conn=("pmod", 2)), Attrs(IO_STANDARD="SB_LVCMOS33")),
Resource("user_btn", 2, Pins("10", dir="i", conn=("pmod", 2)), Attrs(IO_STANDARD="SB_LVCMOS33")),

Resource("user_led", 0, Pins("7", dir="o", conn=("pmod", 2)), Attrs(IO_STANDARD="SB_LVCMOS33")),
Resource("user_led", 1, Pins("1", dir="o", conn=("pmod", 2)), Attrs(IO_STANDARD="SB_LVCMOS33")),
Resource("user_led", 2, Pins("2", dir="o", conn=("pmod", 2)), Attrs(IO_STANDARD="SB_LVCMOS33")),
Resource("user_led", 3, Pins("8", dir="o", conn=("pmod", 2)), Attrs(IO_STANDARD="SB_LVCMOS33")),
Resource("user_led", 4, Pins("3", dir="o", conn=("pmod", 2)), Attrs(IO_STANDARD="SB_LVCMOS33")),

# Color-specific aliases
Resource("user_ledr", 0, Pins("7", dir="o", conn=("pmod", 2)), Attrs(IO_STANDARD="SB_LVCMOS33")),
Resource("user_ledg", 0, Pins("1", dir="o", conn=("pmod", 2)), Attrs(IO_STANDARD="SB_LVCMOS33")),
Resource("user_ledg", 1, Pins("2", dir="o", conn=("pmod", 2)), Attrs(IO_STANDARD="SB_LVCMOS33")),
Resource("user_ledg", 2, Pins("8", dir="o", conn=("pmod", 2)), Attrs(IO_STANDARD="SB_LVCMOS33")),
Resource("user_ledg", 3, Pins("3", dir="o", conn=("pmod", 2)), Attrs(IO_STANDARD="SB_LVCMOS33"))
]

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 Blinky
p = ICEBreakerPlatform()
p.add_resources(p.break_off_pmod)
p.build(Blinky("clk12"), do_program=True)