forked from M-Labs/artiq
1
0
Fork 0
artiq/artiq/gateware/amp/soc.py

40 lines
1.5 KiB
Python
Raw Normal View History

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
2017-01-19 05:28:14 +08:00
from artiq.gateware.amp.kernel_cpu import KernelCPU
from artiq.gateware.amp.mailbox import Mailbox
class AMPSoC:
2017-01-19 05:22:33 +08:00
"""Contains kernel CPU and mailbox for ARTIQ SoCs.
2017-01-19 05:22:33 +08:00
Users must provide a "mailbox" entry in the memory map.
"""
def __init__(self):
2015-11-04 00:35:03 +08:00
if not hasattr(self, "cpu"):
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)
self.csr_devices.append("kernel_cpu")
mailbox_size = 3
self.submodules.mailbox = Mailbox(mailbox_size)
self.add_wb_slave(self.mem_map["mailbox"], 4*mailbox_size,
self.mailbox.i1)
self.kernel_cpu.add_wb_slave(self.mem_map["mailbox"], 4*mailbox_size,
self.mailbox.i2)
self.add_memory_region("mailbox",
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()
bank = wishbone.CSRBank(csrs)
self.submodules += bank
self.kernel_cpu.add_wb_slave(self.mem_map[name], 4*2**bank.decode_bits, bank.bus)
self.add_csr_region(name,
self.mem_map[name] | 0x80000000, 32,
csrs)