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

routing/negotiated-route.ts

import schedule from "./negotiation-order.json"
import { Grid, segmentDist } from "./single-layer"

/** Deterministic congestion negotiation. The recorded schedule seeds search order,
 * not copper geometry: every path is recomputed from the input terminals and vias.
 * DDR_A1 participates in provisional bottom-layer planning before moving to inner1.
 */
export function negotiatedRoute(connections:any[],requiredNames:string[],vias:any[],bounds:any) {
 const routes=new Map<string,any>()
 const grids=new Map(connections.map(c=>{const g=new Grid(bounds);for(const v of vias)if(v.net!==c.name)g.disk(v,.302);return[c.name,g]}))
 const history=new Float32Array(new Grid(bounds).blocked.length)
 let best=0
 for(let iteration=0;iteration<schedule.length;iteration++){
  const c=connections.find(c=>c.name===schedule[iteration]);if(!c)throw new Error('Negotiation schedule does not match input')
  routes.delete(c.name)
  const grid=grids.get(c.name)!,mask=new Grid(bounds)
  for(const r of routes.values())mask.route(r.points,.212)
  grid.occupancy=mask.blocked;grid.penalty=20+Math.floor(iteration/20);grid.history=history
  const path=grid.search(c.points[0],c.points[1]);if(!path)throw new Error(`Via obstacles block ${c.name}`)
  const removed:string[]=[]
  for(const r of routes.values()){
   let hit=false
   for(let i=1;i<path.length;i++)for(let j=1;j<r.points.length;j++)if(segmentDist(path[i-1],path[i],r.points[j-1],r.points[j])<.1999){
    hit=true;const h=new Grid(bounds);h.segment(path[i-1],path[i],.25);h.segment(r.points[j-1],r.points[j],.25)
    for(let k=0;k<h.blocked.length;k++)if(h.blocked[k])history[k]+=.3
   }
   if(hit)removed.push(r.name)
  }
  for(const name of removed)routes.delete(name)
  routes.set(c.name,{name:c.name,points:path})
  if(routes.size>best){best=routes.size;console.log(`Bottom-layer negotiation: ${best}/${requiredNames.length} provisional routes`)}
  if(requiredNames.every(n=>routes.has(n)))return requiredNames.map(n=>routes.get(n))
 }
 throw new Error('No complete no-via solution for the bottom-layer routing plan')
}