Skip to content

Commit

Permalink
FEAT: Configuration file export nets (#623)
Browse files Browse the repository at this point in the history
* hfsspi SimsetupInfo bug fixed

* temp

* unit test
  • Loading branch information
svandenb-dev authored Jul 1, 2024
1 parent bf8b0e5 commit 4dd3b43
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
8 changes: 3 additions & 5 deletions src/pyedb/configuration/cfg_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ def __init__(self, pedb, **kwargs):
if kwargs.get("boundaries", None):
self.boundaries = CfgBoundaries(self, kwargs.get("boundaries", None))

self.nets = None
if kwargs.get("nets"):
self.nets = CfgNets(
self, kwargs.get("nets", {}).get("signal_nets", []), kwargs.get("nets", {}).get("power_ground_nets", [])
)
self.nets = CfgNets(
self, kwargs.get("nets", {}).get("signal_nets", []), kwargs.get("nets", {}).get("power_ground_nets", [])
)

self.components = CfgComponents(self._pedb, components_data=kwargs.get("components", []))

Expand Down
14 changes: 14 additions & 0 deletions src/pyedb/configuration/cfg_nets.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,17 @@ def apply(self):
for power_net in self.power_nets:
if power_net in self._pedb.nets:
self._pedb.nets.nets[power_net].is_power_ground = True

def _load_data_from_db(self):
self.signal_nets = []
self.power_nets = []
for net in self._pedb.nets.signal:
self.signal_nets.append(net)
for net in self._pedb.nets.power:
self.power_nets.append(net)

def get_data_from_db(self):
"""Get net information."""
self._load_data_from_db()
data = {"signal_nets": self.signal_nets, "power_ground_nets": self.power_nets}
return data
7 changes: 4 additions & 3 deletions src/pyedb/configuration/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,11 @@ def get_data_from_db(self, **kwargs):
data["setups"] = self.cfg_data.setups.get_data_from_db()
if kwargs.get("components", False):
data["components"] = self.cfg_data.components.get_data_from_db()

if kwargs.get("nets", False):
data["nets"] = self.cfg_data.nets.get_data_from_db()
return data

def export(self, file_path, stackup=True, package_definitions=True, setups=True):
def export(self, file_path, stackup=True, package_definitions=True, setups=True, nets=True):
"""Export the configuration data from layout to a file.
Parameters
Expand All @@ -292,7 +293,7 @@ def export(self, file_path, stackup=True, package_definitions=True, setups=True)
"""
file_path = file_path if isinstance(file_path, Path) else Path(file_path)
file_path = file_path if file_path.suffix == ".json" else file_path.with_suffix(".json")
data = self.get_data_from_db(stackup=stackup, package_definitions=package_definitions, setups=setups)
data = self.get_data_from_db(stackup=stackup, package_definitions=package_definitions, setups=setups, nets=nets)
with open(file_path, "w") as f:
json.dump(data, f, ensure_ascii=False, indent=4)
return True if os.path.isfile(file_path) else False
14 changes: 14 additions & 0 deletions tests/legacy/system/test_edb_configuration_2p0.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,3 +793,17 @@ def test_16_export_to_external_file(self, edb_examples):
data_file_path = Path(edb_examples.test_folder) / "test.json"
edbapp.configuration.export(data_file_path)
assert data_file_path.is_file()
with open(data_file_path) as f:
data = json.load(f)
assert "stackup" in data
assert data["stackup"]["materials"]
assert data["stackup"]["materials"][0]["name"] == "copper"
assert data["stackup"]["materials"][0]["conductivity"] == 5.8e7
assert data["stackup"]["layers"]
data["stackup"]["layers"][0]["name"] = "1_Top"
data["stackup"]["layers"][0]["type"] = "signal"
data["stackup"]["layers"][0]["material"] = "copper"
assert data["nets"]
assert len(data["nets"]["signal_nets"]) == 342
assert len(data["nets"]["power_ground_nets"]) == 6
edbapp.close()

0 comments on commit 4dd3b43

Please sign in to comment.