From cfaba189c4d9f94d6d169aaa783d93b163aa8b8a Mon Sep 17 00:00:00 2001 From: Hans Baier Date: Tue, 11 Apr 2023 11:02:52 +0700 Subject: [PATCH 1/2] give human readable error messages if a connector or pin is not available --- litex/build/generic_platform.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/litex/build/generic_platform.py b/litex/build/generic_platform.py index 1e160589f..9618ff981 100644 --- a/litex/build/generic_platform.py +++ b/litex/build/generic_platform.py @@ -167,7 +167,8 @@ class ConnectorManager: raise ValueError(f"\"{identifier}\" {err}") from err if pn.isdigit(): pn = int(pn) - + assert conn in self.connector_table, f"No connector named '{conn}' is available" + assert pn in self.connector_table[conn], f"There is no pin '{pn}' on connector '{conn}'" conn_pn = self.connector_table[conn][pn] if ":" in conn_pn: conn_pn = self.resolve_identifiers([conn_pn])[0] From 750f8c41b981ac4191dcf99924c9cea46baa8ce6 Mon Sep 17 00:00:00 2001 From: Hans Baier Date: Tue, 11 Apr 2023 14:10:07 +0700 Subject: [PATCH 2/2] distinguish between dict and list connectors in error message --- litex/build/generic_platform.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/litex/build/generic_platform.py b/litex/build/generic_platform.py index 9618ff981..f79b7f5d6 100644 --- a/litex/build/generic_platform.py +++ b/litex/build/generic_platform.py @@ -168,7 +168,11 @@ class ConnectorManager: if pn.isdigit(): pn = int(pn) assert conn in self.connector_table, f"No connector named '{conn}' is available" - assert pn in self.connector_table[conn], f"There is no pin '{pn}' on connector '{conn}'" + conn_entry = self.connector_table[conn] + if isinstance(conn_entry, dict): + assert pn in conn_entry, f"There is no pin '{pn}' on connector '{conn}'" + else: + assert pn < len(conn_entry), f"There is no pin with number '{pn}' on connector '{conn}', maximum is {len(conn_entry)-1}" conn_pn = self.connector_table[conn][pn] if ":" in conn_pn: conn_pn = self.resolve_identifiers([conn_pn])[0]