Merge pull request #1136 from antmicro/fix-regions-filter

tools/litex_json2renode: Add more restrictions to memory regions filter
This commit is contained in:
enjoy-digital 2021-12-21 15:34:25 +01:00 committed by GitHub
commit 1a9716048f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 7 deletions

View File

@ -584,7 +584,8 @@ def generate_repl(csr, etherbone_peripherals, autoalign):
def filter_memory_regions(raw_regions, alignment=None, autoalign=[]):
""" Filters memory regions skipping those of linker type
""" Filters memory regions, skipping those that are included
in each other, those that have size equal to 0
and those from `non_generated_mem_regions` list
and verifying if they have proper size and do not overlap.
@ -603,10 +604,6 @@ def filter_memory_regions(raw_regions, alignment=None, autoalign=[]):
raw_regions.sort(key=lambda x: x['base'])
for r in raw_regions:
if 'linker' in r['type']:
print('Skipping linker region: {}'.format(r['name']))
continue
if 'io' in r['type']:
print('Skipping io region: {}'.format(r['name']))
continue
@ -637,8 +634,16 @@ def filter_memory_regions(raw_regions, alignment=None, autoalign=[]):
print('Error: `{}` memory region size ({}) is not aligned to {}. This configuration cannot be currently simulated in Renode'.format(r['name'], hex(r['size']), hex(alignment)))
sys.exit(1)
if previous_region is not None and (previous_region['base'] + previous_region['size']) > (r['base'] + r['size']):
print("Error: detected overlaping memory regions: `{}` and `{}`".format(r['name'], previous_region['name']))
if r['size'] == 0:
print('Skipping `{}` due to size equal to 0'.format(r['name']))
continue
if previous_region is not None and r['base'] >= previous_region['base'] and r['base'] + r['size'] <= previous_region['base'] + previous_region['size']:
print('Skipping `{}` since it is included in `{}`'.format(r['name'], previous_region['name']))
continue
if previous_region is not None and r['base'] < previous_region['base'] + previous_region['size'] and r['base'] + r['size'] > previous_region['base'] + previous_region['size']:
print('Error: `{}` overlaps with `{}` - this configuration cannot be currently simulated in Renode'.format(r['name'], previous_region['name']))
sys.exit(1)
previous_region = r