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/ddr-current-trunk-contract.ts

/** Rebind frozen trunk identities to current physical endpoints, never stale XY. */
export function currentDdrTrunkContract(frozen:any,input:any,candidate:any[]){
 return {...frozen,forcedTrunks:frozen.forcedTrunks.map((t:any)=>{
  const first=input.connections.filter((c:any)=>c.name===t.firstConnection),second=input.connections.filter((c:any)=>c.name===t.secondConnection)
  if(first.length!==1||second.length!==1)throw Error(`Missing unique trunk branches ${t.terminal}`)
  const point=(old:any,connections:any[])=>{
   const matches=connections.flatMap(c=>c.pointsToConnect).filter(p=>p.pointId===old.pointId)
   if(!matches.length||matches.some(p=>p.layer!==matches[0].layer||Math.hypot(p.x-matches[0].x,p.y-matches[0].y)>1e-7))throw Error(`Ambiguous current trunk point ${old.pointId}`)
   const p=matches[0],exits=candidate.filter(e=>e.pcb_breakout_point_id===p.pointId)
   if(exits.length!==1||exits[0].layer!==p.layer||Math.hypot(exits[0].x-p.x,exits[0].y-p.y)>1e-7)throw Error(`Routing input differs from actual trunk copper ${p.pointId}`)
   return structuredClone(p)
  }
  return {...t,ram0Tap:point(t.ram0Tap,first),ram1Tap:point(t.ram1Tap,second),cpuPoint:point(t.cpuPoint,[...first,...second])}
 })}
}