Skip to content

migen Hello World

K. A. Brodzki edited this page Apr 2, 2020 · 1 revision

Prerequisites

Things you should have already installed and checked:

  • Vivado
  • LiteX
  • migen

Code

Save the code below to a file, e.g. hello_world.py

from migen import *
from litex.boards.platforms.arty import *

class Blinky(Module):
    def __init__(self, platform, maxperiod):
        self.led = led = platform.request("user_led", 1)
        counter = Signal(max=maxperiod+1)
        period = Signal(max=maxperiod+1)
        self.comb += period.eq(maxperiod)
        self.sync += If(counter == 0,
                        led.eq(~led),
                        counter.eq(period)
        ).Else(
            counter.eq(counter -1)
        )

plat = Platform()
blinky = Blinky(plat, 300000000)
plat.build(blinky)

Compile and load to the Arty board

python3 hello_world.py
cd build
xc3sprog -c nexys top.bit

What you should see is the blinking LED(LD5) on your board

Resources

Clone this wiki locally