Cadence has a stability analysis that returns loop gain (return ratio). Typically, this is done using a log sweep of frequency. The reason is that doing a uniform linear sweep results in too large frequency steps for low frequencies and/or too large of a step for higher frequencies.

Unfortunately, when you do a logarithmic sweep, you can’t cover from negative to positive frequencies–which is what you want when you generate a Nyquist plot. With the code below, you can reflect the positive frequencies onto negative to get the full Nyquist plot:

 ; load “~/cadence/skill/abConcatWaveforms.il” lg = -getData(“loopGain” ?result “stb”) ; abConcatWaveforms externally defined lg2 = abConcatWaveforms(flip(conjugate(lg)) lg) w = newWindow() ocnYvsYplot(?wavex real(lg2) ?wavey imag(lg2)) stb_x = xmin(abs(lg2-complex(-1.0,0.0))**2) stb_margin = value(lg2, stb_x) addTitle(sprintf(nil “stb_margin = %f dB” -dB20(stb_margin))) xLimit( list(-1.6 0.2) ) yLimit( list(-0.5 0.5) ) 

You’ll need Andrew Beckett’s abConcatWaveforms function defined and loaded.