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/check-capacitor-orientation.tsx

import { RootCircuit } from '@tscircuit/core'
import { writeFileSync, mkdirSync } from 'node:fs'
import assert from 'node:assert/strict'
import { Am3352 } from '../imports/AM3352'
import { DecouplingNetwork, decouplingCaps } from '../src/DecouplingNetwork'
const c = new RootCircuit()
c.add(<board width={34} height={34} layers={6} schematicDisabled routingDisabled allowBlindAndBuriedVias={false} minPadEdgeToPadEdgeClearance={.0762} minViaEdgeToPadEdgeClearance={.0762} minTraceToPadEdgeClearance={.0762}><Am3352/><DecouplingNetwork/></board>)
await c.renderUntilSettled()
const json = c.getCircuitJson()
const errors = json.filter(e => e.type.endsWith('_error'))
assert.equal(errors.length, 0, JSON.stringify(errors))
const caps = json.filter(e => e.type === 'source_component').filter(e => /^C\d+$/.test(e.name))
assert.equal(caps.length, decouplingCaps.length)
for (const cap of caps) {
  const pc = json.find(e => e.type === 'pcb_component' && e.source_component_id === cap.source_component_id) as any
  assert.equal(pc.layer, 'bottom')
  for (const pad of json.filter(e => e.type === 'pcb_smtpad' && e.pcb_component_id === pc.pcb_component_id) as any[]) {
    assert.ok(Math.abs(pad.x) + pad.width / 2 <= 8.5 && Math.abs(pad.y) + pad.height / 2 <= 8.5, `${cap.name} must stay within the 1 mm padded fanout boundary`)
  }
}
for (const via of json.filter(e => e.type === 'pcb_via') as any[]) {
  assert.equal(via.layers.length, 6)
  assert.equal(via.hole_diameter, .2)
  assert.equal(via.outer_diameter, .4)
}
mkdirSync('dist', { recursive: true })
writeFileSync('dist/six-layer-placed.circuit.json', JSON.stringify(json, null, 2))
console.log(`${caps.length} bottom-side capacitors within the 17 mm fanout footprint; full-depth 0.2/0.4 mm vias; placement passed`)