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/merge-ddr-signal-antipads.ts

import F from '@flatten-js/core'
/** Subtract conventional signal-barrel voids using the existing polygon library. */
export function mergeDdrSignalAntipads(planes:any[],vias:Array<{x:number,y:number}>,clearanceMm=.1016) {
 if(!Number.isFinite(clearanceMm)||clearanceMm<.1016)throw Error('Antipad clearance below requiredminimum');
 const poly=(vs:any[])=>new F.Polygon(vs.map(p=>[p.x,p.y])),vertices=(f:any)=>[...f.edges].map((e:any)=>({x:e.start.x,y:e.start.y})),changes:any[]=[];
 const result=planes.map(plane=>{let region=poly(plane.brep_shape.outer_ring.vertices);for(const hole of plane.brep_shape.inner_rings){const points=hole.vertices.map((p:any)=>new F.Point(p.x,p.y));if([...poly(hole.vertices).faces][0]!.orientation()!==1)points.reverse();region.addFace(points)}for(const via of vias){const r=(.2286+clearanceMm)/Math.cos(Math.PI/64);region=F.BooleanOperations.subtract(region,poly(Array.from({length:64},(_,i)=>({x:via.x+r*Math.cos(i*Math.PI/32),y:via.y+r*Math.sin(i*Math.PI/32)}))))}const faces=[...region.faces],outers=faces.filter(f=>f.orientation()===-1),holes=faces.filter(f=>f.orientation()===1);if(outers.length!==1)throw Error('Signal antipads fragment referenceplane');const changed=holes.filter(f=>vias.some(v=>poly(vertices(f)).contains(new F.Point(v.x,v.y))));if(!changed.length)throw Error('Missing signalvoid');let minimumWebMm=Infinity;for(const hole of changed){const hp=poly(vertices(hole));const gaps=holes.filter(f=>f!==hole).map(f=>hp.distanceTo(poly(vertices(f)))[0]);const boundary=poly(vertices(outers[0]));gaps.push(...[...boundary.edges].map(e=>hp.distanceTo(e.shape)[0]));minimumWebMm=Math.min(minimumWebMm,...gaps)}if(minimumWebMm<.1524-1e-7)throw Error(`Merged void leaves ${minimumWebMm}mm web on ${plane.layer}`);changes.push({layer:plane.layer,oldHoles:plane.brep_shape.inner_rings.length,newHoles:holes.length,mergedSignalVoidCount:changed.length,outerComponents:1,minimumWebMm,voidOperation:'Existingregion minus union of new64gon barrelclearance voids; no originalvoid refilled.'});return{...plane,brep_shape:{outer_ring:{vertices:vertices(outers[0])},inner_rings:holes.map(f=>({vertices:vertices(f)}))}}});return{planes:result,changes}
}