diff --git a/litex/soc/integration/builder.py b/litex/soc/integration/builder.py index 2c3044d27..ef7e45e6a 100644 --- a/litex/soc/integration/builder.py +++ b/litex/soc/integration/builder.py @@ -136,8 +136,11 @@ class Builder: export.get_soc_header(self.soc.constants)) write_to_file( os.path.join(self.generated_dir, "csr.h"), - export.get_csr_header(self.soc.csr_regions, - self.soc.constants) + export.get_csr_header( + regions = self.soc.csr_regions, + constants = self.soc.constants, + csr_base = self.soc.mem_regions['csr'].origin + ) ) write_to_file( os.path.join(self.generated_dir, "git.h"), diff --git a/litex/soc/integration/export.py b/litex/soc/integration/export.py index ed827ed5a..ebf125550 100644 --- a/litex/soc/integration/export.py +++ b/litex/soc/integration/export.py @@ -118,8 +118,10 @@ def get_mem_header(regions): r = generated_banner("//") r += "#ifndef __GENERATED_MEM_H\n#define __GENERATED_MEM_H\n\n" for name, region in regions.items(): + r += "#ifndef {name}\n".format(name=name.upper()) r += "#define {name}_BASE 0x{base:08x}L\n#define {name}_SIZE 0x{size:08x}\n\n".format( name=name.upper(), base=region.origin, size=region.length) + r += "#endif\n" r += "#endif\n" return r