integration/SoCMemRegion: use type instead of io_region/linker_region and export type to csv/json
Supported types: "cached", "io", "cached+linker", "io+linker", default="cached"
This commit is contained in:
parent
9fcf297387
commit
a0c0a6fd05
|
@ -77,11 +77,11 @@ def SoCConstant(value):
|
|||
return value
|
||||
|
||||
class SoCMemRegion:
|
||||
def __init__(self, origin, length, io_region=False, linker_region=False):
|
||||
def __init__(self, origin, length, type):
|
||||
assert type in ["cached", "io", "cached+linker", "io+linker"]
|
||||
self.origin = origin
|
||||
self.length = length
|
||||
self.io_region = io_region
|
||||
self.linker_region = linker_region
|
||||
self.type = type
|
||||
|
||||
class SoCCSRRegion:
|
||||
def __init__(self, origin, busword, obj):
|
||||
|
|
|
@ -243,7 +243,8 @@ def get_csr_json(csr_regions={}, constants={}, mem_regions={}):
|
|||
for name, region in mem_regions.items():
|
||||
d["memories"][name.lower()] = {
|
||||
"base": region.origin,
|
||||
"size": region.length
|
||||
"size": region.length,
|
||||
"type": region.type,
|
||||
}
|
||||
|
||||
return json.dumps(d, indent=4)
|
||||
|
@ -264,7 +265,9 @@ def get_csr_csv(csr_regions={}, constants={}, mem_regions={}):
|
|||
for name, value in d["constants"].items():
|
||||
r += "constant,{},{},,\n".format(name, value)
|
||||
for name in d["memories"].keys():
|
||||
r += "memory_region,{},0x{:08x},{:d},\n".format(name,
|
||||
r += "memory_region,{},0x{:08x},{:d},{:s}\n".format(name,
|
||||
d["memories"][name]["base"],
|
||||
d["memories"][name]["size"])
|
||||
d["memories"][name]["size"],
|
||||
d["memories"][name]["type"],
|
||||
)
|
||||
return r
|
||||
|
|
|
@ -379,7 +379,7 @@ class SoCCore(Module):
|
|||
r0 = regions[n0]
|
||||
for n1 in list(regions.keys())[i+1:]:
|
||||
r1 = regions[n1]
|
||||
if r0.linker_region or r1.linker_region:
|
||||
if ("linker" in r0.type) or ("linker" in r1.type):
|
||||
continue
|
||||
if r0.origin >= (r1.origin + r1.length):
|
||||
continue
|
||||
|
@ -389,14 +389,16 @@ class SoCCore(Module):
|
|||
i += 1
|
||||
return None
|
||||
|
||||
def add_memory_region(self, name, origin, length, io_region=False, linker_region=False):
|
||||
def add_memory_region(self, name, origin, length, type="cached", io_region=False):
|
||||
if io_region: # 2019-10-30: io_region retro-compatibility
|
||||
deprecated_warning(": io_region replaced by type=\"io\".")
|
||||
type = "io"
|
||||
length = 2**log2_int(length, False)
|
||||
if io_region:
|
||||
if "io" in type:
|
||||
self.check_io_region(name, origin, length)
|
||||
if name in self.mem_regions.keys():
|
||||
raise ValueError("Memory region conflict, {} name already used".format(name))
|
||||
self.mem_regions[name] = SoCMemRegion(origin, length,
|
||||
io_region=io_region, linker_region=linker_region)
|
||||
self.mem_regions[name] = SoCMemRegion(origin, length, type)
|
||||
overlap = self.check_regions_overlap(self.mem_regions)
|
||||
if overlap is not None:
|
||||
raise ValueError("Memory region conflict between {} and {}".format(overlap[0], overlap[1]))
|
||||
|
|
|
@ -54,10 +54,10 @@ class CSRRegister:
|
|||
|
||||
|
||||
class CSRMemoryRegion:
|
||||
def __init__(self, base, size):
|
||||
def __init__(self, base, size, type):
|
||||
self.base = base
|
||||
self.size = size
|
||||
|
||||
self.type = type
|
||||
|
||||
class CSRBuilder:
|
||||
def __init__(self, comm, csr_csv, csr_data_width=None):
|
||||
|
@ -115,7 +115,7 @@ class CSRBuilder:
|
|||
def build_memories(self):
|
||||
d = {}
|
||||
for item in self.items:
|
||||
group, name, base, size, dummy1 = item
|
||||
group, name, base, size, type = item
|
||||
if group == "memory_region":
|
||||
d[name] = CSRMemoryRegion(int(base, 16), int(size))
|
||||
d[name] = CSRMemoryRegion(int(base, 16), int(size), type)
|
||||
return CSRElements(d)
|
||||
|
|
Loading…
Reference in New Issue