Merge pull request #1992 from motec-research/fix_MockCSRRegion_base

integration/export: Fix MockCSRRegion base definition.
This commit is contained in:
enjoy-digital 2024-06-19 09:13:49 +02:00 committed by GitHub
commit d6b0c84f9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -236,8 +236,9 @@ def _generate_csr_definitions_c(reg_name, reg_base, nwords, csr_base, with_csr_b
def _generate_csr_region_definitions_c(name, region, origin, alignment, csr_base, with_csr_base_define): def _generate_csr_region_definitions_c(name, region, origin, alignment, csr_base, with_csr_base_define):
base_define = with_csr_base_define and not isinstance(region, MockCSRRegion) base_define = with_csr_base_define and not isinstance(region, MockCSRRegion)
base = csr_base if not isinstance(region, MockCSRRegion) else 0
region_defs = f"\n/* {name.upper()} Registers */\n" region_defs = f"\n/* {name.upper()} Registers */\n"
region_defs += f"#define CSR_{name.upper()}_BASE {_get_csr_addr(csr_base, origin, base_define)}\n" region_defs += f"#define CSR_{name.upper()}_BASE {_get_csr_addr(base, origin, base_define)}\n"
if not isinstance(region.obj, Memory): if not isinstance(region.obj, Memory):
for csr in region.obj: for csr in region.obj:
@ -246,7 +247,7 @@ def _generate_csr_region_definitions_c(name, region, origin, alignment, csr_base
reg_name = name + "_" + csr.name, reg_name = name + "_" + csr.name,
reg_base = origin, reg_base = origin,
nwords = nr, nwords = nr,
csr_base = csr_base, csr_base = base,
with_csr_base_define = base_define, with_csr_base_define = base_define,
) )
origin += alignment // 8 * nr origin += alignment // 8 * nr