Use slices to access memory contents to support both mmap and SparseMemory

Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
Alex Forencich
2023-03-24 01:23:33 -07:00
parent 62c2eef4ec
commit 5e8b246159

View File

@@ -36,10 +36,10 @@ class Memory:
super().__init__(**kwargs) super().__init__(**kwargs)
def read(self, address, length): def read(self, address, length):
return self.mem.read(address, length) return self.mem[address:address+length]
def write(self, address, data): def write(self, address, data):
self.mem.write(address, data) self.mem[address:address+len(data)] = data
def write_words(self, address, data, byteorder='little', ws=2): def write_words(self, address, data, byteorder='little', ws=2):
words = data words = data