From 4a94bb78f67ececd9522fed9489ff712fc28f290 Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 29 Sep 2020 01:30:09 +0800 Subject: [PATCH] add memory regions to soc.svd svd2rust does not recognize memory regions, but we'd like to make an access crate for Rust that does. This patch adds memory regions to soc.svd using the "vendorExtensions" tag, as specified in https://www.keil.com/pack/doc/cmsis/SVD/html/svd_Format_pg.html The vendorExtensions is added as a block after the Peripherals level, and has a format like this: ```xml SRAM 0x10000000 0x00020000 VEXRISCV_DEBUG 0xEFFF0000 0x00000100 CSR 0xF0000000 0x00040000 ``` --- litex/soc/integration/export.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/litex/soc/integration/export.py b/litex/soc/integration/export.py index 22de39f79..7c3f7c178 100644 --- a/litex/soc/integration/export.py +++ b/litex/soc/integration/export.py @@ -428,6 +428,15 @@ def get_csr_svd(soc, vendor="litex", name="soc", description=None): svd.append(' ') svd.append(' ') svd.append(' ') + if len(soc.mem_regions) > 0: + svd.append(' ') + for name, region in soc.mem_regions.items(): + svd.append(' ') + svd.append(' {}'.format(name.upper())) + svd.append(' 0x{:08X}'.format(region.origin)) + svd.append(' 0x{:08X}'.format(region.size)) + svd.append(' ') + svd.append(' ') svd.append('') return "\n".join(svd)