From 702761d789e8ee25f8877b9290219960330319ad Mon Sep 17 00:00:00 2001 From: Andrew Dennison Date: Tue, 4 Jun 2024 10:38:38 +1000 Subject: [PATCH 1/2] soc/integraion/builder: fix variable names In _get_json_*() variable names were transposed in two places resulting in confusing code with correct functionality. --- litex/soc/integration/builder.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/litex/soc/integration/builder.py b/litex/soc/integration/builder.py index ca140d5ba..bbc22cc34 100644 --- a/litex/soc/integration/builder.py +++ b/litex/soc/integration/builder.py @@ -145,22 +145,22 @@ class Builder: def _get_json_mem_regions(self): mem_regions = {} - for filename, name, origin in self.jsons: - _, _, _mem_regions = export.load_csr_json(filename, name, origin) + for filename, origin, name in self.jsons: + _, _, _mem_regions = export.load_csr_json(filename, origin, name) mem_regions.update(_mem_regions) return mem_regions def _get_json_constants(self): constants = {} - for filename, name, origin in self.jsons: - _, _constants, _ = export.load_csr_json(filename, name, origin) + for filename, origin, name in self.jsons: + _, _constants, _ = export.load_csr_json(filename, origin, name) constants.update(_constants) return constants def _get_json_csr_regions(self): csr_regions = {} - for filename, name, origin in self.jsons: - _csr_regions, _, _ = export.load_csr_json(filename, name, origin) + for filename, origin, name in self.jsons: + _csr_regions, _, _ = export.load_csr_json(filename, origin, name) csr_regions.update(_csr_regions) return csr_regions From 56c284e9bce508d040074d4524e77042957e665d Mon Sep 17 00:00:00 2001 From: Andrew Dennison Date: Tue, 4 Jun 2024 10:41:53 +1000 Subject: [PATCH 2/2] soc/integraion/builder: exclude some constants in add_json() Interrupt numbers from a downstream soc are not relevant in the main SOC so exclude them by default. --- litex/soc/integration/builder.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/litex/soc/integration/builder.py b/litex/soc/integration/builder.py index bbc22cc34..027862e8f 100644 --- a/litex/soc/integration/builder.py +++ b/litex/soc/integration/builder.py @@ -140,26 +140,27 @@ class Builder: def add_software_library(self, name): self.software_libraries.append(name) - def add_json(self, filename, origin=0, name=""): - self.jsons.append((filename, origin, name)) + def add_json(self, filename, origin=0, name="", exclude_constants=["_INTERRUPT"]): + self.jsons.append((filename, origin, name, exclude_constants)) def _get_json_mem_regions(self): mem_regions = {} - for filename, origin, name in self.jsons: + for filename, origin, name, _ in self.jsons: _, _, _mem_regions = export.load_csr_json(filename, origin, name) mem_regions.update(_mem_regions) return mem_regions def _get_json_constants(self): constants = {} - for filename, origin, name in self.jsons: + for filename, origin, name, exclude in self.jsons: _, _constants, _ = export.load_csr_json(filename, origin, name) + _constants = {k: v for k, v in _constants.items() if not any(ex in k for ex in exclude)} constants.update(_constants) return constants def _get_json_csr_regions(self): csr_regions = {} - for filename, origin, name in self.jsons: + for filename, origin, name, _ in self.jsons: _csr_regions, _, _ = export.load_csr_json(filename, origin, name) csr_regions.update(_csr_regions) return csr_regions