Skip to content

Instantly share code, notes, and snippets.

@the6p4c
Created December 30, 2018 13:29
Show Gist options
  • Save the6p4c/dc7d0c0243971ae026fbae479b9998b9 to your computer and use it in GitHub Desktop.
Save the6p4c/dc7d0c0243971ae026fbae479b9998b9 to your computer and use it in GitHub Desktop.
from nmigen import *
from nmigen.cli import main
class Test:
def __init__(self):
self.out = Signal(8)
def get_fragment(self, platform):
data = list(range(10))
arr = Array(data)
idx = Signal(max=len(data))
m = Module()
m.d.comb += self.out.eq(arr[idx])
m.d.sync += idx.eq(idx + 1)
return m.lower(platform)
test = Test()
main(test, ports=[test.out])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment