Category Archives: Mixed-signal systems

A silly script for two-stage OP compensation

As a complement to one of my lectures on compensation of operational amplifiers, I wrote a crude MATLAB example for testing stability and ability to loop for example currents, voltages, etc. In some sense, this could be done using veriloga blocks and slighlty more accurate circuit descriptions. But yet — this is a quite good way of understanding the operation of something as simple as a two-pole system.

I’m referring to a standard two-stage amplifier with a differential-pair in the first stage and a common-source at the output. Attached is also a plot result from octave illustrating the pole/zero placement.

Octave plot of phase and amplitude

Octave plot of phase and amplitude

And you get some results in raw format:

octave:1> antikPoleZero
f_ug = 3.0917e+08
phi_m = 54.465
p_1 = -1.1171e+05
p_2 = -3.2733e+09
p_3 = -7.7695e+12
z_1 = 2.2957e+10

So, just an example/suggestion of simple ways to get some more understanding of the operation of the circuit.


%
% Mainly, this "demo" concentrates on the classical two-stage
% amplifier. This implies also that we have not employed the
% suggested technique by J. Baker, et al.
%
% Some of the design rules:

% Miller

% z_1 approx 10*w_ug => gm_II = 10*gm_I
% p_2 approx 2.2*w_ug => C_C = 0.22 * C_II
% or more generically => C_C = 2.2*C_II/(gm_II/gm_I)

% Nulling resistor:

% And then (nulling resistor option 2, where z_1 -> inf):
% p_2 approx 1.73*w_ug => C_C = 1.73 * C_II / (gm_II/gm_I)
% p_3 > 10 * w_ug
% R_Z = 1/gm_II

% Setting up the frequencies
% No need to touch this
% =========================================================
N = 256;
f = logspace(1, 11, N);
w = 2*pi*f;
s = j*w;

% Some "process"-dependent parameters. Assuming a relatively
% strong channel-length modulation.
lambda = 0.05;

% =========================================================

% =========================================================
% Do your changes here. Why not a for loop on top? You can
% characterize the phase margin as function of tail current,
% or similar.
% =========================================================
% =========================================================
% =========================================================

% Going to a more circuit-level representation:
% Tail current through the differential pair.
I_0 = 100e-6;

% Effective input voltage on diff-pair transistors:
Veff_I = 0.2;

% The second-stage driving capacitor. For sake of argument,
% the effective is slightly higher here.
Veff_II = 0.4;

% The mirror ratio between the output stage and the input
% stage, i.e., the output stage drives K times more current
% than the differential pair.
% Notice that the gm_II = gm_I * K * Veff_I / Veff_II;
K = 20;

% Internal stage capacitance. For sake of modeling, we have
% assumed that the drive transistor in the second stage also
% scales with K (given a constant current and Veff_II).
% C_I is approximately the CGS of the drive transistor.
% Assuming some fF-cap on the gate:

C_I = K*10e-15;

% C_II is the load capacitance.
C_II = 2e-12;

% Some tentative compensation network to start with.
C_C = 0.22 * C_II;
R_Z = 1 ; % AND ALSO SEE BELOW!

% =========================================================
% =========================================================
% =========================================================

% We can now form the different parameters, etc.
% Given the parameters above, calculate the transfer function:
% No need to touch this.
% =============================================================

% First stage:
gm_I = 2*I_0 / Veff_I;
g_I = lambda*I_0;
% Second stage:
gm_II = 2*K*I_0/Veff_II;
g_II = lambda*K*I_0;

A_I = gm_I / g_I;
A_II = gm_II / g_II;

a = A_I * A_II;
b = (C_II + C_C)/g_II + (C_I+C_C)/g_I + a*C_C/gm_I + R_Z*C_C;
c = ((1/(g_I*g_II))*(C_I*C_II + C_C*C_I + C_C*C_II) + ...
R_Z*C_C*(C_I/g_I + C_II/g_II));

d = R_Z*C_I*C_II*C_C/g_I/g_II;

z_1 = 1/(C_C/gm_II - R_Z*C_C);

% =========================================================
% =========================================================
% =========================================================
R_Z = 1 /gm_II;
% =========================================================
% =========================================================
% =========================================================

A_s = a * ( 1 - s /z_1) ./ ...
( 1 + b*s + c*s.^2 + d*s.^3);

% Derive the roots as:
p = roots([1 c/d b/d 1/d ]);

% Just for some pretty-printing.
p_1 = p(3);
p_2 = p(2);
p_3 = p(1);

% Amplitude and phase characteristics
log_A = 20*log10(abs(A_s));
ang_A = 180*unwrap(angle(A_s))/pi;

% Find the unity-gain frequency (in Hz) and phase margin

f_ug = mean(f(find(abs(log_A)==min(abs(log_A)))));
phi_m = mean(ang_A(find(abs(log_A)==min(abs(log_A)))))+180;

% the mean-thing is there to avoid some numerical issues.

fh = figure(1);
subplot(2,1,1);
sh(1) = semilogx(f, log_A);
hold on;
ph(1) = plot(abs(p_1/2/pi), 0, 'x');
ph(2) = plot(abs(p_2/2/pi), 0, 'x');
ph(3) = plot(abs(p_3/2/pi), 0, 'x');
ph(4) = plot(abs(z_1/2/pi), 0, 'o');
lh = line(f_ug*[1 1], [20*log10(abs(A_s(1))) -150]);
tl(1) = title('Amplitude characteristics');
tl(2) = ylabel('|A^2(j \omega )|');
hold off;

subplot(2,1,2);
sh(2) = semilogx(f, ang_A);
hold on;
ph(5) = plot(abs(p_1/2/pi), 0, 'x');
ph(6) = plot(abs(p_2/2/pi), 0, 'x');
ph(7) = plot(abs(p_3/2/pi), 0, 'x');
ph(8) = plot(abs(z_1/2/pi), 0, 'o');
lh = line(f_ug*[1 1], [0 -180]);
tl(3) = ylabel('arg{ A(j \omega )}');
tl(4) = xlabel('Frequency [Hz]');
hold off;

set(tl,'FontSize',18);
set(ph,'LineWidth',4);
set(sh,'LineWidth',4);

% =============================================================
% Dumping some data in raw format

f_ug
phi_m
p_1
p_2
p_3
z_1

% =============================================================

Two-stage OP and macro model

Two-stage OP and macro model


Top Ten: Mixed-signal design books

After some Christmas and New Year holidays as well as wrapping up our course in Mixed-Signal Processing Systems, I think the activity should improve here a bit…

Perhaps starting off with a new Top Ten list…

Since the two courses Analog and Discrete Time Integrated Circuits and Analog Integrated Circuits are to be given this spring (starts in a week or so…) I though it would be nice to start off with a book list. Searching for valid literature within the field of mixed-signal integrated circuit design is a bit tedious. One drawback is that the books are soon outdated. CMOS processes, standards and applications are evolving and the books should feel fairly modern to read. Obviously, some of the basics wrt. filter theory, compensation, etc., do not change, but still … using 10-year old transistor parameters for examples makes the students a bit doubtful.

Anyway, so let’s start (and in this case, no particular order – albeit a bit biased). And the standard disclaimers: The list is not intended to be complete, please add comments with your own examples. And I will not write a complete review, but only give you the link such that you can continue your googling on your own.

So, This is my list of the Top Ten text books for integrated mixed-signal circuit design on an advanced Bachelor’s level, Master level and Ph.D. level.

  • #10: CMOS Data Converters for Communications , by Gustafsson, Wikner, and Tan. and Mixed-Signal Processing Systems, edited by Löwenborg
    We have to start somewhere to get the snowball rolling. and it is perhaps a bit ambitious to put two of our “own” books on this list, but after all there were reasons they were written in the first place. In our case, we needed a book on data converters and then we needed a comprehensive book on the design of mixed-signal systems.

    The data converters book is not a course text book as such, but explains quite well some of the more detailed design aspects of data converters to be put into a telecommunication application. (The book outlines ADSL which was a “hot” topic back in the late 90′s, early 00′s). So, with that said, it is also a bit outdated. The book does not outline any theory behind transistors, etc., so don’t expect that. It is more to be considered as a reference book for data converter design. There are no exercises either.
    The mixed-signal processing book is indeed a dedicated spot-on course book, but without exercises. The book is a compilation of several chapters were each single chapter fills a very important role in the complete design of a mixed-signal communication system (AFE plus parts of PHY). There are chapters on digital-filter design, top-level design, test-driven design, analog filters, data converters, tuning, etc. Each chapter written and compiled by experienced Ph.D. students.

  • #9: CMOS Analog Circuit Design , by Allen and Holberg
    This is my starting book back in 1996 and more or less the first book with integrated CMOS transistors as scope that I ever opened. First, I was a bit scared, since it seemed a bit “dry”, but now after some years, I still claim it is very good book from a theoretical point of view. It has good examples, it has a very good description of how to design an operational amplifier and how to compensate it well. It gives a couple of cookbook recipes for the most common amplifier types.

    The book now exists in a second edition with a few updated chapters and still has a very good theoretical background.
  • #8: Design of Analog CMOS Integrated Circuits, by Razavi.
    This is a somewhat “newer” book which spans more circuits, but perhaps less in detail of things. In this book we find more information on PLLs, bandgaps and the kind of circuits you would expect to find in today’s mixed-signal macros. The book also solely focuses on CMOS circuits.
    Data converters are not covered, which is potentially a drawback with the book. On the other hand, one should also acknowledge the title of the book, which does not imply the digital portion of the circuits.
  • #7: Analog Integrated Circuit Design, by Johns and Martin
    Probably my favourite currently (but I’m a fan of many books, even for courses, especially since the development is so dynamic and one has to stay tuned…). The book has a nice format, easy-to-read, good exercises, etc. The advantage with the book is that it also contains data converters, switched-capacitor circuits, and a short chapter on PLLs. I find it a very good educational book, with a lot of good examples and exercises.
    I use it as the main course book in the two analog courses I give at the University. The book, however, is now some 15 years old and I’m eagerly waiting for a new edition.
  • #6: Analysis and Design of Analog Integrated Circuits, by Gray, Hurst, Lewis, and Meyer.
    The brick. This is is 900 pages of pure analog design. It has excellent chapters on feedback and compensation theory as well as operational amplifier design. It outlines differential design well (which is quite poorly done in most books). The “drawbacks” are that it is very analog and lacks the most important mixed-signal circuits and it has potentially too much of introduction with respect to semiconductors. (Notice that this is not drawbacks as such, but for the mixed-signal design scope … ). The book is now offered in it’s fifth edition which also indicates the robustness and popularity of the book.
    I recommend my students (and you too in case you’re not a student of mine) to read the feedback chapters. Most interesting.
  • #5: Analog Design Essentials by Willy Sansen.
    Now, this is a “new-comer” on the market, well 2006. The main advantage is the nice way of interchanging lecture slides with text and exercises. This is not only a book for a course lecturer, but also for engineers that can get “easy-reading” with clear slides/pictures that guides the reader. Using this presentation method, the book also becomes very easy to read and browse.
    I am now using it as reference material for my courses and my Ph.D. students are also using it.
  • #4: The Design of CMOS Radio-Frequency Integrated Circuits, by Lee.
    Ok, so here we could argue that it is not a mixed-signal book. However, it has a couple of great chapters. Especially those on noise (two chapters on noise) and feedback. Further on, the oscillator chapters and phase-locked loop chapters nowadays would classify as mixed-signal systems in some sense. The book also spans some other “minor” topics that are missing in some of the other books, like performance measures (SNDR, SFDR, etc.) as well as nomenclature also found for normal analog design, such as Class A, B, C, etc. (In Lee’s case, they are referred to in the PA chapter).
    I would also like to recommend the reader to really read the footnotes (as well as the historic “tales”) in the book. There are some really fun comments by Lee in there.
  • #3: CMOS: Mixed-Signal Circuit Design, by Baker
    This is a “hardcore” book getting directly to the point in some sense. There is not that many discussions on the “simplest” building blocks, but instead we get to the filters, data converters, etc. This scope and focus resembles quite a lot the work we do in our mixed-signal processing systems course (which is also the next bullet on this list).

    One great advantage with the Baker book is the “support” from the CMOSEDU web pages, design examples, etc. are found for a large variety of simulators. There are slides, solutions, forums, etc. Very good backup indeeed.
  • #2:Analog VLSI: Signal and Information Processing, by Ismail and Fiez.
    The last two bullets on this list are perhaps not educational text books as such (well, this one is…) but I add them due to nostalgic reasons. They are also the first two books I kind of read as a fresh Ph.D. students back in 1996.
    The book by Ismail and Fiez is from 1994 and I am not sure if it is available for purchase in new-print anymore (the link above is pointing at used books). It is claimed that: “This book presents the first comprehensive treatment of analog VLSI design for signal and information processing applications by blending the basic design concepts of both traditional and contemporary analog VLSI.”. And in some sense it was true back then… It also contains a few examples to “fun” circuits back then, like the super-MOS component, the neurological circuits, etc. It was an inspiring book by then, as it gave me a completely different view on analog integrated circuit design. Rather than just dull (?) amplifiers, there were new things in it!
  • #1: Analogue IC design: the current-mode approach, , by Toumazou, Lidgey, and Haigh (eds) and Switched-currents: an analogue technique for digital technology, by Toumazou, Hughes, and Battersby (eds).
    As for the previous item, this was an eye-opener too. Back in those days, the switched-current technique was (re-)invented and it was fresh material to read. It also opened up for new types of analyses. At our group, quite a lot of switched-current work was published and resulting in Ph.D. dissertations. (If Bengt E Jonsson reads this, he might be able to fill in some gaps.
    The books are perhaps not course books, but they are inspirational for an analog design engineer with some curiosity in “odd” things.

And/or take this poll:


CAD:Just a reminder about Spectre and long simulations

Just a reminder for those who run long simulations in Cadence Spectre, especially the transient ones:

  • Set the saveclock option (in seconds) to the time interval at which you want your simulator to save its state.
  • Set the savefile option to a file name in which you want to save your state.
  • Set the recover option to a file name from which you want to load your state.

So, if you set saveclock to 60, spectre will regularly, every minute save its state to savefile. You can launch the long simulation and press stop and restart as many times as you like. Spectre will restart at the latest minut (clockwise). This is quite handy if there is a power cut or network is dropped.

Notice that the file is overwritten and if you want to save several minutes back, you need to have another script running in parallel saving that data for you. This could also be a handy strategy considering that in the worst case (which is also the most likely case according to Mr. Murphy) you might be writing to disk, just as Spectre or connection dies.

Notice also that you can alter some of the simulator settings. For example the number of nodes saved. This means you can set the simulator to log all nodes first, check them after a while, then stop. Remove some of the probes to save time/disk area, and re-run. Quite handy!


A Silly Script to Create OCEAN desVars

As we are now ramping up some of the projects for the TSTE16 course at our university, I wanted to just propose a small snippet to get your design variables from MATLAB into Cadence (or more exactly the OCEAN-script for simulating Spectre). The idea is to have MATLAB as master in these projects. This also implies that you want to set any design variables using MATLAB rather than hacking multiple files and risking loosing track of what you’ve been doing.

There are many ways to do this:
(1) One option is to use the simulink interface provided by MATLAB and Cadence, but is a bit over the top in this case.
(2) Another option is to create all the required netlists in the Cadence ADE environment. This will actually generate multiple files in your simulation directory. The “full” file which will be used for spectre is normally called “input.scs” . Further on, if you play that play button (Cadence 6) and study the log file, you actually see in the text which spectre command that is run. (Further on, this command is also stored in the runSimulation “script” stored by Cadence in that directory). The input.scs file is just a concatenation of several files, such as netlistHeader, netlist, netlistFooter — but also some dot-files, like .modelFiles and .designVariables. The latter is a text version of your variables that you could alter if you like. Then concatenate the files into the input.scs accordingly. And run. Requires some more hands on and have less post-processing options.

(3) Or assume we have already generated the Cadence test bench and generated an OCEAN script with a bunch of desVar definitions in it. We can replace those rows with a load command, e.g.

(loadi "tste16ProjDesVars.il")

which you have stored accessible somewhere.
Then make sure you can change that file with MATLAB. Like for example:


desVar(1).Name = 'vccr12';
desVar(1).Value = 1.2;

desVar(2).Name = 'vLo';
desVar(2).Value = 0.1;

desVar(3).Name = 'vHi';
desVar(3).Value = 1.1;

desVar(4).Name = 'compGain';
desVar(4).Value = 1000;

fClk = 1e6;
desVar(5).Name = 'fClk';
desVar(5).Value = fClk;

sigLength = 8;
desVar(6).Name = 'sigLength';
desVar(6).Value = sigLength;

desVar(7).Name = 'tStop';
desVar(7).Value = sigLength/fClk;

desVar(8).Name = 'daisyDemoTopReadFile';
desVar(8).Value = '/home/jacobw/TSTE16/testIn.txt';

desVar(9).Name = 'daisyDemoTopWriteFile';
desVar(9).Value = '/home/jacobw/TSTE16/testOut.txt';

%% This part would then be in a separate function.
fid = fopen('tste16ProjDesVar.il','w');
fprintf(fid, ';; ==================================== \n');
fprintf(fid, ';; Design variables generated by MATLAB \n');
fprintf(fid, ';; ==================================== \n');
for M = 1:length(desVar);
if isstr(desVar(M).Value)
fprintf(fid, '(desVar "%s" "\\"%s\\"")\n', desVar(M).Name, ...
desVar(M).Value);
else
fprintf(fid, '(desVar "%s" %f)\n', desVar(M).Name, ...
desVar(M).Value);
end
end;
fprintf(fid, ';; ==================================== \n');
close(fid);

Where I have used structs to store the intermediate design variables. You can also store strings into the design variables to pass on file names or similar to verilog A blocks in Cadence.
This gives you a file like


;; ====================================
;; Design variables generated by MATLAB
;; ====================================
(desVar "vccr12" 1.200000)
(desVar "vLo" 0.100000)
(desVar "vHi" 1.100000)
(desVar "compGain" 1000.000000)
(desVar "fClk" 1000000.000000)
(desVar "sigLength" 8.000000)
(desVar "tStop" 0.000008)
(desVar "daisyDemoTopReadFile" "\"/home/jacobw/TSTE16/testIn.txt\"")
(desVar "daisyDemoTopWriteFile" "\"/home/jacobw/TSTE16/testOut.txt\"")
;; ====================================

Happy hacking!


Follow

Get every new post delivered to your Inbox.

Join 45 other followers