def __init__(self, *, size, data_width=32, granularity=8, writable=True): super().__init__() if not isinstance(size, int) or size <= 0 or size & size - 1: raise ValueError( "Size must be an integer power of two, not {!r}".format(size)) if size < data_width // granularity: raise ValueError( "Size {} cannot be lesser than the data width/granularity ratio " "of {} ({} / {})".format(size, data_width // granularity, data_width, granularity)) self._mem = Memory(depth=(size * granularity) // data_width, width=data_width, name=self.name) self.bus = wishbone.Interface(addr_width=log2_int(self._mem.depth), data_width=self._mem.width, granularity=granularity, features={"cti", "bte"}) map = MemoryMap(addr_width=log2_int(size), data_width=granularity) map.add_resource(self._mem, size=size) self.bus.memory_map = map self.size = size self.granularity = granularity self.writable = writable
def window(self, *, addr_width, data_width, granularity=None, features=frozenset(), alignment=0, addr=None, sparse=None): """Request a window to a subordinate bus. See :meth:`nmigen_soc.wishbone.Decoder.add` for details. Return value ------------ An instance of :class:`nmigen_soc.wishbone.Interface`. """ window = wishbone.Interface(addr_width=addr_width, data_width=data_width, granularity=granularity, features=features) granularity_bits = log2_int(data_width // window.granularity) window.memory_map = MemoryMap(addr_width=addr_width + granularity_bits, data_width=window.granularity, alignment=alignment) self._windows.append((window, addr, sparse)) return window
def __init__(self, core, data_width=32, granularity=8): super().__init__(name="wishbone") self.native_port = core.crossbar.get_native_port() self.ratio = self.native_port.data_width // data_width addr_width = log2_int(core.size // (self.native_port.data_width // data_width)) self.bus = wishbone.Interface(addr_width=addr_width + log2_int(self.ratio), data_width=data_width, granularity=granularity) map = MemoryMap(addr_width=addr_width + log2_int(self.ratio) + log2_int(data_width // granularity), data_width=granularity) self.bus.memory_map = map
def __init__(self): self.bus = wishbone.Interface(addr_width=17, data_width=8) self.bus.memory_map = MemoryMap(addr_width=17, data_width=8) f = open('../x68kd11s/iplromxv.dat', 'rb') dat = f.read() self.mem = Memory(width=8, depth=131072, init=dat)