0hmX/am3352
This code suite comprises TypeScript scripts that analyze, verify, and assemble complex DDR memory interface hardware, focusing on physical routing, via and pad placement, electrical clearance, and physical constraints, often involving precise geometric calculations and consistent provenance tracking.
- Version
- 1.0.5
- License
- unset
- Stars
- 0
scripts/audit-ddr-host-self-contacts.ts
/** Detect nonlocal self-contact of routed host copper; local corner fill is excluded. */
import{readFileSync,writeFileSync}from'node:fs'
import{resolve}from'node:path'
import{ddrCopperShapeGap}from'./check-ddr-system-copper'
export function auditHostSelfContacts(traces:any[]){
const contacts:any[]=[]
for(const trace of traces){let arc=0;const segments:any[]=[]
for(let i=1;i<trace.route.length;i++){const a=trace.route[i-1],b=trace.route[i];if(a.route_type!=='wire'||b.route_type!=='wire'||a.layer!==b.layer)continue;const length=Math.hypot(b.x-a.x,b.y-a.y);if(length<1e-9)continue;segments.push({index:i,startArc:arc,endArc:arc+length,id:`${trace.pcb_trace_id}:${i}`,net:trace.source_trace_id??trace.connection_name,layer:a.layer,a,b,r:Math.max(a.width,b.width)/2,fresh:true});arc+=length}
for(let i=0;i<segments.length;i++)for(let j=i+1;j<segments.length;j++){const a=segments[i],b=segments[j],separation=b.startArc-a.endArc;if(a.layer!==b.layer||separation<=.5+1e-8)continue;const gap=ddrCopperShapeGap(a,b);if(gap<=1e-8)contacts.push({traceId:trace.pcb_trace_id,connection:trace.connection_name,layer:a.layer,segmentIndices:[a.index,b.index],interveningPlanarMm:separation,copperGapMm:gap,a:{a:a.a,b:a.b},b:{a:b.a,b:b.b}})}
}
return{valid:contacts.length===0,contacts,scope:'Same-host same-layer wire capsules with more than0.5mm of intervening planar route. Detects nonlocal wire self-contact; excludes local corner fill, barrels, fixed-copper contact and field-coupling qualification.'}
}
if(import.meta.main){const dir=resolve(process.argv[2]),host=JSON.parse(readFileSync(resolve(dir,'host-bundle.json'),'utf8')),report=auditHostSelfContacts(host.traces);writeFileSync(resolve(dir,'host-self-contact-report.json'),JSON.stringify(report,null,2)+'\n');console.log(JSON.stringify(report));if(!report.valid)process.exitCode=1}