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/render.tsx
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
import { Resvg } from "@resvg/resvg-js"
import { readFileSync,writeFileSync,mkdirSync } from "node:fs"
const json=JSON.parse(readFileSync('src/generated/native.circuit.json','utf8'))
mkdirSync('previews',{recursive:true})
for(const layer of ['top','inner1','inner2','inner3','inner4','bottom'] as const){
const svg=convertCircuitJsonToPcbSvg(json.filter((e:any)=>!e.type.startsWith("pcb_fabrication_note")),{layer,width:1400,height:1400,viewport:{minX:-12,maxX:12,minY:-12,maxY:12},shouldDrawRatsNest:false})
writeFileSync(`previews/${layer}.svg`,svg)
writeFileSync(`previews/${layer}.png`,new Resvg(svg).render().asPng())
}
const labels={top:"TOP · I/O supply and outer escapes",inner1:"INNER1 · Ground reference",inner2:"INNER2 · DDR supply and differential pairs",inner3:"INNER3 · Core supply and signal escapes",inner4:"INNER4 · MPU supply and signal escapes",bottom:"BOTTOM · 1.8 V supply and 82 decoupling capacitors"}
const layers=["top","inner1","inner2","inner3","inner4","bottom"] as const
const combined=`<svg xmlns="http://www.w3.org/2000/svg" width="1600" height="2560" viewBox="0 0 1600 2560"><rect width="1600" height="2560" fill="#10151c"/><text x="32" y="40" font-family="sans-serif" font-size="28" fill="white">AM3352 · saved fanout · 1 mm package padding</text><text x="32" y="70" font-family="sans-serif" font-size="18" fill="#a8bacb">313 cached paths · 17 × 17 mm boundary · 5 pairs, ≤0.1 mm skew · six layers · through-hole vias</text>${layers.map((layer,i)=>{const x=(i%2)*800,y=95+Math.floor(i/2)*820;return `<text x="${x+20}" y="${y+22}" font-family="sans-serif" font-size="19" fill="white">${labels[layer]}</text>`+readFileSync(`previews/${layer}.svg`,"utf8").replace(/<svg /,`<svg viewBox="0 0 1400 1400" x="${x+10}" y="${y+35}" `).replace(/width="1400"/,`width="780"`).replace(/height="1400"/,`height="780"`) }).join("")}</svg>`
writeFileSync('previews/native.svg',combined)
writeFileSync('previews/native.png',new Resvg(combined).render().asPng())
writeFileSync("previews/pcb.png",readFileSync("previews/top.png"))