0hmX/TMDS62LEVM
This code defines the physical layout and component placement for a TI AM62L evaluation module, including mechanical and population components, without routing.
- Version
- 1.0.2
- License
- unset
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone 0hmX/TMDS62LEVM # download the package files into ./TMDS62LEVM
tsci add 0hmX/TMDS62LEVM # add it to your project as @tsci/0hmX.TMDS62LEVMIn a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.
src/generated/altiumFootprintMap.tsx
import type { ReactElement } from "react"
export type GeneratedFootprintKind =
| "passive"
| "testpoint"
| "bga"
| "perimeter-ic"
| "connector"
| "mechanical"
export interface AltiumFootprintSpec {
/** Copper/silkscreen footprint suitable for a chip's `footprint` prop. */
footprint: string | ReactElement
/** Nominal package body, excluding pads and courtyard, in millimetres. */
bodyWidth: number
bodyHeight: number
/** Number of electrical lands represented by the generated footprint. */
pinCount: number
kind: GeneratedFootprintKind
}
const MIL_TO_MM = 0.0254
const standardBody: Record<string, readonly [number, number]> = {
"0201": [0.6, 0.3],
"0402": [1.0, 0.5],
"0603": [1.6, 0.8],
"0805": [2.0, 1.25],
"1206": [3.2, 1.6],
"1210": [3.2, 2.5],
}
/**
* Mechanical bodies that are not encoded in the Altium package name. Values
* come from the component outlines in TI's PROC181E1-1 IDF export.
*/
const bodyOverrides: Record<string, readonly [number, number]> = {
CON_RJ45_14_LPJG16314A4NL_S_R_T_13_6: [21.49, 25.68],
CON_MUSBB5_629105150521_S_R_S_2_7: [11.2, 10.52],
CON_USBC24_2012670_S_R_S_3_9: [13.17, 11.77],
CON_USBA4_629104151_S_R_S_7_4: [17.07, 16.95],
CON_SD9_MEM2051_00_195_00_S_R_S_2_1: [14.22, 15.49],
CON_AV4_SJ_43514_SMT_S_R_S_5_1: [6.86, 17.02],
CON_HDMI19_DC04S019JA1R600_S_R_S_6_3: [16.26, 10.41],
CON_MINIPCI75_2199119_4_S_R_S_3_2_2244: [22.1, 7.87],
CON_FLEX2X11_5019512230_S_S_S_4_6: [13.72, 4.57],
CON_BOX3X1_501331_0307_P_S_S_5_4: [5.08, 3.05],
HDR_1X2_61300211121_S_T_8_6: [5.33, 2.54],
HDR_1X4_TSM_104_02_SV_S_S_12_4: [10.16, 2.54],
HDR_2X5_PEC05DAAN_S_T_8_6: [14.47, 8.0],
HDR_2X10_FTR_110_51_D_06_S_S_8_7: [12.7, 5.08],
HDR_2X15_PEC15DAAN_S_T_8_6: [38.61, 5.08],
HDR_5X2_100_S_T_8_6: [12.7, 5.08],
HDR_5X3_TSM_105_01_T_TM_S_S_9_9: [12.7, 7.62],
HDR_2X5_54202_T0805ALF_P_S_S_9_9: [12.7, 4.83],
}
const normalise = (name: string) => name.replace(/[^A-Z0-9]+/gi, "_")
const round = (value: number) => Math.round(value * 1000) / 1000
const dimensionsEncodedAsMil = (
name: string,
): readonly [number, number] | undefined => {
const matches = [...name.matchAll(/(?:^|_)(\d{2,3})X(\d{2,3})(?=_|$)/gi)]
const match = matches[matches.length - 1]
if (!match) return undefined
return [round(Number(match[1]) * MIL_TO_MM), round(Number(match[2]) * MIL_TO_MM)]
}
const getBody = (name: string): readonly [number, number] => {
const canonical = normalise(name)
const exact = bodyOverrides[canonical]
if (exact) return exact
if (canonical.startsWith("FIDUCIAL")) return [0.508, 0.508]
if (canonical.startsWith("TP_CIR17")) return [0.432, 0.432]
if (canonical.startsWith("TP20")) return [0.508, 0.508]
if (canonical.startsWith("TP30")) return [0.762, 0.762]
if (canonical.startsWith("TP40")) return [1.016, 1.016]
if (canonical.startsWith("TP_40X65")) return [1.651, 1.016]
const metricCode = canonical.match(/(0201|0402|0603|0805|1206|1210)/)?.[1]
if (metricCode) return standardBody[metricCode]
return dimensionsEncodedAsMil(canonical) ?? [2.5, 2.5]
}
const pitchFromAltiumCode = (name: string): number => {
if (name.includes("15-74")) return 0.4
if (name.includes("19-68")) return 0.5
if (name.includes("25-59")) return 0.65
if (name.includes("39-37")) return 1.0
if (name.match(/(?:^|_)0-4(?:_|$)/)) return 0.4
if (name.match(/(?:^|_)0-5(?:_|$)/)) return 0.5
if (name.match(/(?:^|_)0-6(?:_|$)/)) return 0.6
if (name.match(/(?:^|_)0-7(?:_|$)/)) return 0.7
if (name.match(/(?:^|_)0-8(?:_|$)/)) return 0.8
if (name.match(/(?:^|_)0-9(?:_|$)/)) return 0.9
if (name.match(/(?:^|_)1(?:_|$)/)) return 1.0
return 0.5
}
const getPinCount = (name: string): number => {
const canonical = normalise(name)
if (/^FIDUCIAL/.test(canonical)) return 0
if (/^TP(?:_|\d)/.test(canonical)) return 1
if (/^RESA_/.test(canonical)) return 8
if (/^(?:RES|CAP|CAPAE|CAPT|IND(?:_|\d)|DIO|LED|EMIFIL_BLM)/.test(canonical)) return 2
if (/^EMIFIL_NFM/.test(canonical)) return 3
if (/^IND4_/.test(canonical)) return 4
const header = canonical.match(/^HDR_(\d+)X(\d+)/)
if (header) return Number(header[1]) * Number(header[2])
const flex = canonical.match(/^CON_FLEX(\d+)X(\d+)/)
if (flex) return Number(flex[1]) * Number(flex[2])
const connector = canonical.match(/^CON_(?:RJ45_|MUSBB|USBC|USBA|SD|AV|HDMI)(\d+)/)
if (connector) return Number(connector[1])
if (canonical.startsWith("CON_MINIPCI75")) return 75
if (canonical.startsWith("CON_BOX3X1")) return 3
const familyCount = canonical.match(
/^(?:TFBGA|TPBGA|VFBGA|DSBGA|BGA|WQFN|VQFNHR|VQFN|UQFN|QFN|TQFP|LQFP|TVSOP|TSSOP|VSSOP|SSOP|MSOP|SOIC|X2SON|VSONHR|VSON|WSON|SON|UDFN|SOT553|SOT23|SC70|XTAL|OSC|POT|SW)(\d+)/,
)
return familyCount ? Number(familyCount[1]) : 2
}
const makePassiveFootprint = (
bodyWidth: number,
bodyHeight: number,
): ReactElement => {
const padWidth = Math.max(0.28, Math.min(bodyWidth * 0.46, 1.5))
const padHeight = Math.max(0.24, bodyHeight * 1.05)
const padX = Math.max(bodyWidth * 0.36, padWidth * 0.55)
return (
<footprint>
<smtpad portHints={["1"]} pcbX={-padX} pcbY={0} width={padWidth} height={padHeight} shape="rect" />
<smtpad portHints={["2"]} pcbX={padX} pcbY={0} width={padWidth} height={padHeight} shape="rect" />
<silkscreenrect pcbX={0} pcbY={0} width={bodyWidth} height={bodyHeight} strokeWidth={0.08} />
</footprint>
)
}
const makeTestpointFootprint = (diameter: number): ReactElement => (
<footprint>
<smtpad portHints={["1"]} pcbX={0} pcbY={0} radius={diameter / 2} shape="circle" />
</footprint>
)
const makeBgaFootprint = (
pinCount: number,
bodyWidth: number,
bodyHeight: number,
pitch: number,
): ReactElement => {
const aspect = bodyWidth / bodyHeight
const columns = Math.max(2, Math.ceil(Math.sqrt(pinCount * aspect)))
const rows = Math.max(2, Math.ceil(pinCount / columns))
const usablePitch = Math.min(
pitch,
(bodyWidth - 0.4) / Math.max(1, columns - 1),
(bodyHeight - 0.4) / Math.max(1, rows - 1),
)
const padDiameter = Math.max(0.18, Math.min(usablePitch * 0.62, 0.5))
const pads = Array.from({ length: pinCount }, (_, index) => {
const column = index % columns
const row = Math.floor(index / columns)
return (
<smtpad
portHints={[String(index + 1)]}
pcbX={(column - (columns - 1) / 2) * usablePitch}
pcbY={((rows - 1) / 2 - row) * usablePitch}
radius={padDiameter / 2}
shape="circle"
/>
)
})
return (
<footprint>
{pads}
<silkscreenrect pcbX={0} pcbY={0} width={bodyWidth} height={bodyHeight} strokeWidth={0.1} />
</footprint>
)
}
const makePerimeterFootprint = (
pinCount: number,
bodyWidth: number,
bodyHeight: number,
pitch: number,
): ReactElement => {
const horizontalCount = Math.floor(pinCount / 4)
const verticalCount = Math.floor((pinCount - horizontalCount * 2) / 2)
const counts = [verticalCount, horizontalCount, verticalCount, pinCount - verticalCount * 2 - horizontalCount]
let pin = 1
const pads: ReactElement[] = []
for (let side = 0; side < 4; side += 1) {
const count = counts[side]
for (let offset = 0; offset < count; offset += 1) {
const centered = offset - (count - 1) / 2
const vertical = side === 0 || side === 2
const x = vertical ? (side === 0 ? -bodyWidth / 2 - 0.25 : bodyWidth / 2 + 0.25) : centered * pitch
const y = vertical ? -centered * pitch : side === 1 ? bodyHeight / 2 + 0.25 : -bodyHeight / 2 - 0.25
pads.push(
<smtpad
portHints={[String(pin)]}
pcbX={x}
pcbY={y}
width={vertical ? 0.7 : 0.32}
height={vertical ? 0.32 : 0.7}
shape="rect"
/>,
)
pin += 1
}
}
return (
<footprint>
{pads}
<silkscreenrect pcbX={0} pcbY={0} width={bodyWidth} height={bodyHeight} strokeWidth={0.1} />
</footprint>
)
}
const makeConnectorFootprint = (
pinCount: number,
bodyWidth: number,
bodyHeight: number,
throughHole: boolean,
): ReactElement => {
const rows = pinCount > 1 ? 2 : 1
const columns = Math.ceil(pinCount / rows)
const pitchX = Math.min(2.54, (bodyWidth - 1) / Math.max(1, columns - 1))
const pitchY = rows === 1 ? 0 : Math.min(2.54, Math.max(0.8, bodyHeight * 0.45))
const pads = Array.from({ length: pinCount }, (_, index) => {
const row = Math.floor(index / columns)
const column = index % columns
const common = {
portHints: [String(index + 1)],
pcbX: (column - (columns - 1) / 2) * pitchX,
pcbY: ((rows - 1) / 2 - row) * pitchY,
}
return throughHole ? (
<platedhole {...common} shape="circle" holeDiameter={1.0} outerDiameter={1.7} />
) : (
<smtpad {...common} shape="rect" width={0.45} height={1.2} />
)
})
return (
<footprint>
{pads}
<silkscreenrect pcbX={0} pcbY={0} width={bodyWidth} height={bodyHeight} strokeWidth={0.12} />
</footprint>
)
}
/**
* Converts TI's Altium footprint name into compact, placement-safe TSCircuit
* geometry. It intentionally models copper and package dimensions, but not the
* production netlist; callers should supply pin labels/no-connects as needed.
*/
export const getAltiumFootprintSpec = (name: string): AltiumFootprintSpec => {
const canonical = normalise(name)
const [bodyWidth, bodyHeight] = getBody(canonical)
const pinCount = getPinCount(canonical)
const pitch = pitchFromAltiumCode(canonical)
if (/^FIDUCIAL/.test(canonical)) {
return {
footprint: makeTestpointFootprint(Math.min(bodyWidth, bodyHeight)),
bodyWidth,
bodyHeight,
pinCount,
kind: "mechanical",
}
}
if (/^TP(?:_|\d)/.test(canonical)) {
return {
footprint: makeTestpointFootprint(Math.min(bodyWidth, bodyHeight)),
bodyWidth,
bodyHeight,
pinCount,
kind: "testpoint",
}
}
if (/^(?:RES|CAP|CAPAE|CAPT|IND(?:_|\d)|DIO|LED|EMIFIL)/.test(canonical)) {
return {
footprint: makePassiveFootprint(bodyWidth, bodyHeight),
bodyWidth,
bodyHeight,
pinCount,
kind: "passive",
}
}
if (/^(?:TFBGA|TPBGA|VFBGA|DSBGA|BGA)/.test(canonical)) {
return {
footprint: makeBgaFootprint(pinCount, bodyWidth, bodyHeight, pitch),
bodyWidth,
bodyHeight,
pinCount,
kind: "bga",
}
}
if (/^(?:CON|HDR)_/.test(canonical)) {
const throughHole = /^HDR_/.test(canonical) && !canonical.includes("_S_S_")
return {
footprint: makeConnectorFootprint(pinCount, bodyWidth, bodyHeight, throughHole),
bodyWidth,
bodyHeight,
pinCount,
kind: "connector",
}
}
return {
footprint: makePerimeterFootprint(pinCount, bodyWidth, bodyHeight, pitch),
bodyWidth,
bodyHeight,
pinCount,
kind: "perimeter-ic",
}
}