RF IC Design Optimization — LNA cf: Apple C1 Transceiver Architecture · 3.5 GHz LNA · N7
本週習題輔助資料(3/26 週四) Supplementary materials for this week's exercises (Thu 3/26)
來源 Source: https://claude.ai/public/artifacts/51eb7122-afd1-498e-8dcf-83a3834d5f23
標題 Title: 為什麼我們不能直接跑 Spectre? / Why Can't We Just Run Spectre? 副標題 Subtitle: Claude VM 中的 Cadence Spectre vs ngspice — 以及為什麼在 Sub-6 GHz Cascode LNA 需要 Spectre + PDK 才能獲得準確結果 / Cadence Spectre vs ngspice in the Claude VM — and why Spectre + PDK is required for accurate Cascode LNA results at Sub-6 GHz 標籤 Tags: TSMC N7/N4 · 5 GHz target · ngspice-42 used
❌ Cadence Spectre:
✅ ngspice-42(本次使用):
/usr/bin/ngspice / Pre-installed in Claude VM at /usr/bin/ngspiceDC 結果(合理)/ DC Results (reasonable):
| 參數 Parameter | 數值 Value | 目標 Target | 狀態 Status |
|---|---|---|---|
| M1 汲極電流 Drain Current M1 | 7.95 mA | 5–15 mA | ✓ |
| M1 的 gm | 45.9 mS | 高 gm → 高增益潛力 High gm → high gain potential | ✓ |
| DC 功耗 DC Power | 7.2 mW | 5–15 mW | ✓ |
RF 結果(錯誤)/ RF Results (wrong):
| 參數 Parameter | 數值 Value | 目標 Target | 狀態 Status |
|---|---|---|---|
| S₂₁ @ 5 GHz | +1.6 dB | 15–20 dB | ✗ |
| S₁₁ @ 5 GHz | −0.2 dB | < −10 dB | ✗ |
| NF @ 5 GHz | 90 dB | 0.8–1.5 dB | ✗ |
結論 Conclusion: DC 偏壓合理。RF 性能錯誤不是因為電路壞了,而是因為通用 BSIM4 模型不匹配真實 TSMC N7 元件物理特性。/ DC bias is reasonable. RF performance is wrong not because the circuit is broken, but because the generic BSIM4 model does not match real TSMC N7 device physics.
| 參數 Parameter | 通用 BSIM4 (ngspice) | TSMC N7 PDK (Spectre) | 對 LNA 的影響 Impact on LNA |
|---|---|---|---|
| 每指 Cgs / Cgs per finger | ~90 fF(高估)(over-estimated) | ~30 fF(FinFET 鰭片)(FinFET fins) | ωT × Ls >> 50 Ω → S₁₁ 錯誤 wrong |
| 偏壓點 fT / fT at bias | ~900 GHz(不真實)(unrealistic) | ~180 GHz(量測值)(measured) | 增益與匹配偏差 10× / Gain & matching off by 10× |
| Rds(輸出)/ Rds (output) | CLM 建模不足 Under-modelled CLM | 校準 DIBL + CLM / Calibrated DIBL + CLM | 增益和穩定性錯誤 / Gain and stability wrong |
| 熱雜訊 γ / Noise γ (thermal) | 預設 γ = 2/3 / Default γ = 2/3 | 短通道 γ ≈ 1.3–2.0 / Short-channel γ ≈ 1.3–2.0 | NF 低估 3–6 dB / NF under-estimated by 3–6 dB |
| 閘極電阻 Rg / Gate resistance Rg | 未包含 (rgatemod=0) / Not included | 每指 Rg (NQS) / Per-finger Rg (NQS) | NF 由缺失的 Rg 主導 / NF dominated by Rg missing |
| 寄生電容(佈局)/ Parasitic C (layout) | 理想——無 RC 萃取 / Ideal — no RC extraction | 由 GDS 進行 PEX 萃取 / PEX-extracted from GDS | 諧振偏移、頻寬變窄 / Resonance shifts, BW narrows |
| 電感模型 / Inductor model | 理想 L + 串聯 R / Ideal L + series R only | EM 模擬 π 模型 (Sonnet) / EM-simulated π-model (Sonnet) | Q、SRF、趨膚效應缺失 / Q, SRF, skin effect missing |
① 輸入匹配失敗——ωT 錯誤 / Input match broken — wrong ωT
Re{Zin} = ωT · Ls = 50 Ω,其中 ωT = gm / Cgs。通用 BSIM4 高估 Cgs(90 fF vs 真實 N7 FinFET 的 30 fF)→ ωT ≈ 900 GHz 而非 180 GHz → Re{Zin} ≈ 2700 Ω → S₁₁ ≈ 0 dB。/ Re{Zin} = ωT · Ls = 50 Ω, where ωT = gm / Cgs. Generic BSIM4 over-estimates Cgs (90 fF vs real 30 fF for N7 FinFET) → ωT ≈ 900 GHz instead of 180 GHz → Re{Zin} ≈ 2700 Ω → S₁₁ ≈ 0 dB.
② 諧振增益消失——負載未調諧 / Resonant gain lost — load not tuned
ω₀ = 1 / √((Lg+Ls) · Cgs)。錯誤的 Cgs 將諧振偏移至 ~8 GHz 而非 5 GHz。未加入調諧電容 Ctune。峰值增益 = +6.9 dB @ 8 GHz,而非 15+ dB @ 5 GHz。/ Wrong Cgs shifts resonance to ~8 GHz instead of 5 GHz. No tuning capacitor Ctune added to compensate. Peak gain = +6.9 dB at 8 GHz, not 15+ dB at 5 GHz.
③ 雜訊指數無意義——γ 和 Rg 缺失 / Noise Figure meaningless — γ and Rg absent
NF 主要由以下決定:(a) 熱通道雜訊 NF ∝ γ·gd0/gm——短通道 γ ≈ 1.5–2(非 2/3);(b) 閘極電阻 NF += 4kBT·Rg·ω²Cgs² / gm²。通用模型的 rgatemod=0 且使用預設 γ → NF 完全錯誤(計算出 90 dB)。/ NF dominated by: (a) thermal channel noise NF ∝ γ·gd0/gm — short-channel γ ≈ 1.5–2 (not 2/3); (b) gate resistance NF += 4kBT·Rg·ω²Cgs² / gm². Generic model has rgatemod=0 and default γ → NF completely wrong (90 dB computed).
| 屬性 Property | Python MNA | ngspice + BSIM4 |
|---|---|---|
| 需要 BSIM4 模型?/ Needs BSIM4 model? | 否——gm、Cgs 為直接輸入 / No — gm, Cgs are direct inputs | 是——從元件方程式萃取 / Yes — extracts from device equations |
| 誤差來源 / Where errors come from | 對 gm、Cgs 的錯誤假設 / Wrong assumptions about gm, Cgs | 錯誤的元件模型參數 / Wrong device model parameters |
| 使用的 Cgs / Our Cgs used | 405 fF——由 ωT·Ls=50Ω 反算 / back-calc from ωT·Ls = 50 Ω | ~90 fF——通用 BSIM4 萃取 / generic BSIM4 extracted |
| S11 結果 / S11 result | 構造上完美 / Perfect by construction | −0.2 dB——未匹配 / not matched |
| 幾何現實檢查?/ Reality check on geometry? | 無 / None | 有——但受限於模型品質 / Yes — but limited by model quality |
Python MNA 方法: 僅在小訊號域操作;直接輸入 gm、gds、Cgs、Cgd。無 MOSFET 元件模型——電晶體在求解前已線性化。Cgs = 405 fF ← 由 ωT·Ls = 50 Ω 得出;Gm = 40.5 mS ← 由匹配條件得出。S11 看起來完美——是構造出來的。沒有對真實電晶體能否提供這些值做現實檢查。/ Operates in small-signal domain only; takes gm, gds, Cgs, Cgd as direct inputs. No MOSFET device model — transistors already linearized before solver starts. S11 looked perfect — by construction. No reality check on whether any real transistor can deliver them.
ngspice + BSIM4 方法: 先解完整非線性元件方程式;萃取 DC 操作點 → 再得到小訊號參數。若 BSIM4 錯誤,下游所有結果都錯。Cgs = ~90 fF ← 通用 BSIM4;ωT = 924 GHz ← 高 5 倍。ngspice 實際測試了現實——發現分析假設的 Cgs = 405 fF 在物理上不可達。/ Solves full nonlinear device equations first; extracts DC operating point → then small-signal params. If BSIM4 is wrong, everything downstream is wrong. ngspice actually tested reality — found analytically assumed Cgs = 405 fF is not physically achievable.
spectre +preset=liberate <testbench.scs>。需要 RHEL 7/8、8+ GB RAM、LAN 上的授權伺服器。/ Requires RHEL 7/8, 8+ GB RAM, license server on LAN.cascode_lna.cdl 中,將 nfet_g → nfet_rf_4t。設定 fingers=50, w=1u, m=1。更新 cds.lib 路徑至 /pdk/tsmc_n7/。.sp start=1G stop=8G step=10M。晶圓廠的完整「說明書 + 工具箱」——晶片設計師在特定製造製程(TSMC、Samsung、GlobalFoundries…)中設計電路所需的一切。/ The foundry's complete "instruction manual + toolbox" — everything a chip designer needs to design circuits in a specific fabrication process.
內容 Contents:
/pdk/tsmc_n7/ / TSMC never publishes PDKs publicly — hence our placeholder /pdk/tsmc_n7/ path對本 LNA 的重要性 Why It Matters for This LNA: 我們的模擬從設計方程式推導 Gm、Cgs、gds、fT。真實的 PDK 模型卡捕捉:14 nm 通道長度的速度飽和、閘極洩漏(在 N7/N4 至關重要)、閃爍雜訊 (1/f) → NF 下限、相鄰鰭片的佈局相依應力。/ Our simulation derived Gm, Cgs, gds, fT from design equations. A real PDK model card captures: velocity saturation at 14 nm channel length, gate leakage (critical at N7/N4), flicker noise (1/f) → NF floor, layout-dependent stress from adjacent fins.
使用 ngspice ✓ 的時機 USE ngspice ✓ for: DC 偏壓點、拓撲可行性、粗略 gm/ID 定標、暫態/邏輯模擬、快速設計空間掃描、免費/無授權 / DC bias point, topology feasibility, rough gm/ID sizing, transient/logic sim, quick design-space sweep, free/no license.
使用 Spectre + PDK ✓ 的時機 USE Spectre + PDK ✓ for: S 參數精度(簽核等級)、雜訊指數(準確 γ、Rg)、輸入匹配(真實 Cgs)、線性度/IIP3 (HPSS/PSS)、Tape-out 簽核(必須)、EM 萃取寄生效應 (via EMX/Virtuoso) / S-parameter accuracy (sign-off level), Noise Figure (accurate γ, Rg), input matching (real Cgs), linearity/IIP3 (HPSS/PSS), tape-out sign-off (mandatory), EM-extracted parasitics (via EMX/Virtuoso).
結論 Bottom line: ngspice 正確識別偏壓合理(ID ≈ 8 mA,gm ≈ 46 mS)。對於 RF 規格——S₂₁、S₁₁、NF——Cadence Spectre 搭配 TSMC N7 PDK 是通往準確、可 tape-out 結果的唯一路徑。/ ngspice correctly identified that the bias is reasonable. For RF specs — S₂₁, S₁₁, NF — Cadence Spectre with the TSMC N7 PDK is the only path to accurate, tape-out-ready results.
which spectre/ngspice/hspice/xyce — 僅在 /usr/bin/ngspice 找到 ngspice / Ran which — found only ngspice at /usr/bin/ngspice人工輸入:一個電路圖 HTML 檔案 + 「run spectre」。其餘全部自主完成。/ Human input: one schematic HTML file + the words "run spectre". Everything else was autonomous.
bash: which ngspice → /usr/bin/ngspice
file: write lna.sp → BSIM4 netlist(BSIM4 網表)
bash: ngspice -b lna.sp → ac_results.csv
bash: read log → bias wrong → rewrite lna.sp(偏壓錯誤 → 重寫)
bash: ngspice -b lna_v2.sp → ac + noise CSV
bash: python postprocess.py → lna_results.png
file: write slides.html → this deck(此投影片)關鍵使能因素 Key enablers: 持久 Ubuntu VM、bash + 檔案建立工具在同一迴圈、ngspice 已預裝、pip 可用(matplotlib, numpy)、日誌檢查 → 自我修正除錯 / Persistent Ubuntu VM, bash + file creation tools in one loop, ngspice pre-installed, pip available (matplotlib, numpy), log inspection → self-correcting debug.
⚠ 硬性限制 The Hard Limit: 代理迴圈的精度僅取決於它能存取的模型。ngspice + 通用 BSIM4 → 正確的拓撲、錯誤的物理。Cadence Spectre + TSMC N7 PDK → 物理校準、可 tape-out。再多的自主性也無法取代授權的 PDK。/ The agentic loop is only as accurate as the models it has access to. ngspice + generic BSIM4 → correct topology, wrong physics. Cadence Spectre + TSMC N7 PDK → physically calibrated, tape-out ready. No amount of autonomy substitutes for a licensed PDK.
✦ 取代了什麼 What This Replaces: 一位 RF 工程師手動做這些需要:~2 小時撰寫 + 除錯 SPICE 網表、~1 小時在 MATLAB 後處理波形、~1 小時製作結果簡報。Claude:一個對話回合,~40 秒。/ An RF engineer doing this manually would spend ~2 hrs writing + debugging the SPICE netlist, ~1 hr post-processing waveforms in MATLAB, ~1 hr making the results presentation. Claude: one conversation turn, ~40 seconds.
觸發這一切的提示:「run spectre」——2 個字 → 8 個自主步驟 → 完整模擬 + 投影片 / Prompt that started all of this: "run spectre" — 2 words → 8 autonomous steps → full simulation + slides
來源 Source: https://claude.ai/public/artifacts/5a3af580-0bea-45ad-a8f9-2b4ee43da5cc
標題 Title: CASCODE LNA — 設計與模擬報告 / Design & Simulation Report 技術 Technology: TSMC N7/N4 CMOS · 目標頻率 Target Freq: 5 GHz Sub-6G 5G NR · 拓撲 Topology: 電感源極退化 Inductive Source Degen. · 求解器 Solver: Python MNA · Spectre-equiv.
| 參數 Parameter | 數值 Value |
|---|---|
| M1/M2 寬度 Width | 50 µm |
| 閘極長度 Gate Length | 14 nm |
| 指數 Num. Fingers | 50 nf |
| 汲極電流 Drain Current ID | 10 mA |
| 電源 Supply VDD | 0.9 V |
| 閘極電感 Gate Inductor Lg | 2 nH |
| 源極電感 Source Inductor Ls | 0.5 nH |
| 負載電感 Load Inductor Ld | 3 nH |
| Cgs1 | 405.3 fF |
| 埠阻抗 Port Impedance Z₀ | 50 Ω |
9 節點電路 9-node circuit:gnd=0, gate1=1, src1=2, drn1=3, gate2=4, drn2=5, out=6, vdd=7, Ls_node=8。
包含 Includes:被動元件戳記(L、C、R 導納)Passive stamps (L, C, R admittances)、M1 小訊號模型(MOSFET VCCS——gm·Vgs, gds, Cgs, Cgd)、M2 cascode(相同尺寸)(same sizing)。透過 Norton 輸入埠注入萃取 S 參數。/ S-parameter extraction via Norton input port injection.
| 參數 Parameter | 數值 Value | 目標 Target | 狀態 Status |
|---|---|---|---|
| S₂₁(增益 Gain) | +7.68 dB | 15–20 dB | ⚠ 低於目標 BELOW TARGET |
| S₁₁(輸入回損 Input RL) | −30.11 dB | < −10 dB | ✓ 通過 PASS |
| S₁₂(隔離度 Isolation) | −56.91 dB | < −30 dB | ✓ 通過 PASS |
| 3-dB 頻寬 BW | 4.33 GHz | — | — |
| S₂₁ 峰值 Peak S₂₁ | 9.09 dB @ 3.41 GHz | — | — |
| S₁₁ < −10 dB 頻寬 BW | 3.99–6.22 GHz | — | — |
| 群延遲 Group Delay | 73.5 ps | — | — |
| IIP3 估計 estimate | +17.3 dBm | — | — |
| 覆蓋 Coverage | 5G NR Band ✓ | — | — |
掃描 Sweep:0.3–12 GHz,3000 點 pts。
| 參數 Parameter | 規格 Specification | 模擬值 Simulated | 狀態 Status |
|---|---|---|---|
| S₂₁ 增益 Gain @ 5 GHz | 15–20 dB | 7.68 dB | ⚠ 需檢討 REVIEW |
| S₁₁ @ 5 GHz | < −10 dB | −30.11 dB | ✓ 通過 PASS |
| 雜訊指數 NF @ 5 GHz | 0.8–1.5 dB | 2.38 dB | ⚠ 需檢討 REVIEW |
| NF 最小值 minimum | — | 1.89 dB | 最佳可達 Best achievable |
| S₁₂ 隔離度 Isolation | < −30 dB | −56.91 dB | ✓ 通過 PASS |
| 穩定性 Stability K | > 1 | 19.09 | ✓ 通過 PASS |
| IIP3(估計 estimate) | — | +17.3 dBm | 強線性度 Strong linearity |
| 群延遲 Group Delay | — | 73.5 ps | 低色散 Low dispersion |
根本原因 Root causes: Qin = 1.26(Lg 偏低 low Lg)。50 Ω 輸出主導負載 ZL → 增加 Lg 至 6–8 nH。M1 通道雜訊 = 55%,短通道 γ = 1.5 設定實際 NFmin 為 1.89 dB。
達成 15–20 dB 目標 Achieving 15–20 dB Target:
增益路線圖 Gain roadmap: 基線 Baseline 7.68 dB → +Lg 6 nH → ~13 dB → +Ctune 諧振 resonant → ~16 dB → 兩者結合 both combined → ~18–20 dB ✓
NF 改善 NF Improvement:
來源 Source: https://claude.ai/share/72920709-50f6-44c5-adf6-70002e8de97b
分享的 Claude 對話,標題為「模擬結果驗證」。/ Shared Claude conversation titled "Simulation results verification."
所有標註在四捨五入範圍內匹配 CSV:/ All annotations match CSV within rounding:
| 參數 Parameter | 圖表標註 Plot Annotation | CSV 數據 CSV Data | 匹配?Match? |
|---|---|---|---|
| f₀ | 5.0 GHz | 5.001 GHz | ✓ |
| S₂₁ @ f₀ | +7.7 dB | +7.68 dB | ✓ |
| S₁₁ @ f₀ | −30.1 dB | −30.11 dB | ✓ |
| NF @ f₀ | 2.38 dB | 2.38 dB | ✓ |
| NFmin | 1.89 dB | 1.89 dB | ✓ |
| K @ f₀ | 19.09 | 19.09 | ✓ |
| GD @ f₀ | 73 ps | 73.5 ps | ✓ |
| 3-dB BW | 4.33 GHz | 4.33 GHz | ✓ |
| S11 BW | 2.23 GHz | 2.23 GHz | ✓ |
一致 Consistent: 拓撲 Topology(M1 CS + M2 CG)、Lg = 2 nH、Ls = 500 pH、Ld = 3 nH、VDD = 0.9 V、ID = 10 mA。
不一致(性能宣稱 vs 模擬)/ Inconsistent (performance claims vs. sim):
| 項目 Item | 電路圖宣稱 Schematic Claim | 模擬結果 Simulation Result |
|---|---|---|
| 增益 Gain | 15–20 dB | 7.7 dB |
| NF | 0.8–1.5 dB | 2.38 dB |
| IIP3 | −5 ~ +5 dBm | 17.3 dBm(反算,非雙音 back-calculated, not two-tone) |
Ctune = 338 fF 出現在模擬中但未顯示於電路圖上。/ Ctune = 338 fF appears in sim but not shown on schematic.
| 階段 Stage | 說明 Description | 關鍵結果 Key Result |
|---|---|---|
| 1 | MOSFET 模型給出不真實的 gm = 1200 mS / Unrealistic gm = 1200 mS | 以校準 FinFET 模型修正 / Fixed with calibrated FinFET model |
| 2 | 擴展 Ld 最佳化器 / Expand optimizer for Ld | 13.6 dB 增益 gain, 1.72 dB NF |
| 3 | 進一步調諧 / Further tuning | S₂₁ = 15.5 dB, NF = 1.62 dB; RLg ≈ 6 Ω 造成 ~0.5 dB NF costs |
| 4 | 持續最佳化 / Continued optimization | NF = 1.49 dB, S₂₁ = 21.2 dB — 但 S₂₂ = −8.0 dB,負載諧振漂移至 5.6 GHz / but S₂₂ = −8.0 dB, load resonance drifted |
| 5 | 功耗感知調諧 / Power-aware tuning | S₂₁ = 17.0 dB, NF = 1.49 dB — 均在規格內!功耗 23.7 mW(超出預算)/ both in spec! Power over budget |
| 6 | 功耗約束 + 多次隨機重啟 / Power constraints + random restarts | 最佳化器持續碰到 Ld 下限 / Optimizer keeps hitting Ld lower bound |
| 7 | 釋放 C₁/C₂ 為獨立變數 / Freed C₁/C₂ as independent variables | S₂₁ = 20.0 dB, S₂₂ = −10.0 dB |
| 8 | NF 最佳值搜索 / NF optimum search | W = 35 µm, ID = 18 mA: NF = 1.38 dB, S₂₁ = 16.6 dB |
| 最終 Final | 所有規格達標 All specs met | S₂₁ = 20.0 dB, NF = 1.46 dB, S₁₁ = −13.0 dB, S₂₂ ≈ −10 dB, Pdiss = 12.3 mW |
| 參數 Parameter | 原始 Original | 最佳化 Optimized | 目標 Target |
|---|---|---|---|
| S₂₁(增益 Gain) | 7.7 dB | 20.0 dB | 15–20 dB |
| NF @ f₀ | 2.38 dB | 1.46 dB | 0.8–1.5 dB |
| S₁₁ | −30.1 dB | −13.0 dB | < −10 dB |
| S₂₂ | −0.6 dB | −9.9 dB | — |
| 功耗 Pdiss | 9 mW | 12 mW | 5–15 mW |
| K(穩定性 stability) | 19.1 | 11.7 | > 1 |
第一階段——解析約束 Stage 1 — Analytical constraints:
第二階段——網格搜索 Stage 2 — Grid search:
第三階段——Nelder-Mead(5 變數 5-var:Ld, W, I_D, C₁, C₂)/ Stage 3 — Nelder-Mead:
Cost = 3·max(0, 15.5−S₂₁)²
+ 1·max(0, S₂₁−20)²
+ 12·max(0, NF−1.35)²
+ 2·max(0, S₁₁+10)²
+ 8·max(0, S₂₂+10)²
+ 0.5·(Pdiss/14)²升級為差分進化(DE)/ Upgraded to Differential Evolution (DE):
| 方法 Method | 電路評估次數 Circuit Evals | 時間 Time | R_load |
|---|---|---|---|
| v1(網格 + NM grid + NM) | ~26,000+ | ~15 s | Rp·n² = 50 Ω(強制 forced) |
| v2(DE) | 25,026 | 5.4 s | Rp·n² = 73 Ω(真正最佳值,因頻率相依電感損耗 true optimum due to frequency-dependent inductor losses) |
最終 DE 結果 Final DE result: S₂₁ = 20.0 dB, NF = 1.48 dB, S₁₁ = −13 dB, S₂₂ = −9.9 dB, Pdiss = 11.2 mW。
以下適用於 v1 和 v2:/ These apply to both v1 and v2:
要獲得真實結果 To get realistic results: 需要 BSIM-CMG/PDK 模型、EM 萃取電感 S 參數(包含互耦合)、寄生萃取佈局網表、Cadence Spectre 或 ADS。/ need BSIM-CMG/PDK model, EM-extracted inductor S-params (including mutual coupling), parasitic-extracted layout netlists, Cadence Spectre or ADS.