@@ -349,10 +349,11 @@ def _run_grounding_analysis(design: PCBDesignData) -> DomainResult:
349349 # Build ground planes from design zones
350350 planes = []
351351 gnd_zones = [z for z in design .zones if z .net_name and "gnd" in z .net_name .lower ()]
352+ layer_num_map = {l .name : idx for idx , l in enumerate (design .layers )} if design .layers else {}
352353 if gnd_zones :
353354 for i , zone in enumerate (gnd_zones ):
354355 planes .append (GroundPlane (
355- layer_number = i ,
356+ layer_number = layer_num_map . get ( zone . layer , i ) ,
356357 name = zone .layer ,
357358 coverage_percent = 80.0 ,
358359 width_mm = design .board_width_mm or 100 ,
@@ -863,8 +864,12 @@ def _run_pcie_analysis(
863864 lane [key ] = length
864865 lanes .append (lane )
865866
867+ gen_map = {"pcie_gen1" : PCIeGeneration .GEN1 , "pcie_gen2" : PCIeGeneration .GEN2 , "pcie_gen3" : PCIeGeneration .GEN3 , "pcie_gen4" : PCIeGeneration .GEN4 , "pcie_gen5" : PCIeGeneration .GEN5 , "pcie_gen6" : PCIeGeneration .GEN6 }
868+ itype = pcie_iface .interface_type .lower () if hasattr (pcie_iface , 'interface_type' ) else ""
869+ pcie_gen = next ((v for k , v in gen_map .items () if k in itype ), PCIeGeneration .GEN3 )
870+
866871 pcie_result = analyzer .analyze (
867- generation = PCIeGeneration . GEN3 ,
872+ generation = pcie_gen ,
868873 lanes = lanes ,
869874 )
870875
@@ -1187,20 +1192,25 @@ def _build_recommendations(
11871192 recs = []
11881193 seen = set ()
11891194
1195+ # Pre-build finding index by title for O(1) lookup
1196+ finding_by_title : dict [str , Any ] = {}
1197+ for dr in domain_results :
1198+ for f in dr .findings :
1199+ if f .title not in finding_by_title and f .recommendation :
1200+ finding_by_title [f .title ] = f
1201+
11901202 # From risk matrix (highest risk first)
11911203 for risk in risk_matrix :
11921204 if risk .risk_score >= 4 :
1193- # Find the matching finding
1194- for dr in domain_results :
1195- for f in dr .findings :
1196- if f .title == risk .finding_title and f .recommendation and f .recommendation not in seen :
1197- seen .add (f .recommendation )
1198- recs .append ({
1199- "priority" : "high" if risk .risk_score >= 6 else "medium" ,
1200- "domain" : f .domain ,
1201- "recommendation" : f .recommendation ,
1202- "risk_score" : risk .risk_score ,
1203- })
1205+ matched = finding_by_title .get (risk .finding_title )
1206+ if matched and matched .recommendation not in seen :
1207+ seen .add (matched .recommendation )
1208+ recs .append ({
1209+ "priority" : "high" if risk .risk_score >= 6 else "medium" ,
1210+ "domain" : matched .domain ,
1211+ "recommendation" : matched .recommendation ,
1212+ "risk_score" : risk .risk_score ,
1213+ })
12041214
12051215 # From cross-correlations
12061216 for cc in cross_correlations :
0 commit comments