From 831313623d8bb67f00fe8cf3211187a010174397 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Mon, 25 Nov 2024 20:07:20 +0100 Subject: [PATCH] FIX: edb cfg s param export (#914) * draft * FIX: Edb cfg export S-parameter * minor fix * minor fix --------- Co-authored-by: ring630 <@gmail.com> --- src/pyedb/configuration/cfg_components.py | 4 ++-- .../configuration/cfg_s_parameter_models.py | 12 +++++------ src/pyedb/configuration/configuration.py | 11 ++++++---- tests/legacy/system/test_edb_components.py | 20 ------------------- .../system/test_edb_configuration_2p0.py | 1 + 5 files changed, 16 insertions(+), 32 deletions(-) diff --git a/src/pyedb/configuration/cfg_components.py b/src/pyedb/configuration/cfg_components.py index af69d24f47..5908ed73e5 100644 --- a/src/pyedb/configuration/cfg_components.py +++ b/src/pyedb/configuration/cfg_components.py @@ -40,8 +40,8 @@ def __init__(self, pedb, pedb_object, **kwargs): self.solder_ball_properties = kwargs.get("solder_ball_properties", {}) self.ic_die_properties = kwargs.get("ic_die_properties", {}) self.pin_pair_model = kwargs.get("pin_pair_model", []) - self.spice_model = kwargs.get("spice_model", None) - self.s_parameter_model = kwargs.get("s_parameter_model", None) + self.spice_model = kwargs.get("spice_model", {}) + self.s_parameter_model = kwargs.get("s_parameter_model", {}) self.netlist_model = kwargs.get("netlist_model", {}) def retrieve_model_properties_from_edb(self): diff --git a/src/pyedb/configuration/cfg_s_parameter_models.py b/src/pyedb/configuration/cfg_s_parameter_models.py index 89189afa8b..e8ec67e36e 100644 --- a/src/pyedb/configuration/cfg_s_parameter_models.py +++ b/src/pyedb/configuration/cfg_s_parameter_models.py @@ -67,7 +67,7 @@ def apply(self): ref_net = s_param.reference_net comp.use_s_parameter_model(s_param.name, reference_net=ref_net) - def get_data_from_db(self): + def get_data_from_db(self, cfg_components): db_comp_def = self._pedb.definitions.component for name, compdef_obj in db_comp_def.items(): nport_models = compdef_obj.component_models @@ -75,16 +75,16 @@ def get_data_from_db(self): continue else: pin_order = compdef_obj.get_properties()["pin_order"] - temp_comps = compdef_obj.components + temp_comps = [i for i in cfg_components if i["definition"] == name] for model_name, model_obj in nport_models.items(): temp_comp_list = [] reference_net_per_component = {} - for i in temp_comps.values(): - s_param_model = i.model_properties.get("s_parameter_model") + for i in temp_comps: + s_param_model = i.get("s_parameter_model") if s_param_model: if s_param_model["model_name"] == model_name: - temp_comp_list.append(i.refdes) - reference_net_per_component[i.refdes] = s_param_model["reference_net"] + temp_comp_list.append(i["reference_designator"]) + reference_net_per_component[i["reference_designator"]] = s_param_model["reference_net"] else: continue diff --git a/src/pyedb/configuration/configuration.py b/src/pyedb/configuration/configuration.py index dd75d4186a..8d319d4ba8 100644 --- a/src/pyedb/configuration/configuration.py +++ b/src/pyedb/configuration/configuration.py @@ -293,12 +293,16 @@ def get_data_from_db(self, **kwargs): data["sources"] = self.cfg_data.sources.get_data_from_db() if kwargs.get("ports", False): data["ports"] = self.cfg_data.ports.get_data_from_db() - if kwargs.get("components", False): + if kwargs.get("components", False) or kwargs.get("s_parameters", False): self.cfg_data.components.retrieve_parameters_from_edb() components = [] for i in self.cfg_data.components.components: components.append(i.get_attributes()) - data["components"] = components + + if kwargs.get("components", False): + data["components"] = components + elif kwargs.get("s_parameters", False): + data["s_parameters"] = self.cfg_data.s_parameters.get_data_from_db(components) if kwargs.get("nets", False): data["nets"] = self.cfg_data.nets.get_data_from_db() if kwargs.get("pin_groups", False): @@ -316,8 +320,7 @@ def get_data_from_db(self, **kwargs): data["padstacks"] = dict() data["padstacks"]["definitions"] = definitions data["padstacks"]["instances"] = instances - if kwargs.get("s_parameters", False): - data["s_parameters"] = self.cfg_data.s_parameters.get_data_from_db() + if kwargs.get("boundaries", False): data["boundaries"] = self.cfg_data.boundaries.get_data_from_db() diff --git a/tests/legacy/system/test_edb_components.py b/tests/legacy/system/test_edb_components.py index a5e8655ae9..43380a41e7 100644 --- a/tests/legacy/system/test_edb_components.py +++ b/tests/legacy/system/test_edb_components.py @@ -606,26 +606,6 @@ def test_component_lib(self): network.write_touchstone(os.path.join(edbapp.directory, "test_export.s2p")) assert os.path.isfile(os.path.join(edbapp.directory, "test_export.s2p")) - def test_properties(self, edb_examples): - edbapp = edb_examples.get_si_verse() - pp = { - "pin_pair_model": [ - { - "first_pin": "2", - "second_pin": "1", - "is_parallel": True, - "resistance": "10ohm", - "resistance_enabled": True, - "inductance": "1nH", - "inductance_enabled": True, - "capacitance": "1nF", - "capacitance_enabled": True, - } - ] - } - edbapp.components["C378"].model_properties = pp - assert edbapp.components["C378"].model_properties == pp - def test_export_gds_comp_xml(self, edb_examples): edbapp = edb_examples.get_si_verse() xml_output = os.path.join(self.local_scratch.path, "test.xml") diff --git a/tests/legacy/system/test_edb_configuration_2p0.py b/tests/legacy/system/test_edb_configuration_2p0.py index f2a26a92bb..cf18125ac0 100644 --- a/tests/legacy/system/test_edb_configuration_2p0.py +++ b/tests/legacy/system/test_edb_configuration_2p0.py @@ -512,6 +512,7 @@ def test_06_s_parameters(self, edb_examples): assert edbapp.components.nport_comp_definition["CAPC3216X180X55ML20T25"].reference_file assert len(edbapp.components.nport_comp_definition["CAPC3216X180X55ML20T25"].components) == 9 assert len(edbapp.components.nport_comp_definition["CAPC3216X190X55ML30T25"].components) == 12 + edbapp.configuration.get_data_from_db(s_parameters=True) edbapp.close() def test_07_boundaries(self, edb_examples):