abse/am3354-cm4-module

A six-layer AM3354-based compute module with DDR3L, dual 100-pin CM4 connectors, PMIC/buck power regulation, clocks, boot/pull-up support, USB/SD/GPIO interfaces, dense decoupling, and fully routed/verified multilayer copper.

Version
0.1.4
License
unset
Stars
0

Use with the tscircuit CLI

tsci is the tscircuit CLI. Install it with npm install -g tscircuit.

tsci clone abse/am3354-cm4-module  # download the package files into ./am3354-cm4-module
tsci add abse/am3354-cm4-module    # add it to your project as @tsci/abse.am3354-cm4-module

In 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.

source/irdrop.py

# DC drop of each supply over all four inner layers at once (the copper `planes.ts` builds: fills and skeletons on
# every layer, joined at the net's vias; 0.1 mm plated barrel through a 1.0 mm board, 25 um plating). Adapted from
# module/irdrop3d.py: here the supplies start at the module's own regulators (inductor output vias held at 0 V) and the
# load is drawn at the chips' balls and, for 3.3 V / 1.8 V, at the CM4 pins that feed the carrier.
# Usage: DUMP=1 bun planes.ts; python3 irdrop.py [CARRIER_A] (current the carrier draws on 3.3 V and on 1.8 V, default 0.6
# A each, the CM4's own limit). KMAP=prefix writes a current-density picture per net and layer.
import json, base64, os, re, sys, numpy as np
import scipy.sparse as sp, scipy.sparse.linalg as spl
from scipy.sparse import csgraph
d = os.path.dirname(os.path.abspath(__file__))
R = json.load(open(d + '/planes-raster.json')); plan = json.load(open(d + '/plan.json'))
NX, NY, P, x0, y0 = R['NX'], R['NY'], R['P'], R['x0'], R['y0']; RS = 1.72e-8 / 17.5e-6  # ohm per square, 0.5 oz inner copper
ZL = [0.1, 0.4, 0.6, 0.9]  # rough depth of inner1..inner4 in the 1.0 mm board (mm)
RVIA_MM = 1.72e-8 / (np.pi * 0.125e-3 * 25e-6) * 1e-3  # plated barrel, 0.1 mm hole + 25 um wall: ohm per mm of length
CAR = float(sys.argv[1]) if len(sys.argv) > 1 else 0.6
# net: (source vias, {load via pattern: amps}); a pattern 'U1.' / 'U_DDR.' means that chip's balls of the net
LOADS = {
    'VDD_CORE': (r'^V_L_DCDC3_pin2', {'U1.': 0.4}),
    'VDD_MPU': (r'^V_L_DCDC2_pin2', {'U1.': 1.0}),
    'VDDS_DDR': (r'^V_L_DCDC1_pin2', {'U1.': 0.25, 'U_DDR.': 0.35}),
    'VDD_3V3': (r'^V_L_3V3_pin2', {'U1.': 0.25, r'^V_J1_pin(84|86)$': CAR}),
    'VDD_1V8': (r'^V_L_1V8_pin2', {'U1.': 0.2, r'^V_J1_pin(88|90)$': CAR}),
    # 5 V input: from the CM4 pins to the PMIC's AC input and the two bucks (their input current at about 85 %)
    'VIN5': (r'^V_J1_pin(77|79|81|83|85|87)$', {r'^V_U_PMIC_pin10$': 0.6, r'^V_U_3V3_pin4$': (0.25 + CAR) * 3.3 / 5 / 0.85, r'^V_U_1V8_pin4$': (0.2 + CAR) * 1.8 / 5 / 0.85}),
}
Ls = np.stack([np.frombuffer(base64.b64decode(b), dtype=np.int8).reshape(NY, NX) for b in R['layers']])
cell = lambda v: (int((v['y'] - y0) / P), int((v['x'] - x0) / P))
res = {}
print(f"carrier load on 3.3 V and 1.8 V: {CAR:.2f} A each")
for net, (src, loads) in LOADS.items():
    k = R['nets'].index(net) + 1; own = Ls == k; n = int(own.sum()); ix = -np.ones(own.shape, np.int64); ix[own] = np.arange(n)
    mine = [v for v in plan['vias'] if v['net'] == net]
    rows, cols, vals = [], [], []
    def link(a, b, g): rows.extend([a, b, a, b]); cols.extend([a, b, b, a]); vals.extend([g, g, -g, -g])
    G = 1 / RS
    for l in range(4):
        for ax in (0, 1):
            a = ix[l]; b = np.roll(ix[l], -1, axis=ax); m = (a >= 0) & (b >= 0)
            if ax == 0: m[-1, :] = False
            else: m[:, -1] = False
            for p, q in zip(a[m], b[m]): link(p, q, G)
    for v in mine:
        j, i = cell(v); on = [l for l in range(4) if own[l, j, i]]
        for a, b in zip(on, on[1:]): link(ix[a, j, i], ix[b, j, i], 1 / (RVIA_MM * (ZL[b] - ZL[a])))
    A = sp.csr_matrix((vals, (rows, cols)), shape=(n, n))
    cur = np.zeros(n); miss = 0; tot = 0
    for pat, amps in loads.items():
        bv = [cell(v) for v in mine if ((v.get('ball') or '').startswith(pat) if pat.endswith('.') else re.search(pat, v['name']))]
        assert bv, (net, pat)
        tot += amps
        for c in bv:
            on = [l for l in range(4) if own[l][c]]
            if not on: miss += 1; continue
            cur[ix[on[0]][c]] -= amps / len(bv)
    fixed = np.zeros(n, bool); srcs = [v for v in mine if re.search(src, v['name'])]; assert srcs, net
    for v in srcs:
        j, i = cell(v)
        for l in range(4):
            if own[l, j, i]: fixed[ix[l, j, i]] = True
    ncomp, lab = csgraph.connected_components(A, directed=False)
    live = np.isin(lab, np.unique(lab[fixed]))
    fr = np.where(live & ~fixed)[0]; Aff = A[fr][:, fr].tocsc()
    x = np.zeros(n); x[fr] = spl.spsolve(Aff, cur[fr])  # potential (V) relative to the source, negative = below
    V = np.full(own.shape, np.nan); V[own] = x
    ends = [cell(v) for v in mine if v.get('ball') or any(not p.endswith('.') and re.search(p, v['name']) for p in loads)]
    drops = [-np.nanmin(V[:, c[0], c[1]]) * 1e3 for c in ends if own[:, c[0], c[1]].any()]
    gx = np.nan_to_num((V - np.roll(V, -1, axis=2)) / RS); gy = np.nan_to_num((V - np.roll(V, -1, axis=1)) / RS)
    gx[:, :, -1] = 0; gy[:, -1, :] = 0; K = np.hypot(gx, gy) / P; l, j, i = np.unravel_index(K.argmax(), K.shape)
    loss = ((gx ** 2 + gy ** 2) * RS).sum() * 1e3
    lost = int((cur[~live] != 0).sum())
    res[net] = dict(amps=tot, drop_mV=round(max(drops), 2), peak_A_per_mm=round(float(K.max()), 2), at=(round(float(x0 + i * P), 2), round(float(y0 + j * P), 2), f'inner{l + 1}'), above_1A_per_mm_mm2=round(float((K > 1).sum() * P * P), 3), loss_mW=round(loss, 2))
    print(f"{net:9s} {tot:.2f} A: worst load {max(drops):.1f} mV below the source; plane loss {loss:.1f} mW; peak current density {K.max():.2f} A/mm at {res[net]['at']}; copper above 1 A/mm {res[net]['above_1A_per_mm_mm2']:.2f} mm2"
          + (f"; {miss} loads without copper" if miss else '') + (f"; {lost} loads not joined to the source" if lost else ''), flush=True)
    if os.environ.get('KMAP'):
        from PIL import Image
        for l in range(4):
            if not own[l].any(): continue
            img = np.zeros((NY, NX, 3), np.uint8); img[Ls[l] > 0] = (35, 35, 35); t = np.clip(K[l] / 2.0, 0, 1); u = np.clip(K[l] / 0.5, 0, 1)
            img[own[l]] = np.stack([40 + 215 * t, 40 + 215 * u, 90 + 0 * t], -1)[own[l]].astype(np.uint8)
            Image.fromarray(img[::-1]).resize((NX * 2, NY * 2), Image.NEAREST).save(f"{os.environ['KMAP']}-{net}-inner{l + 1}.png")
if os.environ.get('JSON'): json.dump(res, open(os.environ['JSON'], 'w'), indent=1)
: CAR}),\n 'VDD_1V8': (r'^V_L_1V8_pin2', {'U1.': 0.2, r'^V_J1_pin(88|90)
: CAR}),\n # 5 V input: from the CM4 pins to the PMIC's AC input and the two bucks (their input current at about 85 %)\n 'VIN5': (r'^V_J1_pin(77|79|81|83|85|87)
, {r'^V_U_PMIC_pin10
: 0.6, r'^V_U_3V3_pin4
: (0.25 + CAR) * 3.3 / 5 / 0.85, r'^V_U_1V8_pin4
: (0.2 + CAR) * 1.8 / 5 / 0.85}),\n}\nLs = np.stack([np.frombuffer(base64.b64decode(b), dtype=np.int8).reshape(NY, NX) for b in R['layers']])\ncell = lambda v: (int((v['y'] - y0) / P), int((v['x'] - x0) / P))\nres = {}\nprint(f\"carrier load on 3.3 V and 1.8 V: {CAR:.2f} A each\")\nfor net, (src, loads) in LOADS.items():\n k = R['nets'].index(net) + 1; own = Ls == k; n = int(own.sum()); ix = -np.ones(own.shape, np.int64); ix[own] = np.arange(n)\n mine = [v for v in plan['vias'] if v['net'] == net]\n rows, cols, vals = [], [], []\n def link(a, b, g): rows.extend([a, b, a, b]); cols.extend([a, b, b, a]); vals.extend([g, g, -g, -g])\n G = 1 / RS\n for l in range(4):\n for ax in (0, 1):\n a = ix[l]; b = np.roll(ix[l], -1, axis=ax); m = (a \u003e= 0) \u0026 (b \u003e= 0)\n if ax == 0: m[-1, :] = False\n else: m[:, -1] = False\n for p, q in zip(a[m], b[m]): link(p, q, G)\n for v in mine:\n j, i = cell(v); on = [l for l in range(4) if own[l, j, i]]\n for a, b in zip(on, on[1:]): link(ix[a, j, i], ix[b, j, i], 1 / (RVIA_MM * (ZL[b] - ZL[a])))\n A = sp.csr_matrix((vals, (rows, cols)), shape=(n, n))\n cur = np.zeros(n); miss = 0; tot = 0\n for pat, amps in loads.items():\n bv = [cell(v) for v in mine if ((v.get('ball') or '').startswith(pat) if pat.endswith('.') else re.search(pat, v['name']))]\n assert bv, (net, pat)\n tot += amps\n for c in bv:\n on = [l for l in range(4) if own[l][c]]\n if not on: miss += 1; continue\n cur[ix[on[0]][c]] -= amps / len(bv)\n fixed = np.zeros(n, bool); srcs = [v for v in mine if re.search(src, v['name'])]; assert srcs, net\n for v in srcs:\n j, i = cell(v)\n for l in range(4):\n if own[l, j, i]: fixed[ix[l, j, i]] = True\n ncomp, lab = csgraph.connected_components(A, directed=False)\n live = np.isin(lab, np.unique(lab[fixed]))\n fr = np.where(live \u0026 ~fixed)[0]; Aff = A[fr][:, fr].tocsc()\n x = np.zeros(n); x[fr] = spl.spsolve(Aff, cur[fr]) # potential (V) relative to the source, negative = below\n V = np.full(own.shape, np.nan); V[own] = x\n ends = [cell(v) for v in mine if v.get('ball') or any(not p.endswith('.') and re.search(p, v['name']) for p in loads)]\n drops = [-np.nanmin(V[:, c[0], c[1]]) * 1e3 for c in ends if own[:, c[0], c[1]].any()]\n gx = np.nan_to_num((V - np.roll(V, -1, axis=2)) / RS); gy = np.nan_to_num((V - np.roll(V, -1, axis=1)) / RS)\n gx[:, :, -1] = 0; gy[:, -1, :] = 0; K = np.hypot(gx, gy) / P; l, j, i = np.unravel_index(K.argmax(), K.shape)\n loss = ((gx ** 2 + gy ** 2) * RS).sum() * 1e3\n lost = int((cur[~live] != 0).sum())\n res[net] = dict(amps=tot, drop_mV=round(max(drops), 2), peak_A_per_mm=round(float(K.max()), 2), at=(round(float(x0 + i * P), 2), round(float(y0 + j * P), 2), f'inner{l + 1}'), above_1A_per_mm_mm2=round(float((K \u003e 1).sum() * P * P), 3), loss_mW=round(loss, 2))\n print(f\"{net:9s} {tot:.2f} A: worst load {max(drops):.1f} mV below the source; plane loss {loss:.1f} mW; peak current density {K.max():.2f} A/mm at {res[net]['at']}; copper above 1 A/mm {res[net]['above_1A_per_mm_mm2']:.2f} mm2\"\n + (f\"; {miss} loads without copper\" if miss else '') + (f\"; {lost} loads not joined to the source\" if lost else ''), flush=True)\n if os.environ.get('KMAP'):\n from PIL import Image\n for l in range(4):\n if not own[l].any(): continue\n img = np.zeros((NY, NX, 3), np.uint8); img[Ls[l] \u003e 0] = (35, 35, 35); t = np.clip(K[l] / 2.0, 0, 1); u = np.clip(K[l] / 0.5, 0, 1)\n img[own[l]] = np.stack([40 + 215 * t, 40 + 215 * u, 90 + 0 * t], -1)[own[l]].astype(np.uint8)\n Image.fromarray(img[::-1]).resize((NX * 2, NY * 2), Image.NEAREST).save(f\"{os.environ['KMAP']}-{net}-inner{l + 1}.png\")\nif os.environ.get('JSON'): json.dump(res, open(os.environ['JSON'], 'w'), indent=1)\n","content_mimetype":"application/octet-stream","created_at":"2026-11-27T06:06:12.091Z"}; window.SSR_PACKAGE_BUILDS = []; window.SSR_RELATED_PACKAGES = [{"package_id":"e57dec57-6560-49a6-b583-798b18d5cbd3","creator_account_id":"03854e77-22c2-44a0-9cfc-2d4ed6741105","latest_package_release_id":"7fd2a7e5-0adf-4857-ae5e-68f7ee22585b","last_built_release_id":"7fd2a7e5-0adf-4857-ae5e-68f7ee22585b","latest_package_release_fs_sha":"md5-ff57dea7235fe0f1e8eb153a4153a40e","latest_pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=7fd2a7e5-0adf-4857-ae5e-68f7ee22585b\u0026file_path=dist%2Findex%2Fpcb.svg","latest_sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=7fd2a7e5-0adf-4857-ae5e-68f7ee22585b\u0026file_path=dist%2Findex%2Fschematic.svg","latest_cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=7fd2a7e5-0adf-4857-ae5e-68f7ee22585b\u0026file_path=dist%2Findex%2F3d.png","latest_version":"1.0.29","license":"unset","owner_org_id":"7978967e-b956-4ac2-b813-667a08f6310a","org_owner_tscircuit_handle":"abse","owner_github_username":null,"github_repo_full_name":null,"is_source_from_github":false,"description":null,"name":"abse/wifi-smart-switch","unscoped_name":"wifi-smart-switch","star_count":0,"created_at":"2026-08-19T12:46:29.495Z","updated_at":"2026-09-01T14:37:40.775Z","ai_description":"The AO3400A component models a small N-channel MOSFET in a SOT-23 package with drain, gate, and source pins, used for switching or amplification in electronic circuits.","ai_usage_instructions":null,"is_private":false,"is_unlisted":false,"is_public":true,"public_dist_enabled":false,"has_public_dist":true,"starred_at":null,"default_view":"files","website":null,"github_installation_id":null,"allow_pr_previews":false,"related_type":"same_author","thumbnail_url":"https://api.tscircuit.com/package_files/view?package_release_id=7fd2a7e5-0adf-4857-ae5e-68f7ee22585b\u0026file_path=dist%2Findex%2Fpcb.svg"},{"package_id":"f0155dc4-d5c4-4924-b98c-5be0ca6b6bb6","creator_account_id":"97843ce3-26e5-402d-91aa-1f68763ad2dc","latest_package_release_id":"66c53bd4-317b-4137-8137-8b2a26c6547f","last_built_release_id":"66c53bd4-317b-4137-8137-8b2a26c6547f","latest_package_release_fs_sha":"md5-91af0ff278d6de309badac525a13c70f","latest_pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=66c53bd4-317b-4137-8137-8b2a26c6547f\u0026file_path=dist%2Findex%2Fpcb.svg","latest_sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=66c53bd4-317b-4137-8137-8b2a26c6547f\u0026file_path=dist%2Findex%2Fschematic.svg","latest_cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=66c53bd4-317b-4137-8137-8b2a26c6547f\u0026file_path=dist%2Findex%2F3d.png","latest_version":"0.1.5","license":"MIT","owner_org_id":"e6032e13-003f-41f1-b84f-6adfc66f838b","org_owner_tscircuit_handle":"gokul","owner_github_username":null,"github_repo_full_name":null,"is_source_from_github":false,"description":"Engineering draft: four-layer, computer-powered USB 3 hub with one USB-C host socket, two USB-C and two USB-A accessory sockets, and a full-size SD slot. Board and three schematic previews are available. Routing and production checks are incomplete; not fabrication ready.","name":"gokul/usb3-sd-hub","unscoped_name":"usb3-sd-hub","star_count":0,"created_at":"2026-10-11T02:10:47.315Z","updated_at":"2026-10-16T08:50:19.606Z","ai_description":"Four-layer, computer-powered USB 3 hub PCB built around USB5816C/USB2642 controllers, providing one USB-C host, two USB-C and two USB-A peripheral ports, full-size SD storage, regulated 1.2/3.3 V power, per-port current limiting, ESD protection, and high-speed differential routing.","ai_usage_instructions":null,"is_private":false,"is_unlisted":false,"is_public":true,"public_dist_enabled":false,"has_public_dist":true,"starred_at":null,"default_view":"files","website":null,"github_installation_id":null,"allow_pr_previews":false,"related_type":"similar_ai_description","thumbnail_url":"https://api.tscircuit.com/package_files/view?package_release_id=66c53bd4-317b-4137-8137-8b2a26c6547f\u0026file_path=dist%2Findex%2Fpcb.svg"},{"package_id":"ea8b9377-d570-4b77-a415-b62250dbc7ff","creator_account_id":"97843ce3-26e5-402d-91aa-1f68763ad2dc","latest_package_release_id":"8a89486b-fc6d-4334-9548-406cbe74c314","last_built_release_id":"8a89486b-fc6d-4334-9548-406cbe74c314","latest_package_release_fs_sha":"md5-6f05fd76cc2016dc1e0bfd03a44d1d23","latest_pcb_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=8a89486b-fc6d-4334-9548-406cbe74c314\u0026file_path=dist%2Ffabrication%2Ffieldkit-usb-0.4.2%2Fpcb.svg","latest_sch_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=8a89486b-fc6d-4334-9548-406cbe74c314\u0026file_path=dist%2Ffabrication%2Ffieldkit-usb-0.4.2%2Fschematic.svg","latest_cad_preview_image_url":"https://api.tscircuit.com/package_files/view?package_release_id=8a89486b-fc6d-4334-9548-406cbe74c314\u0026file_path=dist%2Findex%2F3d.png","latest_version":"0.4.2","license":"UNLICENSED","owner_org_id":"e6032e13-003f-41f1-b84f-6adfc66f838b","org_owner_tscircuit_handle":"gokul","owner_github_username":null,"github_repo_full_name":null,"is_source_from_github":false,"description":"USB-C-powered ESP32-S3 Wi-Fi/Bluetooth handheld with an SMD 128x32 OLED, six navigation buttons, USB-C power/data, complete checked routing, and four native schematic sheets.","name":"gokul/fieldkit-usb","unscoped_name":"fieldkit-usb","star_count":0,"created_at":"2026-10-02T14:09:54.196Z","updated_at":"2026-10-03T19:40:30.013Z","ai_description":"USB-C-powered ESP32-S3 handheld featuring Wi‑Fi/Bluetooth, a 128×32 SMD OLED, six navigation buttons, protected 1 A power input, and status LEDs.","ai_usage_instructions":null,"is_private":false,"is_unlisted":false,"is_public":true,"public_dist_enabled":false,"has_public_dist":true,"starred_at":null,"default_view":"files","website":null,"github_installation_id":null,"allow_pr_previews":false,"related_type":"random","thumbnail_url":"https://api.tscircuit.com/package_files/view?package_release_id=8a89486b-fc6d-4334-9548-406cbe74c314\u0026file_path=dist%2Ffabrication%2Ffieldkit-usb-0.4.2%2Fpcb.svg"}]; window.SSR_PACKAGE_ROUTE = {"author":"abse","packageName":"am3354-cm4-module","packageNameWithScope":"abse/am3354-cm4-module","version":null,"isLegacyRoute":false,"kind":"file","filePath":"source/irdrop.py"};