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-data-mask-tuning.test.ts
import {test,expect} from 'bun:test'
import {addWestwardTuningExcursion} from '../scripts/tune-ddr-data-mask'
import {auditRouteAngles} from '../scripts/check-route-angles'
const length=(r:any[])=>r.slice(1).reduce((s,p,i)=>s+Math.hypot(p.x-r[i].x,p.y-r[i].y),0)
const trace={route:[{route_type:'wire',x:0,y:0,layer:'inner4',width:.12},{route_type:'wire',x:-12,y:0,layer:'inner4',width:.12}]}
test('both tuning excursion directions add exact length with only45turns and unchanged endpoints',()=>{
for(const sign of [-1,1]){
const tuned=addWestwardTuningExcursion(trace,0,-2,-8,1.824788,sign)
expect(length(tuned.route)-length(trace.route)).toBeCloseTo(1.824788,8)
expect(auditRouteAngles([tuned]).valid).toBe(true)
expect(tuned.route[0]).toEqual(trace.route[0]);expect(tuned.route.at(-1)).toEqual(trace.route.at(-1))
}
expect(trace.route).toHaveLength(2)
})
test('undersized or reversed tuning intervals fail rather than produce sharp bends',()=>{
expect(()=>addWestwardTuningExcursion(trace,0,-2,-2.5,1.8,1)).toThrow()
expect(()=>addWestwardTuningExcursion(trace,0,-8,-2,1.8,1)).toThrow()
expect(()=>addWestwardTuningExcursion(trace,0,-2,-8,.01,1)).toThrow()
})