tools/litex_client/RemoteClient: add base_address parameter.
Useful when address translation is done in the SoC.
This commit is contained in:
parent
78a9579e09
commit
24687cbd9f
|
@ -11,13 +11,14 @@ from litex.tools.remote.csr_builder import CSRBuilder
|
|||
|
||||
|
||||
class RemoteClient(EtherboneIPC, CSRBuilder):
|
||||
def __init__(self, host="localhost", port=1234, csr_csv="csr.csv", csr_data_width=None, debug=False):
|
||||
def __init__(self, host="localhost", port=1234, base_address=0, csr_csv="csr.csv", csr_data_width=None, debug=False):
|
||||
if csr_csv is not None:
|
||||
CSRBuilder.__init__(self, self, csr_csv, csr_data_width)
|
||||
else:
|
||||
assert csr_data_width is not None
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.base_address = base_address
|
||||
self.debug = debug
|
||||
|
||||
def open(self):
|
||||
|
@ -36,7 +37,7 @@ class RemoteClient(EtherboneIPC, CSRBuilder):
|
|||
length_int = 1 if length is None else length
|
||||
# prepare packet
|
||||
record = EtherboneRecord()
|
||||
record.reads = EtherboneReads(addrs=[addr + 4*j for j in range(length_int)])
|
||||
record.reads = EtherboneReads(addrs=[self.base_address + addr + 4*j for j in range(length_int)])
|
||||
record.rcount = len(record.reads)
|
||||
|
||||
# send packet
|
||||
|
@ -51,13 +52,13 @@ class RemoteClient(EtherboneIPC, CSRBuilder):
|
|||
datas = packet.records.pop().writes.get_datas()
|
||||
if self.debug:
|
||||
for i, data in enumerate(datas):
|
||||
print("read {:08x} @ {:08x}".format(data, addr + 4*i))
|
||||
print("read {:08x} @ {:08x}".format(data, self.base_address + addr + 4*i))
|
||||
return datas[0] if length is None else datas
|
||||
|
||||
def write(self, addr, datas):
|
||||
datas = datas if isinstance(datas, list) else [datas]
|
||||
record = EtherboneRecord()
|
||||
record.writes = EtherboneWrites(base_addr=addr, datas=[d for d in datas])
|
||||
record.writes = EtherboneWrites(base_addr=self.base_address + addr, datas=[d for d in datas])
|
||||
record.wcount = len(record.writes)
|
||||
|
||||
packet = EtherbonePacket()
|
||||
|
@ -67,4 +68,4 @@ class RemoteClient(EtherboneIPC, CSRBuilder):
|
|||
|
||||
if self.debug:
|
||||
for i, data in enumerate(datas):
|
||||
print("write {:08x} @ {:08x}".format(data, addr + 4*i))
|
||||
print("write {:08x} @ {:08x}".format(data, self.base_address + addr + 4*i))
|
||||
|
|
Loading…
Reference in New Issue