From 6d07f01f5bedaee208dbb2dbd11e101b69eb9bb9 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Tue, 29 Sep 2020 13:01:44 +0200 Subject: [PATCH] tools/litex_client/RemoteClient: allow use without local csr.csv file. In some case, we just want to access MMAP manually without having the csr.csv file: wb = RemoteClient() wb.open() wb.read(0x40000000) wb.close() --- litex/tools/litex_client.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/litex/tools/litex_client.py b/litex/tools/litex_client.py index dceda94c7..32b55407f 100644 --- a/litex/tools/litex_client.py +++ b/litex/tools/litex_client.py @@ -5,6 +5,7 @@ # Copyright (c) 2016 Tim 'mithro' Ansell # SPDX-License-Identifier: BSD-2-Clause +import os import socket from litex.tools.remote.etherbone import EtherbonePacket, EtherboneRecord @@ -14,11 +15,16 @@ from litex.tools.remote.csr_builder import CSRBuilder class RemoteClient(EtherboneIPC, CSRBuilder): - def __init__(self, host="localhost", port=1234, base_address=0, csr_csv="csr.csv", csr_data_width=None, debug=False): + def __init__(self, host="localhost", port=1234, base_address=0, csr_csv=None, csr_data_width=None, debug=False): + # If csr_csv set to None and local csr.csv file exists, use it. + if csr_csv is None and os.path.exists("csr.csv"): + csr_csv = "csr.csv" + # If valid csr_csv file found, build the CSRs. if csr_csv is not None: CSRBuilder.__init__(self, self, csr_csv, csr_data_width) - else: - assert csr_data_width is not None + # Else if csr_data_width set to None, force to csr_data_width 32-bit. + elif csr_data_width is None: + csr_data_width = 32 self.host = host self.port = port self.base_address = base_address