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/prepare-ddr-d9-host-parent.ts

/** Exact local D9 escape replay on the current fourteen-host parent. */
import{readFileSync,writeFileSync,mkdirSync,copyFileSync}from'node:fs';import{resolve}from'node:path';import{objectHash as hash}from'./improve-ddr-a9-power-launches';import{applyFacingExitReplacements}from'./ddr-facing-context';import{auditCompositeHostTopology}from'./ddr-composite-routing-context';import{auditDdrLocalEscapeContacts}from'./audit-ddr-local-escape-contacts';import{verifyDdrSystemCopper,auditDdrTraceJunctions}from'./check-ddr-system-copper';import{auditRouteAngles}from'./check-route-angles';
const parent=resolve('dist/ddr-fourteen-shorter-strobes'),local=resolve('dist/ddr-twelve-dm1-d9-facing'),out=resolve('dist/ddr-fourteen-d9-facing'),read=(p:string)=>JSON.parse(readFileSync(p,'utf8')),c=read(parent+'/candidate.circuit.json'),h=read(parent+'/host-bundle.json'),prior=read(parent+'/report.json'),input=read(parent+'/routing-input.json'),changes=read(local+'/replacements.json'),candidate=applyFacingExitReplacements(c,changes),connections=input.connections.map((n:any)=>({...n,pointsToConnect:n.pointsToConnect.map((p:any)=>p.pointId===changes.breakoutPoints[0].before.pcb_breakout_point_id?{...p,x:changes.breakoutPoints[0].after.x,y:changes.breakoutPoints[0].after.y,layer:changes.breakoutPoints[0].after.layer}:p)})),topology=auditCompositeHostTopology(candidate,h.traces,connections),fresh=[...h.traces,changes.traces[0].after],ids=new Set(fresh.map((t:any)=>t.pcb_trace_id)),physical=verifyDdrSystemCopper(candidate.filter((e:any)=>!ids.has(e.pcb_trace_id)),fresh,connections,{}),localContacts=auditDdrLocalEscapeContacts(candidate,changes.traces[0].after,connections),angles=auditRouteAngles(candidate.filter((e:any)=>e.type==='pcb_trace')),joins=auditDdrTraceJunctions(candidate,connections);if(hash(c)!==prior.candidateCircuitSha256||h.traces.length!==14||!topology.valid||!localContacts.valid||!angles.valid||!joins.valid||physical.errors.length||physical.violations.length)throw Error('D9replayinvalid');
mkdirSync(out,{recursive:true});const write=(n:string,v:any)=>writeFileSync(out+'/'+n,JSON.stringify(v,null,2)+'\n'),manifest={captureHash:prior.captureHash,parentDirectory:parent,parentCircuitSha256:hash(c),candidateCircuitSha256:hash(candidate),replacements:[...changes.traces,...changes.breakoutPoints].map((r:any)=>({...r,beforeSha256:hash(r.before),afterSha256:hash(r.after)}))};write('replacements.json',changes);write('candidate.circuit.json',candidate);write('host-bundle.json',h);write('routing-input.json',{...input,traces:h.traces,connections});write('original-copper-replacements.json',manifest);write('report.json',{...prior,candidateCircuitSha256:hash(candidate),hostTracesSha256:hash(h.traces),originalCopperReplacementsSha256:hash(manifest),physical,topology,localContacts,allAngles:angles,allJunctions:joins,scope:'Isolated14host board withsource-ownedD9localescape override; D9hostnotyetconnected.'});for(const n of['ram-byte1-facing-progress.trace-paths.json'])copyFileSync(local+'/'+n,out+'/'+n);for(const n of['ram-byte0-facing-progress.trace-paths.json','source-provenance.json'])copyFileSync(parent+'/'+n,out+'/'+n);for(const[n,d]of[['exit-contract.json',parent],['ram-byte1-exit-contract.json',local]]){const ct=read(d+'/'+n);write(n,{...ct,candidateCircuitSha256:hash(candidate)})}console.log(JSON.stringify({out,hosts:14,candidateSha:hash(candidate)}))