E10.4.1 A Current Source You Can Program

MediumImplementngspice 42 + SKY130 · serverReview the topic

Build a current sink that follows a control voltage at 100 µA/V within 0.5 %. It must keep at least 20 MΩ of output resistance and work with the output as low as 0.6 V.

Circuit context: A programmable current sink on SKY130: a control voltage from 0.2 V to 1.0 V, a fixed op-amp with a gain of 5000 and a 1.8 V output limit, and a load that may pull the output down to 0.6 V. Build a voltage-programmed current sink that stays exact when its headroom shrinks.

A DAC needs a reference current that a control voltage sets: 100 µA for each volt. The control runs from 0.2 V to 1.0 V.

The sink pulls its current through a load from the 1.8 V supply. The load may drop up to 1.2 V, so the output node can fall to 0.6 V.

You have one NMOS type, resistors and a ready-made op-amp, the subcircuit oa. Its gain is 5000 and its output stays between 0 V and 1.8 V.

The starter puts the control voltage on a gate with 10 kΩ under the source. It gives 20.5 µA at 1.0 V. Build a circuit that passes every check.

What the Grader Measures

Your subcircuit vtoi (ports in, out, vdd) under the grader's own bench, one run per corner (tt, ss):

CheckCornerRule
Current at 0.2 V of controltt20 µA ± 0.5 %
Current at 1.0 V of controltt100 µA ± 0.5 %
Current with the output at 0.6 Vtt100 µA ± 0.5 %
Output resistancett≥ 20 MΩ
Current at 1.0 V of controlss100 µA ± 0.5 %
Current with the output at 0.6 Vss100 µA ± 0.5 %
Full specification
The subcircuit the grader tests (keep the name and the ports)
.subckt vtoi in out vdd
* sky130_fd_pr__nfet_01v8, resistors, and X instances of the op-amp: Xname inp inn out oa
.ends
CheckCornerRuleHow the grader measures it
Current at 0.2 V of controltt20 µA ± 0.5 %op with the output at 1.2 V
Current at 1.0 V of controltt, ss100 µA ± 0.5 %op with the output at 1.2 V
Current with the output at 0.6 Vtt, ss100 µA ± 0.5 %op with 1.0 V of control
Output resistancett≥ 20 MΩ1 V of AC on the output at 10 Hz, at 1.0 V of control and 1.2 V

The grader adds the op-amp oa itself. Your subcircuit must not define it. The NMOS body goes to node 0.

Examples

Example 1

The Starter: The Control Voltage on the Gate, 10 kΩ Under the Source
Design
.subckt vtoi in out vdd
* the control voltage drives the gate; 10 k under the source should give 100 uA/V
XM1 out in s 0 sky130_fd_pr__nfet_01v8 W=4 L=0.5
RS s 0 10k
.ends
Measured by the grader
Current at 0.2 V of control: 67.97 pA (needs 20 µA ± 0.5 %)
Current at 1.0 V of control: 20.51 µA (needs 100 µA ± 0.5 %)
Current with the output at 0.6 V: 20.14 µA (needs 100 µA ± 0.5 %)
Output resistance: 2.11 MΩ (needs ≥ 20 MΩ)
Current at 1.0 V of control at ss: 19.26 µA (needs 100 µA ± 0.5 %)
Current with the output at 0.6 V at ss: 18.91 µA (needs 100 µA ± 0.5 %)

The transistor needs its own V_{GS} before any current flows, so nothing here equals V_{in}/10 kΩ. The loop gain of plain degeneration is far too small.

Example 2

The Lesson's Converter: An Op-Amp, a 4/0.5 Transistor and 10 kΩ
Design
.subckt vtoi in out vdd
XA in s g oa
XM1 out g s 0 sky130_fd_pr__nfet_01v8 W=4 L=0.5
RS s 0 10k
.ends
Measured by the grader
Current at 0.2 V of control: 19.98 µA (needs 20 µA ± 0.5 %)
Current at 1.0 V of control: 75.85 µA (needs 100 µA ± 0.5 %)
Current with the output at 0.6 V: 54.26 µA (needs 100 µA ± 0.5 %)
Output resistance: 438.9 kΩ (needs ≥ 20 MΩ)
Current at 1.0 V of control at ss: 74.21 µA (needs 100 µA ± 0.5 %)
Current with the output at 0.6 V at ss: 53.9 µA (needs 100 µA ± 0.5 %)

At 0.2 V it is right within 0.1 %. At 1.0 V the sense resistor needs 1.0 V, and the gate would need more than 1.8 V. The loop runs out of room.

Example 3

Open Loop with a Wide, Short Transistor: 40/0.15 on 10 kΩ
Design
.subckt vtoi in out vdd
XM1 out in s 0 sky130_fd_pr__nfet_01v8 W=40 L=0.15
RS s 0 10k
.ends
Measured by the grader
Current at 0.2 V of control: 758.9 pA (needs 20 µA ± 0.5 %)
Current at 1.0 V of control: 35.22 µA (needs 100 µA ± 0.5 %)
Current with the output at 0.6 V: 32.22 µA (needs 100 µA ± 0.5 %)
Output resistance: 253.8 kΩ (needs ≥ 20 MΩ)
Current at 1.0 V of control at ss: 31.82 µA (needs 100 µA ± 0.5 %)
Current with the output at 0.6 V at ss: 29.59 µA (needs 100 µA ± 0.5 %)

A wider device needs less V_{GS}, but it still needs one. At 1.0 V only 35 µA flows, and a short device lowers the output resistance.

Constraints and Contract

  • The netlist defines .subckt vtoi in out vdd ... .ends exactly once, with these ports in this order.
  • Inside vtoi: X instances of sky130_fd_pr__nfet_01v8 and of oa, resistors, and comments. No sources. The port vdd is the 1.8 V supply, if you need it.
  • The grader writes the .lib line for each corner itself. Its bench replaces everything outside vtoi.

Hints

Hint 1

Make the output current cross a resistor, and let the op-amp compare the voltage on it with the control. Check the sign of the loop.

Hint 2

At 1.0 V of control, how much voltage sits on your sense resistor? The output must stay above it, and the gate must stay under 1.8 V.

Hint 3

The transconductance is a ratio. A divider on the control voltage and a smaller sense resistor give the same 100 µA/V.

Hint 4

Do not divide too far. The op-amp needs its output voltage divided by 5000 between its inputs, and that matters on a small sense voltage.

What the grader checks: The grader holds the output with a voltage source. It reads the sink current at two control voltages and two output voltages. It reads the output resistance at 10 Hz. All runs are at 27 °C. Engine: ngspice 42 (libngspice0 42+ds-3build1) with the lean SKY130 library, measured 2026-11-12 with tools/spice-judge.mjs. The op-amp is an ideal gain of 5000 with a limited output and no poles. So the check says nothing about stability, offset, noise or resistor mismatch.

Run simulates your netlist as written, with your own analyses and measurements. Submit sends it to the grader, which keeps only the subcircuit vtoi and makes 2 ngspice runs. The numbers come from ngspice and the SKY130 models the site pins; they prove the measured cases, not every condition a chip meets.

See all 1 steps and the final capstone

Report a problem with this page

Your netlist SPICESaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs
Not run yet
Run your netlist to see its measurements and the ngspice log here.
ngspice 42 + SKY130 · server