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
tests/ddr-dqs-tuning.test.ts
import{test,expect}from'bun:test'
import{createTunedDqsPair,offsetDqsCenterline}from'../scripts/tune-ddr-dqs'
import{auditRouteAngles}from'../scripts/check-route-angles'
const length=(r:any)=>r.route.slice(1).reduce((s:number,p:any,i:number)=>s+Math.hypot(p.x-r.route[i].x,p.y-r.route[i].y),0)
test('paired tuning preserves endpoints, full coupling spacing on vertical leg, equal lengths and45turns',()=>{
const connections=[0,1].map(i=>({name:`dq${i}`,ramByte:0,source_trace_id:`s${i}`,pointsToConnect:[{x:-6.040077,y:-9.344969+.32*i,layer:'inner2'},{x:2.69,y:-3.6+.4*i,layer:'inner2'}]}))
const routes=createTunedDqsPair(connections,-16.35,1.9,-4.8,.2,true)
expect(auditRouteAngles(routes).valid).toBe(true)
expect(Math.abs(length(routes[0])-length(routes[1]))).toBeLessThan(1e-8)
for(let i=0;i<2;i++){
expect(routes[i]!.route[0]).toMatchObject(connections[i]!.pointsToConnect[1]!)
expect(routes[i]!.route.at(-1)).toMatchObject(connections[i]!.pointsToConnect[0]!)
expect(routes[i]!.route.every(p=>p.route_type==='wire'&&p.layer==='inner2'&&p.width===.12)).toBe(true)
}
expect(Math.abs(routes[0]!.route[4]!.x-routes[1]!.route[4]!.x)).toBeCloseTo(.32,8)
})
test('offset geometry rejects zero length and reversal',()=>{
expect(()=>offsetDqsCenterline([{x:0,y:0},{x:0,y:0}],.16)).toThrow()
expect(()=>offsetDqsCenterline([{x:0,y:0},{x:1,y:0},{x:0,y:0}],.16)).toThrow()
})