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-ddr-capture-copper.ts
import {readFileSync,writeFileSync} from 'node:fs'
import {resolve} from 'node:path'
import {verifyDdrCapture} from './ddr-capture-provenance'
import {verifyDdrSystemCopper} from './check-ddr-system-copper'
const [directory,candidatePath,reportPath]=process.argv.slice(2)
if(!directory||!candidatePath||!reportPath)throw Error('Usage: capture-directory candidate-bundle.json report.json')
const read=(file:string)=>JSON.parse(readFileSync(file,'utf8'))
const {captureHash,snapshot}=verifyDdrCapture(directory)
const candidate=read(candidatePath),input=read(resolve(directory,'merged-routing-input.json'))
if(candidate.captureHash!==captureHash||input.__ddrCaptureHash!==captureHash)throw Error('Candidate or merged input belongs to another capture')
if(!['virtual','physical'].includes(candidate.layerSpace)||!Array.isArray(candidate.traces))throw Error('Candidate must declare its layer space and traces')
const map:Record<string,string>={top:'top',inner1:'inner2',inner2:'inner4',bottom:'inner6'}
const layer=(name:string)=>{const result=candidate.layerSpace==='virtual'?map[name]:name;if(!['top','inner2','inner4','inner6'].includes(result!))throw Error(`Illegal host signal layer ${name}`);return result}
const traces=candidate.traces.map((t:any,i:number)=>({...t,pcb_trace_id:t.pcb_trace_id??`host_${i}`,route:t.route.map((p:any)=>p.route_type==='wire'?{...p,layer:layer(p.layer)}:p.route_type==='via'?{...p,from_layer:layer(p.from_layer),to_layer:layer(p.to_layer),via_diameter:p.via_diameter??.4572,via_hole_diameter:p.via_hole_diameter??.254}:p)}))
const report=verifyDdrSystemCopper(read(resolve(directory,'unrouted.circuit.json')),[...(snapshot.hostProfiles?[]:read(resolve(directory,'corridor-leads.json'))),...traces],input.connections)
writeFileSync(reportPath,JSON.stringify({captureHash,...report},null,2)+'\n')
console.log(JSON.stringify({captureHash,valid:report.valid,errors:report.errors.length,clearanceViolations:report.violations.length,angleViolations:report.angles.violations.length,joinedBends:report.joinedBends.length,connectedNets:report.connectivity.filter(c=>c.connected).length,totalNets:report.netCount}))
if(!report.valid)process.exitCode=1