2011-12-18 15:54:39 -05:00
|
|
|
from migen.fhdl.structure import *
|
2011-12-05 11:43:56 -05:00
|
|
|
from migen.fhdl import verilog
|
|
|
|
from migen.bank import description, csrgen
|
2012-02-15 12:23:31 -05:00
|
|
|
from migen.bank.description import READ_ONLY, WRITE_ONLY
|
2011-12-05 11:43:56 -05:00
|
|
|
|
2012-02-15 12:23:31 -05:00
|
|
|
ninputs = 32
|
|
|
|
noutputs = 32
|
2011-12-05 11:43:56 -05:00
|
|
|
|
2012-02-06 07:55:50 -05:00
|
|
|
oreg = description.RegisterField("o", noutputs)
|
2012-02-15 12:23:31 -05:00
|
|
|
ireg = description.RegisterField("i", ninputs, READ_ONLY, WRITE_ONLY)
|
2011-12-05 11:43:56 -05:00
|
|
|
|
|
|
|
# input path
|
2011-12-18 15:54:39 -05:00
|
|
|
gpio_in = Signal(BV(ninputs))
|
|
|
|
gpio_in_s = Signal(BV(ninputs)) # synchronizer
|
2012-02-15 12:23:31 -05:00
|
|
|
insync = [gpio_in_s.eq(gpio_in), ireg.field.w.eq(gpio_in_s)]
|
2012-02-06 07:55:50 -05:00
|
|
|
inf = Fragment(sync=insync)
|
2011-12-05 11:43:56 -05:00
|
|
|
|
|
|
|
bank = csrgen.Bank([oreg, ireg])
|
2011-12-16 10:02:55 -05:00
|
|
|
f = bank.get_fragment() + inf
|
2012-02-06 07:55:50 -05:00
|
|
|
oreg.field.r.name_override = "gpio_out"
|
2011-12-05 11:43:56 -05:00
|
|
|
i = bank.interface
|
2012-02-15 10:42:17 -05:00
|
|
|
v = verilog.convert(f, {i.dat_r, oreg.field.r, i.adr, i.we, i.dat_w, gpio_in})
|
2011-12-16 10:02:55 -05:00
|
|
|
print(v)
|