artiq/soc/targets/artiq.py

75 lines
2.4 KiB
Python
Raw Normal View History

2014-07-04 23:49:08 +08:00
from migen.fhdl.std import *
from mibuild.generic_platform import *
2014-07-04 23:49:08 +08:00
from misoclib import gpio
from targets.ppro import BaseSoC
2014-07-04 23:49:08 +08:00
2014-07-23 01:37:53 +08:00
from artiqlib import rtio, ad9858
2014-09-05 17:06:41 +08:00
2014-07-23 00:45:59 +08:00
_tester_io = [
2014-09-05 12:03:22 +08:00
("user_led", 1, Pins("B:7"), IOStandard("LVTTL")),
("ttl", 0, Pins("C:13"), IOStandard("LVTTL")),
("ttl", 1, Pins("C:11"), IOStandard("LVTTL")),
("ttl", 2, Pins("C:10"), IOStandard("LVTTL")),
("ttl", 3, Pins("C:9"), IOStandard("LVTTL")),
("ttl", 4, Pins("C:8"), IOStandard("LVTTL")),
2014-09-05 12:03:22 +08:00
("ttl_tx_en", 0, Pins("A:9"), IOStandard("LVTTL")),
("dds", 0,
Subsignal("a", Pins("A:5 B:10 A:6 B:9 A:7 B:8")),
Subsignal("d", Pins("A:12 B:3 A:13 B:2 A:14 B:1 A:15 B:0")),
Subsignal("sel", Pins("A:2 B:14 A:1 B:15 A:0")),
Subsignal("p", Pins("A:8 B:12")),
Subsignal("fud_n", Pins("B:11")),
Subsignal("wr_n", Pins("A:4")),
Subsignal("rd_n", Pins("B:13")),
Subsignal("rst_n", Pins("A:3")),
IOStandard("LVTTL")),
2014-07-23 00:45:59 +08:00
]
2014-09-05 17:06:41 +08:00
class _TestGen(Module):
def __init__(self, pad):
divc = Signal(15)
ce = Signal()
self.sync += Cat(divc, ce).eq(divc + 1)
sr = Signal(8, reset=0b10101000)
self.sync += If(ce, sr.eq(Cat(sr[1:], sr[0])))
self.comb += pad.eq(sr[0])
class ARTIQMiniSoC(BaseSoC):
2014-09-05 12:03:22 +08:00
csr_map = {
"rtio": 13
2014-09-05 12:03:22 +08:00
}
csr_map.update(BaseSoC.csr_map)
def __init__(self, platform, cpu_type="or1k", with_test_gen=False, **kwargs):
2014-09-05 12:03:22 +08:00
BaseSoC.__init__(self, platform, cpu_type=cpu_type, **kwargs)
platform.add_extension(_tester_io)
2014-09-05 17:06:41 +08:00
self.submodules.leds = gpio.GPIOOut(Cat(
platform.request("user_led", 0),
2014-09-05 12:03:22 +08:00
platform.request("user_led", 1)))
self.comb += platform.request("ttl_tx_en").eq(1)
rtio_pads = [platform.request("ttl", i) for i in range(4)]
2014-09-11 23:11:22 +08:00
fud = Signal()
rtio_pads.append(fud)
2014-09-05 17:06:41 +08:00
self.submodules.rtiophy = rtio.phy.SimplePHY(
rtio_pads,
2014-09-11 23:11:22 +08:00
output_only_pads={rtio_pads[1], rtio_pads[2], rtio_pads[3]},
mini_pads={fud})
self.submodules.rtio = rtio.RTIO(self.rtiophy, self.clk_freq)
2014-09-05 12:03:22 +08:00
if with_test_gen:
self.submodules.test_gen = _TestGen(platform.request("ttl", 4))
2014-09-11 23:11:22 +08:00
dds_pads = platform.request("dds")
self.submodules.dds = ad9858.AD9858(dds_pads)
2014-09-05 12:03:22 +08:00
self.add_wb_slave(lambda a: a[26:29] == 3, self.dds.bus)
2014-09-11 23:11:22 +08:00
self.comb += dds_pads.fud_n.eq(~fud)
2014-07-06 04:44:20 +08:00
default_subtarget = ARTIQMiniSoC