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/retry-ddr-dq6-after-inner6-dq1.ts

/** Exact tuned-DQ1 reservation and revalidation of an existing DQ6 template. */
import{readFileSync,writeFileSync,mkdirSync}from'node:fs';import{resolve}from'node:path';import{createHash}from'node:crypto';import{objectHash as hash}from'./improve-ddr-a9-power-launches';import{verifyDdrSystemCopper}from'./check-ddr-system-copper';import{auditCompositeHostTopology}from'./ddr-composite-routing-context';import{planDdrGroundAntipads}from'./ddr-ground-plane-antipads';
const parent=resolve('dist/ddr-twelve-dq1-connected'),out=resolve('dist/ddr-dq6-after-inner6-dq1-parent'),transition=resolve('dist/ddr-dq6-after-inner6-dq1-transition'),read=(p:string)=>JSON.parse(readFileSync(p,'utf8')),c=read(parent+'/candidate.circuit.json'),host=read(parent+'/host-bundle.json'),prior=read(parent+'/report.json'),input=read(parent+'/routing-input.json'),mp=resolve('dist/ddr-dq1-retuned/original-copper-replacements.json'),m=read(mp),change=m.replacements[0],oldPlanPath=resolve('dist/ddr-d6-outside-transition-long/transition-plan.json'),old=read(oldPlanPath),fileHash=(p:string)=>createHash('sha256').update(readFileSync(p)).digest('hex');
if(m.captureHash!==prior.captureHash||m.replacements.length!==1||hash(c.find((t:any)=>t.pcb_trace_id===change.before.pcb_trace_id))!==hash(change.before)||hash(host.traces.find((t:any)=>t.pcb_trace_id===change.before.pcb_trace_id))!==hash(change.before))throw Error('DQ1 replacement differs');
const candidate=c.map((t:any)=>t.pcb_trace_id===change.before.pcb_trace_id?change.after:t),h={...host,traces:host.traces.map((t:any)=>t.pcb_trace_id===change.before.pcb_trace_id?change.after:t)},topology=auditCompositeHostTopology(candidate,h.traces,input.connections);if(!topology.valid||h.traces.length!==12)throw Error('Tuned parent invalid');
mkdirSync(out,{recursive:true});const write=(dir:string,n:string,v:any)=>writeFileSync(resolve(dir,n),JSON.stringify(v,null,2)+'\n');write(out,'candidate.circuit.json',candidate);write(out,'host-bundle.json',h);write(out,'routing-input.json',{...input,traces:h.traces});write(out,'report.json',{...prior,candidateCircuitSha256:hash(candidate),physical:topology.physical,topology,reservedDq1Replacement:{manifest:m,manifestFileSha256:fileHash(mp),parentDirectory:parent,parentCircuitSha256:hash(c)},scope:'Isolated routing experiment parent; exact existing DQ1 proposal reserved. No accepted-board mutation.'});
if(old.accepted.length!==1||hash(input.connections.find((t:any)=>t.name===old.connection.name))!==hash(old.connection))throw Error('DQ6 template endpoint contract differs');const t=old.accepted[0],planes=planDdrGroundAntipads(candidate.filter((e:any)=>e.type==='pcb_copper_pour'),[{...t.via,net:'DDR_D6'}]),ids=new Set(h.traces.map((t:any)=>t.pcb_trace_id)),fixed=candidate.filter((e:any)=>e.type!=='pcb_copper_pour'&&!ids.has(e.pcb_trace_id)),physical=verifyDdrSystemCopper([...fixed,...planes.planes],[...h.traces,t.trace],input.connections,{},50,{reportSameNetContacts:true});mkdirSync(transition,{recursive:true});write(transition,'physical-report.json',physical);if(physical.errors.length||physical.violations.length||!physical.angles.valid||physical.joinedBends.length)throw Error('Existing transition fails actual changed-parent geometry');
const inputHashes=Object.fromEntries(['candidate.circuit.json','host-bundle.json','routing-input.json','report.json'].map(n=>[resolve(out,n),fileHash(resolve(out,n))]));write(transition,'planes.json',planes.planes);write(transition,'transition-plan.json',{...old,parentCircuitSha256:hash(candidate),hostTracesSha256:hash(h.traces),inputHashes,accepted:[{...t,addedAntipads:planes.added}],priorTemplate:{path:oldPlanPath,fileSha256:fileHash(oldPlanPath)},scope:'Exact prior DQ6 transition, revalidated against current12host board plus exact proposed DQ1 tuning and regenerated current-plane antipads.'});console.log(JSON.stringify({parent:out,transition,hosts:h.traces.length,via:t.via,errors:physical.errors.length,violations:physical.violations.length}))