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/assess-ddr-f8-opposite-launch.ts

/** One distinct opposite-diagonal F8 relocation; conductor preflight only. */
import{readFileSync,writeFileSync,mkdirSync}from'node:fs'
import{resolve}from'node:path'
import{createHash}from'node:crypto'
import{verifyDdrSystemCopper,auditDdrTraceJunctions}from'./check-ddr-system-copper'
import{auditRouteAngles}from'./check-route-angles'
import{sharedViaApproaches}from'./plan-ddr-ram-power-via-reuse'
const[dirArg,outArg]=process.argv.slice(2),dir=resolve(dirArg!),out=resolve(outArg!),hash=(x:any)=>createHash('sha256').update(JSON.stringify(x)).digest('hex'),read=(p:string)=>JSON.parse(readFileSync(p,'utf8')),parent=read(`${dir}/candidate.circuit.json`),prior=read(`${dir}/report.json`),host=read(`${dir}/host-bundle.json`),input=read(`${dir}/routing-input.json`),power=read(`${dir}/ram-power-launch-audit.json`),old=read('dist/ddr-f8-relocation-experiment/report.json'),attempts:any[]=[]
if(prior.candidateCircuitSha256!==hash(parent)||![19,20].includes(host.traces.length))throw Error('Parent mismatch')
for(const byte of[0,1]){const t=parent.find((e:any)=>e.type==='pcb_trace'&&e.pcb_trace_id===`saved_fanout_pcb_group_${byte?5:3}_53`),e9=parent.find((e:any)=>e.type==='pcb_trace'&&e.pcb_trace_id===`saved_fanout_pcb_group_${byte?5:3}_65`),pad=parent.find((e:any)=>e.type==='pcb_smtpad'&&e.pcb_port_id===t.route[0].start_pcb_port_id),rendered=parent.filter((e:any)=>e.type==='pcb_via'&&e.pcb_trace_id===t.pcb_trace_id),via={x:pad.x+.4,y:pad.y+.4},target=power.rows.find((r:any)=>r.byte===byte&&r.ball==='G8').connectionVia,route=sharedViaApproaches(t.route[0],via)[0]!,moved={...t,route:[...route,{route_type:'via',...via,from_layer:'top',to_layer:'inner1',via_diameter:.4572,via_hole_diameter:.254}]},movedVia={...rendered[0],...via},removed=new Set([t.pcb_trace_id,e9.pcb_trace_id,...host.traces.map((t:any)=>t.pcb_trace_id)]),fixed=parent.filter((e:any)=>e.type!=='pcb_copper_pour'&&!removed.has(e.pcb_trace_id)),relocation=verifyDdrSystemCopper([...fixed,moved,movedVia],[...host.traces,moved],input.connections,{},50,{reportSameNetContacts:true}),reuse=sharedViaApproaches(e9.route[0],target).map(route=>{const trace={...e9,route},physical=verifyDdrSystemCopper([...fixed,moved,movedVia],[...host.traces,moved,trace],input.connections,{},50,{reportSameNetContacts:true});return{route,physical}});attempts.push({byte,via,oldVia:t.route.find((p:any)=>p.route_type==='via'),pad:{x:pad.x,y:pad.y},f8LengthMm:Math.hypot(.4,.4),padDrillGapMm:Math.hypot(.4,.4)-.127-pad.radius,moved,movedVia,relocation,reuse})}
const report={captureHash:prior.captureHash,parentCircuitSha256:hash(parent),priorExperimentSha256:hash(old),priorAttemptCount:old.attempts.length,priorHits:old.hits.length,attempts,scope:'Distinct pad+(0.4,0.4) F8 opposite-diagonal launch, not previously swept. Actual conventional barrel and all19hosts checked; planes excluded only for conductor preflight. No candidate accepted or plane policy changed.'};mkdirSync(out,{recursive:true});writeFileSync(`${out}/report.json`,JSON.stringify(report,null,2));console.log(JSON.stringify(attempts.map(a=>({byte:a.byte,via:a.via,errors:a.relocation.errors,relocationViolations:a.relocation.violations.length,blockers:a.relocation.violations.map((v:any)=>({a:v.aShape.traceId??v.aShape.join,b:v.bShape.traceId??v.bShape.join,layer:v.layer,gap:v.gapMm})),reuse:a.reuse.map((r:any)=>r.physical.violations.length)}))))