Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could you support the board with nmigen? #4

Open
Waxpple opened this issue Jul 25, 2021 · 0 comments
Open

Could you support the board with nmigen? #4

Waxpple opened this issue Jul 25, 2021 · 0 comments

Comments

@Waxpple
Copy link

Waxpple commented Jul 25, 2021

I am new to this domain (open hardware and nmigen).
I am trying to do an example blinky in nmigen and try to make it build the bitstream file for FPGA.
Here is my current example code.

import os
import subprocess
from typing import List
from nmigen import Elaboratable, Module, Signal
from nmigen.build import *
from nmigen.build.run import LocalBuildProducts
from nmigen.cli import main_parser, main_runner
from nmigen.vendor.lattice_ecp5 import *

class Blinker(Elaboratable):
    def __init__(self):
        pass
    def elaborate(self, platform: Platform) -> Module:
        led   = platform.request("led", 0)
        timer = Signal(20)

        m = Module()
        m.d.sync += timer.eq(timer + 1)
        m.d.comb += led.o.eq(timer[-1])
        return m
    
    def ports(self) -> List[Signal]:
        return []

class Board(LatticeECP5Platform):
    device = "LFE5U-25F"
    package = "BG256"
    speed = "6"
    default_clk = "clk1"
    default_rst = "rst"
    resources = [
        Resource("clk1", 0, Pins("P6",dir="i"), Clock(25e6),
            Attrs(IO_TYPE = "LVCMOS33")),
        Resource("rst", 0, Pins("L14",dir="i"),
            Attrs(IO_TYPE = "LVCMOS33")),
        Resource("led", 0, Pins("B11",dir="o"),
            Attrs(IO_TYPE = "LVCMOS33")),
    ]
    connectors = []
    def toolchain_program(self, products, name):  
        iceprog = os.environ.get("ICEPROG", "iceprog")
        with products.extract("{}.bin".format(name)) as bitstream_filename:
            subprocess.check_call([iceprog, bitstream_filename])
if __name__ == "__main__":
    Board().build(Blinker(), do_program= False)

But not sure if it works.. my board is not here yet.
Can you support a board file for nmigen? It would be nice!
Or maybe a blinky example? That would be wonderful!

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant