raise TypeError("Memory initialization value at address {:x}: {}"
.format(addr, e)) from None
- def read_port(self, **kwargs):
- return ReadPort(self, **kwargs)
+ def read_port(self, *, src_loc_at=0, **kwargs):
+ return ReadPort(self, src_loc_at=1 + src_loc_at, **kwargs)
- def write_port(self, **kwargs):
- return WritePort(self, **kwargs)
+ def write_port(self, *, src_loc_at=0, **kwargs):
+ return WritePort(self, src_loc_at=1 + src_loc_at, **kwargs)
def __getitem__(self, index):
"""Simulation only."""
class ReadPort(Elaboratable):
- def __init__(self, memory, *, domain="sync", transparent=True):
+ def __init__(self, memory, *, domain="sync", transparent=True, src_loc_at=0):
if domain == "comb" and not transparent:
raise ValueError("Read port cannot be simultaneously asynchronous and non-transparent")
self.transparent = transparent
self.addr = Signal(range(memory.depth),
- name="{}_r_addr".format(memory.name), src_loc_at=2)
+ name="{}_r_addr".format(memory.name), src_loc_at=2 + src_loc_at)
self.data = Signal(memory.width,
- name="{}_r_data".format(memory.name), src_loc_at=2)
+ name="{}_r_data".format(memory.name), src_loc_at=2 + src_loc_at)
if self.domain != "comb" and not transparent:
- self.en = Signal(name="{}_r_en".format(memory.name), src_loc_at=2, reset=1)
+ self.en = Signal(name="{}_r_en".format(memory.name), reset=1,
+ src_loc_at=2 + src_loc_at)
else:
self.en = Const(1)
class WritePort(Elaboratable):
- def __init__(self, memory, *, domain="sync", granularity=None):
+ def __init__(self, memory, *, domain="sync", granularity=None, src_loc_at=0):
if granularity is None:
granularity = memory.width
if not isinstance(granularity, int) or granularity < 0:
self.granularity = granularity
self.addr = Signal(range(memory.depth),
- name="{}_w_addr".format(memory.name), src_loc_at=2)
+ name="{}_w_addr".format(memory.name), src_loc_at=2 + src_loc_at)
self.data = Signal(memory.width,
- name="{}_w_data".format(memory.name), src_loc_at=2)
+ name="{}_w_data".format(memory.name), src_loc_at=2 + src_loc_at)
self.en = Signal(memory.width // granularity,
- name="{}_w_en".format(memory.name), src_loc_at=2)
+ name="{}_w_en".format(memory.name), src_loc_at=2 + src_loc_at)
def elaborate(self, platform):
f = Instance("$memwr",
self.map_drivers(fragment, new_fragment)
return new_fragment
- def __call__(self, value):
+ def __call__(self, value, *, src_loc_at=0):
if isinstance(value, Fragment):
return self.on_fragment(value)
elif isinstance(value, TransformedElaboratable):
value._transforms_.append(self)
return value
elif hasattr(value, "elaborate"):
- value = TransformedElaboratable(value)
+ value = TransformedElaboratable(value, src_loc_at=1 + src_loc_at)
value._transforms_.append(self)
return value
else:
class TransformedElaboratable(Elaboratable):
- def __init__(self, elaboratable):
+ def __init__(self, elaboratable, *, src_loc_at=0):
assert hasattr(elaboratable, "elaborate")
# Fields prefixed and suffixed with underscore to avoid as many conflicts with the inner
def _insert_control(self, fragment, domain, signals):
raise NotImplementedError # :nocov:
- def __call__(self, value):
- self.src_loc = tracer.get_src_loc()
- return super().__call__(value)
+ def __call__(self, value, *, src_loc_at=0):
+ self.src_loc = tracer.get_src_loc(src_loc_at=src_loc_at)
+ return super().__call__(value, src_loc_at=1 + src_loc_at)
class ResetInserter(_ControlInserter):