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-terminal-copper-obstacles.test.ts

import {test,expect} from 'bun:test'
import {trimProjectionAtTerminal} from '../scripts/ddr-terminal-copper-obstacles'
const w=(x:number,y:number)=>({route_type:'wire',x,y,layer:'inner4',width:.12})
test('terminal clipping reserves the old same-net path and preserves physical input',()=>{
 const trace={route:[w(0,0),w(1,0),w(1,0),w(1.1,.1)]},old=structuredClone(trace)
 const result=trimProjectionAtTerminal(trace,{x:1.1,y:.1,layer:'inner4',pointId:'p'})
 expect(trace).toEqual(old);expect(result.route.at(-1)!.y).toBe(0)
 expect(result.route.at(-1)!.x).toBeCloseTo(1-(.25-Math.SQRT2*.1),9)
})
test('projection never removes an original via and rejects unbounded join exceptions',()=>{
 const trace={route:[{route_type:'via',x:0,y:0,from_layer:'top',to_layer:'inner4'},w(0,0),w(.1,0)]},p={x:.1,y:0,layer:'inner4',pointId:'p'}
 expect(()=>trimProjectionAtTerminal(trace,p)).toThrow()
 expect(()=>trimProjectionAtTerminal(trace,p,1)).toThrow()
 expect(()=>trimProjectionAtTerminal(trace,{...p,x:.2})).toThrow()
})