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-host-fixed-contacts.test.ts
import{test,expect}from'bun:test'
import{verifyDdrSystemCopper}from'../scripts/check-ddr-system-copper'
import{classifyHostFixedContact}from'../scripts/audit-ddr-host-fixed-contacts'
const w=(x:number,y:number)=>({route_type:'wire',x,y,width:.12,layer:'inner4'})
test('same-net barrel shortcut has no foreign clearance error but contact gate detects host interior',()=>{
const fixed=[{type:'source_trace',source_trace_id:'ram',connected_source_port_ids:['pad']},{type:'source_trace',source_trace_id:'host',connected_source_port_ids:['pad','cpu']},{type:'pcb_via',pcb_via_id:'barrel',source_trace_id:'ram',x:0,y:0,outer_diameter:.4572,hole_diameter:.254,layers:['top','inner4','bottom']}],host={type:'pcb_trace',pcb_trace_id:'h',source_trace_id:'host',route:[w(-2,1),w(-1,0),w(1,0),w(2,1)]}
const normal=verifyDdrSystemCopper(fixed,[host],[],{},0),r=verifyDdrSystemCopper(fixed,[host],[],{},0,{reportSameNetContacts:true})
expect(normal.valid).toBe(true);expect(normal).not.toHaveProperty('sameNetContacts');expect(r.violations).toHaveLength(0);expect(r.sameNetContacts).toHaveLength(1)
const hit=classifyHostFixedContact(r.sameNetContacts![0],host);expect(hit.classification).toBe('unintended-interior-contact');expect(hit.hostSegmentIndices).toEqual([1]);expect(hit.fixedObjectId).toBe('barrel')
})
test('exact endpoint continuation is distinguished from interior overlap',()=>{
const host={pcb_trace_id:'h',route:[w(0,0),w(1,0)]},fixed={traceId:'saved',fresh:false,a:{x:-1,y:0},b:{x:0,y:0}},fresh={traceId:'h',fresh:true,a:{x:0,y:0},b:{x:1,y:0}}
expect(classifyHostFixedContact({aShape:fixed,bShape:fresh,layer:'inner4'},host).classification).toBe('endpoint-contact-needs-contract-validation')
expect(classifyHostFixedContact({aShape:{...fixed,a:{x:.4,y:0},b:{x:.8,y:0}},bShape:fresh,layer:'inner4'},host).classification).toBe('unintended-interior-contact')
})
test('fixed segment ending at approved exit cannot exempt distant same-segment overlap',()=>{
const host={pcb_trace_id:'h',route:[w(0,0),w(-.8,0)]},fixed={traceId:'saved',fresh:false,a:{x:-2,y:0},b:{x:0,y:0},r:.06},fresh={traceId:'h',fresh:true,a:{x:0,y:0},b:{x:-.8,y:0},r:.06}
const r=classifyHostFixedContact({aShape:fixed,bShape:fresh,layer:'inner4'},host,.25)
expect(r.contactOutsideTerminalJoin).toBe(true);expect(r.classification).toBe('unintended-interior-contact')
const straight={...fresh,b:{x:1,y:0}}
expect(classifyHostFixedContact({aShape:fixed,bShape:straight,layer:'inner4'},{...host,route:[w(0,0),w(1,0)]},.25).classification).toBe('endpoint-contact-needs-contract-validation')
})