seveibar/am3352-ram-dogbone-and-single-layer-route-test

AM3352BZCZ100 processor connected to a W631GG6MB-12 DDR3 memory chip through a routed, length-matched 16-bit DDR interface with clock/data-strobe pairs and control/address signals.

Version
0.0.9
License
unset
Stars
0

scripts/audit-route-efficiency.py

"""Score real planar copper length relative to the direct pad-to-pad distance."""
import hashlib,json,math,sys,statistics
from pathlib import Path
root=Path(__file__).resolve().parents[1]
p=Path(sys.argv[1]) if len(sys.argv)>1 else root/'dist/index/circuit.json'
raw=p.read_bytes();c=json.loads(raw);rows=[]
for t in c:
 if t['type']!='pcb_trace':continue
 r=t['route'];direct=math.hypot(r[-1]['x']-r[0]['x'],r[-1]['y']-r[0]['y']);length=sum(math.hypot(a['x']-b['x'],a['y']-b['y']) for a,b in zip(r,r[1:]) if a['route_type']==b['route_type']=='wire' and a['layer']==b['layer'])
 rows.append(dict(sourceTraceId=t['source_trace_id'],planarLengthMm=length,directDistanceMm=direct,detourRatio=length/direct,excessLengthMm=length-direct))
rows.sort(key=lambda r:r['detourRatio'],reverse=True)
report=dict(status='PASS' if max(r['detourRatio'] for r in rows)<=3.5 and statistics.mean(r['detourRatio'] for r in rows)<=2.3 else 'FAIL',maxAllowedDetourRatio=3.5,maxAllowedMeanDetourRatio=2.3,circuitSha256=hashlib.sha256(raw).hexdigest(),signals=len(rows),totalPlanarLengthMm=sum(r['planarLengthMm'] for r in rows),maxDetourRatio=rows[0]['detourRatio'],meanDetourRatio=statistics.mean(r['detourRatio'] for r in rows),medianDetourRatio=statistics.median(r['detourRatio'] for r in rows),routes=rows)
print(json.dumps(report,indent=2));sys.exit(report['status']!='PASS')