E10.7.1 The Loop That Fails When Gain Drops

HardVerifyngspice 42 · serverReview the topic

Write the stability bench for a loop amplifier. It must pass three sound loops and fail three faulty ones. One faulty loop has 61.6° of phase margin and still oscillates when its gain drops.

Circuit context: A loop amplifier with its loop opened: behavioural gain, pole, lag-lead and resonance stages, so v(out)/v(in) is the loop gain T. Write the stability sign-off that catches a loop which oscillates when its gain drops.

A regulator team reuses loop amplifiers from several projects. One of them passed a phase-margin check and then oscillated at every power-up. During power-up the gain of an amplifier is low, and that loop is only stable at full gain.

The subcircuit loopamp in the netlist below is one loop amplifier with its loop opened. Drive in, and v(out)/v(in) is the loop gain T. Your bench must decide whether a loopamp meets the two rules in the spec.

The grader swaps each design it tests into your loopamp block and runs your bench. This design and two hidden sound designs must get pass = 1. Three hidden faulty designs must not. Each fault breaks the spec in a different way.

What the Grader Measures

Your bench, with each of these designs swapped into loopamp; it must print pass = 1 on the good ones and not on the faulty ones.

Requirement your bench checksLimit
Phase of T at the highest frequency where |T| = 1≥ −135° (45° of margin)
Phase of T wherever |T| ≥ 1, 1 Hz to 1 GHz> −180°
DesignYour verdict must be
The loop amplifier in your netlist (poles at 500 Hz, 2 MHz and 30 MHz)PASS
A sound loop whose phase dips to −144° and recoversPASS
A sound loop with 100 dB of gain and a 10 Hz polePASS
3 hidden faulty designsFAIL
Full specification
RuleLimitWhere
Phase marginphase of T ≥ −135° (45° of margin)at the highest frequency where |T| = 1
No conditional stabilityphase of T > −180°at every frequency where |T| ≥ 1
The verdict, at the end of your .control block
let pass = ...   * 1 if the design meets both rules, 0 if not
print pass

Check from 1 Hz to 1 GHz. Every design has |T| above 1 at 1 Hz and below 1 at 1 GHz. A phase below −180° is allowed where |T| is below 1.

A design for which your bench prints no verdict, or whose run stops with an error, counts as FAIL. The designs are built from ideal sources, resistors, capacitors and inductors, so no model library is needed.

Examples

Example 1

The Loop Amplifier in the Netlist
Setup
AC sweep, 1 Hz to 1 GHz, 100 points per decade
Measured
pm = 63.83°
lowest phase where |T| ≥ 1 = −115.7°
pass = 1

Two poles lie below the crossover, so the phase never comes near −180° while |T| is above 1. Above the crossover the phase passes −180°, which the spec allows.

Example 2

A Sound Loop with a Dip in Its Phase
Setup
the same bench
Measured
pm = 86.11°
lowest phase where |T| ≥ 1 = −144.5°
pass = 1

A double pole pulls the phase down to −144.5° at 6.6 kHz and a zero brings it back. The dip stays above −180°, so no drop in gain can make this loop oscillate.

Example 3

The Loop That Failed at Power-Up
Setup
the same bench
Measured
pm = 61.59°
lowest phase where |T| ≥ 1 = −214.7°
pass = 0

The margin at the crossover is good. But the phase is below −180° over a band where |T| is far above 1. A lower gain puts the crossover inside that band.

Constraints and Contract

  • Keep exactly one .subckt loopamp in out ... .ends block. The grader replaces it with each design it tests, so changes inside it are not graded.
  • The bench sees the design only through its two ports: no nodes or devices inside x instances, no show or altermod.
  • Print the verdict as pass. Any value of at least 0.5 counts as PASS.

Hints

Hint 1

vp() and ph() wrap the phase into one turn. A phase of −215° then prints as +145° and looks safe. cph() keeps the phase continuous.

Hint 2

|T| can cross 0 dB more than once. meas ... WHEN tdb=0 finds the first crossing. Add CROSS=LAST to find the last one.

Hint 3

A comparison of two vectors gives a vector of 0 and 1. So (tdb ge 0) is 1 at every point where |T| is 1 or more. Use it to keep only those points before you take a minimum.

What the grader checks: The grader runs your bench on this loop amplifier, two hidden sound ones and three hidden faulty ones. It compares your printed verdict with the right one for each design. It grades the decisions, not the numbers you print. Engine: ngspice 42 (libngspice0 42+ds-3build1), measured 2026-11-12 with tools/spice-judge.mjs. The designs are linear models of a loop; the bench does not test clipping, slewing or start-up in the time domain.

Run simulates your netlist as written, with your own analyses and measurements. Submit sends it to the grader, which keeps only your bench and makes 6 ngspice runs, one per design. 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 · server