Skip to content

Commit f28fe9d

Browse files
REFACTOR: EDB CONFIG (#393)
Co-authored-by: ring630 <@gmail.com> Co-authored-by: Samuel Lopez <[email protected]>
1 parent 55edd0a commit f28fe9d

File tree

8 files changed

+65
-20
lines changed

8 files changed

+65
-20
lines changed

examples/00_edb/use_configuration/import_components.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
# +
1313
import json
14+
import toml
1415
from pathlib import Path
1516
import tempfile
1617

@@ -101,21 +102,21 @@
101102
},
102103
]
103104

104-
display(pd.DataFrame(data=[cfg["components"][0]["solder_ball_properties"]]))
105-
106-
display(pd.DataFrame(data=[cfg["components"][0]["port_properties"]]))
107-
108-
display(pd.DataFrame(data=cfg["components"][1]["pin_pair_model"]))
109-
110105
cfg_file_path = Path(temp_folder) / "cfg.json"
111106
with open(cfg_file_path, "w") as f:
112107
json.dump(cfg, f, indent=4, ensure_ascii=False)
113108

114-
# Load config file
109+
# Equivalent toml file looks like below
110+
111+
toml_string = toml.dumps(cfg)
112+
print(toml_string)
113+
114+
# ## Apply config file
115115

116116
edbapp.configuration.load(cfg_file_path, apply_file=True)
117117

118-
# ## Save and close Edb
118+
# Save and close Edb
119+
#
119120
# The temporary folder will be deleted once the execution of this script is finished. Replace **edbapp.save()** with
120121
# **edbapp.save_as("C:/example.aedb")** to keep the example project.
121122

examples/00_edb/use_configuration/import_material.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# +
99
import json
10+
import toml
1011
from pathlib import Path
1112
import tempfile
1213

@@ -54,7 +55,6 @@
5455
# - **advanced_quadratic_lower_constant**. The constant thermal modifier value for temperatures lower than LowerConstantThermalModifierVal
5556
# - **advanced_quadratic_upper_constant**. The constant thermal modifier value for temperatures greater than UpperConstantThermalModifierVal.
5657

57-
# +
5858
materials = [
5959
{
6060
"name": "copper",
@@ -74,11 +74,15 @@
7474
],
7575
},
7676
]
77-
config = {"stackup": {"materials": materials}}
77+
cfg = {"stackup": {"materials": materials}}
7878
file_json = Path(temp_folder.name) / "edb_configuration.json"
7979
with open(file_json, "w") as f:
80-
json.dump(config, f, indent=4, ensure_ascii=False)
81-
# -
80+
json.dump(cfg, f, indent=4, ensure_ascii=False)
81+
82+
# Equivalent toml file looks like below
83+
84+
toml_string = toml.dumps(cfg)
85+
print(toml_string)
8286

8387
# ## Import configuration into example layout
8488

examples/00_edb/use_configuration/import_operations.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
# +
1212
import json
13+
import toml
1314
from pathlib import Path
1415
import tempfile
1516

@@ -109,8 +110,6 @@
109110
# - **keep_lines_as_path**. Keeps lines as `Path` instead of converting to `PolygonData`. Only works in Electronics Desktop (3D Layout). May cause issues in SiWave. Defaults to `False`.
110111
# - **include_voids_in_extents**. Includes voids in the computed extent (for Conforming only). May affect performance. Defaults to `False`.
111112

112-
113-
114113
cutout = {
115114
"reference_list": ["GND"],
116115
"extent_type": "ConvexHull",
@@ -130,6 +129,11 @@
130129
with open(file_json, "w") as f:
131130
json.dump(cfg, f, indent=4, ensure_ascii=False)
132131

132+
# Equivalent toml file looks like below
133+
134+
toml_string = toml.dumps(cfg)
135+
print(toml_string)
136+
133137
# Apply cutout
134138

135139
edbapp = Edb(edb_path, edbversion=AEDT_VERSION)
@@ -167,6 +171,13 @@
167171
with open(file_json, "w") as f:
168172
json.dump(cfg, f, indent=4, ensure_ascii=False)
169173

174+
175+
# Equivalent toml file looks like below
176+
177+
toml_string = toml.dumps(cfg)
178+
print(toml_string)
179+
180+
170181
# Apply cutout
171182

172183
edbapp = Edb(edb_path, edbversion=AEDT_VERSION)

examples/00_edb/use_configuration/import_padstack_definitions.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
# +
1313
import json
14+
import toml
1415
from pathlib import Path
1516
import tempfile
1617

@@ -119,16 +120,17 @@
119120
}
120121
]
121122

122-
df = pd.DataFrame(data=cfg["padstacks"]["definitions"][0]["pad_parameters"]["regular_pad"])
123-
display(df)
124-
125-
df = pd.DataFrame(data=cfg["padstacks"]["definitions"][0]["pad_parameters"]["anti_pad"])
126-
display(df)
127-
128123
cfg_file_path = Path(temp_folder) / "cfg.json"
129124
with open(cfg_file_path, "w") as f:
130125
json.dump(cfg, f, indent=4, ensure_ascii=False)
131126

127+
128+
# Equivalent toml file looks like below
129+
130+
toml_string = toml.dumps(cfg)
131+
print(toml_string)
132+
133+
132134
# Load config file
133135

134136
edbapp.configuration.load(cfg_file_path, apply_file=True)

examples/00_edb/use_configuration/import_ports.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
# +
2020
import json
21+
import toml
2122
from pathlib import Path
2223
import tempfile
2324

@@ -146,6 +147,13 @@
146147
with open(file_json, "w") as f:
147148
json.dump(cfg, f, indent=4, ensure_ascii=False)
148149

150+
151+
# Equivalent toml file looks like below
152+
153+
toml_string = toml.dumps(cfg)
154+
print(toml_string)
155+
156+
149157
# ## Import configuration into example layout
150158

151159
edbapp.configuration.load(config_file=file_json)

examples/00_edb/use_configuration/import_setup_ac.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
# +
1414
import json
15+
import toml
1516
from pathlib import Path
1617
import tempfile
1718

@@ -127,6 +128,12 @@
127128
with open(file_json, "w") as f:
128129
json.dump(cfg, f, indent=4, ensure_ascii=False)
129130

131+
132+
# Equivalent toml file looks like below
133+
134+
toml_string = toml.dumps(cfg)
135+
print(toml_string)
136+
130137
# ## Import configuration into example layout
131138

132139
edbapp.configuration.load(config_file=file_json)

examples/00_edb/use_configuration/import_sources.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
# +
1919
import json
20+
import toml
2021
from pathlib import Path
2122
import tempfile
2223

@@ -155,6 +156,12 @@
155156
with open(file_json, "w") as f:
156157
json.dump(cfg, f, indent=4, ensure_ascii=False)
157158

159+
# Equivalent toml file looks like below
160+
161+
toml_string = toml.dumps(cfg)
162+
print(toml_string)
163+
164+
158165
# ## Import configuration into example layout
159166

160167
edbapp.configuration.load(config_file=file_json)

examples/00_edb/use_configuration/import_stackup.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# +
99
import json
10+
import toml
1011
from pathlib import Path
1112
import tempfile
1213

@@ -64,6 +65,10 @@
6465
with open(file_cfg, "w") as f:
6566
json.dump(data_cfg, f, indent=4, ensure_ascii=False)
6667

68+
# Equivalent toml file looks like below
69+
70+
toml_string = toml.dumps(data_cfg)
71+
print(toml_string)
6772

6873
# ## Load stackup from json configuration file
6974

0 commit comments

Comments
 (0)