2012-07-09 09:16:38 -04:00
|
|
|
from migen.fhdl.structure import *
|
2013-03-12 11:45:28 -04:00
|
|
|
from migen.fhdl.module import Module
|
2012-07-09 09:16:38 -04:00
|
|
|
from migen.fhdl import verilog
|
|
|
|
|
2013-03-12 11:45:28 -04:00
|
|
|
class Example(Module):
|
|
|
|
def __init__(self):
|
|
|
|
dx = 5
|
|
|
|
dy = 5
|
2012-07-09 09:16:38 -04:00
|
|
|
|
2013-03-12 11:45:28 -04:00
|
|
|
x = Signal(max=dx)
|
|
|
|
y = Signal(max=dy)
|
|
|
|
out = Signal()
|
2012-07-09 09:16:38 -04:00
|
|
|
|
2013-03-12 11:45:28 -04:00
|
|
|
my_2d_array = Array(Array(Signal() for a in range(dx)) for b in range(dy))
|
|
|
|
self.comb += out.eq(my_2d_array[x][y])
|
2012-07-09 09:16:38 -04:00
|
|
|
|
2013-03-12 11:45:28 -04:00
|
|
|
we = Signal()
|
|
|
|
inp = Signal()
|
|
|
|
self.sync += If(we,
|
|
|
|
my_2d_array[x][y].eq(inp)
|
|
|
|
)
|
2012-07-09 09:16:38 -04:00
|
|
|
|
2013-03-12 11:45:28 -04:00
|
|
|
print(verilog.convert(Example()))
|