From d3368d7fab587347725ccfad5a086c82af98f515 Mon Sep 17 00:00:00 2001 From: Gwenhael Goavec-Merou Date: Mon, 29 Aug 2022 13:37:48 +0200 Subject: [PATCH] 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")