return value
class SoCMemRegion:
- def __init__(self, origin, length, io_region=False, linker_region=False):
- self.origin = origin
- self.length = length
- self.io_region = io_region
- self.linker_region = linker_region
+ def __init__(self, origin, length, type):
+ assert type in ["cached", "io", "cached+linker", "io+linker"]
+ self.origin = origin
+ self.length = length
+ self.type = type
class SoCCSRRegion:
def __init__(self, origin, busword, obj):
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)
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
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
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]))
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):
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)