From fc0c8fae1e0b5954517e77395779ff8aa69b1926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Morais?= <146729917+SMoraisAnsys@users.noreply.github.com> Date: Mon, 13 Jan 2025 12:56:51 +0100 Subject: [PATCH] Optimize Edb initialization for die designs (#966) Several times die designs don't have any component defined. The changes in code are made to reduce the Component initialization time in this case which significantly reduces the Edb initialization time by ~50% especially when there are >100k Groups in the layout. (cherry picked from commit 40cc8f614d9c1856d5d65773b5949b71f7fec78a) Co-authored-by: skandakotethota --- src/pyedb/dotnet/edb_core/components.py | 66 ++++++++----------------- 1 file changed, 21 insertions(+), 45 deletions(-) diff --git a/src/pyedb/dotnet/edb_core/components.py b/src/pyedb/dotnet/edb_core/components.py index 793729e188..93ad4a899a 100644 --- a/src/pyedb/dotnet/edb_core/components.py +++ b/src/pyedb/dotnet/edb_core/components.py @@ -111,16 +111,9 @@ def __getitem__(self, name): def __init__(self, p_edb): self._pedb = p_edb - self._cmp = {} - self._res = {} - self._cap = {} - self._ind = {} - self._ios = {} - self._ics = {} - self._others = {} + self.refresh_components() self._pins = {} self._comps_by_part = {} - self._init_parts() self._padstack = EdbPadstacks(self._pedb) @property @@ -132,16 +125,6 @@ def _logger(self): def _edb(self): return self._pedb.edb_api - def _init_parts(self): - a = self.instances - a = self.resistors - a = self.ICs - a = self.Others - a = self.inductors - a = self.IOs - a = self.components_by_partname - return True - def _get_edb_value(self, value): return self._pedb.edb_value(value) @@ -205,8 +188,6 @@ def instances(self): >>> edbapp.components.instances """ - if not self._cmp: - self.refresh_components() return self._cmp @property @@ -310,10 +291,29 @@ def export_definition(self, file_path): def refresh_components(self): """Refresh the component dictionary.""" - # self._logger.info("Refreshing the Components dictionary.") self._cmp = {} + self._res = {} + self._ind = {} + self._cap = {} + self._ics = {} + self._ios = {} + self._others = {} for i in self._pedb.layout.groups: self._cmp[i.name] = i + if i.type == "Resistor": + self._res[i.name] = i + elif i.type == "Capacitor": + self._cap[i.name] = i + elif i.type == "Inductor": + self._ind[i.name] = i + elif i.type == "IC": + self._ics[i.name] = i + elif i.type == "IO": + self._ios[i.name] = i + elif i.type == "Other": + self._others[i.name] = i + else: + self._logger.warning(f"Unknown component type {i.name} found while refreshing components, will ignore") return True @property @@ -332,10 +332,6 @@ def resistors(self): >>> edbapp = Edb("myaedbfolder") >>> edbapp.components.resistors """ - self._res = {} - for el, val in self.instances.items(): - if val.type == "Resistor": - self._res[el] = val return self._res @property @@ -354,10 +350,6 @@ def capacitors(self): >>> edbapp = Edb("myaedbfolder") >>> edbapp.components.capacitors """ - self._cap = {} - for el, val in self.instances.items(): - if val.type == "Capacitor": - self._cap[el] = val return self._cap @property @@ -377,10 +369,6 @@ def inductors(self): >>> edbapp.components.inductors """ - self._ind = {} - for el, val in self.instances.items(): - if val.type == "Inductor": - self._ind[el] = val return self._ind @property @@ -400,10 +388,6 @@ def ICs(self): >>> edbapp.components.ICs """ - self._ics = {} - for el, val in self.instances.items(): - if val.type == "IC": - self._ics[el] = val return self._ics @property @@ -423,10 +407,6 @@ def IOs(self): >>> edbapp.components.IOs """ - self._ios = {} - for el, val in self.instances.items(): - if val.type == "IO": - self._ios[el] = val return self._ios @property @@ -446,10 +426,6 @@ def Others(self): >>> edbapp.components.others """ - self._others = {} - for el, val in self.instances.items(): - if val.type == "Other": - self._others[el] = val return self._others @property