seveibar/am3352-ram-dogbone-and-single-layer-route-test
AM3352BZCZ100 processor connected to a W631GG6MB-12 DDR3 memory chip through a routed, length-matched 16-bit DDR interface with clock/data-strobe pairs and control/address signals.
- Version
- 0.0.9
- License
- unset
- Stars
- 0
scripts/score-smoothing.ts
import fs from 'node:fs'
import path from 'node:path'
import assert from 'node:assert/strict'
import {quality} from '../routing/smooth'
import {length} from '../routing/single-layer'
const root=path.resolve(import.meta.dir,'..')
const read=(phase:number)=>JSON.parse(fs.readFileSync(path.join(root,`dist/autorouter-debug/phase-${phase}.output.traces.json`),'utf8'))
const before=read(1),after=read(2)
const parts=(t:any)=>{const first=t.route.findIndex((p:any)=>p.route_type==='via'),last=t.route.findLastIndex((p:any)=>p.route_type==='via');return{prefix:t.route.slice(0,first+1),suffix:t.route.slice(last),points:t.route.slice(first+1,last)}}
const routes=(ts:any[])=>ts.map(t=>({name:t.source_trace_id,layer:parts(t).points[0].layer,points:parts(t).points}))
assert.equal(before.length,47);assert.equal(after.length,47)
let maximumLengthChangeMm=0
for(const t of after){const original=before.find((b:any)=>b.source_trace_id===t.source_trace_id);assert(original)
const a=parts(original),b=parts(t)
assert.deepEqual(b.prefix,a.prefix);assert.deepEqual(b.suffix,a.suffix)
assert(b.points.every((p:any)=>p.route_type==='wire'&&p.layer===a.points[0].layer&&p.width===.1))
const change=Math.abs(length(a.points)-length(b.points));maximumLengthChangeMm=Math.max(change,maximumLengthChangeMm);assert(change<=.00400001)
}
const a=quality(routes(before)),b=quality(routes(after));assert(b.penalty<a.penalty)
const report={criteriaVersion:1,before:a,after:b,penaltyReductionPercent:100*(1-b.penalty/a.penalty),maximumLengthChangeMm,preservedSignals:47,preservedDogboneVias:94,newRoutingVias:0}
fs.writeFileSync(path.join(root,'validation/smoothing-score.json'),JSON.stringify(report,null,2)+'\n')
console.log(JSON.stringify(report,null,2))