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/build.tsx
import{RootCircuit}from'@tscircuit/core'
import{writeFileSync,mkdirSync}from'node:fs'
import assert from 'node:assert/strict'
import {assertRenderedProfileAngles} from './check-profile-junctions'
import Sample from '../src/ProfilePreview'
import {decouplingCaps} from '../src/DecouplingNetwork'
const fixedTraceCount=decouplingCaps.length*2+decouplingCaps.filter(c=>c.ball).length+5
import {assertLayoutProfile, LAYOUT_PROFILES, getAM3352Layers} from '../src/profiles'
import {getAM3352TracePaths} from '../src/saved-paths'
const profile=process.argv[2]??'native'
assertLayoutProfile(profile)
const settings=LAYOUT_PROFILES[profile]
const savedPaths=getAM3352TracePaths(profile)
const c=new RootCircuit()
c.add(<Sample layoutProfile={profile}/>);await c.renderUntilSettled()
const json=c.getCircuitJson()
const errors=json.filter(e=>e.type.endsWith('_error'))
assert.equal(errors.length,0,JSON.stringify(errors))
assertRenderedProfileAngles(json)
assert.equal(json.filter(e=>e.type==='pcb_trace').length,settings.savedPathCount+settings.signalExitCount+fixedTraceCount)
assert.equal(json.filter(e=>e.type==='pcb_breakout_point').length,settings.savedPathCount)
for(const via of json.filter(e=>e.type==='pcb_via')) {
assert.deepEqual(via.layers,getAM3352Layers(profile))
const saved=savedPaths.flatMap(path=>path.route).find(point=>point.route_type==='via'&&Math.hypot(point.x-via.x,point.y-via.y)<1e-6)
if(saved?.route_type==='via') {
assert.equal(via.hole_diameter,saved.via_hole_diameter)
assert.equal(via.outer_diameter,saved.via_diameter)
} else { // Existing fixed capacitor and supply network uses 0.4/0.2 mm through vias.
assert.equal(via.hole_diameter,.2); assert.equal(via.outer_diameter,.4)
}
}
mkdirSync('dist/index',{recursive:true})
writeFileSync('dist/index/circuit.json',JSON.stringify(json,null,2)+'\n')
writeFileSync(`src/generated/${profile}.circuit.json`,JSON.stringify(json,null,2)+'\n')
console.log(`Built ${profile} saved fanout: ${settings.savedPathCount} paths, ${settings.signalExitCount} edge contacts, ${fixedTraceCount} fixed decoupling traces; no errors`)