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/standardize-ddr-host-width.ts

/** Apply a nominal host width only after checking all uncropped physical copper. */
import {readFileSync,mkdirSync,writeFileSync} from 'node:fs'
import {resolve} from 'node:path'
import {createHash} from 'node:crypto'
import {verifyDdrCapture} from './ddr-capture-provenance'
import {verifyDdrSystemCopper} from './check-ddr-system-copper'
const [directory,source,output]=process.argv.slice(2)
if(!directory||!source||!output)throw Error('Usage: capture-directory physical-bundle output-directory')
const {captureHash,snapshot}=verifyDdrCapture(directory)
if(!snapshot.hostProfiles)throw Error('Requires authoritative host-profile capture')
const text=readFileSync(source,'utf8'),bundle=JSON.parse(text)
if(bundle.captureHash!==captureHash||bundle.layerSpace!=='physical')throw Error('Mismatched physical bundle')
const read=(p:string)=>JSON.parse(readFileSync(resolve(directory,p),'utf8'))
const traces=structuredClone(bundle.traces)
for(const trace of traces)for(const point of trace.route)if(point.route_type==='wire')point.width=.12
const report=verifyDdrSystemCopper(read('unrouted.circuit.json'),traces,read('merged-routing-input.json').connections)
if(report.errors.length||report.violations.length||!report.angles.valid||report.joinedBends.length)throw Error('Nominal width fails full physical checks; source preserved')
mkdirSync(output,{recursive:true})
const evidence={source:resolve(source),sourceSha256:createHash('sha256').update(text).digest('hex'),widthMm:.12}
writeFileSync(resolve(output,'candidate.physical.json'),JSON.stringify({captureHash,layerSpace:'physical',widthChange:evidence,traces},null,2)+'\n')
writeFileSync(resolve(output,'physical-report.json'),JSON.stringify({captureHash,widthChange:evidence,...report},null,2)+'\n')
console.log(JSON.stringify({connectedNets:report.connectivity.filter(c=>c.connected).length,netCount:report.netCount,geometryPass:true,complete:report.valid}))