seveibar/am3352-dev-board-4layer-dogbone

Defines PCB footprints and pin mappings for a TI AM3352ZCZ100 processor, JST GH connectors, and assembly-part lookup helpers for capacitors, resistors, and headers.

Version
0.1.5
License
unset
Stars
0

scripts/check-ddr-topology.py

"""Reject DDR route self-intersections and unintended contacts with its own vias."""
import json, os, math, sys, hashlib
from pathlib import Path
from shapely.geometry import LineString, Point
p=Path(os.environ.get('AUDIT_CIRCUIT','dist/index/circuit.json'));c=json.loads(p.read_text());names={e['source_net_id']:e['name'] for e in c if e['type']=='source_net'};traces={e['source_trace_id']:e for e in c if e['type']=='source_trace'};groups={}
for t in c:
 if t['type']!='pcb_trace':continue
 ss=traces.get(t.get('source_trace_id'),{}).get('connected_source_net_ids',[])
 for sid in ss:
  name=names.get(sid,'')
  if name.startswith('DDR_') and name not in ['DDR_1V5','DDR_VREF','DDR_VTP','DDR_RESETn','DDR_ZQ']:groups.setdefault(name,[]).append(t)
errors=[]
for name,ts in groups.items():
 vias={(v['x'],v['y']):v.get('via_diameter',.3)/2 for t in ts for v in t['route'] if v['route_type']=='via'}
 for i,(a,ra) in enumerate(vias.items()):
  for b,rb in list(vias.items())[i+1:]:
   if math.dist(a,b)<ra+rb+.099:errors.append(dict(net=name,kind='via-to-via',a=a,b=b))
 for t in ts:
  r=t['route']
  if any(v['route_type']!='wire' for v in r):continue
  pts=[(v['x'],v['y']) for v in r];pts=[p for i,p in enumerate(pts) if i==0 or p!=pts[i-1]]
  if len(pts)<2:continue
  line=LineString(pts)
  if not line.is_simple:errors.append(dict(net=name,kind='self-intersection',trace=t['pcb_trace_id']))
  for via,radius in vias.items():
   if min(math.dist(via,pts[0]),math.dist(via,pts[-1]))<.001:continue
   gap=line.distance(Point(via))-radius-r[0]['width']/2
   if gap<.099:errors.append(dict(net=name,kind='unintended-via-contact-or-spacing',trace=t['pcb_trace_id'],via=via,gapMm=gap))
report=dict(circuitSha256=hashlib.sha256(p.read_bytes()).hexdigest(),netsChecked=len(groups),errors=errors)
Path(os.environ.get('DDR_TOPOLOGY_REPORT','design/ddr-topology.json')).write_text(json.dumps(report,indent=2)+'\n');print('DDR self-contact/spacing:',len(groups),'nets;',len(errors),'errors')
if '--strict' in sys.argv and (errors or len(groups)!=46):raise SystemExit('DDR topology check failed or matched-net coverage is incomplete')