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

scripts/check-preview-pours.ts

import assert from 'node:assert/strict'
import {readFileSync} from 'node:fs'
import {AM3352_PLANE_DROPS} from '../src/layout'
import {AM3352_PINS} from '../src/pin-map'
import {FIXED_SUPPLY_DROPS} from '../src/fixed-supply-drops'
import {decouplingCaps} from '../src/DecouplingNetwork'
import {getAM3352TracePaths} from '../src/saved-paths'
import{assertLayoutProfile,getAM3352PowerPlanes}from'../src/profiles'
const profile=process.argv[2]??'native'
assertLayoutProfile(profile)
const powerPlanes=getAM3352PowerPlanes(profile)
const am3352TracePaths=getAM3352TracePaths(profile)
const json=JSON.parse(readFileSync(`src/generated/${profile}.circuit.json`,'utf8'))
const inRing=(x:number,y:number,vertices:{x:number,y:number}[])=>{
 let inside=false
 for(let i=0,j=vertices.length-1;i<vertices.length;j=i++){
  const a=vertices[i]!,b=vertices[j]!
  if((a.y>y)!==(b.y>y)&&x<(b.x-a.x)*(y-a.y)/(b.y-a.y)+a.x)inside=!inside
 }
 return inside
}
function touchesPour(x:number,y:number,netName:string){
 const net=json.find((e:any)=>e.type==='source_net'&&e.name===netName)
 const plane=powerPlanes.find(p=>p.netName===netName)!
 const pours=json.filter((e:any)=>e.type==='pcb_copper_pour'&&e.source_net_id===net.source_net_id&&e.layer===plane.layer)
 return Array.from({length:32},(_,i)=>i*Math.PI/16).some(a=>{
  const px=x+.15*Math.cos(a),py=y+.15*Math.sin(a)
  return pours.some((p:any)=>inRing(px,py,p.brep_shape.outer_ring.vertices)&&!p.brep_shape.inner_rings.some((r:any)=>inRing(px,py,r.vertices)))
 })
}
for(const drop of AM3352_PLANE_DROPS){
 const ball=AM3352_PINS[drop.pinNumber-1]!.ballName
 const fixed=FIXED_SUPPLY_DROPS.find(d=>d.ball===ball)
 if(fixed){assert.ok(touchesPour(fixed.via[0]!,fixed.via[1]!,drop.netName),`${ball} fixed supply via misses its pour`);continue}
 const path=am3352TracePaths.find(p=>p.connection===`U1.${ball}`)!
 const vias=path.route.filter(p=>p.route_type==='via')
 assert.ok(vias.some(v=>touchesPour(v.x,v.y,drop.netName)),`${ball} has no physical contact with ${drop.netName} pour`)
}
for(const cap of decouplingCaps){
 assert.ok(touchesPour(cap.ground[0]!,cap.ground[1]!,'GND'),`${cap.name} ground via misses the ground pour`)
 if(!cap.ball)assert.ok(touchesPour(cap.power[0]!,cap.power[1]!,cap.net),`${cap.name} supply via misses its rail pour`)
}
console.log('All 117 power/ground drops and capacitor rail vias physically contact their assigned pours')