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-ram-power-drops.test.ts

import{test,expect}from'bun:test'
import{truncatePowerStubAtVia,makePowerDropDogbone,validatePowerDropResume}from'../scripts/plan-ddr-ram-power-drops'
const wire=(x:number,y=0)=>({route_type:'wire',x,y,width:.12,layer:'top'})
test('early drop preserves pad and trims tail to qualified through via',()=>{
 const route=[{...wire(0),start_pcb_port_id:'pad'},wire(2)],before=structuredClone(route),result=truncatePowerStubAtVia(route,.55,'inner3')
 expect(route).toEqual(before);expect(result[0]).toEqual(route[0]);expect(result[1]).toMatchObject({x:.55,y:0,layer:'top'})
 expect(result[2]).toMatchObject({route_type:'via',x:.55,y:0,from_layer:'top',to_layer:'inner3',via_diameter:.4572,via_hole_diameter:.254})
 expect(result).toHaveLength(3)
})
test('drop planner rejects overlong, nonstraight, and already transitioned launches',()=>{
 expect(()=>truncatePowerStubAtVia([wire(0),wire(2)],1.525,'inner3')).toThrow()
 expect(()=>truncatePowerStubAtVia([wire(0),wire(1,1),wire(2)],.6,'inner1')).toThrow()
 expect(()=>truncatePowerStubAtVia([wire(0),{route_type:'via',x:1,y:0}],.6,'inner1')).toThrow()
})

import{auditRouteAngles}from'../scripts/check-route-angles'
test('power dogbones preserve pad, permit45turns only and enforce total launch budget',()=>{
 for(const first of[false,true]){
  const route=makePowerDropDogbone([wire(0),wire(2)],.5,.4,'inner1',first)
  expect(auditRouteAngles([{route}]).valid).toBe(true)
  expect(route[0]).toEqual(wire(0))
  expect(route.at(-1)).toMatchObject({x:.5,y:.4,from_layer:'top',to_layer:'inner1'})
 }
 expect(()=>makePowerDropDogbone([wire(0),wire(2)],1.3,.7,'inner1')).toThrow()
 expect(()=>makePowerDropDogbone([wire(0),wire(2)],.2,.1,'inner1')).toThrow()
})

test('power-drop resume requires exact capture, host, capacitor and plane provenance',()=>{
 const provenance={captureHash:'capture',hostTracesSha256:'host',capCircuitSha256:'caps',basePlanesSha256:'planes',searchContract:'v1'},checkpoint={provenance,accepted:[{pcb_trace_id:'one'}],planes:[],dogboneSearch:[]}
 expect(validatePowerDropResume(checkpoint,provenance)).toBe(checkpoint)
 for(const key of Object.keys(provenance))expect(()=>validatePowerDropResume({...checkpoint,provenance:{...provenance,[key]:'changed'}},provenance)).toThrow()
 expect(()=>validatePowerDropResume({...checkpoint,accepted:[{pcb_trace_id:'one'},{pcb_trace_id:'one'}]},provenance)).toThrow()
})