import shutil
from litex.build.tools import write_to_file
-from litex.soc.integration import cpu_interface, soc_core
+from litex.soc.integration import export, soc_core
__all__ = ["soc_software_packages", "soc_directory",
"Builder", "builder_args", "builder_argdict"]
compile_software = True,
compile_gateware = True,
csr_json = None,
- csr_csv = None):
+ csr_csv = None,
+ csr_svd = None):
self.soc = soc
# From Python doc: makedirs() will become confused if the path
self.compile_software = compile_software
self.compile_gateware = compile_gateware
- self.csr_csv = csr_csv
+ self.csr_csv = csr_csv
self.csr_json = csr_json
+ self.csr_svd = csr_svd
self.software_packages = []
for name in soc_software_packages:
def define(k, v):
variables_contents.append("{}={}\n".format(k, _makefile_escape(v)))
- for k, v in cpu_interface.get_cpu_mak(self.soc.cpu, self.compile_software):
+ for k, v in export.get_cpu_mak(self.soc.cpu, self.compile_software):
define(k, v)
# Distinguish between LiteX and MiSoC.
define("LITEX", "1")
"".join(variables_contents))
write_to_file(
os.path.join(self.generated_dir, "output_format.ld"),
- cpu_interface.get_linker_output_format(self.soc.cpu))
+ export.get_linker_output_format(self.soc.cpu))
write_to_file(
os.path.join(self.generated_dir, "regions.ld"),
- cpu_interface.get_linker_regions(self.soc.mem_regions))
+ export.get_linker_regions(self.soc.mem_regions))
write_to_file(
os.path.join(self.generated_dir, "mem.h"),
- cpu_interface.get_mem_header(self.soc.mem_regions))
+ export.get_mem_header(self.soc.mem_regions))
write_to_file(
os.path.join(self.generated_dir, "soc.h"),
- cpu_interface.get_soc_header(self.soc.constants))
+ export.get_soc_header(self.soc.constants))
write_to_file(
os.path.join(self.generated_dir, "csr.h"),
- cpu_interface.get_csr_header(self.soc.csr_regions,
+ export.get_csr_header(self.soc.csr_regions,
self.soc.constants)
)
write_to_file(
os.path.join(self.generated_dir, "git.h"),
- cpu_interface.get_git_header()
+ export.get_git_header()
)
if hasattr(self.soc, "sdram"):
self.soc.sdram.controller.settings.phy,
self.soc.sdram.controller.settings.timing))
- def _generate_csr_map(self, csr_json=None, csr_csv=None):
- if csr_json is not None:
- csr_dir = os.path.dirname(os.path.realpath(csr_json))
+ def _generate_csr_map(self):
+ if self.csr_json is not None:
+ csr_dir = os.path.dirname(os.path.realpath(self.csr_json))
os.makedirs(csr_dir, exist_ok=True)
- write_to_file(csr_json, cpu_interface.get_csr_json(self.soc.csr_regions, self.soc.constants, self.soc.mem_regions))
+ write_to_file(self.csr_json, export.get_csr_json(self.soc.csr_regions, self.soc.constants, self.soc.mem_regions))
- if csr_csv is not None:
- csr_dir = os.path.dirname(os.path.realpath(csr_csv))
+ if self.csr_csv is not None:
+ csr_dir = os.path.dirname(os.path.realpath(self.csr_csv))
os.makedirs(csr_dir, exist_ok=True)
- write_to_file(csr_csv, cpu_interface.get_csr_csv(self.soc.csr_regions, self.soc.constants, self.soc.mem_regions))
+ write_to_file(self.csr_csv, export.get_csr_csv(self.soc.csr_regions, self.soc.constants, self.soc.mem_regions))
+
+ if self.csr_svd is not None:
+ svd_dir = os.path.dirname(os.path.realpath(self.csr_svd))
+ os.makedirs(svd_dir, exist_ok=True)
+ write_to_file(self.csr_svd, export.get_csr_svd(self.soc))
def _prepare_software(self):
for name, src_dir in self.software_packages:
if not self.soc.integrated_rom_initialized:
self._initialize_rom()
- self._generate_csr_map(self.csr_json, self.csr_csv)
+ self._generate_csr_map()
if "run" not in kwargs:
kwargs["run"] = self.compile_gateware
parser.add_argument("--csr-json", default=None,
help="store CSR map in JSON format into the "
"specified file")
+ parser.add_argument("--csr-svd", default=None,
+ help="store CSR map in SVD format into the "
+ "specified file")
def builder_argdict(args):
return {
- "output_dir": args.output_dir,
- "gateware_dir": args.gateware_dir,
- "software_dir": args.software_dir,
- "include_dir": args.include_dir,
- "generated_dir": args.generated_dir,
+ "output_dir": args.output_dir,
+ "gateware_dir": args.gateware_dir,
+ "software_dir": args.software_dir,
+ "include_dir": args.include_dir,
+ "generated_dir": args.generated_dir,
"compile_software": not args.no_compile_software,
"compile_gateware": not args.no_compile_gateware,
- "csr_csv": args.csr_csv,
- "csr_json": args.csr_json,
+ "csr_csv": args.csr_csv,
+ "csr_json": args.csr_json,
+ "csr_svd": args.csr_svd,
}
# SVD Export --------------------------------------------------------------------------------------
-def get_svd(soc, vendor="litex", name="soc", description=None):
+def get_csr_svd(soc, vendor="litex", name="soc", description=None):
def sub_csr_bit_range(busword, csr, offset):
nwords = (csr.size + busword - 1)//busword
i = nwords - offset - 1
interrupts[csr] = irq
documented_regions = []
-
- raw_regions = []
- if hasattr(soc, "get_csr_regions"):
- raw_regions = soc.get_csr_regions()
- else:
- for region_name, region in soc.csr_regions.items():
- raw_regions.append((region_name, region.origin,
- region.busword, region.obj))
- for csr_region in raw_regions:
+ for name, region in soc.csr.regions.items():
documented_regions.append(DocumentedCSRRegion(
- csr_region, csr_data_width=soc.csr_data_width))
+ name = name,
+ region = region,
+ csr_data_width = soc.csr.data_width)
+ )
svd = []
svd.append('<?xml version="1.0" encoding="utf-8"?>')