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-mean-fitting.test.ts

import{test,expect}from'bun:test'
import{fitDqsPairMean}from'../scripts/tune-ddr-dqs'
import{auditRouteAngles}from'../scripts/check-route-angles'
const connections=[0,1].map(i=>({name:`p${i}`,source_trace_id:`s${i}`,ramByte:0,pointsToConnect:[{x:-6.040077,y:-9.184969+(i? .16:-.16),layer:'inner2'},{x:2.69,y:-3.4+(i?.2:-.2),layer:'inner2'}]}))
test('diagonal-return pair fits actual mean instead of assuming two units of length per unit depth',()=>{
 const r=fitDqsPairMean(connections,[9.58,9.68],28.423158)
 expect(r.meanMm).toBeCloseTo(28.423158,8)
 expect(r.lengthsMm[1]!-r.lengthsMm[0]!).toBeCloseTo(.1,8)
 expect(auditRouteAngles(r.traces).valid).toBe(true)
 expect(r.traces.every(t=>t.route.every(p=>p.layer==='inner2'))).toBe(true)
})
test('invalid budgets and a target outside the retained template fail closed',()=>{
 expect(()=>fitDqsPairMean(connections,[9.58,NaN],28)).toThrow()
 expect(()=>fitDqsPairMean(connections,[9.58,9.68],5)).toThrow()
})
test('positive excursion fits the upper RAM byte without reversing pair polarity',()=>{
 const upper=connections.map((c,i)=>({...c,ramByte:1,pointsToConnect:[{x:-6.040077,y:3.815031+(i?.16:-.16),layer:'inner4'},{x:2.69,y:-1+(i?.2:-.2),layer:'inner4'}]}))
 const result=fitDqsPairMean(upper,[9.58,9.68],27,1.9,9.6)
 expect(result.meanMm).toBeCloseTo(27,8)
 expect(result.excursionY).toBeGreaterThan(3.975031)
 expect(auditRouteAngles(result.traces).valid).toBe(true)
 expect(()=>fitDqsPairMean(upper,[9.58,9.68],27,1.9,NaN)).toThrow()
})