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-plane-contact-audit.test.ts

import {test,expect} from 'bun:test'
import {refreshDdrPlaneContacts} from '../scripts/ddr-plane-contact-audit'
const ring=(x:number,y:number,r:number)=>Array.from({length:64},(_,i)=>({x:x+r*Math.cos(i*Math.PI/32),y:y+r*Math.sin(i*Math.PI/32)}))
const previous=[{layer:'inner1',source_net_id:'gnd',viaContacts:[{id:'ground-via',x:0,y:0,annulusSamplesInPlane:32}]}]
const plane=(holes:any[])=>[{type:'pcb_copper_pour',layer:'inner1',source_net_id:'gnd',brep_shape:{outer_ring:{vertices:[{x:-2,y:-2},{x:2,y:-2},{x:2,y:2},{x:-2,y:2}]},inner_rings:holes.map(vertices=>({vertices}))}}]
const copper=[{type:'pcb_via',pcb_via_id:'ground-via',x:0,y:0,outer_diameter:.4572}]
test('distant new antipad preserves actual ground-via annulus contact',()=>{
 const audit=refreshDdrPlaneContacts(previous,plane([ring(1,1,.3302)]),copper)
 expect(audit[0].viaContacts[0].annulusSamplesInPlane).toBe(32)
 expect(audit[0].holes).toBe(1)
})
test('hole removing a ground contact or a changed rail identity is rejected',()=>{
 expect(()=>refreshDdrPlaneContacts(previous,plane([ring(0,0,.3302)]),copper)).toThrow('loses existing via contact')
 expect(()=>refreshDdrPlaneContacts(previous,[{...plane([])[0],source_net_id:'other'}],copper)).toThrow('Plane identity changed')
})