From d3368d7fab587347725ccfad5a086c82af98f515 Mon Sep 17 00:00:00 2001 From: Gwenhael Goavec-Merou Date: Mon, 29 Aug 2022 13:37:48 +0200 Subject: [PATCH 1/2] build/generic_platform: allows to dynamically extends connectors dictionary --- litex/build/generic_platform.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/litex/build/generic_platform.py b/litex/build/generic_platform.py index 3054103c0..894508cce 100644 --- a/litex/build/generic_platform.py +++ b/litex/build/generic_platform.py @@ -132,6 +132,12 @@ def _resource_type(resource): class ConnectorManager: def __init__(self, connectors): self.connector_table = dict() + self.add_connector(connectors) + + def add_connector(self, connectors): + if isinstance(connectors, tuple): + connectors = [connectors] + for connector in connectors: cit = iter(connector) conn_name = next(cit) @@ -193,6 +199,9 @@ class ConstraintManager: def add_extension(self, io): self.available.extend(io) + def add_connector(self, connectors): + self.connector_manager.add_connector(connectors) + def request(self, name, number=None, loose=False): resource = _lookup(self.available, name, number, loose) if resource is None: @@ -356,6 +365,9 @@ class GenericPlatform: def add_extension(self, *args, **kwargs): return self.constraint_manager.add_extension(*args, **kwargs) + def add_connector(self, *args, **kwargs): + self.constraint_manager.add_connector(*args, **kwargs) + def finalize(self, fragment, *args, **kwargs): if self.finalized: raise ConstraintError("Already finalized") From fc0f0be67993f469c4862f706f73a2b155b03fc8 Mon Sep 17 00:00:00 2001 From: Gwenhael Goavec-Merou Date: Mon, 29 Aug 2022 13:39:35 +0200 Subject: [PATCH 2/2] build/generic_platform/ConnectorManager: allows to search recursively pins through connectors dictionary --- litex/build/generic_platform.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/litex/build/generic_platform.py b/litex/build/generic_platform.py index 894508cce..c327b9f6a 100644 --- a/litex/build/generic_platform.py +++ b/litex/build/generic_platform.py @@ -168,7 +168,10 @@ class ConnectorManager: if pn.isdigit(): pn = int(pn) - r.append(self.connector_table[conn][pn]) + conn_pn = self.connector_table[conn][pn] + if ":" in conn_pn: + conn_pn = self.resolve_identifiers([conn_pn])[0] + r.append(conn_pn) else: r.append(identifier)