2015-11-04 00:35:03 +08:00
|
|
|
from misoc.cores import timer
|
2016-03-03 13:19:17 +08:00
|
|
|
from misoc.interconnect import wishbone
|
2015-05-01 18:51:24 +08:00
|
|
|
|
2017-01-19 05:28:14 +08:00
|
|
|
from artiq.gateware.amp.kernel_cpu import KernelCPU
|
|
|
|
from artiq.gateware.amp.mailbox import Mailbox
|
2015-05-01 18:51:24 +08:00
|
|
|
|
|
|
|
|
|
|
|
class AMPSoC:
|
2017-01-19 05:22:33 +08:00
|
|
|
"""Contains kernel CPU and mailbox for ARTIQ SoCs.
|
2015-05-01 18:51:24 +08:00
|
|
|
|
2017-01-19 05:22:33 +08:00
|
|
|
Users must provide a "mailbox" entry in the memory map.
|
2015-05-01 18:51:24 +08:00
|
|
|
"""
|
|
|
|
def __init__(self):
|
2015-11-04 00:35:03 +08:00
|
|
|
if not hasattr(self, "cpu"):
|
2015-05-01 18:51:24 +08:00
|
|
|
raise ValueError("Platform SoC must be initialized first")
|
|
|
|
|
2017-01-19 05:28:14 +08:00
|
|
|
self.submodules.kernel_cpu = KernelCPU(self.platform)
|
2015-12-16 14:59:35 +08:00
|
|
|
self.add_cpulevel_sdram_if(self.kernel_cpu.wb_sdram)
|
2016-09-24 20:48:37 +08:00
|
|
|
self.csr_devices.append("kernel_cpu")
|
2015-06-17 21:36:12 +08:00
|
|
|
|
2017-07-13 19:16:49 +08:00
|
|
|
mailbox_size = 3
|
|
|
|
self.submodules.mailbox = Mailbox(mailbox_size)
|
|
|
|
self.add_wb_slave(self.mem_map["mailbox"], 4*mailbox_size,
|
2015-05-01 18:51:24 +08:00
|
|
|
self.mailbox.i1)
|
2017-07-13 19:16:49 +08:00
|
|
|
self.kernel_cpu.add_wb_slave(self.mem_map["mailbox"], 4*mailbox_size,
|
2015-05-01 18:51:24 +08:00
|
|
|
self.mailbox.i2)
|
|
|
|
self.add_memory_region("mailbox",
|
2017-07-13 19:16:49 +08:00
|
|
|
self.mem_map["mailbox"] | 0x80000000,
|
|
|
|
4*mailbox_size)
|
2016-03-03 13:19:17 +08:00
|
|
|
|
2016-10-31 18:09:36 +08:00
|
|
|
def register_kernel_cpu_csrdevice(self, name, csrs=None):
|
|
|
|
if csrs is None:
|
|
|
|
csrs = getattr(self, name).get_csrs()
|
2016-03-03 15:12:15 +08:00
|
|
|
bank = wishbone.CSRBank(csrs)
|
|
|
|
self.submodules += bank
|
2017-07-13 19:16:49 +08:00
|
|
|
self.kernel_cpu.add_wb_slave(self.mem_map[name], 4*2**bank.decode_bits, bank.bus)
|
2016-03-03 15:12:15 +08:00
|
|
|
self.add_csr_region(name,
|
|
|
|
self.mem_map[name] | 0x80000000, 32,
|
|
|
|
csrs)
|