---
title: MOSFET lab
heading: Thresholds, velocity saturation, parameter extraction and g_m/I_D, in Python
eyebrow: S1 · Lesson 49 · MOSFET lab
xp: 60
---

::: hook
Turning a MOSFET's measured curves into model parameters is a daily job in device engineering: threshold voltage from the linear-region curve, subthreshold swing from the log plot, the effect of velocity saturation on drive current, and the transconductance efficiency $g_m/I_D$ that analog designers size circuits by. This lab writes each extraction in Python and tests it on synthetic curves with known answers, including the realistic complications (mobility degradation, finite step sizes) that make the textbook formulas only approximately right.
:::

::: play
- The curve is a MOSFET's saturation current against channel length at 0.5 V of overdrive, with velocity saturation ($I = WC_{ox}v_\text{sat}V_{ov}^2/(V_{ov} + E_cL)$, $E_c = 2v_\text{sat}/\mu$), against the long-channel square law (dashed).
- At long channels they agree; below a micrometer velocity saturation takes over, and halving L no longer doubles the current.
- Raise the mobility: the critical field drops, and saturation sets in at longer channels.
:::

```sim plot
view: graph
x: L = 0.02..10 µm log
y: I = 0.001..100 mA log
slider: u = 100..600 step 25 = 300
plot: 1e-4*2.3e-6*1e7*0.25/(0.5 + 2*1e7/u*L*1e-4)*1000 | label: velocity-saturated
plot: u*2.3e-6*1e-4/(2*L*1e-4)*0.25*1000 | dashed | label: square law
```

::: predict
## At 50 nm, 1.5 nm of oxide and 0.5 V of overdrive (μ = 300, $v_\text{sat} = 10^7$ cm/s), what fraction of the square-law current does a 1 µm wide transistor deliver?

- [ ] About 95%
- [ ] About 70%
- [x] About 40%
- [ ] About 5%

::: reveal
$E_cL = 2 \times 10^7/300 \times 5 \times 10^{-6} = 0.33$ V, so the current is $WC_{ox}v_\text{sat}V_{ov}^2/(V_{ov} + E_cL) = 0.69$ mA against the square law's 1.73 mA: 40%. Short transistors are faster mostly because their capacitance is smaller, not because they carry more current per volt.
:::
:::

::: nameit
## The tools

- **Threshold:** $V_T = \phi_{ms} - Q_{ox}/C_{ox} + 2\phi_F + \sqrt{2q\varepsilon_sN_A(2\phi_F + V_{SB})}/C_{ox}$.
- **Short-channel current:** $I_{D,\text{sat}} = WC_{ox}v_\text{sat}V_{ov}^2/(V_{ov} + E_cL)$ with $E_c = 2v_\text{sat}/\mu$, which reduces to the square law for long channels.
- **Threshold extraction:** in the linear region at small $V_{DS}$, find the gate voltage of maximum $g_m$, extend the tangent there to zero current, and subtract $V_{DS}/2$.
- **Swing:** the steepest $\Delta V_{GS}/\Delta\log_{10}I_D$ in the subthreshold region.
- **$g_m/I_D$:** the transconductance efficiency, at most $1/(nV_T)$ in weak inversion and falling as $2/V_{ov}$ in strong inversion.
:::

::: check
kind: python

## Write `vt(phi_ms, Qox, Cox, NA, Vsb=0.0, ni=1e10)`: the threshold voltage (V) from the formula above, with $V_T$ = 0.02585 V, $\varepsilon_s$ = 1.036 × 10⁻¹² F/cm and $Q_{ox}$ in C/cm².

```python starter
import math

def vt(phi_ms, Qox, Cox, NA, Vsb=0.0, ni=1e10):
    return 0.5
```

```python solution
import math

Q, ES, VT = 1.602e-19, 1.036e-12, 0.02585

def vt(phi_ms, Qox, Cox, NA, Vsb=0.0, ni=1e10):
    pf = 2 * VT * math.log(NA / ni)
    return phi_ms - Qox / Cox + pf + math.sqrt(2 * Q * ES * NA * (pf + Vsb)) / Cox
```

```python tests
cox = 3.45e-13 / 5e-7
assert abs(vt(-1.0, 0, cox, 1e17) - 0.0743) < 5e-4, "n+ poly-like φms = −1.0 V on 1e17, 5 nm oxide: 0.074 V."
assert abs(vt(-1.0, 0, cox, 1e17, 1.0) - vt(-1.0, 0, cox, 1e17) - 0.1165) < 5e-4, "1 V of body bias raises it 0.12 V."
assert vt(-1.0, 1e11 * 1.602e-19, cox, 1e17) < vt(-1.0, 0, cox, 1e17), "Positive oxide charge lowers the threshold."
```

::: right
Right. Every term is a lesson: work functions, oxide charge, the surface potential and the depletion charge.
:::
:::

::: check
kind: python

## Write `idsat(vov, W, L, Cox, mu, vsat)`: the velocity-saturated saturation current (A), all in cm-based units, returning 0 for vov ≤ 0.

```python starter
def idsat(vov, W, L, Cox, mu, vsat):
    return mu * Cox * W / (2 * L) * vov * vov
```

```python solution
def idsat(vov, W, L, Cox, mu, vsat):
    if vov <= 0:
        return 0.0
    Ec = 2 * vsat / mu
    return W * Cox * vsat * vov * vov / (vov + Ec * L)
```

```python tests
a = idsat(0.5, 1e-4, 50e-7, 2.3e-6, 300, 1e7)
assert abs(a - 0.69e-3) < 1e-6, "50 nm: 0.69 mA."
b = idsat(0.5, 1e-4, 10e-4, 2.3e-6, 300, 1e7)
assert abs(b / (300 * 2.3e-6 * 1e-4 / (2 * 10e-4) * 0.25) - 1) < 0.01, "10 µm: within 1% of the square law."
assert idsat(-0.1, 1e-4, 50e-7, 2.3e-6, 300, 1e7) == 0.0, "Below threshold: 0 in this model."
```

::: right
Right. The single denominator $V_{ov} + E_cL$ blends the two limits smoothly.
:::
:::

::: check
kind: python

## Write `vt_extract(vgs, ids, vds)`: from a linear-region transfer curve at small vds, find the point of maximum $g_m$ (central differences), extrapolate its tangent to $I_D$ = 0, and return that intercept minus vds/2.

```python starter
def vt_extract(vgs, ids, vds):
    return 0.0
```

```python solution
def vt_extract(vgs, ids, vds):
    gm = [(ids[k + 1] - ids[k - 1]) / (vgs[k + 1] - vgs[k - 1]) for k in range(1, len(vgs) - 1)]
    k = max(range(len(gm)), key=lambda i: gm[i]) + 1
    g = gm[k - 1]
    return vgs[k] - ids[k] / g - vds / 2
```

```python tests
vts, kk, vds = 0.45, 1e-3, 0.05
vg = [0.2 + 0.02 * i for i in range(60)]
idl = [(kk * (v - vts - vds / 2) * vds / (1 + 0.3 * (v - vts)) if v > vts + vds / 2 else 0.0) for v in vg]
assert abs(vt_extract(vg, idl, vds) - 0.45) < 2e-3, "With mobility degradation, still within 2 mV of 0.45 V."
```

::: right
Right. Extrapolating at maximum $g_m$ is used because there the curve is closest to straight: below it the device is still turning on, above it mobility degradation bends it over.
:::
:::

::: check
kind: python

## Write `swing(vgs, ids)`: the smallest $\Delta V_{GS}/\Delta\log_{10}I_D$ between neighboring points where the current is positive and rising, and `gm_over_id(vgs, ids)`: the list of $g_m/I_D$ (central differences) at the interior points.

```python starter
def swing(vgs, ids):
    return 0.06

def gm_over_id(vgs, ids):
    return []
```

```python solution
import math

def swing(vgs, ids):
    best = float('inf')
    for k in range(len(vgs) - 1):
        if ids[k] > 0 and ids[k + 1] > ids[k]:
            s = (vgs[k + 1] - vgs[k]) / (math.log10(ids[k + 1]) - math.log10(ids[k]))
            best = min(best, s)
    return best

def gm_over_id(vgs, ids):
    return [(ids[k + 1] - ids[k - 1]) / (vgs[k + 1] - vgs[k - 1]) / ids[k] for k in range(1, len(vgs) - 1)]
```

```python tests
vg = [0.01 * i for i in range(40)]
isub = [1e-12 * 10 ** (v / 0.08) for v in vg]
assert abs(swing(vg, isub) - 0.080) < 1e-9, "80 mV per decade."
g = gm_over_id(vg, isub)
assert abs(g[5] / (math.log(10) / 0.08) - 1) < 0.02, "gm/ID = ln10/S = 28.8 per volt, within the step-size error."
```

::: right
Right. In weak inversion $g_m/I_D$ is flat at $\ln 10/S$; the central difference reads slightly high, by $\sinh(x)/x$ for a step of x.
:::
:::

::: explain
## Why do analog designers size MOSFETs by $g_m/I_D$ rather than by overdrive voltage?

::: model
The transconductance efficiency $g_m/I_D$ says how much gain each unit of bias current buys, and it varies smoothly across weak, moderate and strong inversion, from about $1/(nV_T)$, near 25 to 30 per volt, down to $2/V_{ov}$ at high overdrive. The overdrive voltage, by contrast, loses its meaning in weak inversion, where the square law fails and the threshold is fuzzy. Choosing $g_m/I_D$ first fixes the trade between power and speed (high $g_m/I_D$ is efficient but slow, low is fast but power-hungry), and the transistor's width then follows from the current, using curves measured or simulated for the actual process.
:::
:::
