mirror of https://github.com/m-labs/artiq.git
sayma_amc: register RTM CSR regions from CSV
This commit is contained in:
parent
54c75d3274
commit
dbc12540da
|
@ -0,0 +1,40 @@
|
|||
from collections import OrderedDict
|
||||
from operator import itemgetter
|
||||
import csv
|
||||
|
||||
from misoc.interconnect.csr import CSRStatus, CSRStorage
|
||||
|
||||
|
||||
def _get_csr_data(csv_file):
|
||||
csr_data = OrderedDict()
|
||||
with open(csv_file) as csv_file_f:
|
||||
csv_reader = csv.reader(csv_file_f)
|
||||
for name, address, length, ro in csv_reader:
|
||||
region_name, csr_name = name.split(".")
|
||||
address = int(address, 0)
|
||||
length = int(length, 0)
|
||||
ro = ro == "ro"
|
||||
if region_name not in csr_data:
|
||||
csr_data[region_name] = []
|
||||
csr_data[region_name].append((csr_name, address, length, ro))
|
||||
return csr_data
|
||||
|
||||
|
||||
def get_remote_csr_regions(offset, csv_file):
|
||||
regions = []
|
||||
for region_name, csrs_info in _get_csr_data(csv_file).items():
|
||||
csrs_info = sorted(csrs_info, key=itemgetter(1))
|
||||
origin = csrs_info[0][1]
|
||||
next_address = origin
|
||||
csrs = []
|
||||
for csr_name, address, length, ro in csrs_info:
|
||||
if address != next_address:
|
||||
raise ValueError("CSRs are not contiguous")
|
||||
next_address += 4*length
|
||||
if ro:
|
||||
csr = CSRStatus(32*length, name=csr_name)
|
||||
else:
|
||||
csr = CSRStorage(32*length, name=csr_name)
|
||||
csrs.append(csr)
|
||||
regions.append((region_name, offset + origin, 32, csrs))
|
||||
return regions
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import os
|
||||
|
||||
from migen import *
|
||||
|
||||
|
@ -12,6 +13,7 @@ from misoc.targets.sayma_amc import MiniSoC
|
|||
|
||||
from artiq.gateware.amp import AMPSoC, build_artiq_soc
|
||||
from artiq.gateware import serwb
|
||||
from artiq.gateware import remote_csr
|
||||
from artiq.gateware import rtio
|
||||
from artiq.gateware.rtio.phy import ttl_simple
|
||||
from artiq import __version__ as artiq_version
|
||||
|
@ -20,9 +22,9 @@ from artiq import __version__ as artiq_version
|
|||
class SaymaAMCStandalone(MiniSoC, AMPSoC):
|
||||
mem_map = {
|
||||
"cri_con": 0x10000000,
|
||||
"rtio": 0x20000000,
|
||||
"rtio_dma": 0x30000000,
|
||||
"serwb": 0x20000000,
|
||||
"rtio": 0x11000000,
|
||||
"rtio_dma": 0x12000000,
|
||||
"serwb": 0x13000000,
|
||||
"mailbox": 0x70000000
|
||||
}
|
||||
mem_map.update(MiniSoC.mem_map)
|
||||
|
@ -156,9 +158,19 @@ def main():
|
|||
description="ARTIQ device binary builder / Sayma AMC stand-alone")
|
||||
builder_args(parser)
|
||||
soc_sdram_args(parser)
|
||||
parser.add_argument("--rtm-csr-csv",
|
||||
default=os.path.join("artiq_sayma_rtm", "sayma_rtm_csr.csv"),
|
||||
help="CSV file listing remote CSRs on RTM (default: %(default)s)")
|
||||
args = parser.parse_args()
|
||||
|
||||
soc = SaymaAMCStandalone(**soc_sdram_argdict(args))
|
||||
|
||||
remote_csr_regions = remote_csr.get_remote_csr_regions(
|
||||
soc.mem_map["serwb"] | soc.shadow_base,
|
||||
args.rtm_csr_csv)
|
||||
for name, origin, busword, csrs in remote_csr_regions:
|
||||
soc.add_csr_region(name, origin, busword, csrs)
|
||||
|
||||
build_artiq_soc(soc, builder_argdict(args))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue