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-retained-via-route.ts

import { objectHash } from './improve-ddr-a9-power-launches'
import { assertRouteAngles } from './check-route-angles'
const geometry=(p:any)=>p.route_type==='wire'?{type:'wire',x:p.x,y:p.y,layer:p.layer,width:p.width}:{type:'via',x:p.x,y:p.y,from:p.from_layer,to:p.to_layer,pad:p.via_diameter,drill:p.via_hole_diameter}
/** Materialize the implicit departure wire of the existing winding solver, without moving vertices. */
export function retainViaLaunch(raw:any[],prefix:any[]){
 const via=prefix.at(-1),index=prefix.length-1
 if(via?.route_type!=='via'||prefix.filter(p=>p.route_type==='via').length!==1)throw Error('Expected one retained terminal via')
 const route=structuredClone(raw).filter((p:any,i:number)=>!(p.route_type==='via'&&raw[i-1]?.route_type==='via'&&objectHash(geometry(p))===objectHash(geometry(raw[i-1]))))
 if(route.filter((p:any)=>p.route_type==='via').length!==1||objectHash(route.slice(0,index+1).map(geometry))!==objectHash(prefix.map(geometry)))throw Error('Solver changed retained launch or physical via count')
 const first=route[index+1]
 if(first?.route_type!=='wire'||first.layer!==via.to_layer)throw Error('Missing departure on retained via destination layer')
 if(first.x!==via.x||first.y!==via.y)route.splice(index+1,0,{route_type:'wire',x:via.x,y:via.y,layer:via.to_layer,width:first.width})
 const result=[...structuredClone(prefix),...route.slice(index+1)]
 assertRouteAngles([{route:result}])
 return result
}