<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://wulffern.github.io/aic2024/feed.xml" rel="self" type="application/atom+xml" /><link href="https://wulffern.github.io/aic2024/" rel="alternate" type="text/html" /><updated>2024-11-16T14:59:26+00:00</updated><id>https://wulffern.github.io/aic2024/feed.xml</id><title type="html">aic2024</title><subtitle>Lectures on Advanced Integrated Circuits 2024</subtitle><author><name>Carsten Wulff</name><email>carsten@wulff.no</email></author><entry><title type="html">SPICE</title><link href="https://wulffern.github.io/aic2024/2024/09/11/SPICE.html" rel="alternate" type="text/html" title="SPICE" /><published>2024-09-11T00:00:00+00:00</published><updated>2024-09-11T00:00:00+00:00</updated><id>https://wulffern.github.io/aic2024/2024/09/11/SPICE</id><content type="html" xml:base="https://wulffern.github.io/aic2024/2024/09/11/SPICE.html"><![CDATA[<blockquote>
  <p>If you find an error in what I’ve made, then <a href="https://docs.github.com/en/get-started/quickstart/fork-a-repo">fork</a>, fix <a href="https://github.com/wulffern/aic2024/tree/main/lectures/l00_spice.md">lectures/l00_spice.md</a>, <a href="https://git-scm.com/docs/git-commit">commit</a>, <a href="https://git-scm.com/docs/git-push">push</a> and <a href="https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/working-with-your-remote-repository-on-github-or-github-enterprise/creating-an-issue-or-pull-request">create a pull request</a>. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.</p>
</blockquote>

<p><a href="/aic2024/assets/slides/l00_spice.pdf">Slides</a></p>

<ul id="markdown-toc">
  <li><a href="#spice" id="markdown-toc-spice">SPICE</a></li>
  <li><a href="#simulation-program-with-integrated-circuit-emphasis" id="markdown-toc-simulation-program-with-integrated-circuit-emphasis">Simulation Program with Integrated Circuit Emphasis</a>    <ul>
      <li><a href="#today" id="markdown-toc-today">Today</a></li>
      <li><a href="#but" id="markdown-toc-but">But</a></li>
      <li><a href="#sources" id="markdown-toc-sources">Sources</a>        <ul>
          <li><a href="#independent-current-sources" id="markdown-toc-independent-current-sources">Independent current sources</a></li>
          <li><a href="#independent-voltage-source" id="markdown-toc-independent-voltage-source">Independent voltage source</a></li>
        </ul>
      </li>
      <li><a href="#passives" id="markdown-toc-passives">Passives</a></li>
      <li><a href="#transistor-models" id="markdown-toc-transistor-models">Transistor Models</a></li>
      <li><a href="#transistors" id="markdown-toc-transistors">Transistors</a></li>
      <li><a href="#foundries" id="markdown-toc-foundries">Foundries</a></li>
    </ul>
  </li>
  <li><a href="#find-right-transistor-sizes" id="markdown-toc-find-right-transistor-sizes">Find right transistor sizes</a>    <ul>
      <li><a href="#use-unit-size-transistors-for-analog-design" id="markdown-toc-use-unit-size-transistors-for-analog-design">Use unit size transistors for analog design</a></li>
      <li><a href="#what-about-gmid-" id="markdown-toc-what-about-gmid-">What about gm/Id ?</a></li>
      <li><a href="#characterize-the-transistors" id="markdown-toc-characterize-the-transistors">Characterize the transistors</a></li>
    </ul>
  </li>
  <li><a href="#more-information" id="markdown-toc-more-information">More information</a></li>
  <li><a href="#analog-design" id="markdown-toc-analog-design">Analog Design</a></li>
  <li><a href="#demo" id="markdown-toc-demo">Demo</a></li>
</ul>

<h1 id="spice">SPICE</h1>

<iframe width="560" height="315" src="https://www.youtube.com/embed/z9go-m0hnIg?si=YI3uCt9mp4Ei65Xo" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen=""></iframe>

<h1 id="simulation-program-with-integrated-circuit-emphasis">Simulation Program with Integrated Circuit Emphasis</h1>

<p>To manufacture an integrated circuit we have to be able to predict how it’s going to work. The only way to predict is to rely on our knowledge of physics, and build models 
of the real world in our computers.</p>

<p>One simulation strategy for a model of the real world, which absolutely every single integrated circuit in the world has used to come into existence, is SPICE.</p>

<p>Published in 1973 by Nagel and Pederson</p>

<p><a href="https://www2.eecs.berkeley.edu/Pubs/TechRpts/1973/ERL-m-382.pdf">SPICE (Simulation Program with Integrated Circuit Emphasis)</a></p>

<p><img src="/aic2024/assets/media/nagel.png" alt="" width="700" /></p>

<h2 id="today">Today</h2>

<p>There are multiple SPICE programs that has been written, but they all work in a similar fashion. There are expensive ones, closed source, and open source.</p>

<p>Some are better at dealing with complex circuits, some are faster, and some are more accurate. If you don’t have money, then start with ngspice.</p>

<p><strong>Commercial</strong>
<a href="https://www.cadence.com/ko_KR/home/tools/custom-ic-analog-rf-design/circuit-simulation/spectre-simulation-platform.html">Cadence Spectre</a>
<a href="https://eda.sw.siemens.com/en-US/ic/eldo/">Siemens Eldo</a>
<a href="https://www.synopsys.com/implementation-and-signoff/ams-simulation/primesim-hspice.html">Synopsys HSPICE</a></p>

<p><strong>Free</strong>
<a href="http://aimspice.com">Aimspice</a>
<a href="https://www.analog.com/en/design-center/design-tools-and-calculators/ltspice-simulator.html">Analog Devices LTspice</a></p>

<p><strong>Open Source</strong>
<a href="http://ngspice.sourceforge.net">ngspice</a></p>

<h2 id="but">But</h2>

<p>All SPICE simulators understand the same language (yes, even spectre can speak SPICE). We write our testbenches in a text file, and give it to the SPICE program. That’s the same for all programs. Some may have 
built fancy GUI’s to hide the fact that we’re really writing text files, but text files is what is under the hood.</p>

<p>Pretty much the same usage model as 48 years ago</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;spice program&gt; testbench.cir
</code></pre></div></div>

<p>for example</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ngspice testbench.cir
</code></pre></div></div>

<p>Or in the most expensive analog tool (Cadence Spectre)</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> spectre  input.scs  +escchars +log ../psf/spectre.out 
  -format psfxl -raw ../psf   +aps +lqtimeout 900 -maxw 5 -maxn 5 -env ade  -ahdllibdir 
  /tmp/wulff/virtuoso/TB_SUN_BIAS_GF130N/TB_SUN_BIAS/maestro/results/maestro/Interactive.15/sharedData/CDS/ahdl/input.ahdlSimDB 
  +logstatus 
</code></pre></div></div>

<p>The expensive tools have built graphical user interface around the SPICE simulator to make it easier to run multiple scenarios.</p>

<table>
  <thead>
    <tr>
      <th style="text-align: left">Corner</th>
      <th style="text-align: left">Typical</th>
      <th style="text-align: left">Fast</th>
      <th style="text-align: left">Slow</th>
      <th style="text-align: left">All</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: left">Mosfet</td>
      <td style="text-align: left">Mtt</td>
      <td style="text-align: left">Mff</td>
      <td style="text-align: left">Mss</td>
      <td style="text-align: left">Mff,Mfs,Msf,Mss</td>
    </tr>
    <tr>
      <td style="text-align: left">Resistor</td>
      <td style="text-align: left">Rt</td>
      <td style="text-align: left">Rl</td>
      <td style="text-align: left">Rh</td>
      <td style="text-align: left">Rl,Rh</td>
    </tr>
    <tr>
      <td style="text-align: left">Capacitors</td>
      <td style="text-align: left">Ct</td>
      <td style="text-align: left">Cl</td>
      <td style="text-align: left">Ch</td>
      <td style="text-align: left">Cl,Ch</td>
    </tr>
    <tr>
      <td style="text-align: left">Diode</td>
      <td style="text-align: left">Dt</td>
      <td style="text-align: left">Df</td>
      <td style="text-align: left">Ds</td>
      <td style="text-align: left">Df,Ds</td>
    </tr>
    <tr>
      <td style="text-align: left">Bipolar</td>
      <td style="text-align: left">Bt</td>
      <td style="text-align: left">Bf</td>
      <td style="text-align: left">Bs</td>
      <td style="text-align: left">Bf,Bs</td>
    </tr>
    <tr>
      <td style="text-align: left">Temperature</td>
      <td style="text-align: left">Tt</td>
      <td style="text-align: left">Th,Tl</td>
      <td style="text-align: left">Th,Tl</td>
      <td style="text-align: left">Th,Tl</td>
    </tr>
    <tr>
      <td style="text-align: left">Voltage</td>
      <td style="text-align: left">Vt</td>
      <td style="text-align: left">Vh,Vl</td>
      <td style="text-align: left">Vh,Vl</td>
      <td style="text-align: left">Vh,Vl</td>
    </tr>
  </tbody>
</table>

<p><img src="/aic2024/assets/media/assembler.png" alt="" width="700" /></p>

<p>I’m a fan of launching multiple simulations from the command line. I don’t like GUI’s. As such, I wrote <a href="https://github.com/wulffern/cicsim/tree/main">cicsim</a>, and that’s what I use in the video and demo.</p>

<h2 id="sources">Sources</h2>

<p>The SPICE language is a set of conventions for how to write the text files. In general, it’s one line, one command (although, lines can be continued with a +).</p>

<p>I’m not going to go through an extensive tutorial in this document, and there are dialects with different SPICE programs. You’ll find more info at <a href="http://ngspice.sourceforge.net/docs.html">ngspice</a></p>

<h3 id="independent-current-sources">Independent current sources</h3>

<p><sub>Infinite output impedance, changing voltage does not change current</sub></p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>I&lt;name&gt; &lt;from&gt; &lt;to&gt; dc &lt;number&gt; ac &lt;number&gt;

I1 0 VDN dc In
I2 VDP 0 dc Ip

</code></pre></div></div>

<h3 id="independent-voltage-source">Independent voltage source</h3>

<p><sub>Zero output impedance, changing current does not change voltage</sub></p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>V&lt;name&gt; &lt;+&gt; &lt;-&gt; dc &lt;number&gt; ac &lt;number&gt;

V2 VSS 0 dc 0
V1 VDD 0 dc 1.5

</code></pre></div></div>

<h2 id="passives">Passives</h2>

<p>Resistors</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>R&lt;name&gt; &lt;node 1&gt; &lt;node 2&gt; &lt;value&gt;

R1 N1 N2 10k
R2 N2 N3 1Meg
R3 N3 N4 1G
R4 N4 N5 1T
</code></pre></div></div>

<p>Capacitors</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>C&lt;name&gt; &lt;node 1&gt; &lt;node 2&gt; &lt;value&gt;

C1 N1 N2 1a
C2 N1 N2 1f
C4 N1 N2 1p
C3 N1 N2 1n
C5 N1 N2 1u

</code></pre></div></div>

<h2 id="transistor-models">Transistor Models</h2>

<p>Needs a model file the transistor model</p>

<p>BSIM (Berkeley Short-channel IGFET Model)
<a href="http://bsim.berkeley.edu/models/bsim4/">http://bsim.berkeley.edu/models/bsim4/</a></p>

<p><img src="/aic2024/assets/media/fig_transistor.svg" alt="" width="700" /></p>

<p>284 parameters in <a href="http://www-device.eecs.berkeley.edu/~bsim/Files/BSIM4/BSIM480/BSIM480_Manual.pdf">BSIM 4.5</a></p>

<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">.</span><span class="no">MODEL</span> <span class="no">N1</span> <span class="no">NMOS</span> <span class="no">LEVEL</span><span class="o">=</span><span class="mi">14</span> <span class="no">VERSION</span><span class="o">=</span><span class="mf">4.5</span><span class="o">.</span><span class="mi">0</span> <span class="no">BINUNIT</span><span class="o">=</span><span class="mi">1</span> <span class="no">PARAMCHK</span><span class="o">=</span><span class="mi">1</span> <span class="no">MOBMOD</span><span class="o">=</span><span class="mi">0</span>
<span class="no">CAPMOD</span><span class="o">=</span><span class="mi">2</span> <span class="no">IGCMOD</span><span class="o">=</span><span class="mi">1</span> <span class="no">IGBMOD</span><span class="o">=</span><span class="mi">1</span> <span class="no">GEOMOD</span><span class="o">=</span><span class="mi">1</span>  <span class="no">DIOMOD</span><span class="o">=</span><span class="mi">1</span> <span class="no">RDSMOD</span><span class="o">=</span><span class="mi">0</span> <span class="no">RBODYMOD</span><span class="o">=</span><span class="mi">0</span> <span class="no">RGATEMOD</span><span class="o">=</span><span class="mi">3</span>
<span class="no">PERMOD</span><span class="o">=</span><span class="mi">1</span> <span class="no">ACNQSMOD</span><span class="o">=</span><span class="mi">0</span> <span class="no">TRNQSMOD</span><span class="o">=</span><span class="mi">0</span> <span class="no">TEMPMOD</span><span class="o">=</span><span class="mi">0</span>  <span class="no">TNOM</span><span class="o">=</span><span class="mi">27</span> <span class="no">TOXE</span><span class="o">=</span><span class="mf">1.8E-009</span>
<span class="no">TOXP</span><span class="o">=</span><span class="mf">10E-010</span> <span class="no">TOXM</span><span class="o">=</span><span class="mf">1.8E-009</span>  <span class="no">DTOX</span><span class="o">=</span><span class="mf">8E-10</span> <span class="no">EPSROX</span><span class="o">=</span><span class="mf">3.9</span> <span class="no">WINT</span><span class="o">=</span><span class="mf">5E-009</span> <span class="no">LINT</span><span class="o">=</span><span class="mf">1E-009</span>
<span class="no">LL</span><span class="o">=</span><span class="mi">0</span> <span class="no">WL</span><span class="o">=</span><span class="mi">0</span> <span class="no">LLN</span><span class="o">=</span><span class="mi">1</span> <span class="no">WLN</span><span class="o">=</span><span class="mi">1</span>  <span class="no">LW</span><span class="o">=</span><span class="mi">0</span> <span class="no">WW</span><span class="o">=</span><span class="mi">0</span> <span class="no">LWN</span><span class="o">=</span><span class="mi">1</span> <span class="no">WWN</span><span class="o">=</span><span class="mi">1</span>  <span class="no">LWL</span><span class="o">=</span><span class="mi">0</span> <span class="no">WWL</span><span class="o">=</span><span class="mi">0</span> <span class="no">XPART</span><span class="o">=</span><span class="mi">0</span>
<span class="no">TOXREF</span><span class="o">=</span><span class="mf">1.4E-009</span>  <span class="no">SAREF</span><span class="o">=</span><span class="mf">5E-6</span> <span class="no">SBREF</span><span class="o">=</span><span class="mf">5E-6</span> <span class="no">WLOD</span><span class="o">=</span><span class="mf">2E-6</span> <span class="no">KU0</span><span class="o">=-</span><span class="mf">4E-6</span>  <span class="no">KVSAT</span><span class="o">=</span><span class="mf">0.2</span>
<span class="no">KVTH0</span><span class="o">=-</span><span class="mf">2E-8</span> <span class="no">TKU0</span><span class="o">=</span><span class="mf">0.0</span> <span class="no">LLODKU0</span><span class="o">=</span><span class="mf">1.1</span>  <span class="no">WLODKU0</span><span class="o">=</span><span class="mf">1.1</span> <span class="no">LLODVTH</span><span class="o">=</span><span class="mf">1.0</span> <span class="no">WLODVTH</span><span class="o">=</span><span class="mf">1.0</span>
<span class="no">LKU0</span><span class="o">=</span><span class="mf">1E-6</span>  <span class="no">WKU0</span><span class="o">=</span><span class="mf">1E-6</span> <span class="no">PKU0</span><span class="o">=</span><span class="mf">0.0</span> <span class="no">LKVTH0</span><span class="o">=</span><span class="mf">1.1E-6</span> <span class="no">WKVTH0</span><span class="o">=</span><span class="mf">1.1E-6</span>  <span class="no">PKVTH0</span><span class="o">=</span><span class="mf">0.0</span>
<span class="no">STK2</span><span class="o">=</span><span class="mf">0.0</span> <span class="no">LODK2</span><span class="o">=</span><span class="mf">1.0</span> <span class="no">STETA0</span><span class="o">=</span><span class="mf">0.0</span>  <span class="no">LODETA0</span><span class="o">=</span><span class="mf">1.0</span>  <span class="no">LAMBDA</span><span class="o">=</span><span class="mf">4E-10</span>  <span class="no">VSAT</span><span class="o">=</span><span class="mf">1.1</span><span class="no">E</span> <span class="mo">005</span>
<span class="no">VTL</span><span class="o">=</span><span class="mf">2.0E5</span> <span class="no">XN</span><span class="o">=</span><span class="mf">6.0</span> <span class="no">LC</span><span class="o">=</span><span class="mf">5E-9</span>  <span class="no">RNOIA</span><span class="o">=</span><span class="mf">0.577</span> <span class="no">RNOIB</span><span class="o">=</span><span class="mf">0.37</span>
<span class="no">LINTNOI</span><span class="o">=</span><span class="mf">1E-009</span>  <span class="no">WPEMOD</span><span class="o">=</span><span class="mi">0</span> <span class="no">WEB</span><span class="o">=</span><span class="mf">0.0</span> <span class="no">WEC</span><span class="o">=</span><span class="mf">0.0</span> <span class="no">KVTH0WE</span><span class="o">=</span><span class="mf">1.0</span>  <span class="no">K2WE</span><span class="o">=</span><span class="mf">1.0</span> <span class="no">KU0WE</span><span class="o">=</span><span class="mf">1.0</span>
<span class="no">SCREF</span><span class="o">=</span><span class="mf">5.0E-6</span>  <span class="no">TVOFF</span><span class="o">=</span><span class="mf">0.0</span> <span class="no">TVFBSDOFF</span><span class="o">=</span><span class="mf">0.0</span>  <span class="no">VTH0</span><span class="o">=</span><span class="mf">0.25</span>  <span class="no">K1</span><span class="o">=</span><span class="mf">0.35</span> <span class="no">K2</span><span class="o">=</span><span class="mf">0.05</span>
<span class="no">K3</span><span class="o">=</span><span class="mi">0</span>  <span class="no">K3B</span><span class="o">=</span><span class="mi">0</span> <span class="no">W0</span><span class="o">=</span><span class="mf">2.5E-006</span> <span class="no">DVT0</span><span class="o">=</span><span class="mf">1.8</span> <span class="no">DVT1</span><span class="o">=</span><span class="mf">0.52</span>  <span class="no">DVT2</span><span class="o">=-</span><span class="mf">0.032</span> <span class="no">DVT0W</span><span class="o">=</span><span class="mi">0</span> <span class="no">DVT1W</span><span class="o">=</span><span class="mi">0</span>
<span class="no">DVT2W</span><span class="o">=</span><span class="mi">0</span>  <span class="no">DSUB</span><span class="o">=</span><span class="mi">2</span> <span class="no">MINV</span><span class="o">=</span><span class="mf">0.05</span> <span class="no">VOFFL</span><span class="o">=</span><span class="mi">0</span> <span class="no">DVTP0</span><span class="o">=</span><span class="mf">1E-007</span>  <span class="no">DVTP1</span><span class="o">=</span><span class="mf">0.05</span> <span class="no">LPE0</span><span class="o">=</span><span class="mf">5.75E-008</span>
<span class="no">LPEB</span><span class="o">=</span><span class="mf">2.3E-010</span> <span class="no">XJ</span><span class="o">=</span><span class="mf">2E-008</span>  <span class="no">NGATE</span><span class="o">=</span><span class="mi">5</span><span class="no">E</span> <span class="mo">020</span> <span class="no">NDEP</span><span class="o">=</span><span class="mf">2.8</span><span class="no">E</span> <span class="mo">01</span><span class="mi">8</span> <span class="no">NSD</span><span class="o">=</span><span class="mi">1</span><span class="no">E</span> <span class="mo">020</span> <span class="no">PHIN</span><span class="o">=</span><span class="mi">0</span>
<span class="no">CDSC</span><span class="o">=</span><span class="mf">0.0002</span> <span class="no">CDSCB</span><span class="o">=</span><span class="mi">0</span> <span class="no">CDSCD</span><span class="o">=</span><span class="mi">0</span> <span class="no">CIT</span><span class="o">=</span><span class="mi">0</span>  <span class="no">VOFF</span><span class="o">=-</span><span class="mf">0.15</span> <span class="no">NFACTOR</span><span class="o">=</span><span class="mf">1.2</span> <span class="no">ETA0</span><span class="o">=</span><span class="mf">0.05</span>
<span class="no">ETAB</span><span class="o">=</span><span class="mi">0</span>  <span class="no">UC</span><span class="o">=-</span><span class="mf">3E-011</span>  <span class="no">VFB</span><span class="o">=-</span><span class="mf">0.55</span> <span class="no">U0</span><span class="o">=</span><span class="mf">0.032</span> <span class="no">UA</span><span class="o">=</span><span class="mf">5.0E-011</span> <span class="no">UB</span><span class="o">=</span><span class="mf">3.5E-018</span>  <span class="no">A0</span><span class="o">=</span><span class="mi">2</span>
<span class="no">AGS</span><span class="o">=</span><span class="mf">1E-020</span> <span class="no">A1</span><span class="o">=</span><span class="mi">0</span> <span class="no">A2</span><span class="o">=</span><span class="mi">1</span> <span class="no">B0</span><span class="o">=-</span><span class="mf">1E-020</span> <span class="no">B1</span><span class="o">=</span><span class="mi">0</span>  <span class="no">KETA</span><span class="o">=</span><span class="mf">0.04</span> <span class="no">DWG</span><span class="o">=</span><span class="mi">0</span> <span class="no">DWB</span><span class="o">=</span><span class="mi">0</span> <span class="no">PCLM</span><span class="o">=</span><span class="mf">0.08</span>
<span class="no">PDIBLC1</span><span class="o">=</span><span class="mf">0.028</span> <span class="no">PDIBLC2</span><span class="o">=</span><span class="mf">0.022</span> <span class="no">PDIBLCB</span><span class="o">=-</span><span class="mf">0.005</span> <span class="no">DROUT</span><span class="o">=</span><span class="mf">0.45</span>  <span class="no">PVAG</span><span class="o">=</span><span class="mf">1E-020</span>
<span class="no">DELTA</span><span class="o">=</span><span class="mf">0.01</span> <span class="no">PSCBE1</span><span class="o">=</span><span class="mf">8.14</span><span class="no">E</span> <span class="mo">00</span><span class="mi">8</span> <span class="no">PSCBE2</span><span class="o">=</span><span class="mf">5E-008</span>  <span class="no">RSH</span><span class="o">=</span><span class="mi">0</span> <span class="no">RDSW</span><span class="o">=</span><span class="mi">0</span> <span class="no">RSW</span><span class="o">=</span><span class="mi">0</span> <span class="no">RDW</span><span class="o">=</span><span class="mi">0</span>
<span class="no">FPROUT</span><span class="o">=</span><span class="mf">0.2</span> <span class="no">PDITS</span><span class="o">=</span><span class="mf">0.2</span> <span class="no">PDITSD</span><span class="o">=</span><span class="mf">0.23</span> <span class="no">PDITSL</span><span class="o">=</span><span class="mf">2.3</span><span class="no">E</span> <span class="mo">006</span>  <span class="no">RSH</span><span class="o">=</span><span class="mi">0</span> <span class="no">RDSW</span><span class="o">=</span><span class="mi">50</span> <span class="no">RSW</span><span class="o">=</span><span class="mi">150</span>
<span class="no">RDW</span><span class="o">=</span><span class="mi">150</span>  <span class="no">RDSWMIN</span><span class="o">=</span><span class="mi">0</span> <span class="no">RDWMIN</span><span class="o">=</span><span class="mi">0</span> <span class="no">RSWMIN</span><span class="o">=</span><span class="mi">0</span> <span class="no">PRWG</span><span class="o">=</span><span class="mi">0</span>  <span class="no">PRWB</span><span class="o">=</span><span class="mf">6.8E-011</span> <span class="no">WR</span><span class="o">=</span><span class="mi">1</span>
<span class="no">ALPHA0</span><span class="o">=</span><span class="mf">0.074</span> <span class="no">ALPHA1</span><span class="o">=</span><span class="mf">0.005</span>  <span class="no">BETA0</span><span class="o">=</span><span class="mi">30</span> <span class="no">AGIDL</span><span class="o">=</span><span class="mf">0.0002</span> <span class="no">BGIDL</span><span class="o">=</span><span class="mf">2.1</span><span class="no">E</span> <span class="mo">00</span><span class="mi">9</span> <span class="no">CGIDL</span><span class="o">=</span><span class="mf">0.0002</span>
<span class="no">EGIDL</span><span class="o">=</span><span class="mf">0.8</span>  <span class="no">AIGBACC</span><span class="o">=</span><span class="mf">0.012</span> <span class="no">BIGBACC</span><span class="o">=</span><span class="mf">0.0028</span> <span class="no">CIGBACC</span><span class="o">=</span><span class="mf">0.002</span>  <span class="no">NIGBACC</span><span class="o">=</span><span class="mi">1</span>
<span class="no">AIGBINV</span><span class="o">=</span><span class="mf">0.014</span> <span class="no">BIGBINV</span><span class="o">=</span><span class="mf">0.004</span> <span class="no">CIGBINV</span><span class="o">=</span><span class="mf">0.004</span>  <span class="no">EIGBINV</span><span class="o">=</span><span class="mf">1.1</span> <span class="no">NIGBINV</span><span class="o">=</span><span class="mi">3</span> <span class="no">AIGC</span><span class="o">=</span><span class="mf">0.012</span>
<span class="no">BIGC</span><span class="o">=</span><span class="mf">0.0028</span>  <span class="no">CIGC</span><span class="o">=</span><span class="mf">0.002</span> <span class="no">AIGSD</span><span class="o">=</span><span class="mf">0.012</span> <span class="no">BIGSD</span><span class="o">=</span><span class="mf">0.0028</span> <span class="no">CIGSD</span><span class="o">=</span><span class="mf">0.002</span>  <span class="no">NIGC</span><span class="o">=</span><span class="mi">1</span>
<span class="no">POXEDGE</span><span class="o">=</span><span class="mi">1</span> <span class="no">PIGCD</span><span class="o">=</span><span class="mi">1</span> <span class="no">NTOX</span><span class="o">=</span><span class="mi">1</span>  <span class="no">VFBSDOFF</span><span class="o">=</span><span class="mf">0.0</span>  <span class="no">XRCRG1</span><span class="o">=</span><span class="mi">12</span> <span class="no">XRCRG2</span><span class="o">=</span><span class="mi">5</span>  <span class="no">CGSO</span><span class="o">=</span><span class="mf">6.238E-010</span>
<span class="no">CGDO</span><span class="o">=</span><span class="mf">6.238E-010</span> <span class="no">CGBO</span><span class="o">=</span><span class="mf">2.56E-011</span> <span class="no">CGDL</span><span class="o">=</span><span class="mf">2.495E-10</span>  <span class="no">CGSL</span><span class="o">=</span><span class="mf">2.495E-10</span>
<span class="no">CKAPPAS</span><span class="o">=</span><span class="mf">0.03</span> <span class="no">CKAPPAD</span><span class="o">=</span><span class="mf">0.03</span> <span class="no">ACDE</span><span class="o">=</span><span class="mi">1</span>  <span class="no">MOIN</span><span class="o">=</span><span class="mi">15</span> <span class="no">NOFF</span><span class="o">=</span><span class="mf">0.9</span> <span class="no">VOFFCV</span><span class="o">=</span><span class="mf">0.02</span>  <span class="no">KT1</span><span class="o">=-</span><span class="mf">0.37</span>
<span class="no">KT1L</span><span class="o">=</span><span class="mf">0.0</span> <span class="no">KT2</span><span class="o">=-</span><span class="mf">0.042</span> <span class="no">UTE</span><span class="o">=-</span><span class="mf">1.5</span>  <span class="no">UA1</span><span class="o">=</span><span class="mf">1E-009</span> <span class="no">UB1</span><span class="o">=-</span><span class="mf">3.5E-019</span> <span class="no">UC1</span><span class="o">=</span><span class="mi">0</span> <span class="no">PRT</span><span class="o">=</span><span class="mi">0</span>
<span class="no">AT</span><span class="o">=</span><span class="mi">53000</span>  <span class="no">FNOIMOD</span><span class="o">=</span><span class="mi">1</span> <span class="no">TNOIMOD</span><span class="o">=</span><span class="mi">0</span>  <span class="no">JSS</span><span class="o">=</span><span class="mf">0.0001</span> <span class="no">JSWS</span><span class="o">=</span><span class="mf">1E-011</span> <span class="no">JSWGS</span><span class="o">=</span><span class="mf">1E-010</span> <span class="no">NJS</span><span class="o">=</span><span class="mi">1</span>
<span class="no">IJTHSFWD</span><span class="o">=</span><span class="mf">0.01</span> <span class="no">IJTHSREV</span><span class="o">=</span><span class="mf">0.001</span> <span class="no">BVS</span><span class="o">=</span><span class="mi">10</span> <span class="no">XJBVS</span><span class="o">=</span><span class="mi">1</span>  <span class="no">JSD</span><span class="o">=</span><span class="mf">0.0001</span> <span class="no">JSWD</span><span class="o">=</span><span class="mf">1E-011</span>
<span class="no">JSWGD</span><span class="o">=</span><span class="mf">1E-010</span> <span class="no">NJD</span><span class="o">=</span><span class="mi">1</span>  <span class="no">IJTHDFWD</span><span class="o">=</span><span class="mf">0.01</span> <span class="no">IJTHDREV</span><span class="o">=</span><span class="mf">0.001</span> <span class="no">BVD</span><span class="o">=</span><span class="mi">10</span> <span class="no">XJBVD</span><span class="o">=</span><span class="mi">1</span>  <span class="no">PBS</span><span class="o">=</span><span class="mi">1</span> <span class="no">CJS</span><span class="o">=</span><span class="mf">0.0005</span>
<span class="no">MJS</span><span class="o">=</span><span class="mf">0.5</span> <span class="no">PBSWS</span><span class="o">=</span><span class="mi">1</span>  <span class="no">CJSWS</span><span class="o">=</span><span class="mf">5E-010</span> <span class="no">MJSWS</span><span class="o">=</span><span class="mf">0.33</span> <span class="no">PBSWGS</span><span class="o">=</span><span class="mi">1</span> <span class="no">CJSWGS</span><span class="o">=</span><span class="mf">3E-010</span>  <span class="no">MJSWGS</span><span class="o">=</span><span class="mf">0.33</span>
<span class="no">PBD</span><span class="o">=</span><span class="mi">1</span> <span class="no">CJD</span><span class="o">=</span><span class="mf">0.0005</span> <span class="no">MJD</span><span class="o">=</span><span class="mf">0.5</span>  <span class="no">PBSWD</span><span class="o">=</span><span class="mi">1</span> <span class="no">CJSWD</span><span class="o">=</span><span class="mf">5E-010</span> <span class="no">MJSWD</span><span class="o">=</span><span class="mf">0.33</span> <span class="no">PBSWGD</span><span class="o">=</span><span class="mi">1</span>
<span class="no">CJSWGD</span><span class="o">=</span><span class="mf">5E-010</span><span class="no">MJSWGD</span><span class="o">=</span><span class="mf">0.33</span> <span class="no">TPB</span><span class="o">=</span><span class="mf">0.005</span> <span class="no">TCJ</span><span class="o">=</span><span class="mf">0.001</span> <span class="no">TPBSW</span><span class="o">=</span><span class="mf">0.005</span> <span class="no">TCJSW</span><span class="o">=</span><span class="mf">0.001</span> <span class="no">TPBSWG</span><span class="o">=</span><span class="mf">0.005</span>
<span class="no">TCJSWG</span><span class="o">=</span><span class="mf">0.001</span>  <span class="no">XTIS</span><span class="o">=</span><span class="mi">3</span> <span class="no">XTID</span><span class="o">=</span><span class="mi">3</span>  <span class="no">DMCG</span><span class="o">=</span><span class="mf">0E-006</span> <span class="no">DMCI</span><span class="o">=</span><span class="mf">0E-006</span> <span class="no">DMDG</span><span class="o">=</span><span class="mf">0E-006</span> <span class="no">DMCGT</span><span class="o">=</span><span class="mf">0E-007</span>  <span class="no">DWJ</span><span class="o">=</span><span class="mf">0.0E-008</span> <span class="no">XGW</span><span class="o">=</span><span class="mf">0E-007</span>
<span class="no">XGL</span><span class="o">=</span><span class="mf">0E-008</span>  <span class="no">RSHG</span><span class="o">=</span><span class="mf">0.4</span> <span class="no">GBMIN</span><span class="o">=</span><span class="mf">1E-010</span> <span class="no">RBPB</span><span class="o">=</span><span class="mi">5</span> <span class="no">RBPD</span><span class="o">=</span><span class="mi">15</span>  <span class="no">RBPS</span><span class="o">=</span><span class="mi">15</span> <span class="no">RBDB</span><span class="o">=</span><span class="mi">15</span> <span class="no">RBSB</span><span class="o">=</span><span class="mi">15</span> <span class="no">NGCON</span><span class="o">=</span><span class="mi">1</span>
<span class="no">JTSS</span><span class="o">=</span><span class="mf">1E-4</span> <span class="no">JTSD</span><span class="o">=</span><span class="mf">1E-4</span> <span class="no">JTSSWS</span><span class="o">=</span><span class="mf">1E-10</span> <span class="no">JTSSWD</span><span class="o">=</span><span class="mf">1E-10</span> <span class="no">JTSSWGS</span><span class="o">=</span><span class="mf">1E-7</span> <span class="no">JTSSWGD</span><span class="o">=</span><span class="mf">1E-7</span>  <span class="no">NJTS</span><span class="o">=</span><span class="mf">20.0</span>
<span class="no">NJTSSW</span><span class="o">=</span><span class="mi">20</span> <span class="no">NJTSSWG</span><span class="o">=</span><span class="mi">6</span> <span class="no">VTSS</span><span class="o">=</span><span class="mi">10</span> <span class="no">VTSD</span><span class="o">=</span><span class="mi">10</span> <span class="no">VTSSWS</span><span class="o">=</span><span class="mi">10</span> <span class="no">VTSSWD</span><span class="o">=</span><span class="mi">10</span>  <span class="no">VTSSWGS</span><span class="o">=</span><span class="mi">2</span> <span class="no">VTSSWGD</span><span class="o">=</span><span class="mi">2</span>
<span class="no">XTSS</span><span class="o">=</span><span class="mf">0.02</span> <span class="no">XTSD</span><span class="o">=</span><span class="mf">0.02</span> <span class="no">XTSSWS</span><span class="o">=</span><span class="mf">0.02</span> <span class="no">XTSSWD</span><span class="o">=</span><span class="mf">0.02</span> <span class="no">XTSSWGS</span><span class="o">=</span><span class="mf">0.02</span> <span class="no">XTSSWGD</span><span class="o">=</span><span class="mf">0.02</span>
</code></pre></div></div>

<h2 id="transistors">Transistors</h2>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
M&lt;name&gt; &lt;drain&gt; &lt;gate&gt; &lt;source&gt; &lt;bulk&gt; &lt;modelname&gt; [parameters]


M1 VDN VDN VSS VSS nmos W=0.6u L=0.15u
M2 VDP VDP VDD VDD pmos W=0.6u L=0.15u


</code></pre></div></div>

<h2 id="foundries">Foundries</h2>

<p>Each foundry has their own SPICE models bacause the transistor parameters depend on the exact physics of the technology!</p>

<p><a href="https://skywater-pdk.readthedocs.io/en/main/">https://skywater-pdk.readthedocs.io/en/main/</a></p>

<h1 id="find-right-transistor-sizes">Find right transistor sizes</h1>

<p>Assume active (\(V_{ds} &gt; V_{eff}\) in strong inversion, or \(V_{ds} &gt; 3 V_T\) in weak inversion). For diode connected transistors, that is always true.</p>

<p>Weak inversion: 
\(I_{D} = I_{D0} \frac{W}{L} e^{V_eff / n V_T}\), \(V_{eff} \propto \ln{I_D}\)</p>

<p>Strong inversion: 
\(I_{D} = \frac{1}{2} \mu_n C_{ox} \frac{W}{L} V_{eff}^2\), \(V_{eff} \propto \sqrt{I_D}\)</p>

<p><strong>Operating region for a diode connected transistor only depends on the current</strong></p>

<p><img src="/aic2024/assets/media/trop.png" alt="" width="700" /></p>

<h2 id="use-unit-size-transistors-for-analog-design">Use unit size transistors for analog design</h2>

<p>\(W/L \approx \in[4, 6, 10]\), but should have space for two contacts</p>

<p>Use parallel transistors for larger W/L</p>

<p>Amplifiers \(\Rightarrow L \approx 1.2 \times L_{min}\)</p>

<p>Current mirrors \(\Rightarrow L \approx 4 \times L_{min}\)</p>

<p>Choose sizes that have been used by foundry for measurement to match SPICE model</p>

<h2 id="what-about-gmid-">What about gm/Id ?</h2>

<p>Weak \(\frac{g_m}{I_d} = \frac{1}{nV_T}\)</p>

<p>Strong \(\frac{g_m}{I_d} = \frac{2}{V_{eff}}\)</p>

<h2 id="characterize-the-transistors">Characterize the transistors</h2>

<p><a href="http://analogicus.com/cnr_atr_sky130nm/mos/CNRATR_NCH_2C1F2.html">http://analogicus.com/cnr_atr_sky130nm/mos/CNRATR_NCH_2C1F2.html</a></p>

<h1 id="more-information">More information</h1>

<p><a href="http://ngspice.sourceforge.net/docs/ngspice-43-manual.pdf">Ngspice Manual</a></p>

<p><a href="https://analogicus.com/aicex/started/">Installing tools</a></p>

<h1 id="analog-design">Analog Design</h1>

<ol>
  <li><strong>Define the problem, what are you trying to solve?</strong></li>
  <li><strong>Find a circuit that can solve the problem (papers, books)</strong></li>
  <li><strong>Find right transistor sizes. What transistors should be weak inversion, strong inversion, or don’t care?</strong></li>
  <li><strong>Check operating region of transistors (.op)</strong></li>
  <li><strong>Check key parameters (.dc, .ac, .tran)</strong></li>
  <li><strong>Check function. Exercise all inputs. Check all control signals</strong></li>
  <li>Check key parameters in all corners. Check mismatch (Monte-Carlo simulation)</li>
  <li>Do layout, and check it’s error free. Run design rule checks (DRC). Check layout versus schematic (LVS)</li>
  <li>Extract parasitics from layout. Resistance, capacitance, and inductance if necessary.</li>
  <li>On extracted parasitic netlist, check key parameters in all corners and mismatch (if possible).</li>
  <li>If everything works, then your done.</li>
</ol>

<p><em>On failure, go back</em></p>

<h1 id="demo">Demo</h1>

<p><a href="https://github.com/analogicus/jnw_spice_sky130A/tree/main">https://github.com/analogicus/jnw_spice_sky130A/tree/main</a></p>]]></content><author><name>Carsten Wulff</name><email>carsten@wulff.no</email></author><summary type="html"><![CDATA[If you find an error in what I’ve made, then fork, fix lectures/l00_spice.md, commit, push and create a pull request. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.]]></summary></entry><entry><title type="html">MOSFETs</title><link href="https://wulffern.github.io/aic2024/2024/07/07/MOSFETs.html" rel="alternate" type="text/html" title="MOSFETs" /><published>2024-07-07T00:00:00+00:00</published><updated>2024-07-07T00:00:00+00:00</updated><id>https://wulffern.github.io/aic2024/2024/07/07/MOSFETs</id><content type="html" xml:base="https://wulffern.github.io/aic2024/2024/07/07/MOSFETs.html"><![CDATA[<blockquote>
  <p>If you find an error in what I’ve made, then <a href="https://docs.github.com/en/get-started/quickstart/fork-a-repo">fork</a>, fix <a href="https://github.com/wulffern/aic2024/tree/main/lectures/lr0_mosfet.md">lectures/lr0_mosfet.md</a>, <a href="https://git-scm.com/docs/git-commit">commit</a>, <a href="https://git-scm.com/docs/git-push">push</a> and <a href="https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/working-with-your-remote-repository-on-github-or-github-enterprise/creating-an-issue-or-pull-request">create a pull request</a>. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.</p>
</blockquote>

<p><a href="/aic2024/assets/slides/lr0_mosfet.pdf">Slides</a></p>

<ul id="markdown-toc">
  <li><a href="#metal-oxide-semiconductor" id="markdown-toc-metal-oxide-semiconductor">Metal Oxide Semiconductor</a></li>
  <li><a href="#field-effect" id="markdown-toc-field-effect">Field Effect</a></li>
  <li><a href="#transistors-in-strong-inversion" id="markdown-toc-transistors-in-strong-inversion">Transistors in strong inversion</a>    <ul>
      <li><a href="#where-are-the-free-electrons" id="markdown-toc-where-are-the-free-electrons">Where are the free electrons?</a></li>
    </ul>
  </li>
</ul>

<p>I’m stunned if you’ve never heared the word “transistor”. I think most people have heard the word. What I find funny is that almost nobody understand in full detail how transistors work.</p>

<p>Through my 30 year venture into the world of electronics I’ve met  “analog designers”, or people 
that should understand exactly how transistors work. I used to hire analog designers, and I’ve interviewed hundred plus “analog designers” 
in my 8 years as manager and I’ve met hundreds of students of analog design. I would go as far as to say none of them know everything
about transistors, including myself.</p>

<p>Most of the people I’ve met have a good brain, so that is not the reason they don’t understand. Transistors are incredibly complicated! 
I say this, because if at some point in this document, <strong>you</strong> don’t understand, then don’t worry, you are not alone.</p>

<p>In this document I’m focusing on Metal Oxide Semiconductor Field Effect Transistors (MOSFETs), and ignore all other transistors.</p>

<h2 id="metal-oxide-semiconductor">Metal Oxide Semiconductor</h2>

<p>The first part of the MOSFET name illustrates the 3 dimensional composition of the transistor. Take a semiconductor (Silicon), grow 
some oxide (Silicon Oxide, SiO2), and place a metal, or conductive, gate on top of the oxide.
With those three components we can build our transistor.</p>

<p>Something like the cartoon below where only the Metal (gate) of the MOS name is shown.</p>

<p>The oxide and the silicon bulk is not visible, 
but you can imagine them to be underneath the gate, with a thin oxide (a few nano meters thick) 
and the silicon the transparent part of the picture.</p>

<p>The length (L), and width (W) of the MOS is annotated in blue.</p>

<p><img src="/aic2024/assets/media/3dcross.svg" alt="" width="700" /></p>

<p>MOSFETs come in two main types. There is NMOS, and PMOS. The symbols are as shown below. 
The NMOS is MN1 and PMOS is MP1.</p>

<p><img src="/aic2024/assets/media/fig_nmospmos.svg" alt="" width="700" /></p>

<p>The MOS part of the name can be seen in MN1, where $V_{G}$ is the gate connected to a vertical line (metal), a space (oxide), 
and another vertical line (the silicon substrate or silicon bulk).</p>

<p>On the sides of the gate we have two connections, a drain $V_{D}$ and a source $V_{S}$.</p>

<p>If we have a sufficient voltage between gate and source $V_{GS}$, then the transistor will conduct from drain to source. 
If the voltage is too low, then there will not be much current.</p>

<p>The “source” name is because that’s where the charge carrier (electrons) come from, they come from the source, and flow towards the drain.
As you may remember, the “current”, as we’ve defined it, flows opposite of the electron current, from drain to source.</p>

<p>The PMOS works in a similar manner, however, the PMOS is made of a different type of silicon, where the 
dominant charge carrier is holes in the valence band. As a result, the gate-source voltage needs to be negative for the 
PMOS to conduct.</p>

<p>In a PMOS the holes come from the source, and flow to the drain. Since holes are positive charge carriers, the current
flows from source to drain.</p>

<p>In most MOSFETs there is no physical difference between source and drain. If you flip
the transistor it would work almost exactly the same.</p>

<h2 id="field-effect">Field Effect</h2>

<p>Imagine that the bulk (the empty space underneath the gate), and the source is connected to 0 V. 
Assume that the gate is 0 V.</p>

<p>In the  source and drain parts of the transistor there is an abundance of <strong>free</strong> electrons that can move around, exactly like in a metal conductor, however, underneath the gate there are almost 
no <strong>free</strong> electrons.</p>

<p>There are electrons underneath the gate though, trillions upon trillions of electrons, but they are stuck in co-valent bonds
between the Silicon atoms, and around the nucleus of the Silicon atoms. These electrons are what we call bound electrons, they cannot move, or more precisely, they cannot contribute to current (because they do move, all the time, but mostly around the atoms).</p>

<p>Imagine that your eyes could see the free electrons as a blue fluorescent color. What you would see is a bright blue drain, and bright blue source, but no color underneath the gate.</p>

<p><img src="/aic2024/assets/media/mosfet_off.svg" alt="" width="700" /></p>

<p>As you increase the gate voltage, the color underneath the gate would change. First, you would think there might be some blue color, but it would be barely noticeable.</p>

<p><img src="/aic2024/assets/media/mosfet_subthreshold.svg" alt="" width="700" /></p>

<p>At a certain voltage, suddenly, there would be a thin blue sheet underneath the gate. You’d have to
zoom in to see it, in reality it’s a ultra thin, 2 dimensional electron sheet.</p>

<p>As you continue to increase the gate voltage the blue color would become a little brighter, but not much.</p>

<p><img src="/aic2024/assets/media/mosfet_strong_inversion.svg" alt="" width="700" /></p>

<p>This thin blue sheet extend from source to drain, and create a conductive channel where the electrons can move from source to drain (or drain to source), exactly like a resistor. The conductance of the sheet is the same as the brightness, higher gate source voltage, more bright blue, higher conductance, less resistance.</p>

<p>Assume you raise the drain voltage. The electrons would move from source to drain proportional to the voltage. 
How many electrons could  move would depend on the gate voltage.</p>

<p>If the gate voltage was low, then there is low density of electrons in the sheet, and low current.</p>

<p>If the gate voltage is high, then the electron density in the sheet is high, and there can be a high current, although, the electrons do 
have a maximum speed, so at some point the current does not change as fast with the gate voltage.</p>

<p>At a certain drain voltage you would see the blue color disappear close to the drain and there would be a gap 
in the sheet.</p>

<p><img src="/aic2024/assets/media/mosfet_strong_inversion_and_saturation.svg" alt="" width="700" /></p>

<p>That could make you think the current would stop, but it turns out, that the electrons close to drain get swept across 
the gap because the electric field is so high from the edge of the sheet to the drain.</p>

<p>As you continue to increase the drain voltage, the gap increases, but the current does not really increase that much. It’s this exact feature that 
make transistor so attractive in analog circuits. I can create a current from drain to source that does not depend much on the drain to source voltage! That’s why we 
sometimes imagine transistors as a “trans-conductance”. The conductance between drain and source depends on the voltage somewhere else, the gate-source voltage.</p>

<p>And now you may think you understand how the transistor works. By changing the gate voltage, we can change the electron current from source to drain. 
We can turn on, and off, currents, creating a 0 and 1 state.</p>

<p>For example, if I take a PMOS and connect the source to a high voltage, the drain to an output, and an NMOS with the source to ground and the drain to the output, and connect the gates together, I would have the simplest logic gate, an inverter, as shown below.</p>

<p>If the input $V_{in}$ is a high voltage, then the output $V_{out}$ is a low voltage, because the NMOS is on. If the input $V_{in}$ is a low voltage, then the output $V_{out}$ is a high voltage, because the PMOS is on.</p>

<p><img src="/aic2024/assets/media/fig_inv.svg" alt="" width="700" /></p>

<p>I can now build more complex “logic gates”. The one below is a Not-AND gate (NAND). If both inputs (A and B) are high, then the output is low (both NMOS are on). Otherwise, the output is high.</p>

<p>I find it amazing that all digital computers in existence can be constructed from the NAND gate. In principle, it’s the only logic gate you need. If you actually did construct computers from NANDs only, they would be costly, and 
consume lots of power. There are smarter ways to use the transistors.</p>

<p><img src="/aic2024/assets/media/nand_tr.png" alt="" width="700" /></p>

<p>You may be too young to have seen the Matrix, but now is the time to decide between the <a href="https://en.m.wikipedia.org/wiki/Red_pill_and_blue_pill">red pill and the blue pill</a>.</p>

<p>The red will start your journey to discover the reality behind the transistor, the blue pill will return you to your normal life, and you can continue to think that you now understand how 
transistors work.</p>

<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Red_and_blue_pill.jpg/1024px-Red_and_blue_pill.jpg" alt="" /></p>

<p>Because:</p>

<ul>
  <li>Why did the area underneath the gate turn blue?</li>
  <li>Why is it only a thin sheet that turns blue?</li>
  <li>Where did the electrons for the sheet come from?</li>
  <li>Why did the blue color change suddenly?</li>
  <li>How does the brightness of the blue change with gate-source voltage?</li>
  <li>How can the electrons stay in that sheet when we connect the bulk to 0 V?</li>
  <li>Why is there not a current from the bulk (0 V) to drain?</li>
  <li>Why does not the electrons jump from source to drain? It’s a gap, the same as from the sheet to drain?</li>
</ul>

<p>And did you realize I never in this chapter explained how the field effect worked?</p>

<p>–&gt;</p>

<h1 id="transistors-in-strong-inversion">Transistors in strong inversion</h1>

<p>The conditions to be in strong inversion is that the gate/source voltage is above some magic values (threshold voltage), and then some. In the nomenclature I’ve used above, there is lot’s of blue stuff underneath the gate.</p>

<h2 id="where-are-the-free-electrons">Where are the free electrons?</h2>

<p>The quantum state of the electron is fully determined by it’s spin, momentum and position in space. How those parameters evolve with time is determined by the Schrodinger equation. In the general form</p>

\[i\hbar\frac{d}{dt}\Psi(r,t) = \widehat{H} \Psi(r,t)\]

<p>The Hamiltonian ($H$) is an “energy matrix” operator and may contain terms both for the momentum and Columb force (electric field) experienced by the system.</p>

<p>But what does the Schrodinger equation tell us? Well, the equation above does not tell me much, it can’t be “solved”, or rather, it does not have a single solution. It’s more a framework for how the wave function, and the Hamiltonian, describes the quantum states of a system, and the probability ampltiudes of transition between states.</p>

<p>The Schrodinger equation describes the time evolution of the bound electrons shared between the Silicon atoms, and the fact that applying a electric field to silicon can free co-valent bonds.</p>

<p>As the gate voltage increases the wave function that fits in the Schrodinger equation predicts that the free electrons will form  a 2d sheet underneath the gate. The thickness of the sheet is only a few nano meters.</p>

<p>In Figure 2 in <a href="https://www.sciencedirect.com/science/article/pii/0038110189900609">Carrier transport near the Si/SiO2 interface of a MOSFET</a> you can see how the free electron density is located underneath the gate.</p>

<p>I would really recommend that you have a look at Mark Lundstrom’s lecture series on <a href="https://www.youtube.com/watch?v=5eG6CvcEHJ8&amp;list=PLtkeUZItwHK6F4a4OpCOaKXKmYBKGWcHi">Essentials of MOSFETs</a>. It’s the most complete description of electrons in MOSFET’s I’ve seen</p>

<!-- https://pdf.sciencedirectassets.com/271497/1-s2.0-S0038110100X02584/1-s2.0-0038110189900609/main.pdf-->]]></content><author><name>Carsten Wulff</name><email>carsten@wulff.no</email></author><summary type="html"><![CDATA[If you find an error in what I’ve made, then fork, fix lectures/lr0_mosfet.md, commit, push and create a pull request. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.]]></summary></entry><entry><title type="html">Lecture 11 - Analog SystemVerilog</title><link href="https://wulffern.github.io/aic2024/2024/04/19/Lecture-11-Analog-SystemVerilog.html" rel="alternate" type="text/html" title="Lecture 11 - Analog SystemVerilog" /><published>2024-04-19T00:00:00+00:00</published><updated>2024-04-19T00:00:00+00:00</updated><id>https://wulffern.github.io/aic2024/2024/04/19/Lecture-11---Analog-SystemVerilog</id><content type="html" xml:base="https://wulffern.github.io/aic2024/2024/04/19/Lecture-11-Analog-SystemVerilog.html"><![CDATA[<blockquote>
  <p>If you find an error in what I’ve made, then <a href="https://docs.github.com/en/get-started/quickstart/fork-a-repo">fork</a>, fix <a href="https://github.com/wulffern/aic2024/tree/main/lectures/l11_aver.md">lectures/l11_aver.md</a>, <a href="https://git-scm.com/docs/git-commit">commit</a>, <a href="https://git-scm.com/docs/git-push">push</a> and <a href="https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/working-with-your-remote-repository-on-github-or-github-enterprise/creating-an-issue-or-pull-request">create a pull request</a>. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.</p>
</blockquote>

<p><a href="/aic2024/assets/slides/l11_aver.pdf">Slides</a></p>

<ul id="markdown-toc">
  <li><a href="#digital-simulation" id="markdown-toc-digital-simulation">Digital simulation</a>    <ul>
      <li><a href="#digital-simulators" id="markdown-toc-digital-simulators">Digital Simulators</a></li>
      <li><a href="#counter" id="markdown-toc-counter">Counter</a></li>
    </ul>
  </li>
  <li><a href="#transient-analog-simulation" id="markdown-toc-transient-analog-simulation">Transient analog simulation</a></li>
  <li><a href="#mixed-signal-simulation" id="markdown-toc-mixed-signal-simulation">Mixed signal simulation</a></li>
  <li><a href="#analog-systemverilog-example" id="markdown-toc-analog-systemverilog-example">Analog SystemVerilog Example</a>    <ul>
      <li><a href="#tinytapeout-tt06_sar" id="markdown-toc-tinytapeout-tt06_sar">TinyTapeout TT06_SAR</a></li>
      <li><a href="#sar-operation" id="markdown-toc-sar-operation">SAR operation</a></li>
    </ul>
  </li>
  <li><a href="#want-to-learn-more" id="markdown-toc-want-to-learn-more">Want to learn more?</a></li>
</ul>

<iframe width="560" height="315" src="https://www.youtube.com/embed/56oK9FAE858" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen=""></iframe>

<p>Design of integrated circuits is split in two, analog design, and digital design.</p>

<p>Digital design is highly automated. The digital functions are coded in SystemVerilog (yes, I know 
there are others, but don’t use those), translated into a gate level netlist, and automatically generated
layout. Not everything is push-button automation, but most is.</p>

<p>Analog design, however, is manual work. We draw schematic, simulation with a mathematical 
model of the real world, draw the analog layout needed for the foundries to make the circuit,
verify that we drew the schematic and layout the same, extract parasitics, simulate again, and in the end
get a GDSII file.</p>

<p>When we mix analog and digital designs, we have two choices, analog on top, or digital on top.</p>

<p>In analog on top we take the digital IP, and do the top level layout by hand in analog tools.</p>

<p>In digital on top we include the analog IPs in the SystemVerilog, and allow the digital tools to do the layout. The digital layout is still orchestrated by people.</p>

<p>Which strategy is chosen depends on the complexity of the integrated circuit. For medium to low level 
of complexity, analog on top is fine. For high complexity ICs, then digital on top is the way to go.</p>

<p>Below is a description of the open source digital-on-top flow. The analog is included into GDSII 
at the OpenRoad stage of the flow.</p>

<p>The GDSII is not sufficient to integrate the analog IP. The digital needs to know how the analog works, 
what capacitance is on every digital input, the propagation delay for digital input to digital outputs
, the relation between digital outputs and clock inputs, and the possible load on digital outputs.</p>

<p>The details on timing and capacitance is covered in a Liberty file. The behavior, or function 
of the analog circuit must be described in a SystemVerilog file.</p>

<p>But how do we describe an analog function in SystemVerilog? SystemVerilog is simulated 
in an digital simulator.</p>

<p><img src="/aic2024/assets/media/dig_des.svg" alt="" width="700" /></p>

<h1 id="digital-simulation">Digital simulation</h1>

<p>Conceptually, the digital simulator is easy.</p>

<ul>
  <li>
    <p>The order of execution of events at the same time-step do not matter</p>
  </li>
  <li>
    <p>The system is causal. Changes in the future do not affect signals in the past or the now</p>
  </li>
</ul>

<p>In a digital simulator there will be an event queue, see below. From start, set the current time step equals 
to the next time step. Check if there are any events scheduled for the time step.
Assume that execution of events will add new time steps. Check if there is another time step, and repeat.</p>

<p>Since the digital simulator only acts when something is supposed to be done, they are inherently fast, 
and can handle complex systems.</p>

<p><img src="/aic2024/assets/media/eventqueue.png" alt="" width="700" /></p>

<p>It’s a fun exercise to make a digital simulator. On my Ph.D I wanted to model ADCs, and first
I had a look at SystemC, however, I disliked C++, so I made <a href="https://sourceforge.net/projects/systemdotnet/">SystemDotNet</a></p>

<p>In SystemDotNet I implemented the event queue as a hash table, so it ran a bit faster. See below.</p>

<p><img src="/aic2024/assets/media/systemdotnet.png" alt="" width="700" /></p>

<h3 id="digital-simulators">Digital Simulators</h3>

<p>There are both commercial an open source tools for digital simulation. If you’ve never 
used a digital simulator, then I’d recommend you start with iverilog. I’ve made some examples 
at <a href="https://github.com/wulffern/dicex/tree/main/project/verilog">dicex</a>.</p>

<p><strong>Commercial</strong></p>

<ul>
  <li><a href="https://www.cadence.com/ko_KR/home/tools/system-design-and-verification/simulation-and-testbench-verification/xcelium-simulator.html">Cadence Excelium</a></li>
  <li><a href="https://eda.sw.siemens.com/en-US/ic/questa/simulation/advanced-simulator/">Siemens Questa</a></li>
  <li><a href="https://www.synopsys.com/verification/simulation/vcs.html">Synopsys VCS</a></li>
</ul>

<p><strong>Open Source</strong></p>
<ul>
  <li><a href="https://github.com/steveicarus/iverilog">iverilog/vpp</a></li>
  <li><a href="https://www.veripool.org/verilator/">Verilator</a></li>
  <li><a href="https://sourceforge.net/projects/systemdotnet/">SystemDotNet</a></li>
</ul>

<h3 id="counter">Counter</h3>

<p>Below is an example of a counter in  SystemVerilog. The code can be found at <a href="https://github.com/wulffern/dicex/tree/main/sim/verilog/counter_sv">counter_sv</a>.</p>

<p>In the always_comb section we code what will become the combinatorial logic. 
In the always_ff section we code what will become our registers.</p>

<div class="language-verilog highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">module</span> <span class="n">counter</span><span class="p">(</span>
               <span class="kt">output</span> <span class="kt">logic</span> <span class="p">[</span><span class="n">WIDTH</span><span class="o">-</span><span class="mi">1</span><span class="o">:</span><span class="mi">0</span><span class="p">]</span> <span class="n">out</span><span class="p">,</span>
               <span class="kt">input</span> <span class="kt">logic</span>              <span class="n">clk</span><span class="p">,</span>
               <span class="kt">input</span> <span class="kt">logic</span>              <span class="n">reset</span>
               <span class="p">);</span>

   <span class="k">parameter</span> <span class="n">WIDTH</span> <span class="o">=</span> <span class="mi">8</span><span class="p">;</span>

   <span class="kt">logic</span> <span class="p">[</span><span class="n">WIDTH</span><span class="o">-</span><span class="mi">1</span><span class="o">:</span><span class="mi">0</span><span class="p">]</span>                    <span class="n">count</span><span class="p">;</span>
   <span class="k">always_comb</span> <span class="k">begin</span>
      <span class="n">count</span> <span class="o">=</span> <span class="n">out</span> <span class="o">+</span> <span class="mi">1</span><span class="p">;</span>
   <span class="k">end</span>

   <span class="k">always_ff</span> <span class="o">@</span><span class="p">(</span><span class="kt">posedge</span> <span class="n">clk</span> <span class="kt">or</span> <span class="kt">posedge</span> <span class="n">reset</span><span class="p">)</span> <span class="k">begin</span>
      <span class="k">if</span> <span class="p">(</span><span class="n">reset</span><span class="p">)</span>
        <span class="n">out</span> <span class="o">&lt;=</span> <span class="mi">0</span><span class="p">;</span>
      <span class="k">else</span>
        <span class="n">out</span> <span class="o">&lt;=</span> <span class="n">count</span><span class="p">;</span>
   <span class="k">end</span>

<span class="k">endmodule</span> <span class="c1">// counter</span>
</code></pre></div></div>

<p>In the context of a digital simulator, we can think through how the event queue will look.</p>

<p>When the clk or reset changes from zero to 1, then schedule an event where if the reset is 1, then 
out will be zero in the next time step. If reset is 0, then out will be <code class="language-plaintext highlighter-rouge">count</code> in the next time step.</p>

<p>In a time-step where <code class="language-plaintext highlighter-rouge">out changes, then schedule an event to set </code>count<code class="language-plaintext highlighter-rouge"> to </code>out` plus one. As such, each 
positive edge of the clock at least 2 events must be scheduled in the register transfer level (RTL) simulation.</p>

<p>For example:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Assume <span class="sb">`</span>clk, reset, out <span class="o">=</span> 0<span class="sb">`</span>

Assume event with <span class="sb">`</span>clk <span class="o">=</span> 1<span class="sb">`</span>

0: Set <span class="sb">`</span>out <span class="o">=</span> count<span class="sb">`</span> <span class="k">in </span>next event <span class="o">(</span>1<span class="o">)</span>

1: Set <span class="sb">`</span>count <span class="o">=</span> out + 1<span class="sb">`</span> using 
   logic <span class="o">(</span>may consume multiple events<span class="o">)</span> 

X: no further events
</code></pre></div></div>

<p>When we synthesis the code below into a <a href="https://github.com/wulffern/dicex/blob/main/sim/verilog/counter_sv/counter_netlist.v">netlist</a>
it’s a bit harder to see how the events will be scheduled, but we can notice that clk and reset
are still inputs, and for example the clock is connected to d-flip-flops. The image below is 
the synthesized netlist</p>

<p>It should feel intuitive that a gate-level netlist will take longer to simulate than an RTL, there
are more events.</p>

<p><img src="/aic2024/assets/media/sv_counter.png" alt="" width="700" /></p>

<h1 id="transient-analog-simulation">Transient analog simulation</h1>

<p>Analog simulation is different. There is no quantized time step. How fast “things” 
happen in the circuit is entirely determined by the time constants, change in voltage, 
and change in current in the system.</p>

<p>It is possible to have a fixed time-step in analog simulation, for example, we say that nothing
is faster than 1 fs, so we pick that as our time step. If we wanted to simulate 
1 s, however, that’s at least 1e15 events, and with 1 event per microsecond on a computer it’s still a 
simulation time of 31 years. Not a viable solution for all analog circuits.</p>

<p>Analog circuits are also non-linear, properties of resistors, capacitors, inductors, diodes may 
depend on the voltage or current across, or in, the device. Solving for all the
non-linear differential equations is tricky.</p>

<p>An analog simulation engine must 
parse spice netlist, and setup partial/ordinary differential equations for node matrix</p>

<p>The nodal matrix could look like the matrix below, $i$ are the currents, $v$ the voltages, 
and $G$ the conductances between nodes.</p>

\[\begin{pmatrix}
G_{11} &amp;G_{12}  &amp;\cdots  &amp;G_{1N} \\ 
G_{21} &amp;G_{22}  &amp;\cdots  &amp;G_{2N} \\ 
\vdots &amp;\vdots  &amp;\ddots  &amp; \vdots\\ 
G_{N1} &amp;G_{N2}  &amp;\cdots  &amp;G_{NN} 
\end{pmatrix}
\begin{pmatrix}
v_1\\ 
v_2\\ 
\vdots\\ 
v_N
\end{pmatrix}=
\begin{pmatrix}
i_1\\ 
i_2\\ 
\vdots\\ 
i_N
\end{pmatrix}\]

<p>The simulator, and devices 
model the non-linear current/voltage behavior between all nodes</p>

<p>as such, the $G$’s may be non-linear functions, and include the $v$’s and $i$’s.</p>

<p>Transient analysis use 
numerical methods to compute time evolution</p>

<p>The time step is adjusted automatically, often by proprietary algorithms, to trade 
accuracy and simulation speed.</p>

<p>The numerical methods can be forward/backward Euler, or the others listed below.</p>

<ul>
  <li><a href="https://aquaulb.github.io/book_solving_pde_mooc/solving_pde_mooc/notebooks/02_TimeIntegration/02_01_EulerMethod.html">Euler</a></li>
  <li><a href="https://aquaulb.github.io/book_solving_pde_mooc/solving_pde_mooc/notebooks/02_TimeIntegration/02_02_RungeKutta.html">Runge-Kutta</a></li>
  <li><a href="https://en.wikipedia.org/wiki/Crank%E2%80%93Nicolson_method">Crank-Nicolson</a></li>
  <li><a href="https://ieeexplore.ieee.org/document/1083221">Gear</a></li>
</ul>

<p>If you wish to learn more, I would recommend starting with the original paper on analog transient analysis.</p>

<p><a href="https://www2.eecs.berkeley.edu/Pubs/TechRpts/1973/ERL-m-382.pdf">SPICE (Simulation Program with Integrated Circuit Emphasis)</a>
published in 1973 by Nagel and Pederson</p>

<p>The original paper has spawned a multitude of commercial, free and open source simulators, some are listed below.</p>

<p>If you have money, then buy Cadence Spectre. If you have no money, then start with ngspice.</p>

<p><strong>Commercial</strong></p>
<ul>
  <li><a href="https://www.cadence.com/ko_KR/home/tools/custom-ic-analog-rf-design/circuit-simulation/spectre-simulation-platform.html">Cadence Spectre</a></li>
  <li><a href="https://eda.sw.siemens.com/en-US/ic/eldo/">Siemens Eldo</a></li>
  <li><a href="https://www.synopsys.com/implementation-and-signoff/ams-simulation/primesim-hspice.html">Synopsys HSPICE</a></li>
</ul>

<p><strong>Free</strong></p>
<ul>
  <li><a href="http://aimspice.com">Aimspice</a></li>
  <li><a href="https://www.analog.com/en/design-center/design-tools-and-calculators/ltspice-simulator.html">Analog Devices LTspice</a></li>
  <li><a href="https://xyce.sandia.gov">xyce</a></li>
</ul>

<p><strong>Open Source</strong></p>
<ul>
  <li><a href="http://ngspice.sourceforge.net">ngspice</a></li>
</ul>

<h1 id="mixed-signal-simulation">Mixed signal simulation</h1>

<p>It is possible to co-simulate both analog and digital functions. An illustration is shown below.</p>

<p>The system will have two simulators, one analog, with transient simulation and differential equation solver,
and a digital, with event queue.</p>

<p>Between the two simulators there would be analog-to-digital, and digital-to-analog converters.</p>

<p>To orchestrate the time between simulators there must be a global event and time-step control. 
Most often, the digital simulator will end up waiting for the analog simulator.</p>

<p>The challenge with mixed-mode simulation is that if the digital circuit becomes to large,
and the digital simulation must wait for analog solver, then the simulation would take too long.</p>

<p>Most of the time, it’s stupid to try and simulate complex system-on-chip with mixed-signal
, full detail, simulation.</p>

<p>For IPs, like an ADC, co-simulation works well, and is the best way to verify the digital and analog.</p>

<p>But if we can’t run mixed simulation, how do we verify analog with digital?</p>

<p><img src="/aic2024/assets/media/mixed_simulator.svg" alt="" width="700" /></p>

<h1 id="analog-systemverilog-example">Analog SystemVerilog Example</h1>

<h2 id="tinytapeout-tt06_sar">TinyTapeout TT06_SAR</h2>

<p><img src="/aic2024/assets/media/tt_um_TT06_SAR_wulffern.svg" alt="" width="700" /></p>

<p><img src="/aic2024/assets/media/tt06_sar_anawave.png" alt="" width="700" /></p>

<h2 id="sar-operation">SAR operation</h2>

<p>The key idea is to model the analog behavior to sufficient detail such that we can
verify the digital code. I think it’s best to have a look at a concrete example.</p>

<ul>
  <li>Analog input is sampled when clock goes low (sarp/sarn)</li>
  <li>uio_out[0] goes high when bit-cycling is done</li>
  <li>Digital output (ro) changes when uio_out[0] goes high</li>
</ul>

<div class="language-verilog highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">//tt06-sar/src/project.v</span>
<span class="k">module</span> <span class="n">tt_um_TT06_SAR_wulffern</span> <span class="p">(</span>
                                <span class="kt">input</span> <span class="kt">wire</span>        <span class="n">VGND</span><span class="p">,</span>
                                <span class="kt">input</span> <span class="kt">wire</span>        <span class="n">VPWR</span><span class="p">,</span>
                                <span class="kt">input</span> <span class="kt">wire</span> <span class="p">[</span><span class="mi">7</span><span class="o">:</span><span class="mi">0</span><span class="p">]</span>  <span class="n">ui_in</span><span class="p">,</span>
                                <span class="kt">output</span> <span class="kt">wire</span> <span class="p">[</span><span class="mi">7</span><span class="o">:</span><span class="mi">0</span><span class="p">]</span> <span class="n">uo_out</span><span class="p">,</span>
                                <span class="kt">input</span> <span class="kt">wire</span> <span class="p">[</span><span class="mi">7</span><span class="o">:</span><span class="mi">0</span><span class="p">]</span>  <span class="n">uio_in</span><span class="p">,</span>
                                <span class="kt">output</span> <span class="kt">wire</span> <span class="p">[</span><span class="mi">7</span><span class="o">:</span><span class="mi">0</span><span class="p">]</span> <span class="n">uio_out</span><span class="p">,</span>
                                <span class="kt">output</span> <span class="kt">wire</span> <span class="p">[</span><span class="mi">7</span><span class="o">:</span><span class="mi">0</span><span class="p">]</span> <span class="n">uio_oe</span><span class="p">,</span>
<span class="cp">`ifdef</span> <span class="n">ANA_TYPE_REAL</span>
                                <span class="kt">input</span> <span class="kt">real</span>        <span class="n">ua_0</span><span class="p">,</span>
                                <span class="kt">input</span> <span class="kt">real</span>        <span class="n">ua_1</span><span class="p">,</span>
<span class="cp">`else</span>
                                <span class="c1">// analog pins</span>
                                <span class="kt">inout</span> <span class="kt">wire</span> <span class="p">[</span><span class="mi">7</span><span class="o">:</span><span class="mi">0</span><span class="p">]</span>  <span class="n">ua</span><span class="p">,</span> 
<span class="cp">`endif</span>
                                <span class="kt">input</span> <span class="kt">wire</span>        <span class="n">ena</span><span class="p">,</span>
                                <span class="kt">input</span> <span class="kt">wire</span>        <span class="n">clk</span><span class="p">,</span>
                                <span class="kt">input</span> <span class="kt">wire</span>        <span class="n">rst_n</span>
                                <span class="p">);</span>

</code></pre></div></div>

<div class="language-verilog highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">//tt06-sar/src/tb_ana.v</span>
<span class="cp">`ifdef</span> <span class="n">ANA_TYPE_REAL</span>
   <span class="kt">real</span>        <span class="n">ua_0</span>  <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
   <span class="kt">real</span>        <span class="n">ua_1</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>

<span class="cp">`else</span>
   <span class="kt">tri</span> <span class="p">[</span><span class="mi">7</span><span class="o">:</span><span class="mi">0</span><span class="p">]</span>   <span class="n">ua</span><span class="p">;</span>
   <span class="kt">logic</span>       <span class="n">uain</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
   <span class="k">assign</span> <span class="n">ua</span> <span class="o">=</span> <span class="n">uain</span><span class="p">;</span>
<span class="cp">`endif</span>

<span class="cp">`ifdef</span> <span class="n">ANA_TYPE_REAL</span>
   <span class="k">always</span> <span class="p">#</span><span class="mi">100</span> <span class="k">begin</span>
      <span class="n">ua_0</span> <span class="o">=</span> <span class="p">$</span><span class="nb">sin</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="mf">3.14</span><span class="o">*</span><span class="mi">1</span><span class="o">/</span><span class="mi">7750</span><span class="o">*</span><span class="p">$</span><span class="kt">time</span><span class="p">);</span>
      <span class="n">ua_1</span> <span class="o">=</span> <span class="o">-</span><span class="p">$</span><span class="nb">sin</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="mf">3.14</span><span class="o">*</span><span class="mi">1</span><span class="o">/</span><span class="mi">7750</span><span class="o">*</span><span class="p">$</span><span class="kt">time</span><span class="p">);</span>
   <span class="k">end</span>
<span class="cp">`endif</span>


</code></pre></div></div>

<div class="language-verilog highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">//tt06-sar/src/tb_ana.v</span>
   <span class="n">tt_um_TT06_SAR_wulffern</span> <span class="n">dut</span> <span class="p">(</span>
                                <span class="p">.</span><span class="n">VGND</span><span class="p">(</span><span class="n">VGND</span><span class="p">),</span>
                                <span class="p">.</span><span class="n">VPWR</span><span class="p">(</span><span class="n">VPWR</span><span class="p">),</span>
                                <span class="p">.</span><span class="n">ui_in</span><span class="p">(</span><span class="n">ui_in</span><span class="p">),</span>
                                <span class="p">.</span><span class="n">uo_out</span><span class="p">(</span><span class="n">uo_out</span><span class="p">),</span>
                                <span class="p">.</span><span class="n">uio_in</span><span class="p">(</span><span class="n">uio_in</span><span class="p">),</span>
                                <span class="p">.</span><span class="n">uio_out</span><span class="p">(</span><span class="n">uio_out</span><span class="p">),</span>
                                <span class="p">.</span><span class="n">uio_oe</span><span class="p">(</span><span class="n">uio_oe</span><span class="p">),</span>
<span class="cp">`ifdef</span> <span class="n">ANA_TYPE_REAL</span>
                                <span class="p">.</span><span class="n">ua_0</span><span class="p">(</span><span class="n">ua_0</span><span class="p">),</span>
                                <span class="p">.</span><span class="n">ua_1</span><span class="p">(</span><span class="n">ua_1</span><span class="p">),</span>
<span class="cp">`else</span>
                                <span class="p">.</span><span class="n">ua</span><span class="p">(</span><span class="n">ua</span><span class="p">),</span>
<span class="cp">`endif</span>
                                <span class="p">.</span><span class="n">ena</span><span class="p">(</span><span class="n">ena</span><span class="p">),</span>
                                <span class="p">.</span><span class="n">clk</span><span class="p">(</span><span class="n">clk</span><span class="p">),</span>
                                <span class="p">.</span><span class="n">rst_n</span><span class="p">(</span><span class="n">rst_n</span><span class="p">)</span>
                                <span class="p">);</span>
</code></pre></div></div>

<div class="language-makefile highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#tt06-sar/src/Makefile
</span><span class="nl">runa</span><span class="o">:</span>
	iverilog  <span class="nt">-g2012</span> <span class="nt">-o</span> my_design <span class="nt">-c</span> tb_ana.fl <span class="nt">-DANA_TYPE_REAL</span>
	vvp <span class="nt">-n</span> my_design

<span class="nl">rund</span><span class="o">:</span>
	iverilog  <span class="nt">-g2012</span> <span class="nt">-o</span> my_design <span class="nt">-c</span> tb_ana.fl
	vvp <span class="nt">-n</span> my_design
</code></pre></div></div>

<div class="language-verilog highlighter-rouge"><div class="highlight"><pre class="highlight"><code>   <span class="c1">//tt06-sar/src/project.v</span>
   <span class="c1">//Main SAR loop</span>
   <span class="k">always_ff</span> <span class="o">@</span><span class="p">(</span><span class="kt">posedge</span> <span class="n">clk</span> <span class="kt">or</span> <span class="kt">negedge</span> <span class="n">clk</span><span class="p">)</span> <span class="k">begin</span>
      <span class="k">if</span><span class="p">(</span><span class="o">~</span><span class="n">ui_in</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="k">begin</span>
         <span class="n">state</span> <span class="o">&lt;=</span> <span class="n">OFF</span><span class="p">;</span>
         <span class="n">tmp</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
         <span class="n">dout</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
      <span class="k">end</span>
      <span class="k">else</span> <span class="k">begin</span>
         <span class="k">if</span><span class="p">(</span><span class="n">OFF</span><span class="p">)</span> <span class="k">begin</span>

         <span class="k">end</span>
         <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="n">clk</span> <span class="o">==</span> <span class="mi">1</span><span class="p">)</span> <span class="k">begin</span>
            <span class="n">state</span> <span class="o">=</span> <span class="n">SAMPLE</span><span class="p">;</span>
         <span class="k">end</span>
         <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="n">clk</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="k">begin</span>
            <span class="n">state</span> <span class="o">=</span> <span class="n">CONVERT</span><span class="p">;</span>
      <span class="cp">`ifdef</span> <span class="n">ANA_TYPE_REAL</span>
            <span class="n">smpl</span> <span class="o">=</span> <span class="n">ua_0</span> <span class="o">-</span> <span class="n">ua_1</span><span class="p">;</span>
            <span class="n">tmp</span> <span class="o">=</span> <span class="n">smpl</span><span class="p">;</span>

            <span class="k">for</span><span class="p">(</span><span class="kt">int</span> <span class="n">i</span><span class="o">=</span><span class="mi">7</span><span class="p">;</span><span class="n">i</span><span class="o">&gt;=</span><span class="mi">0</span><span class="p">;</span><span class="n">i</span><span class="o">--</span><span class="p">)</span> <span class="k">begin</span>
               <span class="k">if</span><span class="p">(</span><span class="n">tmp</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">)</span> <span class="k">begin</span>
                  <span class="n">tmp</span> <span class="o">=</span> <span class="n">tmp</span> <span class="o">-</span> <span class="n">lsb</span><span class="o">*</span><span class="mi">2</span><span class="o">**</span><span class="p">(</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">);</span>
                  <span class="k">if</span><span class="p">(</span><span class="n">i</span><span class="o">==</span><span class="mi">7</span><span class="p">)</span>
                    <span class="n">dout</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">&lt;=</span> <span class="mi">0</span><span class="p">;</span>
                  <span class="k">else</span>
                    <span class="n">dout</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">&lt;=</span> <span class="mi">1</span><span class="p">;</span>
               <span class="k">end</span>
</code></pre></div></div>

<div class="language-verilog highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
               <span class="k">else</span> <span class="k">begin</span>
                  <span class="n">tmp</span> <span class="o">=</span> <span class="n">tmp</span> <span class="o">+</span> <span class="n">lsb</span><span class="o">*</span><span class="mi">2</span><span class="o">**</span><span class="p">(</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">);</span>
                  <span class="k">if</span><span class="p">(</span><span class="n">i</span><span class="o">==</span><span class="mi">7</span><span class="p">)</span>
                    <span class="n">dout</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
                  <span class="k">else</span>
                    <span class="n">dout</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
               <span class="k">end</span>
            <span class="k">end</span>
<span class="cp">`else</span>
            <span class="k">if</span><span class="p">(</span><span class="n">tmp</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="k">begin</span>
               <span class="n">dout</span><span class="p">[</span><span class="mi">7</span><span class="p">]</span> <span class="o">&lt;=</span> <span class="mi">1</span><span class="p">;</span>
               <span class="n">tmp</span> <span class="o">&lt;=</span> <span class="mi">1</span><span class="p">;</span>

            <span class="k">end</span>
            <span class="k">else</span> <span class="k">begin</span>
               <span class="n">dout</span><span class="p">[</span><span class="mi">7</span><span class="p">]</span> <span class="o">&lt;=</span> <span class="mi">0</span><span class="p">;</span>
               <span class="n">tmp</span>  <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
            <span class="k">end</span>
<span class="cp">`endif</span>

         <span class="k">end</span>
         <span class="n">state</span> <span class="o">=</span> <span class="n">next_state</span><span class="p">;</span>
      <span class="k">end</span> <span class="c1">// else: !if(~ui_in[0])</span>
   <span class="k">end</span> <span class="c1">// always_ff @ (posedge clk)</span>
</code></pre></div></div>

<div class="language-verilog highlighter-rouge"><div class="highlight"><pre class="highlight"><code>   <span class="c1">//tt06-sar/src/project.v</span>
   <span class="k">always</span> <span class="o">@</span><span class="p">(</span><span class="kt">posedge</span> <span class="n">done</span><span class="p">)</span> <span class="k">begin</span>
      <span class="n">state</span> <span class="o">=</span> <span class="n">DONE</span><span class="p">;</span>
      <span class="n">sampled_dout</span> <span class="o">=</span> <span class="n">dout</span><span class="p">;</span>
   <span class="k">end</span>

   <span class="k">always</span> <span class="o">@</span><span class="p">(</span><span class="n">state</span><span class="p">)</span> <span class="k">begin</span>
      <span class="k">if</span><span class="p">(</span><span class="n">state</span> <span class="o">==</span> <span class="n">OFF</span><span class="p">)</span>
        <span class="p">#</span><span class="mi">2</span> <span class="n">done</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
      <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="n">state</span> <span class="o">==</span> <span class="n">SAMPLE</span><span class="p">)</span>
        <span class="p">#</span><span class="mf">1.6</span> <span class="n">done</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
      <span class="k">else</span> <span class="k">if</span><span class="p">(</span><span class="n">state</span> <span class="o">==</span> <span class="n">CONVERT</span><span class="p">)</span>
        <span class="p">#</span><span class="mi">115</span> <span class="n">done</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
   <span class="k">end</span>
</code></pre></div></div>

<p><img src="/aic2024/assets/media/tt06_sar_anawave2.png" alt="" width="700" />
<img src="/aic2024/assets/media/tt06_sar_digwave.png" alt="" width="700" /></p>

<h1 id="want-to-learn-more">Want to learn more?</h1>

<p>For more information on real-number modeling I would recommend <a href="https://youtu.be/gNpPslQZT-Y">The Evolution of Real Number Modeling</a></p>

<iframe width="560" height="315" src="https://www.youtube.com/embed/gNpPslQZT-Y" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay;
clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen=""></iframe>]]></content><author><name>Carsten Wulff</name><email>carsten@wulff.no</email></author><summary type="html"><![CDATA[If you find an error in what I’ve made, then fork, fix lectures/l11_aver.md, commit, push and create a pull request. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.]]></summary></entry><entry><title type="html">Lecture X - Energy Sources</title><link href="https://wulffern.github.io/aic2024/2024/04/12/Lecture-X-Energy-Sources.html" rel="alternate" type="text/html" title="Lecture X - Energy Sources" /><published>2024-04-12T00:00:00+00:00</published><updated>2024-04-12T00:00:00+00:00</updated><id>https://wulffern.github.io/aic2024/2024/04/12/Lecture-X---Energy-Sources</id><content type="html" xml:base="https://wulffern.github.io/aic2024/2024/04/12/Lecture-X-Energy-Sources.html"><![CDATA[<blockquote>
  <p>If you find an error in what I’ve made, then <a href="https://docs.github.com/en/get-started/quickstart/fork-a-repo">fork</a>, fix <a href="https://github.com/wulffern/aic2024/tree/main/lectures/lx_energysrc.md">lectures/lx_energysrc.md</a>, <a href="https://git-scm.com/docs/git-commit">commit</a>, <a href="https://git-scm.com/docs/git-push">push</a> and <a href="https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/working-with-your-remote-repository-on-github-or-github-enterprise/creating-an-issue-or-pull-request">create a pull request</a>. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.</p>
</blockquote>

<p><a href="/aic2024/assets/slides/lx_energysrc.pdf">Slides</a></p>

<ul id="markdown-toc">
  <li><a href="#thermoelectric" id="markdown-toc-thermoelectric">Thermoelectric</a>    <ul>
      <li><a href="#radioisotope-thermoelectric-generator" id="markdown-toc-radioisotope-thermoelectric-generator">Radioisotope Thermoelectric generator</a></li>
      <li><a href="#thermoelectric-generators" id="markdown-toc-thermoelectric-generators">Thermoelectric generators</a></li>
    </ul>
  </li>
  <li><a href="#photovoltaic" id="markdown-toc-photovoltaic">Photovoltaic</a></li>
  <li><a href="#piezoelectric" id="markdown-toc-piezoelectric">Piezoelectric</a></li>
  <li><a href="#electromagnetic" id="markdown-toc-electromagnetic">Electromagnetic</a>    <ul>
      <li><a href="#near-field-harvesting" id="markdown-toc-near-field-harvesting">“Near field” harvesting</a></li>
      <li><a href="#ambient-rf-harvesting" id="markdown-toc-ambient-rf-harvesting">Ambient RF Harvesting</a></li>
    </ul>
  </li>
  <li><a href="#triboelectric-generator" id="markdown-toc-triboelectric-generator">Triboelectric generator</a></li>
  <li><a href="#comparison" id="markdown-toc-comparison">Comparison</a></li>
  <li><a href="#want-to-learn-more" id="markdown-toc-want-to-learn-more">Want to learn more?</a></li>
</ul>

<iframe width="560" height="315" src="https://www.youtube.com/embed/Tb2CFHLmkzw?si=4f29EI_Hwj3My9fn" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen=""></iframe>

<p>Integrated circuits are wasteful of energy. Digital circuits charge transistor gates to change states, and when
discharged, the charges are dumped to ground. In analog circuits the transconductance requires a DC current,
a continuous flow of charges from positive supply to ground.</p>

<p>Integrated circuits are incredibly useful though. Life without would be different.</p>

<p>A continuous effort from engineers like me have reduced the power consumption of both digital and analog circuits by
order of magnitudes since the invention of the transistor 75 years ago.</p>

<p>One of the first commercial ADCs, the <a href="https://www.analog.com/media/en/training-seminars/design-handbooks/Data-Conversion-Handbook/Chapter1.pdf">DATRAC</a> on page 24, was a 11-bit 50 kSps that consumed 500 W. That’s Walden figure of merit of 
4 $\mu$J/conv.step. Today’s state-of-the-art ADCs in the same sampling range have a Walden figure of merit of <a href="https://ieeexplore.ieee.org/document/8310273">0.6 fJ/conv.step</a>.</p>

<p>4 $\mu$ / 0.6 f = 8.1e9, a difference in power consumption of almost 10 billion times !!!</p>

<p>Improvements to power consumption have become harder and harder, but I believe there is still far to go before we 
cannot reduce power consumption any more.</p>

<p><a href="https://ieeexplore.ieee.org/document/8762143">Towards a Green and Self-Powered Internet of Things Using Piezoelectric Energy Harvesting</a> [1]
has a nice overview of power consumption of technologies, seen in the next figures below.</p>

<p>In the context of energy harvesting, there is energy in electromagnetic fields, temperature, and mechanical stress, and there are ways to translate between them the energy forms.</p>

<!--[fit](https://ieeexplore.ieee.org/mediastore_new/IEEE/content/media/6287639/8600701/8762143/shirv5-2928523-large.gif)-->
<p><img src="/aic2024/assets/media/shirv5-2928523-large.gif" alt="" width="700" /></p>

<p>Below we can see a figure of the potential energy that can be harvested per volume, and the type power consumption of technologies [1].</p>

<p>As devices approach average power consumption of $\mu W$ it becomes possible to harvest the energy from the environment, and do away with the battery.</p>

<!--[fit](https://ieeexplore.ieee.org/mediastore_new/IEEE/content/media/6287639/8600701/8762143/shirv6-2928523-large.gif)-->
<p><img src="/aic2024/assets/media/shirv6-2928523-large.gif" alt="" width="700" /></p>

<p>For wireless standards, there are some that can be run on energy harvesting. Below is an overview from [1]. Many of us will have a NFC card in our pocket for payment, or entry to buildings. NFC card has a integrated circuit that is powered from the electromagnetic field from the NFC reader.</p>

<p>Other standards, like Bluetooth, WiFi, LTE are harder to run battery less, because the energy requirement above 1 mW.</p>

<p>Technologies like Bluetooth LE, however, can approach &lt; 10 $\mu$W for some applications, although the burst power may still be 10 mW to 100 mW. As such, although the average power is low, the energy harvesting cannot support peak loads and a charge storage device is required (battery, super-capacitor, large capacitor).</p>

<!--[inline fit](https://ieeexplore.ieee.org/mediastore_new/IEEE/content/media/6287639/8600701/8762143/shirv11-2928523-large.gif)-->
<p><img src="/aic2024/assets/media/shirv11-2928523-large.gif" alt="" width="700" /></p>

<p>I’d like to give you an introduction to the possible ways of harvesting energy. I know of five methods:</p>
<ul>
  <li>thermoelectric</li>
  <li>photovoltaic</li>
  <li>piezoelectric</li>
  <li>electromagnetic</li>
  <li>triboelectric</li>
</ul>

<h1 id="thermoelectric"><a href="https://en.wikipedia.org/wiki/Thermoelectric_effect">Thermoelectric</a></h1>

<p>Apply heat to one end of a metal wire, what happens to the free electrons? As we heat the material we must increase 
the energy of the free electrons at the hot end of the wire. The atoms wiggle more, and when the free electrons scatter off the atomic structure there should be an exchange of energy. Think of the electrons at the hot side as high energy
electrons, while on the cold side there are low energy electrons, I think.</p>

<p>There will be diffusion current of electrons 
in both directions in the material, however, if the mobility of electrons in the material is dependent on 
the energy, then we would get a difference in current of low energy electrons and high energy electrons. 
A difference in current would lead to a charge difference at the hot end and cold end, 
which would give a difference in voltage.</p>

<p>Take a copper wire, bend it in half, heat the end with the loop, and measure the voltage at the cold end. Would we
measure a voltage difference?</p>

<p><strong>NO</strong>, there would not be a voltage difference between the two ends of the wire. The voltage 
on the loop side would be different, but on the cold side, where we have the ends, there would be no voltage difference.</p>

<p>Gauss law tell us that inside a conductor there cannot be a static field without a current. As such, if there was 
a voltage difference between the cold ends, it would quickly dissipated, and no DC current would flow.</p>

<p>The voltage difference in the material between the hot and cold end will create currents, but we can’t use them if we
only have one type of material.</p>

<p>Imagine we have Iron and copper wires, as shown below, and we heat one end. In that case, we can draw current between the cold ends.</p>

<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Thermoelectric_effect.svg/2560px-Thermoelectric_effect.svg.png" alt="" /></p>

<p>The voltage difference at the hot and cold end
is described by the</p>

<p><a href="https://en.wikipedia.org/wiki/Seebeck_coefficient">Seebeck coefficient</a></p>

<p>Imagine two parallel wires with different Seebeck coefficients, one of copper ($6.5\text{ } \mu V/K$) and one of iron ($19\text{ } \mu/K$).
We connect them at the hot end. The voltage difference between hot and cold would be higher in the iron, than in the copper. 
At the cold end, we would now measure a difference in voltage between the wires!</p>

<p>In silicon, the Seebeck coefficient can be modified through doping. A model of Seebeck coefficient is shown below. 
The value of the Seebeck coefficient depends on the location of the Fermi level in relation to the Conduction band or the V
valence band.</p>

<p><img src="https://upload.wikimedia.org/wikipedia/commons/e/e5/Absolute_Seebeck_coefficients_of_various_metals_up_to_high_temperatures.svg" alt="" /></p>

<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/Mott_Seebeck_silicon.svg/440px-Mott_Seebeck_silicon.svg.png" alt="" /></p>

<p>In the picture below we have a silicon (the cyan and yellow colors).</p>

<p>Assume we dope with acceptors (yellow, p-type), that shifts the Fermi level closer to the Valence band ($E_V$), and the dominant
current transport will be by holes, maybe we get 1 mV/K from the picture above.</p>

<p>For the material doped with donors (cyan, n-type) the Fermi level is shifted towards the Conduction band ($E_C$), and the dominant 
charge transport is by electrons, maybe we get -1 mV/K from the picture above.</p>

<p>Assume we have a temperature difference of 50 degrees, then maybe we could get a voltage difference at the cold end of 
100 mV. That’s a low voltage, but is possible to use.</p>

<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/8b/Thermoelectric_Generator_Diagram.svg/440px-Thermoelectric_Generator_Diagram.svg.png" alt="" /></p>

<p>The process can be run in reverse. In the picture below we force a current through the material, 
we heat one end, and cool the other. Maybe you’ve heard of <a href="https://en.wikipedia.org/wiki/Thermoelectric_cooling">Peltier elements</a>.</p>

<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Thermoelectric_Cooler_Diagram.svg/440px-Thermoelectric_Cooler_Diagram.svg.png" alt="" /></p>

<h2 id="radioisotope-thermoelectric-generator"><a href="https://en.wikipedia.org/wiki/Radioisotope_thermoelectric_generator">Radioisotope Thermoelectric generator</a></h2>

<p>Maybe you’ve heard of a nuclear battery. Sounds fancy, right? Must be complicated, right?</p>

<p>Not really, take some radioactive material, which generates heat, stick a thermoelectric generator to the hot side, 
make sure you can cool the cold side, and we have a nuclear battery.</p>

<p>Nuclear batteries are “simple”, and ultra reliable. There’s not really a chemical reaction. The nucleus of the 
radioactive material degrades, but not fast. In the thermoelectric generator, there are no moving parts.</p>

<p>In a normal battery there is a chemical reaction that happens when we pull a current. Atoms move around. 
Eventually the chemical battery will change and degrade.</p>

<p>Nuclear batteries were used in Voyager, and they still work to this day. The nuclear battery is the round thing 
underneath Voyager in the picture below. The radioisotopes provide the heat, space provides the cold, and voila, 
<a href="https://en.wikipedia.org/wiki/Voyager_1">470 W</a> to run the electronics.</p>

<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Voyager_spacecraft_model.png/1280px-Voyager_spacecraft_model.png" alt="" /></p>

<h2 id="thermoelectric-generators"><a href="https://en.wikipedia.org/wiki/Thermoelectric_generator">Thermoelectric generators</a></h2>

<p>Assume a we wanted to drive a watch from a thermoelectric generator (TEG). 
The skin temperature is maybe 33 degrees Celsius, while the 
ambient temperature is maybe 23 degrees Celsius on average.</p>

<p>From the model of a thermoelectric generator below we’d get a voltage of 10 mV to 500 mV, too low for most integrated circuits.</p>

<p>In order to drive an integrated circuit we’d need to boost the voltage to maybe 1.8 V.</p>

<p>The main challenge with thermoelectric generators is to provide a cold-boot function where the energy harvester starts up at a low voltage.</p>

<p>In silicon, it is tricky to make anything work below some thermal voltages (kT/q). We at least need about 3 – 4 thermal voltages to make anything function.</p>

<p>The key enabler for an efficient, low temperature differential, energy harvester is an oscillator that works at low voltage (i.e 75 mV). If we have a clock, then we can boost with capacitors</p>

<p>In <a href="https://ieeexplore.ieee.org/document/9302641">A 3.5-mV Input Single-Inductor Self-Starting Boost Converter With Loss-Aware MPPT for Efficient Autonomous Body-Heat Energy Harvesting</a> they use a combination of both switched capacitor and switched inductor boost.</p>

<p><img src="/aic2024/assets/media/l11_teg_mdl.svg" alt="" width="700" /></p>

<h1 id="photovoltaic"><a href="https://en.wikipedia.org/wiki/Photovoltaic_effect">Photovoltaic</a></h1>

<p>In silicon, photons can knock out electron/hole pairs. If we have a PN junction,
then it’s possible to separate the electron/holes before they recombine as shown in figure below.</p>

<p>An electron/hole pair knocked out in the depletion region (1) will 
separate due to the built-in field. The hole will go to P and the electron to N. 
This increases the voltage VD across the diode.</p>

<p>A similar effect will occur if the 
electron/hole pair is knocked out in the P region (2). Although the 
P region has an abundance of holes, the electron will not recombine immediately. 
If the  electron diffuses close to the depletion region, then it will be swept across to the N side,
and further increase VD.</p>

<p>On the N-side the same minority carrier effect would further increase the voltage (3).</p>

<p><img src="/aic2024/assets/media/l11_pv_pn.svg" alt="" width="700" /></p>

<p>A circuit model of a Photodiode can be seen in figure below, where it is assumed that a 
single photodiode is used. It is possible to stack photodiodes to get a higher output voltage.</p>

<p><img src="/aic2024/assets/media/l11_pv_mdl.svg" alt="" width="700" /></p>

<p>As the load current is increased, the voltage VD will drop. As the photo current is increased,
the voltage VD will increase. As such, there is an optimum current load where there is a balance
between the photocurrent, the voltage VD and the load current.</p>

\[I_D = I_S\left(e^\frac{V_D}{V_T} - 1\right)\]

\[I_D = I_{Photo} - I_{Load}\]

\[V_D = V_T ln{\left(\frac{I_{Photo} - I_{Load}}{I_S} + 1 \right)}\]

\[P_{Load} = V_D I_{Load}\]

<p>Below is a model of the power in the load as a function of diode voltage</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">#!/usr/bin/env python3
</span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="n">np</span>
<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="n">plt</span>

<span class="n">m</span> <span class="o">=</span> <span class="mf">1e-3</span>  
<span class="n">i_load</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="n">linspace</span><span class="p">(</span><span class="mf">1e-5</span><span class="p">,</span><span class="mf">1e-3</span><span class="p">,</span><span class="mi">200</span><span class="p">)</span>

<span class="n">i_s</span> <span class="o">=</span> <span class="mf">1e-12</span>  <span class="c1"># saturation current 
</span><span class="n">i_ph</span> <span class="o">=</span> <span class="mf">1e-3</span>  <span class="c1"># Photocurrent
</span>
<span class="n">V_T</span> <span class="o">=</span> <span class="mf">1.38e-23</span><span class="o">*</span><span class="mi">300</span><span class="o">/</span><span class="mf">1.6e-19</span>  <span class="c1">#Thermal voltage
</span>
<span class="n">V_D</span> <span class="o">=</span> <span class="n">V_T</span><span class="o">*</span><span class="n">np</span><span class="p">.</span><span class="n">log</span><span class="p">((</span><span class="n">i_ph</span> <span class="o">-</span> <span class="n">i_load</span><span class="p">)</span><span class="o">/</span><span class="p">(</span><span class="n">i_s</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>

<span class="n">P_load</span> <span class="o">=</span> <span class="n">V_D</span><span class="o">*</span><span class="n">i_load</span>

<span class="n">plt</span><span class="p">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>
<span class="n">plt</span><span class="p">.</span><span class="n">plot</span><span class="p">(</span><span class="n">i_load</span><span class="o">/</span><span class="n">m</span><span class="p">,</span><span class="n">V_D</span><span class="p">)</span>
<span class="n">plt</span><span class="p">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s">"Diode voltage [mA]"</span><span class="p">)</span>
<span class="n">plt</span><span class="p">.</span><span class="n">grid</span><span class="p">()</span>
<span class="n">plt</span><span class="p">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span>
<span class="n">plt</span><span class="p">.</span><span class="n">plot</span><span class="p">(</span><span class="n">i_load</span><span class="o">/</span><span class="n">m</span><span class="p">,</span><span class="n">P_load</span><span class="o">/</span><span class="n">m</span><span class="p">)</span>
<span class="n">plt</span><span class="p">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s">"Current load [mA]"</span><span class="p">)</span>
<span class="n">plt</span><span class="p">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s">"Power Load [mW]"</span><span class="p">)</span>
<span class="n">plt</span><span class="p">.</span><span class="n">grid</span><span class="p">()</span>
<span class="n">plt</span><span class="p">.</span><span class="n">savefig</span><span class="p">(</span><span class="s">"pv.pdf"</span><span class="p">)</span>
<span class="n">plt</span><span class="p">.</span><span class="n">show</span><span class="p">()</span>

</code></pre></div></div>

<p>From the plot below we can see that to optimize the power we could extract from the photovoltaic cell we’d want to have a current 
of 0.9 mA in the model above.</p>

<p><img src="/aic2024/assets/media/pv.svg" alt="" width="700" /></p>

<p>Most photovoltaic energy harvesting circuits will include a maximum power point tracker 
as the optimum changes with light conditions.</p>

<p>In <a href="https://ieeexplore.ieee.org/abstract/document/9423810">A Reconfigurable Capacitive Power Converter With Capacitance Redistribution for Indoor Light-Powered Batteryless Internet-of-Things Devices</a> they include a maximum power point tracker and a reconfigurable charge pump to optimize efficiency.</p>

<h1 id="piezoelectric"><a href="https://en.wikipedia.org/wiki/Piezoelectricity">Piezoelectric</a></h1>

<p>I’m not sure I  understand the piezoelectric effect, but I think it goes something like this.</p>

<p>Consider a crystal made of a combination of elements, for example <a href="http://lampx.tugraz.at/~hadley/ss1/crystalstructure/structures/semiconductors/GaN.html">Gallium Nitride</a>. In GaN it’s possible to get a polarization of the unit cell, with a more negative charge on one side, and a positive charge on the other side. The polarization comes from an asymmetry in the electron and nucleus distribution within the material.</p>

<p>In a polycrystaline substance the polarization domains will usually be random, and no electric field will observable. The polarization domains can be aligned by heating the material and applying a electric field. Now all the small electric fields point in the same direction.</p>

<p>From Gausses law we know that the electric field through a surface is determined by the volume integral of the charges inside.</p>

\[\oint_{\partial \Omega} \mathbf{E} \cdot d\mathbf{S} = \frac{1}{\epsilon_0} \iiint_{V} \rho
\cdot dV\]

<p>Although there is a net zero charge inside the material, there is an uneven distribution of charges, as such, some of the field lines will cross through the surface.</p>

<p>Assume we have a polycrystaline GaN material with polarized domains. If we measure the voltage across the material we will read 0 V. Even though the domains are polarized, and we should observe an external electric field, the free charges in the material will redistribute if there is a field inside, such that there is no current flowing, and thus no external field.</p>

<p>If we apply stress, however, all the domains inside the material will shift. Now the free charges do not exactly cancel the electric field in the material, the free charges are in the wrong place. If we have a material with low conductivity, then it will take time for the free charges to redistribute. As such, for a while, we can measure an voltage across the material.</p>

<p>Assuming the above explanation is true, then there should not be piezoelectric materials with high conductivity, and indeed, most piezoelectric materials have resistance of <a href="https://www.f3lix-tutorial.com/piezo-materials">$10^{12}$ to $10^{14}$ Ohm</a>.</p>

<p>Vibrations on a piezoelectric material will result in a AC voltage across the surface, which we can harvest.</p>

<p>A model of a piezoelectric transducer can be seen below.</p>

<p>The voltage on the transducer can be on the order of a few volts, 
but the current is usually low (nA – µA). The key challenge is to rectify the AC signal into a DC signal.
It is common to use tricks to reduce the energy waste due to the rectifier.</p>

<p>An example of piezoelectric energy harvester can be found in <a href="https://ieeexplore.ieee.org/document/8642406">A Fully Integrated Split-Electrode SSHC Rectifier for Piezoelectric Energy Harvesting</a></p>

<p><img src="/aic2024/assets/media/lx_piezo_mdl.svg" alt="" width="700" /></p>

<h1 id="electromagnetic">Electromagnetic</h1>

<h2 id="near-field-harvesting">“Near field” harvesting</h2>

<p>Near Field Communication (NFC) operates at close physical distances</p>

<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/5d/FarNearFields-USP-4998112-1.svg/618px-FarNearFields-USP-4998112-1.svg.png" alt="" /></p>

<p>Reactive near field or inductive near field</p>

\[\text{Inductive} &lt; \frac{\lambda}{2 \pi}\]

<p>Within the inductive near field the antenna’s can “feel” each other. The NFC reader inside the card reader can “feel” the antenna of the NFC tag. When the tag get’s
close it will load down the NFC reader by presenting a load impedance. As the circuit inside the tag is powered, it can change the impedance of it’s antenna, which is 
sensed by the reader, and thus the reader can get data from the tag. The tag could lock in on the 13.56 MHz frequency and decode both amplitude and phase modulation 
from the reader.</p>

<p>Since the NFC or Qi system operates at close distances, then the coupling factor between antenna’s, or really, inductors, can be decent, and it’s 
possible to achieve efficiencies of maybe 70 %.</p>

<p>At Bluetooth frequencies, as can be seen below, it does not really make sense to couple inductors, as they need to be within 2 cm to be in the inductive near field. 
The inductive near field is a significant problem for the coupling between inductors on chip, but I don’t think I would use it to transfer power.</p>

<table>
  <thead>
    <tr>
      <th style="text-align: left">Standard</th>
      <th style="text-align: center">Frequency [MHz]</th>
      <th style="text-align: center">Inductive [m]</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: left">AirFuel Resonant</td>
      <td style="text-align: center">6.78</td>
      <td style="text-align: center">7.03</td>
    </tr>
    <tr>
      <td style="text-align: left">NFC</td>
      <td style="text-align: center">13.56</td>
      <td style="text-align: center">3.52</td>
    </tr>
    <tr>
      <td style="text-align: left">Qi</td>
      <td style="text-align: center">0.205</td>
      <td style="text-align: center">232</td>
    </tr>
    <tr>
      <td style="text-align: left">Bluetooth</td>
      <td style="text-align: center">2400</td>
      <td style="text-align: center">0.02</td>
    </tr>
  </tbody>
</table>

<h2 id="ambient-rf-harvesting">Ambient RF Harvesting</h2>

<p>Extremely inefficient idea, but may find special use-cases at short-distance.</p>

<p>Will get better with beam-forming and directive antennas</p>

<p>There are companies that think RF harvesting is a good idea.</p>

<p><a href="https://airfuel.org/airfuel-rf/">AirFuel RF</a></p>

<p>I think that ambient RF harvesting should tingle your science spidy senses.</p>

<p>Let’s consider the power transmitted in wireless standards. Your cellphone may transmit 30 dBm, your WiFi router maybe 20 dBm,
and your Bluetooth LE device 10 dBm.</p>

<p>In case those numbers don’t mean anything to you, below is a conversion to watts.</p>

<table>
  <thead>
    <tr>
      <th style="text-align: center">dBm</th>
      <th style="text-align: center">W</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">30</td>
      <td style="text-align: center">1</td>
    </tr>
    <tr>
      <td style="text-align: center">0</td>
      <td style="text-align: center">1 m</td>
    </tr>
    <tr>
      <td style="text-align: center">-30</td>
      <td style="text-align: center">1 u</td>
    </tr>
    <tr>
      <td style="text-align: center">-60</td>
      <td style="text-align: center">1 n</td>
    </tr>
    <tr>
      <td style="text-align: center">-90</td>
      <td style="text-align: center">1 p</td>
    </tr>
  </tbody>
</table>

<p>Now ask your self the question “What’s the power at a certain distance?”. It’s easier to flip the question, and 
use Friis to calculate the distance.</p>

<p>Assume \(P_{TX}\) = 1 W (30 dBm) and \(P_{RX}\) = 10 uW (-20 dBm)</p>

<p>then</p>

\[D = 10^\frac{P_{TX} - P_{RX} + 20 log_{10}\left(\frac{c}{4 \pi f}\right)}{20}\]

<p>In the table below we can see the distance is not that far!</p>

<table>
  <thead>
    <tr>
      <th>Freq</th>
      <th style="text-align: center"><strong>\(20 log_{10}\left(c/4 \pi f\right)\)</strong> [dB]</th>
      <th style="text-align: right">D [m]</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>915M</td>
      <td style="text-align: center">-31.7</td>
      <td style="text-align: right">8.2</td>
    </tr>
    <tr>
      <td>2.45G</td>
      <td style="text-align: center">-40.2</td>
      <td style="text-align: right">3.1</td>
    </tr>
    <tr>
      <td>5.80G</td>
      <td style="text-align: center">-47.7</td>
      <td style="text-align: right">1.3</td>
    </tr>
  </tbody>
</table>

<p>I believe ambient RF is a stupid idea.</p>

<p>Assuming an antenna that transmits equally in all direction, then the loss on the first meter is 40 dB at 2.4 GHz.
If I transmitted 1 W, there would only be 100 µW available at 1 meter. 
That’s an efficiency of 0.01 %.</p>

<p>Just fundamentally stupid. <strong>Stupid, I tell you!!!</strong></p>

<p><sub>Stupidity in engineering really annoys me, especially when people don’t understand how stupid ideas are.</sub></p>

<h1 id="triboelectric-generator">Triboelectric generator</h1>

<p>Although static electricity is an old phenomenon, 
it is only recently that triboelectric nanogenerators have been used to
harvest energy.</p>

<p>An overview can be seen in <a href="https://ieeexplore.ieee.org/document/9729411">Current progress on power management systems for triboelectric nanogenerators</a>.</p>

<p>A model of a triboelectric generator can be seen in below.
Although the current is  low (nA) the voltage can be high, 
tens to hundreds of volts.</p>

<p>The key circuit challenge is the rectifier, and the high voltage output of the triboelectric generator.</p>

<p>Take a look in <a href="https://ieeexplore.ieee.org/document/9441315">A Fully Energy-Autonomous Temperature-to-Time Converter Powered by a Triboelectric Energy Harvester for Biomedical Applications</a>
for more details.</p>

<p><img src="/aic2024/assets/media/lx_trib_mdl.svg" alt="" width="700" /></p>

<p>Below is a custom triboelectric material that converts friction into a sparse electric field.</p>

<!--[fit](https://ieeexplore.ieee.org/mediastore_new/IEEE/content/media/4/9546917/9441315/yoo6ab-3080383-large.gif)-->
<p><img src="/aic2024/assets/media/yoo6ab-3080383-large.gif" alt="" width="700" /></p>

<p>The key idea of the triboelectric circuit below is to rectify the sparse voltage pulses and store the charge on a capacitor. 
Once the voltage is high enough, then a temperature sensor is started.</p>

<!--[fit](https://ieeexplore.ieee.org/mediastore_new/IEEE/content/media/4/9546917/9441315/yoo1ab-3080383-large.gif)-->

<p><img src="/aic2024/assets/media/yoo1ab-3080383-large.gif" alt="" width="700" /></p>

<p>Below is some more details on the operation of the harvesting circuit, and the temperature sensor. Notice how the temperature sensor part of the circuit (PTAT bandgap, capacitor and comparator)
produce a pulse width modulated signal that depends on temperature.</p>

<p>Also notice the “VDD_ext” in the figure. That means the system is not fully harvested. The paper is a prime example on how we in academia can ignore key portions of 
a system. They’ve focused on the harvesting part, and making the temperature dependent pulse width modulated signal. Maybe they’ve completely ignored how the data
is transmitted from the system to where it would be used, and that’s OK.</p>

<p>It’s academia’s job to prove that something could be possible. It’s industry’s job to make some that could be possible actually work.</p>

<!--
[inline fit](https://ieeexplore.ieee.org/mediastore_new/IEEE/content/media/4/9546917/9441315/yoo2-3080383-large.gif)

[inline fit](https://ieeexplore.ieee.org/mediastore_new/IEEE/content/media/4/9546917/9441315/yoo3-3080383-large.gif)
-->

<p><img src="/aic2024/assets/media/yoo2-3080383-large.gif" alt="" width="700" /></p>

<p><img src="/aic2024/assets/media/yoo3-3080383-large.gif" alt="" width="700" /></p>

<h1 id="comparison">Comparison</h1>

<p>Imagine you’re a engineer in a company that makes integrated circuits. Your CEO comes to you and says
“You need to make a power management IC that harvest energy and works with everything”.</p>

<p>Hopefully, your response would now be “That’s a stupid idea, any energy harvester circuit must be made specifically 
for the energy source”.</p>

<p>Thermoelectric and photovoltaic provide low DC voltage. Piezoelectric and Triboelectric provide an AC voltage. 
Ambient RF is stupid.</p>

<p>For a “energy harvesting circuit” you must also know the application (wrist watch, or wall switch) to know
what energy source is available.</p>

<p>Below is a table that show’s a comparison in the power that can be extracted.</p>

<p>The power levels below
are too low for the peak power consumption of integrated circuits, so most applications must include 
a charge storage device, either a battery, or a capacitor.</p>

<!--[fit](https://ieeexplore.ieee.org/mediastore_new/IEEE/content/media/4/9546917/9441315/yoo4-3080383-large.gif)-->
<p><img src="/aic2024/assets/media/yoo4-3080383-large.gif" alt="" width="700" /></p>

<h1 id="want-to-learn-more">Want to learn more?</h1>

<p>[1] <a href="https://ieeexplore.ieee.org/document/8762143">Towards a Green and Self-Powered Internet of Things Using Piezoelectric Energy Harvesting</a></p>

<p><a href="https://ieeexplore.ieee.org/document/9302641">A 3.5-mV Input Single-Inductor Self-Starting Boost Converter With Loss-Aware MPPT for Efficient Autonomous Body-Heat Energy Harvesting</a></p>

<p><a href="https://ieeexplore.ieee.org/abstract/document/9423810">A Reconfigurable Capacitive Power Converter With Capacitance Redistribution for Indoor Light-Powered Batteryless Internet- of-Things Devices</a></p>

<p><a href="https://ieeexplore.ieee.org/document/8642406">A Fully Integrated Split-Electrode SSHC Rectifier for Piezoelectric Energy Harvesting</a></p>

<p><a href="https://ieeexplore.ieee.org/document/9729411">Current progress on power management systems for triboelectric nanogenerators</a></p>

<p><a href="https://ieeexplore.ieee.org/document/9441315">A Fully Energy-Autonomous Temperature-to-Time Converter Powered by a Triboelectric Energy Harvester for Biomedical Applications</a></p>]]></content><author><name>Carsten Wulff</name><email>carsten@wulff.no</email></author><summary type="html"><![CDATA[If you find an error in what I’ve made, then fork, fix lectures/lx_energysrc.md, commit, push and create a pull request. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.]]></summary></entry><entry><title type="html">Lecture 10 - Low Power Radio</title><link href="https://wulffern.github.io/aic2024/2024/03/22/Lecture-10-Low-Power-Radio.html" rel="alternate" type="text/html" title="Lecture 10 - Low Power Radio" /><published>2024-03-22T00:00:00+00:00</published><updated>2024-03-22T00:00:00+00:00</updated><id>https://wulffern.github.io/aic2024/2024/03/22/Lecture-10---Low-Power-Radio</id><content type="html" xml:base="https://wulffern.github.io/aic2024/2024/03/22/Lecture-10-Low-Power-Radio.html"><![CDATA[<blockquote>
  <p>If you find an error in what I’ve made, then <a href="https://docs.github.com/en/get-started/quickstart/fork-a-repo">fork</a>, fix <a href="https://github.com/wulffern/aic2024/tree/main/lectures/l10_lpradio.md">lectures/l10_lpradio.md</a>, <a href="https://git-scm.com/docs/git-commit">commit</a>, <a href="https://git-scm.com/docs/git-push">push</a> and <a href="https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/working-with-your-remote-repository-on-github-or-github-enterprise/creating-an-issue-or-pull-request">create a pull request</a>. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.</p>
</blockquote>

<p><a href="/aic2024/assets/slides/l10_lpradio.pdf">Slides</a></p>

<ul id="markdown-toc">
  <li><a href="#data-rate" id="markdown-toc-data-rate">Data Rate</a>    <ul>
      <li><a href="#data" id="markdown-toc-data">Data</a></li>
      <li><a href="#rate" id="markdown-toc-rate">Rate</a></li>
      <li><a href="#data-rate-1" id="markdown-toc-data-rate-1">Data Rate</a></li>
    </ul>
  </li>
  <li><a href="#carrier-frequency--range" id="markdown-toc-carrier-frequency--range">Carrier Frequency &amp; Range</a>    <ul>
      <li><a href="#ism-industrial-scientific-and-medical-bands" id="markdown-toc-ism-industrial-scientific-and-medical-bands">ISM (industrial, scientific and medical) bands</a></li>
      <li><a href="#antenna" id="markdown-toc-antenna">Antenna</a></li>
      <li><a href="#range-friis" id="markdown-toc-range-friis">Range (Friis)</a></li>
      <li><a href="#range-free-space" id="markdown-toc-range-free-space">Range (Free space)</a></li>
      <li><a href="#range-real-world" id="markdown-toc-range-real-world">Range (Real world)</a></li>
    </ul>
  </li>
  <li><a href="#power-supply" id="markdown-toc-power-supply">Power supply</a>    <ul>
      <li><a href="#battery" id="markdown-toc-battery">Battery</a></li>
    </ul>
  </li>
  <li><a href="#decisions" id="markdown-toc-decisions">Decisions</a>    <ul>
      <li><a href="#modulation" id="markdown-toc-modulation">Modulation</a></li>
      <li><a href="#bpsk" id="markdown-toc-bpsk">BPSK</a></li>
      <li><a href="#single-carrier-or-multi-carrier" id="markdown-toc-single-carrier-or-multi-carrier">Single carrier, or multi carrier?</a></li>
      <li><a href="#use-a-software-defined-radio" id="markdown-toc-use-a-software-defined-radio">Use a Software Defined Radio</a></li>
    </ul>
  </li>
  <li><a href="#bluetooth" id="markdown-toc-bluetooth">Bluetooth</a>    <ul>
      <li><a href="#bluetooth-basic-rateextended-data-rate" id="markdown-toc-bluetooth-basic-rateextended-data-rate">Bluetooth Basic Rate/Extended Data rate</a></li>
      <li><a href="#bluetooth-low-energy" id="markdown-toc-bluetooth-low-energy">Bluetooth Low Energy</a></li>
    </ul>
  </li>
  <li><a href="#algorithm-to-design-state-of-the-art-le-radio" id="markdown-toc-algorithm-to-design-state-of-the-art-le-radio">Algorithm to design state-of-the-art LE radio</a>    <ul>
      <li><a href="#lnta" id="markdown-toc-lnta">LNTA</a></li>
      <li><a href="#mixer" id="markdown-toc-mixer">MIXER</a></li>
      <li><a href="#aaf" id="markdown-toc-aaf">AAF</a></li>
      <li><a href="#adc" id="markdown-toc-adc">ADC</a></li>
      <li><a href="#ad-pll" id="markdown-toc-ad-pll">AD-PLL</a></li>
      <li><a href="#baseband" id="markdown-toc-baseband">Baseband</a></li>
    </ul>
  </li>
  <li><a href="#what-do-we-really-want-in-the-end" id="markdown-toc-what-do-we-really-want-in-the-end">What do we really want, in the end?</a></li>
  <li><a href="#want-to-learn-more" id="markdown-toc-want-to-learn-more">Want to learn more?</a></li>
</ul>

<p>Keywords: Range, Antenna Size, Modulation, OFDM, GFSK, pi/4-qpsk, 8-psk, 16 QAM, Bluetooth LE, LP RX, LNA, MIxer, AAF, ADC, BB</p>

<iframe width="560" height="315" src="https://www.youtube.com/embed/_hgmxi3F5Ew?si=vVYy8txyCYsAZ7oD" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen=""></iframe>

<p>Radio’s are all around us. In our phone, on our wrist, in our house, there is Bluetooth, WiFi, Zigbee, LTE, GPS and many more.</p>

<p>A radio is a device that receives and transmits light encoded with information. The frequency of the light depends on the standard. How the information is encoded onto 
the light depends on the standard.</p>

<p>Assume that we did not know any standards, what would we do if we wanted to make the best radio IC for gaming mice?</p>

<p>There are a few key concepts we would have to know before we decide on a radio type: Data Rate, Carrier Frequency and range, and the power supply.</p>

<h1 id="data-rate">Data Rate</h1>

<h2 id="data">Data</h2>

<p>A mouse reports on the relative X and Y displacement of the mouse as a function of time. A mouse has buttons. There can be many mice in a room, as such, they must have an address , so 
PCs can tell them apart.</p>

<p>A mouse must be low-power. As such, the radio cannot be on all the time. The radio must start up and be ready to receive quickly.</p>

<p>We don’t know how far 
away from the PC the mice might be, as such, we don’t know the dB loss in the communication channel. As a result, the radio needs to have a high dynamic range, from weak signals
to strong signals. In order for the radio to adjust the gain of the reciever we should include a pre-amble, a known sequence, for example 01010101, such that the radio can 
adjust the gain, and also, recover the symbol timing.</p>

<p>All in all, the packets we send from the mouse may need to have the following bits.</p>

<table>
  <thead>
    <tr>
      <th>What</th>
      <th>Bits</th>
      <th>Why</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>X displacement</td>
      <td>8</td>
      <td> </td>
    </tr>
    <tr>
      <td>Y displacement</td>
      <td>8</td>
      <td> </td>
    </tr>
    <tr>
      <td>CRC</td>
      <td>4</td>
      <td>Bit errors</td>
    </tr>
    <tr>
      <td>Buttons</td>
      <td>16</td>
      <td>One-hot coding. Most mice have buttons</td>
    </tr>
    <tr>
      <td>Preamble</td>
      <td>8</td>
      <td>Synchronization</td>
    </tr>
    <tr>
      <td>Address</td>
      <td>32</td>
      <td>Unique identifier</td>
    </tr>
    <tr>
      <td>Total</td>
      <td>76</td>
      <td> </td>
    </tr>
  </tbody>
</table>

<h2 id="rate">Rate</h2>

<p>Gamers are crazy for speed, they care about milliseconds. So our mice needs to be able to send and receive data quite often.</p>

<p>Assume 1 ms update rate</p>

<h2 id="data-rate-1">Data Rate</h2>

<p>To compute the data rate, let’s do a back of the envelope estimate of the data, and the rate.</p>

<p>Application Data Rate &gt; 76 bits/ms = 76 kbps</p>

<p>Assume 30 % packet loss</p>

<p>Raw Data Rate &gt; 228 kbps</p>

<p>Multiply by \(\pi\) &gt; 716 kbps</p>

<p>Round to nearest nice number = 1Mbps</p>

<p>The above statements are a exact copy of what happens in industry when we start design of something. We make an educated guess and multiply by a number.
More optimistic people would multiply with $e$.</p>

<h1 id="carrier-frequency--range">Carrier Frequency &amp; Range</h1>

<h2 id="ism-industrial-scientific-and-medical-bands">ISM (industrial, scientific and medical) bands</h2>

<p>There are rules and regulations that prevent us from transmitting and receiving at any frequency we want. We need to pick one of the ISM bands, or 
we need to get a license from governments around the world.</p>

<p>For the ISM bands, there are regions, as seen below.</p>

<p><img src="https://upload.wikimedia.org/wikipedia/commons/9/9b/International_Telecommunication_Union_regions_with_dividing_lines.svg" alt="" /></p>
<ul>
  <li>Yellow: Region 1</li>
  <li>Blue: Region 2</li>
  <li>Pink: Region 3</li>
</ul>

<p>Below is a table of the available frequencies, but how should we pick which one to use? There are at least two criteria that should be investigated. Antenna and Range.</p>

<table>
  <thead>
    <tr>
      <th style="text-align: left">Flow</th>
      <th style="text-align: left">Fhigh</th>
      <th style="text-align: left">Bandwidth</th>
      <th style="text-align: left">Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: left">40.66 MHz</td>
      <td style="text-align: left">40.7 MHz</td>
      <td style="text-align: left">40 kHz</td>
      <td style="text-align: left">Worldwide</td>
    </tr>
    <tr>
      <td style="text-align: left">433.05 MHz</td>
      <td style="text-align: left">434.79 MHz</td>
      <td style="text-align: left">1.74 MHz</td>
      <td style="text-align: left">Region 1</td>
    </tr>
    <tr>
      <td style="text-align: left">902 MHz</td>
      <td style="text-align: left">928 MHz</td>
      <td style="text-align: left">26 MHz</td>
      <td style="text-align: left">Region 2</td>
    </tr>
    <tr>
      <td style="text-align: left">2.4 GHz</td>
      <td style="text-align: left">2.5 GHz</td>
      <td style="text-align: left">100 MHz</td>
      <td style="text-align: left">Worldwide</td>
    </tr>
    <tr>
      <td style="text-align: left">5.725 GHz</td>
      <td style="text-align: left">5.875 GHz</td>
      <td style="text-align: left">150 MHz</td>
      <td style="text-align: left">Worldwide</td>
    </tr>
    <tr>
      <td style="text-align: left">24 GHz</td>
      <td style="text-align: left">24.25 GHz</td>
      <td style="text-align: left">250 MHz</td>
      <td style="text-align: left">Worldwide</td>
    </tr>
    <tr>
      <td style="text-align: left">61 GHz</td>
      <td style="text-align: left">61.5 GHz</td>
      <td style="text-align: left">500 MHz</td>
      <td style="text-align: left">Subject to local acceptance</td>
    </tr>
  </tbody>
</table>

<h2 id="antenna">Antenna</h2>

<p>For a mouse we want to hold in our hand, there is a size limit to the antenna. There are many types of antenna, but</p>

<p>assume \(\lambda/4\) is an OK antenna size (\(\lambda = c/f\))</p>

<p>The below table shows the ISM band and the size of a quarter wavelength antenna. Any frequency above 2.4 GHz may be OK from a size perspective.</p>

<table>
  <thead>
    <tr>
      <th>ISM band</th>
      <th style="text-align: right">\(\lambda/4\)</th>
      <th style="text-align: right">Unit</th>
      <th style="text-align: right">OK/NOK</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>40.68 MHz</td>
      <td style="text-align: right">1.8</td>
      <td style="text-align: right">m</td>
      <td style="text-align: right">:x:</td>
    </tr>
    <tr>
      <td>433.92 MHz</td>
      <td style="text-align: right">17</td>
      <td style="text-align: right">cm</td>
      <td style="text-align: right">:x:</td>
    </tr>
    <tr>
      <td>915 MHz</td>
      <td style="text-align: right">8.2</td>
      <td style="text-align: right">cm</td>
      <td style="text-align: right"> </td>
    </tr>
    <tr>
      <td>2450 MHz</td>
      <td style="text-align: right">3.06</td>
      <td style="text-align: right">cm</td>
      <td style="text-align: right">:white_check_mark:</td>
    </tr>
    <tr>
      <td>5800 MHz</td>
      <td style="text-align: right">1.29</td>
      <td style="text-align: right">cm</td>
      <td style="text-align: right">:white_check_mark:</td>
    </tr>
    <tr>
      <td>24.125 GHz</td>
      <td style="text-align: right">3.1</td>
      <td style="text-align: right">mm</td>
      <td style="text-align: right">:white_check_mark:</td>
    </tr>
    <tr>
      <td>61.25 GHz</td>
      <td style="text-align: right">1.2</td>
      <td style="text-align: right">mm</td>
      <td style="text-align: right">:white_check_mark:</td>
    </tr>
  </tbody>
</table>

<h2 id="range-friis">Range (Friis)</h2>

<p>One of the worst questions a radio designer can get is “What is the range of your radio?”, especially if the people asking are those that don’t understand
physics, or the real world. The answer to the question is incredibly complicated, as it depends on exactly what is between two devices talking.</p>

<p>If we assume, however, that there is only free space, and no real reflections from anywhere, then we can make an estimate of the range.</p>

<p>Assume no antenna gain, power density p at distance D is</p>

\[p = \frac{P_{TX}}{4 \pi D^2}\]

<p>Assume reciever antenna has no gain, then the effective aperture is</p>

\[A_e = \frac{\lambda^2}{4 \pi}\]

<p>Power received is then</p>

\[P_{RX} = \frac{P_{TX}}{D^2} \left[\frac{\lambda}{4 \pi}\right]^2\]

<p>Or in terms of distance</p>

\[D = 10^\frac{P_{TX} - P_{RX} + 20 log_{10}\left(\frac{c}{4 \pi f}\right)}{20}\]

<h2 id="range-free-space">Range (Free space)</h2>

<p>If we take the ideal equation above, and use some realistic numbers for TX and RX power, we can estimate a range.</p>

<p>Assume TX = 0 dBm, assume RX sensitivity is -80 dBm</p>

<table>
  <thead>
    <tr>
      <th>Freq</th>
      <th style="text-align: center"><strong>\(20 log_{10}\left(c/4 \pi f\right)\)</strong> [dB]</th>
      <th style="text-align: right">D [m]</th>
      <th style="text-align: right">OK/NOK</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>915 MHz</td>
      <td style="text-align: center">-31.7</td>
      <td style="text-align: right">260.9</td>
      <td style="text-align: right">:white_check_mark:</td>
    </tr>
    <tr>
      <td><strong>2.45 GHz</strong></td>
      <td style="text-align: center"><strong>-40.2</strong></td>
      <td style="text-align: right"><strong>97.4</strong></td>
      <td style="text-align: right">:white_check_mark:</td>
    </tr>
    <tr>
      <td>5.80 GHz</td>
      <td style="text-align: center">-47.7</td>
      <td style="text-align: right">41.2</td>
      <td style="text-align: right">:white_check_mark:</td>
    </tr>
    <tr>
      <td>24.12 GHz</td>
      <td style="text-align: center">-60.1</td>
      <td style="text-align: right">9.9</td>
      <td style="text-align: right">:x:</td>
    </tr>
    <tr>
      <td>61.25 GHz</td>
      <td style="text-align: center">-68.2</td>
      <td style="text-align: right">3.9</td>
      <td style="text-align: right">:x:</td>
    </tr>
    <tr>
      <td>160 GHz</td>
      <td style="text-align: center">-76.52</td>
      <td style="text-align: right">1.5</td>
      <td style="text-align: right">:x:</td>
    </tr>
  </tbody>
</table>

<h2 id="range-real-world">Range (Real world)</h2>

<p>In the real world, however, the</p>

<p>path loss factor, \(n \in [1.6,6]\), \(D = 10^\frac{P_{TX} - P_{RX} + 20 log_{10}\left(\frac{c}{4 \pi f}\right)}{n
\times 10}\)</p>

<p>So the real world range of a radio can vary more than an order of magnitude. Still, 2.4 GHz seems like a good choice for a mouse.</p>

<table>
  <thead>
    <tr>
      <th>Freq</th>
      <th style="text-align: center"><strong>\(20 log_{10}\left(c/4 \pi f\right)\)</strong> [dB]</th>
      <th style="text-align: right">D@n=2 [m]</th>
      <th style="text-align: right">D@n=6 [m]</th>
      <th style="text-align: right">OK/NOK</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><strong>2.45 GHz</strong></td>
      <td style="text-align: center"><strong>-40.2</strong></td>
      <td style="text-align: right"><strong>97.4</strong></td>
      <td style="text-align: right"><strong>4.6</strong></td>
      <td style="text-align: right">:white_check_mark:</td>
    </tr>
    <tr>
      <td>5.80 GHz</td>
      <td style="text-align: center">-47.7</td>
      <td style="text-align: right">41.2</td>
      <td style="text-align: right">3.45</td>
      <td style="text-align: right">:white_check_mark:</td>
    </tr>
    <tr>
      <td>24.12 GHz</td>
      <td style="text-align: center">-60.1</td>
      <td style="text-align: right">9.9</td>
      <td style="text-align: right">2.1</td>
      <td style="text-align: right">:x:</td>
    </tr>
  </tbody>
</table>

<h1 id="power-supply">Power supply</h1>

<p>We could have a wired mouse for power, but that’s boring. Why would we want a wired mouse to have wireless communication? It must be powered by a battery, but 
what type of battery?</p>

<p>There exists a bible of batteries, see picture below. It’s worth a read if you want to dive deeper into chemistry and properties of primary (non-chargeable) and secondary (chargeable) cells.</p>

<h2 id="battery">Battery</h2>

<p><img src="/aic2024/assets/media/lindens_handbook_of_batteries.png" alt="" width="700" /></p>

<p>Mouse is maybe AA,  3000 mAh</p>

<table>
  <thead>
    <tr>
      <th>Cell</th>
      <th style="text-align: left">Chemistry</th>
      <th style="text-align: right">Voltage (V)</th>
      <th style="text-align: right">Capacity (Ah)</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>AA</td>
      <td style="text-align: left">LiFeS2</td>
      <td style="text-align: right">1.0 - 1.8</td>
      <td style="text-align: right">3</td>
    </tr>
    <tr>
      <td>2xAA</td>
      <td style="text-align: left">LiFeS2</td>
      <td style="text-align: right">2.0 - 3.6</td>
      <td style="text-align: right">3</td>
    </tr>
    <tr>
      <td>AA</td>
      <td style="text-align: left">Zn/Alk/MnO2</td>
      <td style="text-align: right">0.8 - 1.6</td>
      <td style="text-align: right">3</td>
    </tr>
    <tr>
      <td>2xAA</td>
      <td style="text-align: left">Zn/Alk/MnO2</td>
      <td style="text-align: right">1.6 - 3.2</td>
      <td style="text-align: right">3</td>
    </tr>
  </tbody>
</table>

<h1 id="decisions">Decisions</h1>

<p>Now we know that we need a 1 Mbps radio at 2.4 GHz that runs of a 1.0 V - 1.8 V or 2.0 V - 3.6 V supply.</p>

<p>Next we need to decide what modulation scheme we want for our light. How should we encode the bits onto the 2.4 GHz carrier wave?</p>

<h2 id="modulation">Modulation</h2>

<p>Any modulation can be described by the function below.</p>

\[A_m(t) \times cos\left( 2 \pi f_{carrier}(t)t + \phi_{m}(t)\right)\]

<p>The amplitude of the carrier can be modulated, or the phase of the carrier.</p>

<p>People have been creative over the last 50 years in terms of encoding bits onto carriers. Below is a small excerpt of some common schemes.</p>

<table>
  <thead>
    <tr>
      <th>Scheme</th>
      <th>Acronym</th>
      <th>Pro</th>
      <th>Con</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Binary phase shift keying</td>
      <td>BPSK</td>
      <td>Simple</td>
      <td>Not constant envelope</td>
    </tr>
    <tr>
      <td>Quadrature phase-shift keying</td>
      <td>QPSK</td>
      <td>2bits/symbol</td>
      <td>Not constant envelope</td>
    </tr>
    <tr>
      <td>Offset QPSK</td>
      <td>OQPSK</td>
      <td>2bits/symbol</td>
      <td>Constant envelope with half-sine pulse shaping</td>
    </tr>
    <tr>
      <td>Gaussian Frequency Shift Keying</td>
      <td>GFSK</td>
      <td>1 bit/symbol</td>
      <td>Constant envelope</td>
    </tr>
    <tr>
      <td>Quadrature amplitude modulation</td>
      <td>QAM</td>
      <td>&gt; 1024 bits/symbol</td>
      <td>Really non-constant envelope</td>
    </tr>
  </tbody>
</table>

<h2 id="bpsk">BPSK</h2>

<p>In binary phase shift keying the 1 and 0 is encoded in the phase change. Change the phase 180 degrees and we’ve transitioned from a 0 to a 1. Do another 180 degrees and
we’re back to where we were.</p>

<p>It’s common to show modulation schemes in a constellation diagram with the real axis and the complex axis. 
For the real light we send the phase and amplitude is usually real.</p>

<p>I say usually, because in quantum mechanics, and the time evolution of a particle, the amplitude of the wave function is actually a complex variable. As such, nature 
is actually complex at the most fundamental level.</p>

<p>But for now, let’s keep it real in the real world.</p>

<p>Still, the maths is much more elegant in the complex plane.</p>

<p>The equation for the unit circle is $y = e^{i( \omega t + \phi)}$ where $\phi$ is the phase, and $\omega$ is the angular frequency.</p>

<p>Imagine we spin a bike wheel around at a constant frequency (constant $\omega$), on the bike wheel there is a red dot. If you keep your eyes open all 
the time, then the red dot would go round and round. But imagine that you only opened your eyes every second for a brief moment to see where the dot was. 
Sometimes it could be on the right side, sometimes on the left side. If our “eye opening rate”, or your sample rate, matched how fast the “wheel rotator” changed 
the location of the dot, then you could receive information.</p>

<p>Now imagine you have a strobe light matched to the “normal” carrier frequency. If one rotation of the wheel matched the frequency of the strobe light, then the red dot would
stay in exactly the same place. If the wheel rotation was slightly faster, then the red dot would move one way around the circle at every strobe. If the wheel rotation was
slightly slower, the red dot would move the other way around the circle.</p>

<p>That’s exactly how we can change the position in the constellation. We increase the carrier frequency for a bit to rotate 180 degrees, and we can decrease the frequency to 
go back 180 degrees. In this example the dot would move around the unit circle, and the amplitude of the carrier can stay constant.</p>

<p><img src="/aic2024/assets/media/l7_bpsk_real.svg" alt="" width="700" /></p>

<p>There is another way to change phase 180 degrees, and that’s simply to swap the phase in the transmitter circuit. Imagine as below we have a local oscillator driving 
pseudo differential common source stages with switches on top. If we flip the switches we can change the phase 180 degrees pretty fast.</p>

<p>A challenge is, however, that the amplitude will change. In general, constant envelope (don’t change amplitude) modulation is less bandwidth efficient (slower) than schemes
that change both phase and amplitude.</p>

<p><img src="/aic2024/assets/media/l7_bpsk_circuit.svg" alt="" width="700" /></p>

<p>Standards like Zigbee used offset quadrature phase shift keying, with a constellation as shown below. With 4 points we can send 2 bits per symbol.</p>

<p><img src="/aic2024/assets/media/l7_qpsk.svg" alt="" width="700" /></p>

<p>In ZigBee, or 802.15.4 as the standard is called, the phase changes
is actually done with a constant envelope.</p>

<p>The nice thing about constant envelope is that the radio transmitter can be simple. We don’t need to change the amplitude. 
If we have a PLL as a local oscillator, where we can change the phase (or frequency), then we only need a power amplifier before the antenna.</p>

<p><img src="/aic2024/assets/media/l7_const_env.svg" alt="" width="700" /></p>

<p>For phase and amplitude modulation, or complex transmitters, we need a way to change the amplitude and phase. What a shocker. There are two ways to do that. A polar architecture 
where phase change is done in the PLL, and amplitude in the power amplifier.</p>

<p><img src="/aic2024/assets/media/l7_polar.svg" alt="" width="700" /></p>

<p>Or a Cartesian architecture where we make the in-phase component, and quadrature-phase 
components in digital, then use two digital to analog converters, and a set of complex mixers to encode onto the carrier. The power amplifier would not need to change
the amplitude, but it does need to be linear.</p>

<p><img src="/aic2024/assets/media/l8_cartesian.svg" alt="" width="700" /></p>

<p>We can continue to add constellation points around the unit circle. Below we can see 8-PSK, where we can send 3-bits per symbol. Assuming we could shift position between the 
constellation points at a fixed rate, i.e 1 mega symbols per second. With 1-bit per symbol we’d get 1 Mbps. With 3-bits per symbol we’d get 3 Mbps.</p>

<p>We could add 16 points, 32 points and so on to the unit circle, however, there is always noise in the transmitter, which will create a cloud around each constellation point,
and it’s harder and harder to distinguish the points from each other.</p>

<p><img src="/aic2024/assets/media/l8_8psk.svg" alt="" width="700" /></p>

<p>Bluetooth Classic uses $\pi/4$-DQPSK and 8DPSK.</p>

<p>DPSK means differential phase shift keying. Think about DPSK like this. In the QPSK diagram above the symbols (00,01,10,11) are determined by the constellation point $1 + j$, $1-j$ 
and so on. What would happen if the constellation rotated slowly? Would $1+j$ turn into $1-j$ at some point? That might screw up our decoding if the received constellation
point was at $1 + 0j$, we would not know what it was.</p>

<p>If we encoded the symbols as a change in phase instead (differential), then it would not matter if the 
constellation rotated slowly. A change from $1+j$ to $1-j$ would still be 90 degrees.</p>

<p>Why would the constellation rotate you ask? Imagine the transmitter transmits at 2 400 000 000 Hz. How does our reciever generate the same frequency? We need a reference
and a PLL. The crystal-oscillator reference has a variation of +-50 ppm, so $2.4e9 \times 50/1e6 = 120$ kHz.</p>

<p>Assume our receiver local oscillator was at 2 400 120 000 Hz. The transmitter sends 2 400 000 000 Hz + modulation. At the reciever we multiply with our local oscillator, 
and if you remember your math, multiplication of two sine creates a sum and a difference between the two frequencies. As such, the low frequency part 
(the difference between the frequencies) would be 120 kHz + modulation. As a result, our constellation would rotate 120 000 times per second. Assuming a symbol rate 
of 1MS/s our constellation would rotate roughly 1/10 of the way each symbol.</p>

<p>In DPSK the rotation is not that important. In PSK we have to measure the carrier offset, and continuously de-rotate the constellation.</p>

<p>Most radios will de-rotate somewhat based on the preamble, for example in Bluetooth Low Energy there is an initial 10101010 sequence that we can use to estimate 
the offset between TX and RX carriers, or the frequency offset.</p>

<p>The $\pi/4$ part of $\pi/4-DQPSK$ just means we actively rotate the constellation 45 degrees every symbol, as a consequence, the amplitude never goes through the 
origin. In the transmitter circuit, it’s difficult to turn the carrier off, so we try to avoid the zero point in the constellation.</p>

<p><img src="/aic2024/assets/media/EDR.png" alt="" width="700" /></p>

<p>I don’t think 16PSK is that common, at 4-bits per symbol it’s common to switch to Quadrature Amplitude Modulation (QAM), as shown below. The goal of QAM is to maximize
the distance between each symbol. The challenge with QAM is the amplitude modulation. The modulation scheme is sensitive to variations in the transmitter amplitude. As such,
more complex circuits than 8PSK could be necessary.</p>

<p>If you wanted to research “new fancy modulation schemes” I’d think about <a href="https://en.wikipedia.org/wiki/Sphere_packing">Sphere packing</a>.</p>

<p><img src="/aic2024/assets/media/l8_16qam.svg" alt="" width="700" /></p>

<h2 id="single-carrier-or-multi-carrier">Single carrier, or multi carrier?</h2>

<p>Assume we wanted to send 1024 Mbps over the air. We could choose a bandwidth of a about 1 GHz with 1-bit per symbol, or  have a bandwidth of 1 MHz if
we sent 1024 QAM at 1MS/s. Both cases would look like the figure below.</p>

<p>In both cases we get problems with the physical communication channel, the change in phase and amplitude affect what is received. 
For a 1 GHz bandwidth at 2.4 GHz carrier we’d have problems with the phase. At 1024 QAM we’d have problems with the amplitude.</p>

<p><img src="/aic2024/assets/media/l10_single_carrier.svg" alt="" width="700" /></p>

<p>Back in 1966 <a href="https://en.wikipedia.org/wiki/Orthogonal_frequency-division_multiplexing#:~:text=OFDM%20is%20a%20frequency%2Ddivision,is%20divided%20into%20multiple%20streams.">Orthogonal frequency division multiplexing</a>
was introduced to deal with the communication channel. In OFDM we modulate a number of sub-carriers in the frequency space with our wanted modulation scheme (BPSK, PSK, QAM), then do an inverse fourier transform to 
get the time domain signal, mix on to the carrier, and transmit. At the reciever we take an FFT and do demodulation in the frequency space. See example in figure below.</p>

<p>The name “multiple carriers” is a bit misleading. Although there are multiple carriers on the left and right side of the figure, there is normally still just one carrier in the TX/RX.</p>

<p><img src="/aic2024/assets/media/l10_multiple_carrier.svg" alt="" width="700" /></p>

<p>There are more details in OFDM than the simple statement above, but the details are just to fix challenges, such as “How do I recover the symbol timing? 
How do I correct for frequency offset? How do I ensure that my time domain signal terminates correctly for every FFT chunk”</p>

<p>The genius with OFDM is that we can pick a few of the sub-carriers to be pilot tones that carry no new information. If we knew exactly what was sent in phase and amplitude, 
then we could measure the phase and amplitude change due to the physical communication channel, and we could correct the frequency space before we tried to de-modulate.</p>

<p>It’s possible to do the same with single carrier modulation also. Imagine we made a 128-QAM modulation on a single carrier. As long as we constructed the time domain signal
correctly (cyclic prefix to make the FFT work nicely, some preamble to measure the communication channel, then we could take an FFT at the reciever, correct 
the phase and amplitude, do an IFFT and demodulate the time-domain signal as normal.</p>

<p>In radio design there are so many choices it’s easy to get lost.</p>

<h2 id="use-a-software-defined-radio">Use a Software Defined Radio</h2>

<p>For our mouse, what radio scheme should we choose? One common instances of “how to make a choice” in industry is “Delay the choice as long as possible so
your sure the choice is right”.</p>

<p>Maybe the best would be to use a software defined radio reciever? Something like the picture below, an antenna, low noise amplifier, and a 
analog-to-digital converter. That way we could support any transmitter. Fantastic idea, right?</p>

<p><img src="/aic2024/assets/media/lg_lna_adc.svg" alt="" width="700" /></p>

<p>Well, lets check if it’s a good idea. We know we’ll use 2.4 GHz, so we need about 2.5 GHz bandwidth, at least. We know we want good range, so maybe 100 dB
dynamic range. 
In analog to digital 
converter design there are figure of merits, so we can actually compute a rough power consumption for such an ADC.</p>

<p>ADC FOM \(= \frac{P}{2 BW 2^n}\)</p>

<p>State of the art FOM \(\approx 5 \text{ fJ/step}\)</p>

\[BW = 2.5\text{ GHz}\]

\[DR = 100\text{ dB} = (96-1.76)/6.02 \approx 16\text{ bit}\]

\[P = 5\text{ fF} \times 5 \text{ GHz} \times 2^{16} = 1.6\text{ W}\]

<p>At 1.6 W our mouse would only last for 2 hours. That’s too short. It will never be a low power idea to convert the full 2.5 GHz bandwidth to digital, we need some bandwidth selectivity 
in the receive chain.</p>

<h1 id="bluetooth">Bluetooth</h1>

<p><a href="https://www.bluetooth.com/specifications/specs/core-specification-5-4/">Bluetooth</a> was made to be a “simple” standard and was introduced in 1998. 
The standard has continued to develop, with Low Energy introduced in 2010. The latest planned changes can be seen at <a href="https://www.bluetooth.com/specifications/specifications-in-development/">Specifications in Development</a>.</p>

<h2 id="bluetooth-basic-rateextended-data-rate">Bluetooth Basic Rate/Extended Data rate</h2>

<ul>
  <li>2.400 GHz to 2.4835 GHz</li>
  <li>1 MHz channel spacing</li>
  <li>78 Channels</li>
  <li>Up to 20 dBm</li>
  <li>Minimum -70 dBm sensitivity (1 Mbps)</li>
  <li>1 MHz GFSK (1 Mbps), pi/4-DQPSK (2 Mbps), 8DPSK (3 Mbps)</li>
</ul>

<p>You’ll find BR/EDR in most audio equipment, cars and legacy devices. For new devices (also audio), there is now a transition to Bluetooth Low Energy.</p>

<h2 id="bluetooth-low-energy">Bluetooth Low Energy</h2>

<ul>
  <li>2.400 GHz to 2.480 GHz</li>
  <li>2 MHz channel spacing</li>
  <li>40 Channels (3 primary advertising channels)</li>
  <li>Up to 20 dBm</li>
  <li>Minimum -70 dBm sensitivity (1 Mbps)</li>
  <li>1 MHz GFSK (1 Mbps, 500 kbps, 125 kbps), 2 MHz GFSK (2 Mbps)</li>
</ul>

<p>Below are the Bluetooth LE channels. The green are the advertiser channels, the blue are the data channels, and the yellow is the WiFi channels.</p>

<p>The advertiser channels have been intentionally placed where there is space between the WiFi channels to decrease the probability of collisions.</p>

<p><img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/map.PNG" alt="" /></p>

<p>Any Bluetooth LE peripheral will advertise it’s presence, it will wake up once in a while (every few hundred milliseconds, to seconds) and transmit a short “I’m here” packet. 
After transmitting it will wait a bit in receive to see if anyone responds.</p>

<p>A Bluetooth LE central will camp in receive on a advertiser channel and look for these short messages from peripherals. If one is observed, the Central may choose to respond.</p>

<p>Take any spectrum analyzer anywhere, and you’ll see traffic on 2402, 2426, and 2480 MHz.</p>

<p><img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-blogs-components-weblogfiles/00-00-00-00-12-DZ-21/ble_5F00_connection.jpg" alt="" /></p>

<p>In a connection a central and peripheral (the master/slave names below have been removed from the spec, that was a fun update to a 3500 page document) will have 
agreed on an interval to talk. Every “connection interval” they will transmit and receive data. The connection interval is tunable from 7.5 ms to seconds.</p>

<p>Bluetooth LE is the perfect standard for wireless mice.</p>

<p><img src="https://devzone.nordicsemi.com/resized-image/__size/1042x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-00-28/2148.pastedimage1646833758482v3.png" alt="" /></p>

<p>For further information <a href="https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/software/posts/building-a-ble-application-on-ncs-comparing-and-contrasting-to-softdevice-based-ble-applications">Building a Bluetooth application on nRF Connect SDK</a></p>

<p><a href="https://www.bluetooth.com/specifications/specifications-in-development/">Bluetooth Specifications in Development</a></p>

<h1 id="algorithm-to-design-state-of-the-art-le-radio">Algorithm to design state-of-the-art LE radio</h1>
<ul>
  <li>Find most recent digest from International Solid State Circuit Conference (ISSCC)</li>
  <li>Find Bluetooth low energy papers</li>
  <li>Pick the best blocks from each paper</li>
</ul>

<p>A typical Bluetooth radio may look something like the picture below. There would be a single antenna for both RX and Tx. There will be 
some way to combine the transmit and receive path in a match, or balun.</p>

<p>The receive chain would have a LNA, mixer, anti-alias filter and analog-to-digital converters. It’s likely that the receive path would be complex (in-phase and quadrature phase) after mixer.</p>

<p>There would be a local oscillator (all-digital phase-locked-loop) to provide the frequency to the mixers and transmit path, which could 
be either polar or Cartesian.</p>

<p><img src="/aic2024/assets/media/l10_lprxarch.svg" alt="" width="700" /></p>

<p>In the typical radio we’ll need the blocks below. I’ve added a column for how many people I would want if I was to lead development of a new radio.</p>

<table>
  <thead>
    <tr>
      <th>Blocks</th>
      <th>Key parameter</th>
      <th>Architecture</th>
      <th>Complexity (nr people)</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Antenna</td>
      <td>Gain, impedance</td>
      <td>lambda/4</td>
      <td>&lt;1</td>
    </tr>
    <tr>
      <td>RF match</td>
      <td>loss, input impedance</td>
      <td>PI-match</td>
      <td>&lt;1</td>
    </tr>
    <tr>
      <td>Low noise amp</td>
      <td>NF, current, linearity</td>
      <td>LNTA</td>
      <td>1</td>
    </tr>
    <tr>
      <td>Mixer</td>
      <td>NF, current, linearity</td>
      <td>Passive</td>
      <td>1</td>
    </tr>
    <tr>
      <td>Anti-alias filter</td>
      <td>NF, current, linearity</td>
      <td>Active-RC</td>
      <td>1</td>
    </tr>
    <tr>
      <td>ADC</td>
      <td>Sample rate, dynamic range, linearity</td>
      <td>NS-SAR</td>
      <td>1 - 2</td>
    </tr>
    <tr>
      <td>PLL</td>
      <td>Phase noise, current</td>
      <td>AD-PLL</td>
      <td>2-3</td>
    </tr>
    <tr>
      <td>Baseband</td>
      <td>Eb/N0, gate count, current.</td>
      <td>SystemVerilog</td>
      <td>&gt; 10</td>
    </tr>
  </tbody>
</table>

<h2 id="lnta">LNTA</h2>

<p>The first thing that must happen in the radio is to amplify the noise as early as possible. Any circuit has inherent noise, be it thermal-, flicker-, burst-, or shot-noise. 
The earlier we can amplify the input noise, the less contribution there will be from the radio circuits.</p>

<p>The challenges in the low noise amplifier is to provide the right gain. If there is a strong input signal, then reduce the gain. If there is a low input signal, then 
increase the gain.</p>

<p>One way to implement variable gain is to reconfigure the LNA. For an example, see</p>

<p><a href="https://ieeexplore.ieee.org/document/9063021">30.5 A 0.5V BLE Transceiver with a 1.9mW RX Achieving -96.4dBm Sensitivity and 4.1dB Adjacent Channel Rejection at 1MHz Offset in 22nm FDSOI</a></p>

<p>A typical Low Noise Transconductance Amplifier is seen below. It’s a combination of both a common source, and a common gate amplifier. The current in the NMOS and PMOS is controlled by Vgp and Vgn. Keep in mind that at RF frequencies the signals are weak, so it’s easy to provide the DC for the LNA with a resistor to a diode connected PMOS or NMOS.</p>

<p>In a LNA the input impedance must be matched to what is required by the antenna/match in order to have maximum power transfer, that’s the role of the inductors/capacitors.</p>

<p><img src="/aic2024/assets/media/l10_lna.svg" alt="" width="700" /></p>

<h2 id="mixer">MIXER</h2>

<p>In the mixer we multiply the input signal with our local oscillator. Most often a complex mixer is used. There is nothing complex about complex signal processing, 
just read</p>

<p><a href="https://ieeexplore.ieee.org/document/1333231">Complex signal processing is not complex</a></p>

<p>In order to reduce power, it’s most common with a passive mixer as shown below. A passive mixer is just MOS that we turn on and off with 25% duty-cycle. See example in</p>

<p><a href="https://ieeexplore.ieee.org/document/9062973/">A 370uW 5.5dB-NF BLE/BT5.0/IEEE 802.15.4-Compliant Receiver with &gt;63dB Adjacent Channel Rejection at &gt;2 Channels Offset in 22nm FDSOI</a></p>

<p><img src="/aic2024/assets/media/l10_mix.svg" alt="" width="700" /></p>

<p>To generate the quadrature and in-phase clock signals, which must be 90 degrees phase offset, it’s common to generate twice the frequency in the 
local oscillator (4.8 GHz), and then divide down to 4 2.4 GHz clock signals.</p>

<p>If the LO is the same as the carrier, then the modulation signal 
will be at DC, often called direct conversion.</p>

<p>The challenge at DC is that there is flicker noise, offset, and burst noise. The modulation type, however, can impact whether low frequency noise is an issue. In OFDM we
can choose to skip the sub-carriers around 0 Hz, and direct conversion works well. An advantage with direct conversion is that there is no “image frequency” and 
we can use the full complex bandwidth.</p>

<p>For FSK and direct conversion the low frequency noise can cause issues, as such, it’s common to offset the LO from the transmitted signal, for example 4 MHz offset. 
The low frequency noise problem disappears, however, we now have a challenge with the image frequency (-4 MHz) that must be rejected, and we need an increased bandwidth.</p>

<p>There is no “one correct choice”, there are trade-offs that both ways. KISS (Keep It Simple Stupid) is one of my guiding principles when working on radio architecture.</p>

<p>These days most de-modulation happens in digital, and we need to convert the analog signal to digital, but first AAF.</p>

<h2 id="aaf">AAF</h2>

<p>The anti alias filter rejects frequencies that can fold into the band of interest due to sampling. A simple active-RC 
filters is often good enough.</p>

<p>We often need gain in the AAF, as the LNA does not have sufficient gain for the weakest signals. -100 dBm in 50 ohm is 6.2 nV RMS, while input 
range of an ADC may be 1 V. Assume we place the lowest input signal at 0.1 V, so we need a voltage gain of $20\log(0.1/6.2e-9) = 76$dB in the reciever.</p>

<p><img src="/aic2024/assets/media/l4_activebiquad.svg" alt="" width="700" /></p>

<h2 id="adc">ADC</h2>

<p>Aaah, ADCs, an IP close to my heart. I did my Ph.d and Post-Doc on ADCs, and the Ph.D students I’ve co-supervised have worked on ADCs.</p>

<p>At NTNU there have been multiple students through the years that have made world-class ADCs, and there’s still students at NTNU working on state-of-the-art ADCs.</p>

<p>These days, a good option is a SAR, or a Noise-Shaped SAR.</p>

<p>If I were to pick, I’d make something like <a href="https://ieeexplore.ieee.org/document/9056925">A 68 dB SNDR Compiled Noise-Shaping SAR ADC With On-Chip CDAC Calibration</a> as shown in the figure below.</p>

<p><img src="/aic2024/assets/media/l6_harald_arch.gif" alt="" width="700" /></p>

<p>Or if I did not need high resolution, I’d choose my trusty <a href="https://ieeexplore.ieee.org/document/7906479">A Compiled 9-bit 20-MS/s 3.5-fJ/conv.step SAR ADC in 28-nm FDSOI for Bluetooth Low Energy Receivers</a>.</p>

<p>The main selling point of that ADC was that it’s compiled from a <a href="https://github.com/wulffern/sun_sar9b_sky130nm/blob/main/cic/ip.json">JSON</a> file, a <a href="https://github.com/wulffern/sun_sar9b_sky130nm/blob/main/cic/ip.spi">SPICE</a> file 
and a <a href="https://github.com/wulffern/sun_sar9b_sky130nm/blob/main/cic/sky130.tech">technology</a> file into a DRC/LVS clean layout.</p>

<p>I also included a few circuit improvements. The bottom plate of the SAR capacitor is in the clock loop for the comparator (DN0, DP1 below), as such, the 
delay of the comparator automatically adjusts with capacitance corner, so it’s more robust over corners</p>

<p><img src="/aic2024/assets/media/fig_sar_logic.svg" alt="" width="700" /></p>

<p>The compiled nature also made it possible to quickly change the transistor technology. Below is a picture with 180 nm FDSOI transistors on the left, and 28 nm FDSOI transistors on the right.</p>

<p>I detest doing anything twice, so I love the fact that I never have to re-draw that ADC again. I just fix the technology file (and maybe some tweaks to the other files), and 
I have a completed ADC.</p>

<p><img src="/aic2024/assets/media/l06_fig_toplevel.svg" alt="" width="700" /></p>

<h2 id="ad-pll">AD-PLL</h2>

<p>The phase locked loop is the heart of the radio, and it’s probably the most difficult part to make. Depends a bit on technology, but these days, All Digital PLLs are cool. Start by reading Razavi’s PLL book.</p>

<p>You can spend your life on PLLs.</p>

<p><img src="/aic2024/assets/media/l08_pll_2mod.svg" alt="" width="700" /></p>

<p>AD-PLL with Bang-Bang phase detector for steady-state</p>

<p><img src="/aic2024/assets/media/pll_master_arch_28feb2020.svg" alt="" width="700" /></p>

<h2 id="baseband">Baseband</h2>

<p>Once the signal has been converted to digital, then the de-modulation, and signal fixing start. That’s for another course, but there are interesting challenges.</p>

<table>
  <thead>
    <tr>
      <th>Baseband block</th>
      <th>Why</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Mixer?</td>
      <td>If we’re using low intermediate frequency to avoid DC offset problems and flicker noise</td>
    </tr>
    <tr>
      <td>Channel filters?</td>
      <td>If the AAF is insufficient for adjacent channel</td>
    </tr>
    <tr>
      <td>Power detection</td>
      <td>To be able to control the gain of the radio</td>
    </tr>
    <tr>
      <td>Phase extraction</td>
      <td>Assuming we’re using FSK</td>
    </tr>
    <tr>
      <td>Timing recovery</td>
      <td>Figure out when to slice the symbol</td>
    </tr>
    <tr>
      <td>Bit detection</td>
      <td>single slice, multi-bit slice, correlators etc</td>
    </tr>
    <tr>
      <td>Address detection</td>
      <td>Is the packet for us?</td>
    </tr>
    <tr>
      <td>Header detection</td>
      <td>What does the packet contain</td>
    </tr>
    <tr>
      <td>CRC</td>
      <td>Does the packet have bit errors</td>
    </tr>
    <tr>
      <td>Payload de-crypt</td>
      <td>Most links are encrypted by AES</td>
    </tr>
    <tr>
      <td>Memory access</td>
      <td>Payload need to be stored until CPU can do something</td>
    </tr>
  </tbody>
</table>

<h1 id="what-do-we-really-want-in-the-end">What do we really want, in the end?</h1>

<p>The reciever part can be summed up in one equation for the sensitivity. The noise in a certain bandwidth. The Noise Figure of the analog reciever. The Energy per bit over Noise
of the de-modulator.</p>

\[P_{RX_{sens}} = -174 dBm + 10 \times log10(DR)  + NF + Eb/N0\]

<p>for example, for nRF5340</p>

\[P_{RX_{sens}} + 174 - 60 =  NF + Eb/N0 = 17 dB\]

<p><img src="/aic2024/assets/media/nrf53_rx.png" alt="" width="700" /></p>

<p>In the block diagram of the device the radio might be a small box, and the person using the radio might not realize how complex the radio actually is.</p>

<p>I hope you understand now that it’s actually complicated.</p>

<p><img src="/aic2024/assets/media/nrf53.png" alt="" width="700" /></p>

<h1 id="want-to-learn-more">Want to learn more?</h1>

<p><a href="https://ieeexplore.ieee.org/document/9063021">A 0.5V BLE Transceiver with a 1.9mW RX Achieving -96.4dBm Sensitivity and 4.1dB Adjacent Channel Rejection at 1MHz Offset in 22nm FDSOI</a>, M. Tamura, Sony Semiconductor Solutions, Atsugi, Japan, 30.5, ISSCC 2020</p>

<p><a href="https://ieeexplore.ieee.org/document/9062973/">A 370uW 5.5dB-NF BLE/BT5.0/IEEE 802.15.4-Compliant Receiver with &gt;63dB Adjacent Channel Rejection at &gt;2 Channels Offset in 22nm FDSOI</a>, B. J. Thijssen, University of Twente, Enschede, The Netherlands</p>

<p><a href="https://ieeexplore.ieee.org/document/9056925">A 68 dB SNDR Compiled Noise-Shaping SAR ADC With On-Chip CDAC Calibration</a>, H. Garvik, C. Wulff, T. Ytterdal</p>

<p><a href="https://ieeexplore.ieee.org/document/7906479">A Compiled 9-bit 20-MS/s 3.5-fJ/conv.step SAR ADC in 28-nm FDSOI for Bluetooth Low Energy Recievers</a>, C. Wulff, T. Ytterdal</p>

<p>Cole Nielsen, <a href="https://github.com/nielscol/thesis_presentations">https://github.com/nielscol/thesis_presentations</a></p>

<p>“Python Framework for Design and Simulation of Integer-N ADPLLs”, Cole Nielsen, <a href="https://github.com/nielscol/tfe4580-report/blob/master/report.pdf">https://github.com/nielscol/tfe4580-report/blob/master/report.pdf</a></p>

<p><a href="https://doi.org/10.1017/9781108626200">Design of CMOS Phase-Locked Loops</a>, Behzad Razavi, University of California, Los Angeles</p>]]></content><author><name>Carsten Wulff</name><email>carsten@wulff.no</email></author><summary type="html"><![CDATA[If you find an error in what I’ve made, then fork, fix lectures/l10_lpradio.md, commit, push and create a pull request. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.]]></summary></entry><entry><title type="html">Lecture 9 - Oscillators</title><link href="https://wulffern.github.io/aic2024/2024/03/14/Lecture-9-Oscillators.html" rel="alternate" type="text/html" title="Lecture 9 - Oscillators" /><published>2024-03-14T00:00:00+00:00</published><updated>2024-03-14T00:00:00+00:00</updated><id>https://wulffern.github.io/aic2024/2024/03/14/Lecture-9---Oscillators</id><content type="html" xml:base="https://wulffern.github.io/aic2024/2024/03/14/Lecture-9-Oscillators.html"><![CDATA[<blockquote>
  <p>If you find an error in what I’ve made, then <a href="https://docs.github.com/en/get-started/quickstart/fork-a-repo">fork</a>, fix <a href="https://github.com/wulffern/aic2024/tree/main/lectures/l09_osc.md">lectures/l09_osc.md</a>, <a href="https://git-scm.com/docs/git-commit">commit</a>, <a href="https://git-scm.com/docs/git-push">push</a> and <a href="https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/working-with-your-remote-repository-on-github-or-github-enterprise/creating-an-issue-or-pull-request">create a pull request</a>. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.</p>
</blockquote>

<p><a href="/aic2024/assets/slides/l09_osc.pdf">Slides</a></p>

<ul id="markdown-toc">
  <li><a href="#atomic-clocks" id="markdown-toc-atomic-clocks">Atomic clocks</a>    <ul>
      <li><a href="#microchip-5071b-cesium-primary-time-and-frequency-standard" id="markdown-toc-microchip-5071b-cesium-primary-time-and-frequency-standard">Microchip 5071B Cesium Primary Time and Frequency Standard</a></li>
      <li><a href="#rubidium-standard" id="markdown-toc-rubidium-standard">Rubidium standard</a></li>
    </ul>
  </li>
  <li><a href="#crystal-oscillators" id="markdown-toc-crystal-oscillators">Crystal oscillators</a>    <ul>
      <li><a href="#impedance" id="markdown-toc-impedance">Impedance</a></li>
      <li><a href="#circuit" id="markdown-toc-circuit">Circuit</a></li>
      <li><a href="#temperature-behavior" id="markdown-toc-temperature-behavior">Temperature behavior</a></li>
    </ul>
  </li>
  <li><a href="#controlled-oscillators" id="markdown-toc-controlled-oscillators">Controlled Oscillators</a>    <ul>
      <li><a href="#ring-oscillator" id="markdown-toc-ring-oscillator">Ring oscillator</a></li>
      <li><a href="#capacitive-load" id="markdown-toc-capacitive-load">Capacitive load</a></li>
      <li><a href="#realistic" id="markdown-toc-realistic">Realistic</a></li>
      <li><a href="#digitally-controlled-oscillator" id="markdown-toc-digitally-controlled-oscillator">Digitally controlled oscillator</a></li>
      <li><a href="#differential" id="markdown-toc-differential">Differential</a></li>
      <li><a href="#lc-oscillator" id="markdown-toc-lc-oscillator">LC oscillator</a></li>
    </ul>
  </li>
  <li><a href="#relaxation-oscillators" id="markdown-toc-relaxation-oscillators">Relaxation oscillators</a></li>
  <li><a href="#want-to-learn-more" id="markdown-toc-want-to-learn-more">Want to learn more?</a>    <ul>
      <li><a href="#crystal-oscillators-1" id="markdown-toc-crystal-oscillators-1">Crystal oscillators</a></li>
      <li><a href="#cmos-oscillators" id="markdown-toc-cmos-oscillators">CMOS oscillators</a></li>
    </ul>
  </li>
</ul>

<!--

Lecture Notes: https://analogicus.com/aic2024/2024/03/14/Lecture-9-Oscillators.html

00:00 Introduction
01:28 Cesium clocks
05:17 Rubidium clocks
10:20 Crystal Oscillators
31:53 Pierce inverter
41:23 Controlled oscillators
42:00 Ring oscillator
58:26 LC oscillators
1:07:03 Relaxation Oscillators

-->

<p>Keywords: Crystal model, Pierce, Temperature, Controlled oscillator, Ring osc, Ictrl Rosc, DCO Ring, LCOSC, RCOSC</p>

<iframe width="560" height="315" src="https://www.youtube.com/embed/Y7EkdvkB43M?si=tK4vCz4N3wuK90NV" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen=""></iframe>

<p>The world depends on accurate clocks. From the timepiece on your wrist, to the
phone in your pocket, they all have a need for an accurate
way of counting the passing of time.</p>

<p>Without accurate clocks an accurate GPS location would not be possible. In GPS
we even correct for <a href="https://en.wikipedia.org/wiki/Error_analysis_for_the_Global_Positioning_System">Special and General
Relativity</a>
to the tune of about $+38.6 \mu\text{s/day }$.</p>

<p>Let’s have a look at the most accurate clocks first.</p>

<h1 id="atomic-clocks">Atomic clocks</h1>

<p><a href="https://en.wikipedia.org/wiki/Caesium_standard">Cesium standard</a></p>

<p>The second is defined by taking the fixed numerical value of the cesium frequency Cs, the unperturbed ground-state hyper-fine transition frequency of the cesium 133 atom, to be 9 192 631 770 when expressed in the unit Hz, which is equal to s–1</p>

<p>As a result, by definition, the cesium clocks are exact. That’s how the second is defined. When we make a real circuit, however, we never get a perfect, unperturbed system.</p>

<h2 id="microchip-5071b-cesium-primary-time-and-frequency-standard">Microchip 5071B Cesium Primary Time and Frequency Standard</h2>

<p>One example of a ultra precise time piece is shown below. The bullets in the list below is from the marketing blurb.</p>

<p>Why would the thing take 30 minutes to start up? Does the temperature need to settle? Is it the loop bandwidth of the PLL that is low? Who knows, but 30 minutes is too long for a IC startup time.
And we can’t really pack the big box onto a chip.</p>

<ul>
  <li>&lt; 5E-13 accuracy high-performance models</li>
  <li>Accuracy levels achieved within 30 minutes of startup</li>
  <li>&lt; 8.5E-13 at 100s high-performance models</li>
  <li>&lt; 1E-14 flicker floor high-performance models</li>
</ul>

<p>Also, when they say</p>

<p>“Ask for a quote” =&gt; The price is really high, and we don’t want to tell you yet</p>

<p><img src="/aic2024/assets/media/microchip_cesium.jpeg" alt="" width="700" /></p>

<h2 id="rubidium-standard">Rubidium standard</h2>

<p><a href="https://en.wikipedia.org/wiki/Rubidium_standard">Rubidium standard</a>, use the rubidium hyper-fine transition of 6.8 GHz (6834682610.904 Hz)</p>

<p>and can actually be made quite small. Below is a picture of a tiny atomic clock. According to the marketing blurb:</p>

<p><em>The MAC is a passive atomic clock, incorporating the interrogation technique of Coherent Population Trapping (CPT) and operating upon the D1 optical resonance of atomic Rubidium Isotope 87.</em></p>

<p><strong>A rubidium clock is basically a crystal oscillator locked to an atomic reference.</strong></p>

<p><img src="https://cdn.sparkfun.com/r/455-455/assets/parts/1/3/1/0/0/14830-Atomic_Clock-04.jpg" alt="" /></p>

<p>But how do the clocks work? According to Wikipedia, the picture below, is a common way to operate a rubidium clock.</p>

<p>A light passing through the Rubidium gas will be affected if the frequency injected is at the hyper-fine energy levels (E = hf). The change in brightness can be detected by the photo detector, and we can 
adjust the frequency of the crystal oscillator, we’ll see later how that can be done. The crystal oscillator is used as reference for a PLL (freqency synthesizer   ) to generate the exact frequency needed.</p>

<p>The negative feedback loop ensures that the 5 MHz clock coming out is proportional to the hyper-fine energy levels in the Rubidium atoms. Negative feedback is cool! Especially when we have a pole at DC and infinite gain.</p>

<p><img src="https://upload.wikimedia.org/wikipedia/commons/0/0a/Rubidium-oscillator.jpg" alt="" /></p>

<h1 id="crystal-oscillators">Crystal oscillators</h1>

<p>For accuracy’s of parts per million, which is sufficient for your wrist watch, or
most communication, it’s possible to use crystals.</p>

<p>A quartz crystal can resonate at specific frequencies. If we apply a electric
field across a crystal, we will induce a vibration in the crystal, which can
again affect the electric field. For some history, see <a href="https://en.wikipedia.org/wiki/Crystal_oscillator">Crystal
Oscillators</a></p>

<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/d/dc/Quartz_crystal_internal.jpg/440px-Quartz_crystal_internal.jpg" alt="" /></p>

<p>The vibrations in the crystal lattice can have many modes, as illustrated by figure below.</p>

<p>All we need to do with a crystal is to inject sufficient energy to sustain the
oscillation,
and the resonance of the crystal will ensure we have
a correct enough frequency.</p>

<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/8b/Crystal_modes_multilingual.svg/300px-Crystal_modes_multilingual.svg.png" alt="" /></p>

<h2 id="impedance">Impedance</h2>

<p>The impedance of a crystal is usually modeled as below. A RLC circuit with a parallel capacitor.</p>

<p>Our job is to make a circuit that we can connect to the two pins and provide the energy we will loose due to $R_s$.</p>

<p><img src="/aic2024/assets/media/xosc_model.svg" alt="" width="700" /></p>

<p>Assuming zero series resistance</p>

\[Z_{in} = \frac{s^2 C_F L + 1}{s^3 C_P L C_F + s C_P + s C_F}\]

<p>Notice that at $s=0$ the impedance goes to infinity, so a crystal is high impedant at DC.</p>

<p>Since the 1/(sCp) does not change much at resonance, then</p>

\[Z_{in} \approx \frac{L C_F s^2 + 1}{L C_F C_p s^2 + C_F + C_P}\]

<p>See <a href="https://github.com/wulffern/aic2023/blob/main/jupyter/xosc.ipynb">Crystal oscillator impedance</a> for a detailed explanation.</p>

<p>In the impedance plot below we can clearly see that there are two “resonance” points. Usually noted by series and parallel resonance.</p>

<p>I would encourage you to read <a href="https://ieeexplore.ieee.org/document/7954123">The Crystal Oscillator</a> for more details.</p>

<p><img src="/aic2024/assets/media/xosc_res.svg" alt="" width="700" /></p>

<h2 id="circuit">Circuit</h2>

<p>Below is a common oscillator circuit, a Pierce Oscillator. The crystal is the below the dotted line, and the two capacitance’s are the on-PCB capacitance’s.</p>

<p>Above the dotted line is what we have inside the IC. Call the left side of the inverter XC1 and right side XC2. 
The inverter is biased by a resistor, $R_1$, to keep the XC1 at a reasonable voltage.
The XC1 and XC2 will oscillate in opposite directions. As XC1 increases, XC2 will decrease. The $R_2$ is to model the internal resistance (on-chip wires, bond-wire).</p>

<p><img src="/aic2024/assets/media/xosc_pierce.svg" alt="" width="700" /></p>

<p><strong>Negative transconductance compensate crystal series resistance</strong></p>

<p>The transconductance of the inverter must compensate for the energy loss caused by $R_s$ in the crystal model. 
The transconductor also need to be large enough for the oscillation to start, and build up.</p>

<p>I’ve found that sometimes people get confused by the negative transconductance. There is nothing magical about that. 
Imagine the PMOS and the NMOS in the inverter, and that the input voltage is exactly the voltage we need for the current in the
PMOS and NMOS to be the same. If the current in the PMOS and NMOS is the same, then there can be no current flowing in the output.</p>

<p>Imagine we increase the voltage. The PMOS current would decrease, and the NMOS current would increase. We would pull current from the output.</p>

<p>Imagine we now decrease the voltage instead. The PMOS current would increase, and the NMOS current would decrease.
The current in the output would increase.</p>

<p>As such, a negative transconductance is just that as we increase the input voltage, the current into the output decreases, and visa versa.</p>

<p><strong>Long startup time caused by high Q</strong></p>

<p>The <a href="https://en.wikipedia.org/wiki/Q_factor">Q factor</a> has a few definitions, so it’s easy to get confused. Think of Q like this, if 
a resonator has high Q, then the oscillations die out slowly.</p>

<p>Imagine a perfect world without resistance, and an inductor and capacitor in parallel. Imagine we initially store some voltage across the capacitor, and 
we let the circuit go. The inductor shorts the plates of the capacitor, and the current in the inductor will build up until the voltage across
the capacitor is zero. The inductor still has stored current, and that current does not stop, so the voltage across the capacitor will
become negative, and continue decreasing until the inductor current is zero. At that point the negative voltage will flip the current in the inductor, 
and we go back again.</p>

<p>The LC circuit will resonate back and forth. If there was no resistance in the circuit, then the oscillation would never die out.
The system would be infinite Q.</p>

<p>The Q of the crystal oscillator can be described as $Q = 1/(\omega R_s C_f)$, assuming some common values 
of $R_s = 50$, $C_f = 5e^{-15}$ and $\omega = 2 \pi \times 32$ MHz then $Q \approx 20$ k.</p>

<p>That number may not tell you much, but think of it like this, it will take 20 000 clock cycles before the amplitude falls by 1/e. For example, if the amplitude
of oscillation was 1 V, and you stop introducing energy into the system, then 20 000 clock cycles later, or 0.6 ms, the amplitude would be 0.37 V.</p>

<p>The same is roughly true for startup of the oscillator. If the crystal had almost no amplitude, then an increase $e$ would take 20 k cycles. 
Increasing the amplitude of the crystal to 1 V could take milliseconds.</p>

<p>Most circuits on-chip have startup times on the order of microseconds, while crystal oscillators have startup time on the order of milliseconds. As such, for low power
IoT, the startup time of crystal oscillators, or indeed keeping the oscillator running at a really low current, are key research topics.</p>

<p><strong>Can fine tune frequency with parasitic capacitance</strong></p>

<p>The resonance frequency of the crystal oscillator can be modified by the parasitic capacitance from XC1 and XC2 to ground. The tunability of crystals is usually in ppm/pF.
Sometimes micro-controller vendors will include internal <a href="https://infocenter.nordicsemi.com/topic/ps_nrf5340/chapters/oscillators/doc/oscillators.html?cp=4_0_0_3_11_0_0#concept_internal_caps">load capacitance’s</a>
to support multiple crystal vendors without changing the PCB.</p>

<h2 id="temperature-behavior">Temperature behavior</h2>

<p>One of the key reasons for using crystals is their stability over temperature. Below is a plot of a typical temperature behavior. The cutting angle of the crystal affect the 
temperature behavior, as such, the closer crystals are to “no change in frequency over temperature”, the more expensive they become.</p>

<p>In communication standards, like Bluetooth Low Energy, it’s common to specify timing accuracy’s of +- 50 ppm. Have a look in the <a href="https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=556599">Bluetooth Core Specification 5.4</a>
Volume 6, Part A, Chapter 3.1 (page 2653) for details.</p>

<p><img src="/aic2024/assets/media/at_crystal.jpeg" alt="" width="700" /></p>

<h1 id="controlled-oscillators">Controlled Oscillators</h1>

<p>On an integrated circuit way may need multiple clocks, and we can’t have crystal oscillators for all of them. We can use frequency locked loops, phase locked loops and delay locked loops
to make multiples of the crystal reference frequency.</p>

<p>All phase locked loops contain an oscillator where we control the frequency of oscillation.</p>

<h2 id="ring-oscillator">Ring oscillator</h2>

<p>The simplest oscillator is a series of inverters biting their own tail, a ring oscillator.</p>

<p>The delay of each stage can be thought of as a RC time constant, where the R is the transconductance of the inverter, and the C is the gate capacitance
of the next inverter.</p>

\[t_{pd} \approx R C\]

\[R \approx \frac{1}{gm} \approx \frac{1}{\mu_n C_{ox} \frac{W}{L} (VDD - V_{th})}\]

\[C \approx \frac{2}{3} C_{ox} W L\]

<p><img src="/aic2024/assets/media/osc_ring.svg" alt="" width="700" /></p>

<p>One way to change the oscillation frequency is to change the VDD of the ring oscillator. 
Based on the delay of a single inverter we can make an estimate of the oscillator gain. How large change in frequency do we get for a change in VDD.</p>

\[t_{pd} \approx \frac{2/3 C_{ox} W L}{\frac{W}{L} \mu_n C_{ox}(VDD - V_{th})}\]

\[f = \frac{1}{2 N t_{pd}} = \frac{\mu_n (VDD-V_{th})}{\frac{4}{3} N L^2}\]

\[K_{vco} = 2 \pi \frac{\partial f}{\partial VDD} = \frac{2 \pi \mu_n}{\frac{4}{3} N L^2}\]

<p>The $K_{vco}$ is proportional to mobility, and inversely proportional to the number of stages and the length of the transistor squared. 
In most PLLs we don’t want the $K_{vco}$ to be too large. Ideally we want the ring oscillator to oscillate close to the frequency we want, i.e 512 MHz, and a small
$K_{vco}$ to account for variation over temperature (mobility of transistors decreases with increased temperature, the threshold voltage of transistors decrease with
temperature), and changes in VDD.</p>

<p>To reduce the $K_{vco}$ of the standard ring oscillator we can increase the gate length, and increase the number of stages.</p>

<p>I think it’s a good idea to always have a prime number of stages in the ring oscillator. I have seen some ring oscillators with 21 stages oscillate at 3 times the frequency 
in measurement. Since $21 = 7 \times 3$ it’s possible to have three “waves” of traveling through the ring oscillator at all times, forever. If you use a prime number of stages,
then sustained oscillation at other frequencies cannot happen.</p>

<p>As such, then number of inverter stages should be $\in [3, 5, 7, 11, 13, 17, 19, 23, 29, 31]$</p>

<h2 id="capacitive-load">Capacitive load</h2>

<p>The oscillation frequency of the ring oscillator can also be changed by adding capacitance.</p>

\[f = \frac{\mu_n C_{ox} \frac{W}{L} (VDD - V_{th})}{2N\left(\frac{2}{3}C_{ox}WL + C\right)}\]

\[K_{vco} = \frac{2 \pi \mu_n C_{ox} \frac{W}{L}}{2N\left(\frac{2}{3}C_{ox}WL + C\right)}\]

<p>Assume that the extra capacitance is much larger than the gate capacitance, then</p>

\[f = \frac{\mu_n C_{ox} \frac{W}{L} (VDD - V_{th})}{2N C }\]

\[K_{vco} = \frac{2 \pi \mu_n C_{ox} \frac{W}{L}}{2N C }\]

<p>And maybe we could make the $K_{vco}$ relatively small.</p>

<p>The power consumption of an oscillator, however, will be similar to a digital circuit of $P = C \times f \times VDD^2$, so increasing capacitance will also increase
the power consumption.</p>

<p><img src="/aic2024/assets/media/osc_ring_c.svg" alt="" width="700" /></p>

<h2 id="realistic">Realistic</h2>

<p>Assume you wanted to design a phase-locked loop, what type of oscillator should you try first? If the noise of the clock is not too important, so you don’t need an 
LC-oscillator, then I’d try the oscillator below, although I’d expand the number of stages to fit the frequency.</p>

<p>The circuit has a capacitance loaded ring oscillator fed by a current. The $I_{control}$ will give a coarse control of the frequency, while the $V_{control}$ can give a
more precise control of the frequency.</p>

<p>Since the $V_{control}$ can only increase the frequency it’s important that the $I_{control}$ is set such that the frequency is below the target.</p>

<p>Most PLLs will include some form of self calibration at startup. At startup the PLL will do a coarse calibration to find a sweet-spot for $I_{control}$, and then use $V_{control}$
to do fine tuning.</p>

<p>Since PLLs always have a reference frequency, and a phase and frequency detector, it’s possible to sweep the calibration word for $I_{control}$ and then check whether the output
frequency is above or below the target based on the phase and frequency detector output. Although we don’t know exactly what the oscillator frequency is, we can know the frequency close enough.</p>

<p>It’s also possible to run a counter on the output frequency of the VCO, and count the edges between two reference clocks. That way we can get a precise 
estimate of the oscillation frequency.</p>

<p>Another advantage with the  architecture below is that we have some immunity towards supply noise. If we decouple both the current mirror, and the $V_{control}$ towards VDD, 
then any change to VDD will not affect the current into the ring oscillator.</p>

<p>Maybe a small side track, but inject a signal into an oscillator from an amplifier, the oscillator will have a tendency to lock to the injected signal, we call 
this “injection locking”, and it’s common to do in ultra high frequency oscillators (60 - 160 GHz). Assume we allow the PLL to find the right $V_{control}$ that corresponds
to the injected frequency. Assume that the injected frequency changes, for example frequency shift keying (two frequencies that mean 1 or 0), as in Bluetooth Low Energy.
The PLL will vary the $V_{control}$ of the PLL to match the frequency change of the injected signal, as such, the $V_{control}$ is now the demodulated frequency change.</p>

<p>Still today, there are radio recievers that use a PLLs to directly demodulate the incoming frequency shift keyed modulated carrier.</p>

<p><img src="/aic2024/assets/media/osc_ring_adv.svg" alt="" width="700" /></p>

<p>We can calculate the $K_{vco}$ of the oscillator as shown below. The inverters mostly act as switches, and when the PMOS is on, then the rise time is controlled 
by the PMOS current mirror, the additional $V_{control}$ and the capacitor. For the calculation below we assume that the pull-down of the capacitor by the NMOS 
does not affect the frequency much.</p>

<p>The advantage with the above ring-oscillator is that we can control the frequency of oscillation with $I_{control}$
and have a independent $K_{vco}$ based on the sizing of the $V_{control}$ transistors.</p>

\[I = C \frac{dV}{dt}\]

\[f \approx \frac{ I_{control}  + \frac{1}{2}\mu_p C_{ox} \frac{W}{L} (VDD - V_{control} -
V_{th})^2}{C \frac{VDD}{2} N}\]

\[K_{vco} = 2 \pi \frac{\partial f}{\partial V_{control}}\]

\[K_{vco} = 2 \pi  \frac{\mu_p C_{ox} W/L }{C\frac{VDD}{2}N}\]

<h2 id="digitally-controlled-oscillator">Digitally controlled oscillator</h2>

<p>We can digitally control the oscillator frequency as shown below by adding capacitors.</p>

<p>Today there are all digital loops where the oscillator is not really a “voltage controlled oscillator”, but rather a “digital control oscillator”. DCOs are common in
all-digital PLLs.</p>

<p>Another reason to use digital frequency control is to compensate for process variation. We know that mobility affects the $K_{vco}$, as such, for fast transistors 
the frequency can go up. We could measure the free-running frequency in production, and compensate with a digital control word.</p>

<p><img src="/aic2024/assets/media/osc_ring_cap.svg" alt="" width="700" /></p>

<h2 id="differential">Differential</h2>

<p>Differential circuits are  potentially less sensitive to supply noise</p>

<p>Imagine a single ended ring oscillator. If I inject a voltage onto the input of one of the inverters that was just about to flip, I can either delay the flip, or 
speed up the flip, depending on whether the voltage pulse increases or decreases the input voltage for a while. Such voltage pulses will lead to jitter.</p>

<p>Imagine the same scenario on a differential oscillator (think diff pair). As long as the voltage pulse is the same for both inputs, then no change will incur. I may change
the current slightly, but that depends on the tail current source.</p>

<p>Another cool thing about differential circuits is that it’s easy to multiply by -1, just flip the wires, as a result, I can use a 2 stage ring differential ring oscillator.</p>

<p><img src="/aic2024/assets/media/osc_ring_diff.svg" alt="" width="700" /></p>

<h2 id="lc-oscillator">LC oscillator</h2>

<p>Most radio’s are based on modulating information on-to a carrier frequency, for example 2.402 GHz for a Bluetooth Low Energy Advertiser. One of the key properties
of the carrier waves is that it must be “clean”. We’re adding a modulated signal on top of the carrier, so if there is noise inherent on the carrier, then 
we add noise to our modulation signal, which is bad.</p>

<p>Most ring oscillators are too high noise for radio’s, we must use a inductor and capacitor to create the resonator.</p>

<p>Inductors are huge components on a IC. Take a look at the nRF51822 below, the two round inductors are easily identifiable. Actually, based on the die image we can
guess that there are two oscillators in the nRF51822. Maybe it’s a <a href="https://en.wikipedia.org/wiki/Superheterodyne_receiver#Multiple_conversion">multiple conversion superheterodyne reciever</a></p>

<p><img src="https://s.zeptobars.com/nRF51822.jpg" alt="" /></p>

<p>Below is a typical LC oscillator. The main resonance is set by the L and C, while the tunability is provided by a varactor, a voltage variable capacitor. Or with
less fancy words, the gate capacitance of a transistor, since the gate capacitance of a transistor depends on the effective voltage, and is thus a “varactor”</p>

<p>The NMOS at the bottom provide the “negative transconductance” to compensate for the loss in the LC tank.</p>

<p><img src="/aic2024/assets/media/lcosc.svg" alt="" width="700" /></p>

\[f \propto \frac{1}{\sqrt{LC}}\]

<h1 id="relaxation-oscillators">Relaxation oscillators</h1>

<p>A last common oscillator is the relaxation oscillator, or “RC” oscillator. By now you should be proficient enough to work through the equations below, and understand how the circuit works. If not, ask me.</p>

<p><img src="/aic2024/assets/media/rcosc.svg" alt="" width="700" /></p>

\[V_1 = I R\]

\[I = C \frac{dV}{dt}\]

\[dt = \frac{C V_2}{I} = \frac{C I R}{I}\]

\[f = \frac{1}{dt} = \frac{1}{RC}\]

\[f_o = \frac{1}{2}f =  \frac{1}{2RC}\]

<h1 id="want-to-learn-more">Want to learn more?</h1>

<h2 id="crystal-oscillators-1">Crystal oscillators</h2>

<p><a href="https://ieeexplore.ieee.org/document/7954123">The Crystal Oscillator - A Circuit for All Seasons</a></p>

<p><a href="https://ieeexplore.ieee.org/document/318">High-performance crystal oscillator circuits: theory and application</a></p>

<p><a href="https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;arnumber=9542926">Ultra-low Power 32kHz Crystal Oscillators: Fundamentals and Design Techniques</a></p>

<p><a href="https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;arnumber=9173539">A Sub-nW Single-Supply 32-kHz Sub-Harmonic Pulse Injection Crystal Oscillator</a></p>

<h2 id="cmos-oscillators">CMOS oscillators</h2>

<p><a href="https://ieeexplore.ieee.org/document/8901474">The Ring Oscillator - A Circuit for All Seasons</a></p>

<p><a href="https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;arnumber=494195">A Study of Phase Noise in CMOS Oscillators</a></p>

<p><a href="https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;arnumber=9081906">An Ultra-Low-Noise Swing-Boosted Differential Relaxation Oscillator in 0.18-um CMOS</a></p>

<p><a href="https://hdl.handle.net/11250/2778127">Ultra Low Power Frequency Synthesizer</a></p>]]></content><author><name>Carsten Wulff</name><email>carsten@wulff.no</email></author><summary type="html"><![CDATA[If you find an error in what I’ve made, then fork, fix lectures/l09_osc.md, commit, push and create a pull request. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.]]></summary></entry><entry><title type="html">Lecture 8 - Clocks and PLLs</title><link href="https://wulffern.github.io/aic2024/2024/03/08/Lecture-8-Clocks-and-PLLs.html" rel="alternate" type="text/html" title="Lecture 8 - Clocks and PLLs" /><published>2024-03-08T00:00:00+00:00</published><updated>2024-03-08T00:00:00+00:00</updated><id>https://wulffern.github.io/aic2024/2024/03/08/Lecture-8---Clocks-and-PLLs</id><content type="html" xml:base="https://wulffern.github.io/aic2024/2024/03/08/Lecture-8-Clocks-and-PLLs.html"><![CDATA[<blockquote>
  <p>If you find an error in what I’ve made, then <a href="https://docs.github.com/en/get-started/quickstart/fork-a-repo">fork</a>, fix <a href="https://github.com/wulffern/aic2024/tree/main/lectures/l08_pll.md">lectures/l08_pll.md</a>, <a href="https://git-scm.com/docs/git-commit">commit</a>, <a href="https://git-scm.com/docs/git-push">push</a> and <a href="https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/working-with-your-remote-repository-on-github-or-github-enterprise/creating-an-issue-or-pull-request">create a pull request</a>. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.</p>
</blockquote>

<p><a href="/aic2024/assets/slides/l08_pll.pdf">Slides</a></p>

<ul id="markdown-toc">
  <li><a href="#why-clocks" id="markdown-toc-why-clocks">Why clocks?</a>    <ul>
      <li><a href="#a-customer-story" id="markdown-toc-a-customer-story">A customer story</a>        <ul>
          <li><a href="#imagine-a-world" id="markdown-toc-imagine-a-world">Imagine a world</a></li>
          <li><a href="#imagine-a-better-world" id="markdown-toc-imagine-a-better-world">Imagine a better world</a></li>
        </ul>
      </li>
      <li><a href="#frequency" id="markdown-toc-frequency">Frequency</a></li>
      <li><a href="#noise" id="markdown-toc-noise">Noise</a></li>
      <li><a href="#stability" id="markdown-toc-stability">Stability</a></li>
      <li><a href="#conclusion" id="markdown-toc-conclusion">Conclusion</a></li>
    </ul>
  </li>
  <li><a href="#a-typical-system-on-chip-clock-system" id="markdown-toc-a-typical-system-on-chip-clock-system">A typical System-On-Chip clock system</a>    <ul>
      <li><a href="#32-mhz-crystal" id="markdown-toc-32-mhz-crystal">32 MHz crystal</a></li>
      <li><a href="#32-kihz-crystal" id="markdown-toc-32-kihz-crystal">32 KiHz crystal</a></li>
      <li><a href="#pcb-antenna" id="markdown-toc-pcb-antenna">PCB antenna</a></li>
      <li><a href="#dcdc-inductor" id="markdown-toc-dcdc-inductor">DC/DC inductor</a></li>
    </ul>
  </li>
  <li><a href="#pll" id="markdown-toc-pll">PLL</a>    <ul>
      <li><a href="#integer-pll" id="markdown-toc-integer-pll">Integer PLL</a></li>
      <li><a href="#fractional-pll" id="markdown-toc-fractional-pll">Fractional PLL</a></li>
      <li><a href="#modulation-in-plls" id="markdown-toc-modulation-in-plls">Modulation in PLLs</a></li>
    </ul>
  </li>
  <li><a href="#pll-example" id="markdown-toc-pll-example">PLL Example</a>    <ul>
      <li><a href="#loop-gain" id="markdown-toc-loop-gain">Loop gain</a></li>
      <li><a href="#controlled-oscillator" id="markdown-toc-controlled-oscillator">Controlled oscillator</a>        <ul>
          <li><a href="#sun_pll_sky130nmsimrosc" id="markdown-toc-sun_pll_sky130nmsimrosc">SUN_PLL_SKY130NM/sim/ROSC/</a></li>
        </ul>
      </li>
      <li><a href="#phase-detector-and-charge-pump" id="markdown-toc-phase-detector-and-charge-pump">Phase detector and charge pump</a></li>
      <li><a href="#loop-filter" id="markdown-toc-loop-filter">Loop filter</a></li>
      <li><a href="#divider" id="markdown-toc-divider">Divider</a></li>
      <li><a href="#loop-transfer-function" id="markdown-toc-loop-transfer-function">Loop transfer function</a>        <ul>
          <li><a href="#python-model" id="markdown-toc-python-model">Python model</a></li>
        </ul>
      </li>
    </ul>
  </li>
  <li><a href="#want-to-learn-more" id="markdown-toc-want-to-learn-more">Want to learn more?</a></li>
</ul>

<p>Keywords: Systems, Feedback, PLL, Integer Divider, SD, SD PLL, Modulation, linear phase model</p>

<iframe width="560" height="315" src="https://www.youtube.com/embed/f0dJtMrwuJk?si=jZpeDYCXxWd8Ysh3" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen=""></iframe>

<h1 id="why-clocks">Why clocks?</h1>

<p>Virtually all integrated circuits have some form of clock system.</p>

<p>For digital we need clocks to tell us when the data is correct. For Radio’s we need clocks to generate the carrier wave. For analog we need 
clocks for switched regulators, ADCs, accurate delay’s or indeed, long delays.</p>

<p>The principle of a clock is simple. Make a 1-bit digital signal that toggles with a period $T$ and a frequency $f = 1/T$.</p>

<p>The implementation is not necessarily simple.</p>

<p>The key parameters of a clock are the frequency of the fundamental, noise of the frequency spectrum, and stability over 
process and enviromental conditions.</p>

<p>When I start a design process, I want to know why, how, what (and sometimes who). If I understand the problem from first principles
it’s more likely that the design will be suitable.</p>

<p>But proving that something is suitable, or indeed optimal, is not easy in the world of analog design. Analog design is similar
to physics. An hypothesis is almost impossible to prove “correct”, but easier to prove wrong.</p>

<h2 id="a-customer-story">A customer story</h2>

<p>Take an example.</p>

<h3 id="imagine-a-world">Imagine a world</h3>

<blockquote>
  <p>“I have a customer that needs an accurate clock to count seconds”. – Some manager that talked to a customer, but don’t understand details.</p>
</blockquote>

<p>As a designer, I might latch on to the word “accurate clock”, and translate into “most accurate clock in the world”, then I’d google atomic clocks, like 
<a href="https://en.wikipedia.org/wiki/Rubidium_standard">Rubidium standard</a> that I know is based on the hyperfine transition of electrons between two energy levels in rubidium-87.</p>

<p>I know from quantum mechanics that the hyperfine transition between two energy levels will produce an precise frequency, as the frequency of the 
photons transmitted is defined by $E = \hbar \omega = h f$.</p>

<p>I also know that quantum electro dynamics is the most precise theory in 
physics, so we know what’s going on.</p>

<p>As long as the Rubidium crystal is clean (few energy states in the vicinity of the hyperfine transition), the distance between atoms stay constant, the temperature 
does not drift too much, then the frequency will be precise. So I buy a <a href="https://www2.mouser.com/ProductDetail/IQD/LFRBXO059244Bulk?qs=iw0hurA%2FaD0K8weKx%2Fu2ow%3D%3D">rubidium oscillator</a> at 
a cost of $ 3k.</p>

<p>I design a an ASIC to count the clock ticks, package it plastic, make a box, and give my manager.</p>

<p>Who will most likely say something like</p>

<blockquote>
  <p>“Are you insane? The customer want’s to put the clock on a wristband, and make millions. We can’t have a cost of $ 3k per device. You must
make it smaller an it must cost 10 cents to make”</p>
</blockquote>

<p>Where I would respond.</p>

<blockquote>
  <p>“What you’re asking is physically impossible. We can’t make the device that cheap, or that small. Nobody can do that.”</p>
</blockquote>

<p>And both my manager and I would be correct.</p>

<h3 id="imagine-a-better-world">Imagine a better world</h3>

<p>Most people in this world have no idea how things work. Very few people are able to understand the full stack. Everyone of us must
simplify what we know to some extent. As such, as a circuit designer, it’s your responsibility to fully understand what is asked of you.</p>

<p>When someone says</p>

<blockquote>
  <p>” I have a customer that needs an accurate clock to count seconds”</p>
</blockquote>

<p>Your response should be “Why does the customer need an accurate clock? How accurate? What is the customer going to use the clock for?”. Unless you understand the details of the problem, 
then your design will be sub-optimal. It might be a great clock source, but it will be useless for 
solving the problem.</p>

<h2 id="frequency">Frequency</h2>

<p>The frequency of the clock is the frequency of the fundamental. If it’s a digital clock (1-bit) with 50 % duty-cycle, then we know that a digital 
pulse train is an infinite sum of odd-harmnoics, where the fundamental is given by the period of the train.</p>

<h2 id="noise">Noise</h2>

<p>Clock noise have many names. Cycle-to-cycle jitter is how the period changes with time. Jitter may also mean how the period right now
will change in the future, so a time-domain change in the amount of cycle-to-cycle jitter. Phase noise is how the period changes as a 
function of time scales. For example, a clock might have fast period changes over short time spans, but if we average over a year, the period is stable.</p>

<p>What type of noise you care about depends on the problem. Digital will care about the cycle-to-cycle jitter affects on setup and hold times. 
Radio’s will care about the frequency content of the noise with an offset to the carrier wave.</p>

<h2 id="stability">Stability</h2>

<p>The variation over all corners and enviromental conditions is usually given in a percentage, parts per million, or parts per billion.</p>

<p>For a digital clock to run a Micro-Controller, maybe it’s sufficient with 10% accuracy of the clock frequency. For a Bluetooth radio we must
have +-50 ppm, set by the standard. For GPS we might need parts-per-billion.</p>

<h2 id="conclusion">Conclusion</h2>

<p>Each “clock problem” will have different frequency, noise and stability requirements. You must know the order of magnitude of those before you can design a clock source. There is no “one-solution fits all” clock generation IP.</p>

<h1 id="a-typical-system-on-chip-clock-system">A typical System-On-Chip clock system</h1>

<p>On the <a href="https://www.nordicsemi.com/Products/Development-hardware/nrf52-dk">nRF52832 development kit</a> you can see some components that indicate what type of clock system must be inside the IC.</p>

<p>In the figure below you can see the following items.</p>

<ol>
  <li>32 MHz crystal</li>
  <li>32 KiHz crystal</li>
  <li>PCB antenna</li>
  <li>DC/DC inductor</li>
</ol>

<p><img src="/aic2024/assets/media/l08_nrf53.png" alt="" width="700" /></p>

<h2 id="32-mhz-crystal">32 MHz crystal</h2>

<p>Any Bluetooth radio will need a frequency reference. We need to generate an accurate 2.402 MHz - 2.480 MHz carrier frequency for the 
gaussian frequency shift keying (GFSK) modulation. The Bluetooth Standard requires a +- 50 ppm accurate timing reference, and carrier frequency offset accuracy.</p>

<p>I’m not sure it’s possible yet to make an IC that does not have some form of frequency reference, like a crystal. The ICs I’ve seen 
so far that have “crystal less radio” usually have a resonator (crystal or bulk-accustic-wave or MEMS resonator) on die.</p>

<p>The power consumption of a high frequency crystal will be proportional to frequency. Assuming we have a digital output, then the power of that
digital output will be $P = C V^2 f$, for example 
$P = 100\text{ fF} \times 1\text{ V}^2 \times 32\text{ MHz} = 3.2\text{ } \mu\text{W}$
is probably close to a minimum power consumption of a 32 MHz clock.</p>

<h2 id="32-kihz-crystal">32 KiHz crystal</h2>

<p>Reducing the frequency, we can get down to minimum power consumption of $P = 100\text{ fF} \times 1\text{ V}^2 \times 32\text{ KiHz} = 3.2 \text{ nW}$ for a clock.</p>

<p>For a system that sleeps most of the time, and only wakes up at regular ticks to do something, then a low-frequency crystal might be worth the effort.</p>

<h2 id="pcb-antenna">PCB antenna</h2>

<p>Since we can see the PCB antenna, we know that the IC includes a radio. From that fact we can deduce what must be inside the SoC. If we read 
the <a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fstruct_nrf52%2Fstruct%2Fnrf52832_ps.html">Product Specification</a> we can understand more.</p>

<h2 id="dcdc-inductor">DC/DC inductor</h2>

<p>Since we can see a large inductor, we can also make the assumption that the IC contains a switched regulator. That switched regulator, especially if it has a pulse-width-modulated control loop, will need a clock.</p>

<p>From our assumptions we could make a guess what must be inside the IC, something like the picture below.</p>

<p>There will be a crystal oscillator connected to the crystal. We’ll learn about those later.</p>

<p>These crystal oscillators generate a fixed frequency, 32 MHz, or 32 KiHz, but there might be other clocks needed inside the IC.</p>

<p>To generate those clocks, there will be phase-locked loops (PLL), frequency locked loops (FLL), or delay-locked loops (DLL).</p>

<p>PLLs take a reference input, and can generate a higher frequency, (or indeed lower frequency) output. A PLL is a magical block. It’s one of the few analog IPs where we can actually design for infinite gain in our feedback loop.</p>

<p><img src="/aic2024/assets/media/l10_clockic.svg" alt="" width="700" /></p>

<p>Most of the digital blocks on an IC will be synchronous logic, see figure below. A fundamental principle of sychnronous logic is that the data at the flip-flops (DFF, rectangles with triangle clock input, D, Q and $\overline{\text{Q}}$) only need to be correct at certain times.</p>

<p>The sequence of transitions in the combinatorial logic is of no consequence, as long as the B 
inputs are correct when the clock goes high next time.</p>

<p>The registers, or flip-flops, are your SystemVerilog “always_ff” code. While the blue cloud is your “always_comb” code.</p>

<p>In a SoC we have to check, for all paths between a Y[N] and B[M] that the path is fast enough for all transients to settle before the clock
strikes next time. How early the B data must arrive in relation to the clock edge is the setup time of the DFFs.</p>

<p>We also must check for all paths that the B[M] are held for long enough after the clock strikes such that our flip-flop does not change 
state. The hold time is the distance from the clock edge to where the data is allowed to change. Negative hold times are common in DFFs, so the data can start to change before the clock edge.</p>

<p>In an IC with millions of flip-flops there can be billions of paths. The setup and hold time for every single one must be checked. One could imagine a simulation 
of all the paths on a netlist with parasitics (capacitors and resistors from layout) to check the delays, but there are so many combinations that the simulation time becomes unpractical.</p>

<p>Static Timing Analysis (STA) is a light-weight way to check all the paths. For the STA we make a model of the delay in each cell (captured in a liberty file), the setup/hold times of all flip-flops, wire propagation delays, clock frequency (or period), and the variation in the clock frequency. The process, voltage, temperature variation must also be checked for all components, so the number of liberty files can quickly grow large.</p>

<p>For an analog designer the constraints from digital will tell us what’s the maximum frequency we can have at any point in time, and what is the maximum cycle-to-cycle variation in the period.</p>

<p><img src="/aic2024/assets/media/logic.svg" alt="" width="700" /></p>

<h1 id="pll">PLL</h1>

<p>PLL, or it’s cousins FLL and DLL are really cool. A PLL is based on the familiar concept of feedback, shown in the figure below. As long
as we make $H(s)$ infinite we can force the output to be an exact copy of the input.</p>

<p><img src="/aic2024/assets/media/l10_fb.svg" alt="" width="700" /></p>

<h2 id="integer-pll">Integer PLL</h2>

<p>For a frequency loop the figure looks a bit different. If we want a higher output frequency we can divide the frequency by a number (N) 
and compare with our reference (for example the 32 MHz reference from the crystal oscillator).</p>

<p>We then take the error, apply a transfer function $H(s)$ with high gain, and control our oscillator frequency.</p>

<p>If the down-divided output frequency is too high, we force the oscillator to a lower frequency. If the down-divided output frequency
is too low we force the oscillator to a higher frequency.</p>

<p>If we design the $H(s)$ correctly, then we have $f_o = N \times f_{in}$</p>

<p><img src="/aic2024/assets/media/l10_freq_fb.svg" alt="" width="700" /></p>

<p>Sometimes you want a finer frequency resolution, in that case you’d add a divider on the reference and get $f_o = N \times \frac{f_{in}}{M}$..</p>

<p><img src="/aic2024/assets/media/l08_pll_m.svg" alt="" width="700" /></p>

<h2 id="fractional-pll">Fractional PLL</h2>

<p>Trouble is that dividing down the input frequency will reduce your loop bandwidth, as the low-pass filter needs to be about 1/10’th of the reference frequency. As such, the PLL will respond slower to a frequency change.</p>

<p>We can also use a fractional divider, where we swap between two, or more, integeres in a sigma-delta fashion in the divider.</p>

<p><img src="/aic2024/assets/media/l08_pll_sd.svg" alt="" width="700" /></p>

<h2 id="modulation-in-plls">Modulation in PLLs</h2>

<p>From your signal processing, or communication courses, you may recognize the equation below.</p>

\[A_m(t) \times cos\left( 2 \pi f_{carrier}t + \phi_{m}(t)\right)\]

<p>The $A_m$ is the amplitude modulation, while the $\phi_m$ is the phase modulation. Bluetooth Low Energy is constant envelope, so the $A_m$ is a constant. The phase modulation is applied to the carrier, but how is it done?</p>

<p>One option is shown below. We could modulate our frequency reference directly. That could maybe be a sigma-delta divider on the reference, or directly modulating the oscillator.</p>

<p><img src="/aic2024/assets/media/l08_pll_mod.svg" alt="" width="700" /></p>

<p>Most modern radios, however, will have a two-point modulation. The modulation signal is applied to the VCO (or DCO), and the opposite signal is applied to the feedback divider. As such, the modulation is not seen by the loop.</p>

<p><img src="/aic2024/assets/media/l08_pll_2mod.svg" alt="" width="700" /></p>

<h1 id="pll-example">PLL Example</h1>

<p>I’ve made an example <a href="https://github.com/wulffern/sun_pll_sky130nm">PLL</a> that you can download and play with. I make no claims that 
it’s a good PLL. Actually, I know it’s a bad PLL. The ring-oscillator frequency varies to fast with the voltage control.  But it does give you a starting point.</p>

<p>A PLL can consist of a oscillator (SUN_PLL_ROSC) that generates our output frequency. A divider (SUN_PLL_DIVN) that generates a feedback frequency that we can compare to the reference. A Phase and Frequency Detector (SUN_PLL_PFD) and a charge-pump (SUN_PLL_CP) that model the $+$, or the comparison function in our previous picture. And a loop filter (SUN_PLL_LPF and SUN_PLL_BUF) that is our $H(s)$.</p>

<p><img src="/aic2024/assets/media/l08_sun_pll.svg" alt="" width="700" /></p>

<p>Read any book on PLLs, talk to any PLL designer and they will all tell you the same thing. <strong>PLLs require calculation</strong>. You must 
setup a linear model of the feedback loop, and calculate the loop transfer function to check the stability, and the loop gain. 
<strong>This is the way!</strong> (to quote Mandalorian).</p>

<p>But how can we make a linear model of a non-linear system? The voltages inside a PLL must be non-linear, they are clocks. A PLL is not linear 
in time-domain!</p>

<p>I have no idea who first thought of the idea, but it turns out, that one can model a PLL as a linear system if one consider the phase of the voltages inside the PLL, especially when the PLL is locked (phase of the output and reference is mostly aligned). Where the phase is defined as</p>

\[\phi(t) = 2 \pi \int_0^t f(t) dt\]

<p>As long as the bandwidth of the $H(s)$ is about $\frac{1}{10}$ of the reference frequency, then the linear model below holds (at least is good enough).</p>

<p>The phase of our input is $\phi_{in}(s)$, the phase of the output is $\phi(s)$, the divided phase is $\phi_{div}(s)$ and the phase error is $\phi_d(s)$.</p>

<p>The $K_{pd}$ is the gain of our phase-frequency detector and charge-pump. The $K_{lp}H_{lp}(s)$ is our loop filter $H(s)$. 
The $K_{osc}/s$ is our oscillator transfer function. And the $1/N$ is our feedback divider.</p>

<p><img src="/aic2024/assets/media/l10_pll_sm.svg" alt="" width="700" /></p>

<h2 id="loop-gain">Loop gain</h2>

<p>The loop transfer function can then be analyzed and we get.</p>

\[\frac{\phi_d}{\phi_{in}} = \frac{1}{1 + L(s)}\]

\[L(s) = \frac{ K_{osc} K_{pd} K_{lp} H_{lp}(s) }{N s}\]

<p>Here is the magic of PLLs. Notice what happens when $s = j\omega = j 0$, or at zero frequency. If we assume that $H_{lp}(s)$ is a low pass filter, then $H_{lp}(0) = \text{constant}$. The loop gain, however, will have a $L(0) \propto \frac{1}{0}$ which approaces infinity at 0.</p>

<p>That means, we have an infinite DC gain in the loop transfer function. It is the only case I know of in an analog design where we can actually have infinite gain. Infinite gain translate can translate to infinite precision.</p>

<p>If the reference was a Rubidium oscillator we could generate any frequency with the same precision as the frequency of the Rubidium oscillator. Magic.</p>

<p>For the linear model, we need to figure out the factors, like $K_{vco}$, which must be determined by simulation.</p>

<h2 id="controlled-oscillator">Controlled oscillator</h2>

<p>The gain of the oscillator is the change in output frequency as a function of the change of the control node. For a voltage-controlled oscillator (VCO) we could sweep the control voltage, and check the frequency. The derivative of the f(V) would be proportional to the  $K_{vco}$.</p>

<p>The control node does not need to be a voltage. Anything that changes the frequency of the oscillator can be used as a control node. There 
exist PLLs with voltage control, current control, capacitance control, and digital control.</p>

<p>For the SUN_PLL_ROSC it is the VDD of the ring-oscillator (VDD_ROSC) that is our control node.</p>

\[K_{osc} = 2 \pi\frac{ df}{dV_{cntl}}\]

<p><img src="/aic2024/assets/media/SUN_PLL_ROSC.svg" alt="" width="700" /></p>

<h3 id="sun_pll_sky130nmsimrosc"><a href="https://github.com/wulffern/sun_pll_sky130nm/tree/main/sim/ROSC">SUN_PLL_SKY130NM/sim/ROSC/</a></h3>

<p>I simulate the ring oscillator in ngspice with a transient simulation and get the oscillator frequency as a function of voltage.</p>

<p><strong>tran.spi</strong></p>
<pre><code class="language-spice">let start_v = 1.1
let stop_v = 1.7
let delta_v = 0.1
let v_act = start_v
* loop
while v_act le stop_v
alter VROSC v_act
tran 1p 40n
meas tran vrosc avg v(VDD_ROSC)
meas tran tpd trig v(CK) val='0.8' rise=10 targ v(CK) val='0.8' rise=11
let v_act = v_act + delta_v
end
</code></pre>

<p>I use <code class="language-plaintext highlighter-rouge">tran.py</code> to extract the time-domain signal from ngspice into a CSV file.</p>

<p>Then I use a python script to extract the $K_{osc}$</p>

<p><strong>kvco.py</strong></p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    <span class="n">df</span> <span class="o">=</span> <span class="n">pd</span><span class="p">.</span><span class="n">read_csv</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
    <span class="n">freq</span> <span class="o">=</span> <span class="mi">1</span><span class="o">/</span><span class="n">df</span><span class="p">[</span><span class="s">"tpd"</span><span class="p">]</span>
    <span class="n">kvco</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="n">mean</span><span class="p">(</span><span class="n">freq</span><span class="p">.</span><span class="n">diff</span><span class="p">()</span><span class="o">/</span><span class="n">df</span><span class="p">[</span><span class="s">"vrosc"</span><span class="p">].</span><span class="n">diff</span><span class="p">())</span>
</code></pre></div></div>

<p>Below I’ve made a plot of the oscillation frequency over corners.</p>

<p><img src="/aic2024/assets/media/SUN_PLL_ROSC_KVCO.svg" alt="" width="700" /></p>

<h2 id="phase-detector-and-charge-pump">Phase detector and charge pump</h2>

<p>The gain of the phase-detector and charge pump is the current we feed into the loop filter over a period. I don’t remember why, check in the book for a detailed description.</p>

<p>The two blocks compare our reference clock to our feedback clock, and produce an error signal.</p>

\[K_{pd} = \frac{I_{cp}}{2 \pi}\]

<p><img src="/aic2024/assets/media/SUN_PLL_CP.svg" alt="" width="700" /></p>

<h2 id="loop-filter">Loop filter</h2>

<p>In the book you’ll find a first order loop filter, and a second order loop filter. Engineers are creative, so you’ll likely find other loop filters in the literature.</p>

<p>I would start with the “known to work” loop filters 
before you explore on your own.</p>

<p>If you’re really interested in PLLs, you should buy <a href="https://www.amazon.com/Design-CMOS-Phase-Locked-Loops-Architecture/dp/1108494544">Design of CMOS Phase-Locked Loops</a> by Behzad Razavi.</p>

<p>The loop filter has a unity gain buffer. My oscillator draws current, while the VPLF node is high impedant, so I can’t draw current from the loop filter without changing the filter transfer function.</p>

\[K_{lp}H_{lp}(s)= K_{lp}\left(\frac{1}{s} + \frac{1}{\omega_z}\right)\]

\[K_{lp}H_{lp}(s) = \frac{1}{s(C_1 + C_2)}\frac{1 + s R C_1}{1 +
sR\frac{C_1C_2}{C_1 + C_2}}\]

<p><img src="/aic2024/assets/media/SUN_PLL_LP.svg" alt="" width="700" /></p>

<h2 id="divider">Divider</h2>

<p>The divider is modelled as</p>

\[K_{div} = \frac{1}{N}\]

<p><img src="/aic2024/assets/media/SUN_PLL_DIV.svg" alt="" width="700" /></p>

<h2 id="loop-transfer-function">Loop transfer function</h2>

<p>With the loop transfer function we can start to model what happens in the linear loop. What is the phase response, and what is the gain response.</p>

\[L(s) = \frac{ K_{osc} K_{pd} K_{lp} H_{lp}(s) }{N s}\]

<h3 id="python-model">Python model</h3>

<p>I’ve made a python model of the loop, you can find it at
<a href="https://github.com/wulffern/sun_pll_sky130nm/blob/main/jupyter/pll.ipynb">sun_pll_sky130nm/jupyter/pll</a></p>

<p>In the jupyter notbook below you can find some more information on the phase/frequency detector, and charge pump.</p>

<p><a href="https://github.com/wulffern/sun_pll_sky130nm/blob/main/jupyter/pfd.ipynb">sun_pll_sky130nm/jupyter/pfd</a></p>

<p>Below is a plot  of the loop gain, and the transfer function from input phase to divider phase.</p>

<p>We can see that the loop gain at low frequency is large, and proportional to $1/s$. As such, the phase of the divided down feedback clock is the same as our reference.</p>

<p>The closed loop transfer function $\phi_{div}/\phi_{in}$ shows us that the divided phase at low frequency is the same as the input phase. Since the phase is the same, and the frequency must be the same, then we know that the output clock will be N times reference frequency.</p>

<p><img src="/aic2024/assets/media/pll.svg" alt="" width="700" /></p>

<p>The top testbench for the PLL is <a href="https://github.com/wulffern/sun_pll_sky130nm/blob/main/sim/SUN_PLL/tran.spi">tran.spi</a>.</p>

<p>I power up the PLL and wait for the output clock to settle. I use <a href="https://github.com/wulffern/sun_pll_sky130nm/blob/main/sim/SUN_PLL/freq.py">freq.py</a> to plot the frequency as a function of time. The orange curve is the average frequency. We can see that the output frequency settles to 256 MHz.</p>

<p><img src="/aic2024/assets/media/sun_pll_lay_typ.svg" alt="" width="700" /></p>

<p>You can find the schematics, layout, testbenches, python script etc at <a href="https://github.com/wulffern/sun_pll_sky130nm">SUN_PLL_SKY130NM</a></p>

<p>Below are a couple layout images of the finished PLL</p>

<p><img src="/aic2024/assets/media/sun_pll_layout0.png" alt="" width="700" />
<img src="/aic2024/assets/media/sun_pll_layout1.png" alt="" width="700" /></p>

<h1 id="want-to-learn-more">Want to learn more?</h1>

<p>Back in 2020 there was a Master student at NTNU on PLL. I would recommend looking at that 
thesis to learn more, and to get inspired <a href="https://ntnuopen.ntnu.no/ntnu-xmlui/handle/11250/2778127">Ultra Low Power Frequency Synthesizer</a>.</p>

<p><a href="https://ieeexplore.ieee.org/document/5342373">A Low Noise Sub-Sampling PLL in Which Divider Noise is Eliminated and PD/CP Noise is Not Multiplied by N2</a></p>

<p><a href="https://ieeexplore.ieee.org/document/1546223">All-digital PLL and transmitter for mobile phones</a></p>

<p><a href="https://ieeexplore.ieee.org/document/6006551">A 2.9–4.0-GHz Fractional-N Digital PLL With Bang-Bang Phase Detector and 560-fsrms Integrated Jitter at 4.5-mW Power</a></p>]]></content><author><name>Carsten Wulff</name><email>carsten@wulff.no</email></author><summary type="html"><![CDATA[If you find an error in what I’ve made, then fork, fix lectures/l08_pll.md, commit, push and create a pull request. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.]]></summary></entry><entry><title type="html">Lecture 7 - Voltage regulation</title><link href="https://wulffern.github.io/aic2024/2024/03/01/Lecture-7-Voltage-regulation.html" rel="alternate" type="text/html" title="Lecture 7 - Voltage regulation" /><published>2024-03-01T00:00:00+00:00</published><updated>2024-03-01T00:00:00+00:00</updated><id>https://wulffern.github.io/aic2024/2024/03/01/Lecture-7---Voltage-regulation</id><content type="html" xml:base="https://wulffern.github.io/aic2024/2024/03/01/Lecture-7-Voltage-regulation.html"><![CDATA[<blockquote>
  <p>If you find an error in what I’ve made, then <a href="https://docs.github.com/en/get-started/quickstart/fork-a-repo">fork</a>, fix <a href="https://github.com/wulffern/aic2024/tree/main/lectures/l07_vreg.md">lectures/l07_vreg.md</a>, <a href="https://git-scm.com/docs/git-commit">commit</a>, <a href="https://git-scm.com/docs/git-push">push</a> and <a href="https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/working-with-your-remote-repository-on-github-or-github-enterprise/creating-an-issue-or-pull-request">create a pull request</a>. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.</p>
</blockquote>

<p><a href="/aic2024/assets/slides/l07_vreg.pdf">Slides</a></p>

<ul id="markdown-toc">
  <li><a href="#voltage-source" id="markdown-toc-voltage-source">Voltage source</a>    <ul>
      <li><a href="#why-transistors-die" id="markdown-toc-why-transistors-die">Why transistors die</a></li>
      <li><a href="#core-voltage" id="markdown-toc-core-voltage">Core voltage</a></li>
      <li><a href="#io-voltage" id="markdown-toc-io-voltage">IO voltage</a></li>
      <li><a href="#supply-planning" id="markdown-toc-supply-planning">Supply planning</a></li>
    </ul>
  </li>
  <li><a href="#linear-regulators" id="markdown-toc-linear-regulators">Linear Regulators</a>    <ul>
      <li><a href="#pmos-pass-fet" id="markdown-toc-pmos-pass-fet">PMOS pass-fet</a></li>
      <li><a href="#nmos-pass-fet" id="markdown-toc-nmos-pass-fet">NMOS pass-fet</a></li>
      <li><a href="#control-of-pass-fet" id="markdown-toc-control-of-pass-fet">Control of pass-fet</a></li>
    </ul>
  </li>
  <li><a href="#switched-regulators" id="markdown-toc-switched-regulators">Switched Regulators</a>    <ul>
      <li><a href="#principles-of-switched-regulators" id="markdown-toc-principles-of-switched-regulators">Principles of switched regulators</a>        <ul>
          <li><a href="#inductive-buck-dcdc" id="markdown-toc-inductive-buck-dcdc">Inductive BUCK DC/DC</a></li>
          <li><a href="#capacitive-buck-dcdc" id="markdown-toc-capacitive-buck-dcdc">Capacitive BUCK DC/DC</a></li>
          <li><a href="#inductive-boost-dcdc" id="markdown-toc-inductive-boost-dcdc">Inductive BOOST DC/DC</a></li>
          <li><a href="#capacitive-boost-dcdc" id="markdown-toc-capacitive-boost-dcdc">Capacitive BOOST DC/DC</a></li>
        </ul>
      </li>
      <li><a href="#inductive-dcdc-converter-details" id="markdown-toc-inductive-dcdc-converter-details">Inductive DC/DC converter details</a></li>
      <li><a href="#pulse-width-modulation-pwm" id="markdown-toc-pulse-width-modulation-pwm">Pulse width modulation (PWM)</a></li>
      <li><a href="#real-world-use" id="markdown-toc-real-world-use">Real world use</a></li>
      <li><a href="#pulsed-frequency-mode-pfm" id="markdown-toc-pulsed-frequency-mode-pfm">Pulsed Frequency Mode (PFM)</a></li>
    </ul>
  </li>
  <li><a href="#want-to-learn-more" id="markdown-toc-want-to-learn-more">Want to learn more?</a>    <ul>
      <li><a href="#linear-regulators-1" id="markdown-toc-linear-regulators-1">Linear regulators</a></li>
      <li><a href="#dc-dc-converters" id="markdown-toc-dc-dc-converters">DC-DC converters</a></li>
    </ul>
  </li>
</ul>

<p>Keywords: Battery, Vreg, LDOP, LDON, Flipped voltage follower, Buck, Boost, Load, Line, PSRR, MAX C, Quiescent, Settling, Efficiency, PWM, PFM</p>

<iframe width="560" height="315" src="https://www.youtube.com/embed/Nf-MXWMP1KI?si=zaxwrVcJEu4l_7tG" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen=""></iframe>

<h1 id="voltage-source">Voltage source</h1>

<p>Most, if not all, integrated circuits need a supply and ground to work.</p>

<p>Assume a system is AC powered. Then there will be switched regulator to turn wall AC into DC. The DC might be 48 V, 24 V, 12 V, 5 V, 3 V
1.8 V, 1.0 V, 0.8 V, or who knows. The voltage depends on the type of IC and the application.</p>

<p>Many ICs are battery operated, whether it’s your phone, watch, heart rate monitor, mouse, keyboard, game controller or car.</p>

<p>For batteries the voltage is determined by the difference in Fermi level on the two electrodes, and the Fermi level (chemical potential) 
is a function of the battery chemistry.
As a result, we need to know the battery chemistry in order to know the voltage.</p>

<p><a href="https://www.amazon.com/Lindens-Handbook-Batteries-Fifth-Kirby/dp/1260115925">Linden’s Handbook of Batteries</a> is a good book
if you want to dive deep into primary (non-chargeable) or secondary (chargeable) batteries and their voltage curves.</p>

<p><img src="/aic2024/assets/media/lindens_handbook_of_batteries.png" alt="" width="700" /></p>

<p>Some common voltage sources are listed below.</p>

<table>
  <thead>
    <tr>
      <th> </th>
      <th style="text-align: left">Chemistry</th>
      <th style="text-align: right">Voltage [V]</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Primary Cell</td>
      <td style="text-align: left">LiFeS2 , Zn/Alk/MnO2 , LiMnO2</td>
      <td style="text-align: right">0.8 - 3.6</td>
    </tr>
    <tr>
      <td>Secondary Cell</td>
      <td style="text-align: left">Li-Ion</td>
      <td style="text-align: right">2.5 - 4.3</td>
    </tr>
    <tr>
      <td>USB</td>
      <td style="text-align: left">-</td>
      <td style="text-align: right">4.0 - 6.5 (20)</td>
    </tr>
  </tbody>
</table>

<p>The battery determines the voltage of the “electron source”, however, can’t we just run everything directly off the battery? Why do we need DC to DC converters or voltage regulators?</p>

<p>Turns out, transistors can die.</p>

<p>Today’s transistor, as shown below, are a complicated three dimensional structure. Dimensions are measured in nano-meter, which makes 
the transistors fragile.</p>

<p>In <a href="https://ieeexplore.ieee.org/document/5247174">Analog Circuit Design in Nanoscale CMOS Technologies</a>
Lanny explains how to design around some of the breakdown effects.</p>

<p><img src="/aic2024/assets/media/advmos.svg" alt="" width="700" /></p>

<p>The transistors in a particular technology (from GlobalFoundries, TSMC, Samsung or others) have a maximum 
voltage that they can survive for a certain time. Exceed that time, or voltage, and the transistors die.</p>

<h3 id="why-transistors-die">Why transistors die</h3>

<p>A gate oxide will break due to Time Dependent Dielectric Breakdown (TDDB) if the voltage across the gate oxide is too large. Silicon oxide can break down at approximately 5 MV/cm. The breakdown forms a conductive channel from the gate to the channel and is permanent. After breakdown there will be a resistor of kOhms between gate and channel.</p>

<p>A similar breakdown phenomena is used in <a href="https://ieeexplore.ieee.org/document/6193402">Metal-Oxide RRAM</a> and the <a href="https://sky130-fd-pr-reram.readthedocs.io/en/latest/">SkyWater 
ReRAM</a></p>

<p>Below is an example of ReRAM. In the Pristine state the conductance is low, resistance is in the hundreds of mega Ohm. In a transistor we want the oxide to stay high resistive. In ReRAM, however, we apply a high voltage across the oxide, which forms a conductive channel across the oxide. Turns out, that the conductive channel can be flipped back and forth between a high resistive state, and a low resistive state to store a 1 or a 0 in a non-volatile manner.</p>

<p><img src="https://sky130-fd-pr-reram.readthedocs.io/en/latest/_images/forming.png" alt="" /></p>

<p>The threshold voltage of a transistor can shift excessively over time caused by Hot-Carrier Injection (HCI) or Negative Bias Temperature Instability.</p>

<p>Hot-Carrier injection is caused by electrons, or holes, accelerated to high velocity in the channel, or drain depletion region , causing impact ionization (breaking a co-valent bond releasing an electron/hole pair). At a high drain/source field, and<br />
medium gate/(source or drain) field, the channel minority carriers can be accelerated to high energy and transition to traps in the oxide, shifting the 
threshold voltage.</p>

<p>Negative Bias Temperature Instability is a shift in threshold voltage due to a physical change in the oxide. 
A strong electric field across the oxide for a long time can break co-valent, or ionic bonds, in the oxide. The bond break will change the forces (stress) in the amorphous silicon oxide which might not recover. As such, there might be more traps (states) than before. See <a href="https://ieeexplore.ieee.org/document/4419069">Simultaneous Extraction of Recoverable and Permanent Components Contributing to Bias-Temperature Instability</a> for more details.</p>

<p>For a long time, I had trouble with “traps in the oxide””. I had a hard time visualizing how electrons wandered down 
the channel and got caught in the oxide. I was trying to imagine the electric field, and that the electron needed to find 
a positive charge in the oxide to cancel. Diving a bit deeper into quantum mechanics, my mental image improved a bit, so I’ll
try to give you a more accurate mental model for how to think about traps.</p>

<p>Quantum mechanics tells us that bound electrons can only occupy fixed states. The probability 
of finding an electron in a state is given by the Fermi function, but if there is no energy state at a point in space, there cannot be an electron there.</p>

<p>For example, there might be a 50 % probability of finding an electron in the oxide, but if there is no state there, then there will not be any electron
, and thus no change to the threshold voltage.</p>

<p>What happens when we make “traps”, through TDDB, HCI, or NBTI is that we create new states that can potentially be occupied by electrons. For example one, or more, broken silicon co-valent bonds and a dislocation of the crystal lattice.</p>

<p>If the Fermi-Dirac statistics tells us the probability of an electron being in those new states is 50 %, then there will likely be electrons there.</p>

<p>The threshold voltage is defined as the voltage at which we can invert the channel, or create the same density of electrons in the channel (for NMOS) as  density of dopant
atoms (density of holes) in the bulk.</p>

<p>If the oxide has a net negative charge (because of electrons in new states), then we have to pull harder 
(higher gate voltage) to establish the channel. As a result, the threshold voltage increases with electrons stuck in the oxide.</p>

<p>In quantum mechanics the time evolution, and the complex probability amplitude of an electron changing state, could, in theory, be computed with the Schrodinger equation. 
Unfortunately, for any real scenario, like the gate oxide of a transistor, using Schrodinger to compute exactly what will happen is beyond the capability of the 
largest supercomputers.</p>

<h2 id="core-voltage">Core voltage</h2>

<p>The voltage where the transistor can survive is estimated by the foundry, by approximation, and testing, and may be like the table below.</p>

<table>
  <thead>
    <tr>
      <th style="text-align: center">Node [nm]</th>
      <th style="text-align: center">Voltage [V]</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">180</td>
      <td style="text-align: center">1.8</td>
    </tr>
    <tr>
      <td style="text-align: center">130</td>
      <td style="text-align: center">1.5</td>
    </tr>
    <tr>
      <td style="text-align: center">55</td>
      <td style="text-align: center">1.2</td>
    </tr>
    <tr>
      <td style="text-align: center">22</td>
      <td style="text-align: center">0.8</td>
    </tr>
  </tbody>
</table>

<h2 id="io-voltage">IO voltage</h2>

<p>Most ICs talk to other ICs, and they have a voltage for the general purpose input/output. The voltage reduction in I/O voltage does not need to scale as fast 
as the core voltage, because foundries have thicker oxide transistors that can survive the voltage.</p>

<table>
  <thead>
    <tr>
      <th style="text-align: right">Voltage [V]</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: right">5.0</td>
    </tr>
    <tr>
      <td style="text-align: right"><strong>3.0</strong></td>
    </tr>
    <tr>
      <td style="text-align: right"><em>1.8</em></td>
    </tr>
    <tr>
      <td style="text-align: right">1.2</td>
    </tr>
  </tbody>
</table>

<h2 id="supply-planning">Supply planning</h2>

<p>For any IC, we must know the application. We must know where the voltage comes from, the IO voltage, the core voltage, and any other requirements (like charging batteries).</p>

<p>One example could be an IC that is powered from a Li-Ion battery, with a USB to provide charging capability.</p>

<p>Between each voltage we need an analog block, a regulator, to reduce the voltage in an effective manner. What type of regulator depends again on the application, 
but the architecture of the analog design would be either a linear regulator, or a switched regulator.</p>

<p><img src="/aic2024/assets/media/l9_sarc.svg" alt="" width="700" /></p>

<p>The dynamic range of the power consumed by an IC can be large. From nA when it’s not doing anything, to hundreds of mA when there is high computation load.</p>

<p>As a result, it’s not necessarily possible, or effective, to have one regulator from 1.8 V to 0.8 V. We may need multiple regulators. Some that can
handle low load (nA - $\mu$A) effectively, and some that can handle high loads.</p>

<p>For example, if you design a regulator to deliver 500 mA to the load, and the regulator uses 5 mA, that’s only 1 % of the current, which may be OK. 
The same regulator might consume 5 mA even though the load is 1 uA, which would be bad. All the current flows in the regulator at low loads.</p>

<table>
  <thead>
    <tr>
      <th style="text-align: center">Name</th>
      <th style="text-align: center">Voltage</th>
      <th style="text-align: center">Min [nA]</th>
      <th style="text-align: center">Max [mA]</th>
      <th style="text-align: center">PWR DR [dB]</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">VDD_VBUS</td>
      <td style="text-align: center">5</td>
      <td style="text-align: center">10</td>
      <td style="text-align: center">500</td>
      <td style="text-align: center">77</td>
    </tr>
    <tr>
      <td style="text-align: center">VDD_VBAT</td>
      <td style="text-align: center">4</td>
      <td style="text-align: center">10</td>
      <td style="text-align: center">400</td>
      <td style="text-align: center">76</td>
    </tr>
    <tr>
      <td style="text-align: center">VDD_IO</td>
      <td style="text-align: center">1.8</td>
      <td style="text-align: center">10</td>
      <td style="text-align: center">50</td>
      <td style="text-align: center">67</td>
    </tr>
    <tr>
      <td style="text-align: center">VDD_CORE</td>
      <td style="text-align: center">0.8</td>
      <td style="text-align: center">10</td>
      <td style="text-align: center">350</td>
      <td style="text-align: center">75</td>
    </tr>
  </tbody>
</table>

<p>Most <a href="https://docs.nordicsemi.com/bundle/nRF5340_PS_v1.3.1/resource/nRF5340_PS_v1.3.1.pdf">product specifications</a> will give you a view into what type of 
regulators there are on an IC. The picture below is from nRF5340 (page 23)</p>

<p><img src="/aic2024/assets/media/l9_nrf53.svg" alt="" width="700" /></p>

<h1 id="linear-regulators">Linear Regulators</h1>

<h2 id="pmos-pass-fet">PMOS pass-fet</h2>

<p>One way to make a regulator is to control the current in a PMOS with a feedback loop, as shown below. The OTA continuously adjusts the gate-source voltage of
the PMOS to force the input voltages of the OTA to be equal.</p>

<p><img src="/aic2024/assets/media/l9_ldo_pmos.svg" alt="" width="700" /></p>

<p>For digital loads, where $I_{load}$ is a digital current, with high current every rising edge of the clock, it’s an option to place a large external decoupling capacitor 
(a reservoir of charge) in parallel with the load. Accordingly, the OTA would supply the average current.</p>

<p>The device between supply (1.5 V) and output voltage (0.8 V) is often called a pass-fet. A PMOS pass-fet regulator is often called a LDO, or low dropout regulator, since
we only need a $V_{DSSAT}$ across the PMOS, which can be a few hundred mV.</p>

<p>Key parameters of regulators are</p>

<table>
  <thead>
    <tr>
      <th style="text-align: left">Parameter</th>
      <th style="text-align: left">Description</th>
      <th style="text-align: right">Unit</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: left">Load regulation</td>
      <td style="text-align: left">How much does the output voltage change with load current</td>
      <td style="text-align: right">V/A</td>
    </tr>
    <tr>
      <td style="text-align: left">Line regulation</td>
      <td style="text-align: left">How much does the output voltage change with input voltage</td>
      <td style="text-align: right">V/V</td>
    </tr>
    <tr>
      <td style="text-align: left">Power supply rejection ratio</td>
      <td style="text-align: left">What is the transfer function from input voltage to output voltage? The PSRR at DC is the line regulation</td>
      <td style="text-align: right">dB</td>
    </tr>
    <tr>
      <td style="text-align: left">Max current</td>
      <td style="text-align: left">How much current can be delivered through the pass-fet?</td>
      <td style="text-align: right">A</td>
    </tr>
    <tr>
      <td style="text-align: left">Quiescent current</td>
      <td style="text-align: left">What is the current used by the regulator</td>
      <td style="text-align: right">A</td>
    </tr>
    <tr>
      <td style="text-align: left">Settling time</td>
      <td style="text-align: left">How fast does the output voltage settle at a current step</td>
      <td style="text-align: right">s</td>
    </tr>
  </tbody>
</table>

<p>A disadvantage of a PMOS is the hole mobility, which is lower than for NMOS. If the maximum current of an LDO is large, then the PMOS can be big. Maybe even 
50 % of the IC area.</p>

<h2 id="nmos-pass-fet">NMOS pass-fet</h2>

<p>An NMOS pass-fet will be smaller than a PMOS for large loads. The disadvantage with an NMOS is the gate-source voltage needed. For some scenarios the needed gate voltage might
exceed the input voltage (1.5 V). A gate voltage above input voltage is possible, but increases complexity, as a charge pump (switched capacitor regulator) is needed to make  the gate voltage.</p>

<p>Another interesting phenomena with NMOS pass-fet is that the PSRR is usually better, but we do have a common gate amplifier, as such, high frequency voltage ripple on output voltage will be amplified to the input voltage, and may cause issues for others using the input voltage.</p>

<p><img src="/aic2024/assets/media/l9_ldo_nmos.svg" alt="" width="700" /></p>

<h2 id="control-of-pass-fet">Control of pass-fet</h2>

<p>The large dynamic range in power management systems can make it challenging to have a single pass-fet.</p>

<p>The size of the pass-fet is set by the maximum Vgs, and the current that needs to be delivered.</p>

<p>Assume we need 500 mA from the LDO. If we assume that the maximum Vgs is 1.5 V, then we can simulate to try and find a size.</p>

<p>I’ve made a testbench at</p>

<p><a href="https://github.com/wulffern/cnr_atr_sky130nm/blob/main/sim/LDO_PFET/loadreg.spi">Testbench for LDO pass-fet</a></p>

<p>Below is an excerpt from the testbench. The pass-fet size has been determined by iteration.</p>

<p>The OTA in the LDO is modeled by the B source. Notice the use of the tanh function in order to keep the G voltage within the rails.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>* Pass-fet
XM1 OUT G VDD VDD sky130_fd_pr__pfet_01v8 L=0.252 W=11.52 nf=2 ...  m=1000

* Reference
VREF VREF 0 dc 0.8

* OTA
BOTA G 0 V=(1 + tanh(-1000*(v(vref) -v(out) )))/2*{AVDD}

* Load cap
CL OUT 0 1u

* Current load
ILOAD OUT 0 pwl 0 0 1u 0 50u 0.5

</code></pre></div></div>

<p>Below is a plot of the current on the y-axis as a function of the Vgs on the x-axis. Although it’s possible to have almost 6 orders of magnitude change in current
in the transistor it does become hard to make the loop stable over such a large range.</p>

<p>Sometimes it’s easier to split the range into multiple ranges.</p>

<p><img src="/aic2024/assets/media/l7_loadreg.svg" alt="" width="700" /></p>

<p>As such, there are multiple control options for the pass-fet. Below is a summary of a few methods.</p>

<p>We can control the Vgs, or we can switch the number of instances, or we can turn the pass-fet on and off dynamically. What 
we choose will depend on the application.</p>

<p><img src="/aic2024/assets/media/l6_ldo_types.svg" alt="" width="700" /></p>

<h1 id="switched-regulators">Switched Regulators</h1>

<p>Linear regulator have poor power efficiency. Linear regulators have the same current in the load, as from the input.</p>

<p>For some applications a poor efficiency might be OK, but for most battery operated systems we’re interested in using the electrons from the battery in the most effective manner.</p>

<p>Another challenge is temperature. A linear regulator with a 5 V input voltage, and 1 V output voltage will have a maximum power efficiency of 20 % (1/5). 80 % of the power is wasted in the pass-fet as heat.</p>

<p>Imagine a LDO driving an 80 W CPU at 1 V from a 5 V power supply. The power drawn from the 5 V supply is 400 W, as such, 320 W would be wasted in the LDO. A quad flat no-leads (QFN) package usually have a thermal resistance of 20 $^{\circ}$C/W, so if it would be possible, the temperature of the LDO would be 6400 $^{\circ}$C. Obviously, that cannot work.</p>

<p>For increased power efficiency, we must use switched regulators.</p>

<p>Imagine a switched regulator with 93 % power efficiency. 
The power from the 5 V supply would be $80\text{ W}/ 0.93 = 86\text{ W}$, as such, 
only 6 W is wasted as heat. A temperature increase of $6\text{ W} \times 20\text{ } ^{\circ}\text{C/W}  = 120 ^{\circ}$C is still high, but not impossible with a small heat-sink.</p>

<p>All switched regulators are based on devices that store electric field (capacitors), or magnetic field (inductors).</p>

<h2 id="principles-of-switched-regulators">Principles of switched regulators</h2>

<blockquote>
  <p>There is a big difference between the idea for a circuit, and the actual implementation. A real DC/DC implementation may seem overwhelming.</p>
</blockquote>

<p>Just look at figure 7 in <a href="https://ieeexplore.ieee.org/document/8187654">A 10-MHz 2–800-mA 0.5–1.5-V 90% Peak Efficiency Time-Based Buck Converter With Seamless Transition Between PWM/PFM Modes</a></p>

<p>So before we go into details, let’s have a look at the principles.</p>

<h3 id="inductive-buck-dcdc">Inductive BUCK DC/DC</h3>

<p>Below is a common illustration of a inductive DC/DC to step down the voltage.</p>

<p>Imagine Vout is at our desired output voltage, for example 0.8 V. Assume Vin is 1.8 V.</p>

<p>When we close the switch, the inductor will begin to integrate the voltage across the inductor, and the current from Vin to Vout increases.</p>

<p>When we turn off the switch, the inductor current will not stop immediately, it cannot, that’s what</p>

\[V = L \frac{d I}{dt}\]

<p>tells us. As a result, the current continues, but now the current is pulled from ground through the diode.</p>

<p>Since we’re pulling current from ground, it should be intuitive that the current from Vin is less 
than the load current at Vout, assuming Vin &gt; Vout.</p>

<p>The output voltage can be controlled by how long we turn on the switch. Each time we turn on the switch the inductor will inject 
a charge packet into the load capacitance.</p>

<p>If we have a control loop on the output voltage, then we can get an output voltage that is independent of the input voltage.</p>

<p><img src="/aic2024/assets/media/l7_ind_buck.svg" alt="" width="700" /></p>

<h3 id="capacitive-buck-dcdc">Capacitive BUCK DC/DC</h3>

<p>In a capacitive buck below what we’re doing is charging two capacitors in series to a high voltage, Vin, and then re-configuring the 
capacitors to be in parallel.</p>

<p>If the capacitors are the same size, then the output voltage would be half the input voltage.</p>

<p>To re-configure the circuit we’d use switches.</p>

<p>A disadvantage with capacitive bucks is that the output voltage is always a factor of the input voltage. When 
the input voltage changes, the output voltages changes proportionally.</p>

<p>Often we have to insert an LDO after a capacitive buck to make the output voltage independent of input voltage.</p>

<p><img src="/aic2024/assets/media/l7_cap_buck.svg" alt="" width="700" /></p>

<h3 id="inductive-boost-dcdc">Inductive BOOST DC/DC</h3>

<p>Consider the circuit below. Here we setup a current from Vin to ground when the switch is on. When the switch is off
push the current through the diode, and thus, the Vout can be higher than Vin.</p>

<p>In a similar manner to the Buck, the output voltage will be impacted by how long we turn on the switch for.</p>

<p><img src="/aic2024/assets/media/l7_ind_boost.svg" alt="" width="700" /></p>

<h3 id="capacitive-boost-dcdc">Capacitive BOOST DC/DC</h3>

<p>In a capacitive boost we start with a parallel connection, charge the capacitors to Vin, then reconfigure the circuit to a series combination.</p>

<p>As such, the output voltage would be two times the input voltage, assuming the capacitors are equal.</p>

<p>The configuration below is quite often called a “Charge pump”, and can be configured to generate both positive, or negative voltages.</p>

<p><img src="/aic2024/assets/media/l7_cap_boost.svg" alt="" width="700" /></p>

<h2 id="inductive-dcdc-converter-details">Inductive DC/DC converter details</h2>

<p>I’ve found that people struggle with inductive DC/DCs. They see a circuit inductors, capacitors, and transistors and think filters, Laplace and steady state. The path of Laplace and steady state will lead you astray and you won’t understand how it works.</p>

<p>Hopefully I can put you on the right path to understanding.</p>

<p>In the figure below we can see a typical inductive switch mode DC/DC converter. The input voltage is $V_{DDH}$, and the output is $V_O$.</p>

<p>Most DC/DCs are feedback systems, so the control will be adjusted to force the output to be what is wanted, however, let’s ignore closed loop for now.</p>

<p><img src="/aic2024/assets/media/l7_buck.svg" alt="" width="700" /></p>

<p>To see what happens I find the best path to understanding is to look at the integral equations.</p>

<p>The current in the inductor is given by</p>

\[I_x(t) = \frac{1}{L} \int{V_x(t) dt}\]

<p>and the voltage on the capacitor is given by</p>

\[V_o(t) = \frac{1}{C} \int{(I_x(t) - I_o(t))}dt\]

<p>Before you dive into Matlab, Mathcad, Maple, SymPy or another of your favorite math software, it helps to think a bit.</p>

<p>My mathematics is not great, but I don’t think there is any closed form solution to the output voltage of the DC/DC, especially since the state of the NMOS and PMOS is time-dependent.</p>

<p>The output voltage also affect the voltage across the inductor, which affects the current, which affects the output voltage, etc, etc.</p>

<p>The equations can be solved numerically, but a numerical solution to the above integrals needs initial conditions.</p>

<p>There are many versions of the control block, let’s look at two.</p>

<h2 id="pulse-width-modulation-pwm">Pulse width modulation (PWM)</h2>

<p>Assume $I_x=0$ and $I_{o} = 0$ at $t=0$. Assume the output voltage is $V_O=0$. Imagine we set $A=1$ for a fixed time duration.  The voltage at $V_1=V_{DDH}$, and $V_x = V_{VDDH}-V_O$. As $V_x$ is positive, and roughly constant, the current $I_x$ would increase linearly, as given by the equation of the current above.</p>

<p>Since the $I_x$ is linear, then the increase in $V_o$ would be a second order, as given by the equation of the output voltage above.</p>

<p>Let’s set $A=0$ and $B=1$ for  fixed time duration (it does not need to be the same as duration as we set $A=1$). The voltage across the inductor would be $V_x = 0 - V_o$. The output voltage would not have increased much, so the absolute value of $V_x$ during $A=1$ would be higher than the absolute value of $V_x$ during the first $B=1$.</p>

<p>The $V_x$ is now negative, so the current will decrease, however, since $V_x$ is small, it does not decrease much.</p>

<p>I’ve made a</p>

<p><a href="https://github.com/wulffern/aic2024/blob/main/jupyter/buck.ipynb">Jupyter PWM BUCK model</a></p>

<p>that numerically solves the equations.</p>

<p>In the figure below we can see how the current during A increases fast, while during B it decreases little. The output voltage increases similarly to a second order function.</p>

<p><img src="/aic2024/assets/media/l07_buck_pwm_fig_start.svg" alt="" width="700" /></p>

<p>If we run the simulation longer, see plot below, the DC/DC will start to settle into a steady state condition.</p>

<p>On the top we can see the current $I_x$ and $I_o$, the second plot you can see the output voltage.  Turns out that the output voltage will be</p>

\[V_o = V_{in} \times \text{ Duty-Cycle}\]

<p>, where the duty-cycle is the ratio between the duration of $A=1$ and $B=1$.</p>

<p><img src="/aic2024/assets/media/l07_buck_pwm_fig_.svg" alt="" width="700" /></p>

<p>Once the system has fully settled, see figure below, we can see the reason for why DC/DC converters are useful.</p>

<p>During $A=1$ the current $I_x$ increases fast, and it’s only during $A=1$ we pull current from $V_{DDH}$. At the start of $A=0$ the current is still positive, which means we pull current from ground. The average current in the inductor is the same as the average current in the load, however, the current from $V_{DDH}$ is lower than the average inductor current, since some of the current comes from ground.</p>

<p>If the DC/DC was 100% efficient, then the current from the 4 V input supply would be 1/4’th of the 1 V output supply. 100% efficient DC/DC converters violate the laws of nature, as such, we can expect to get up to 9X% under optimal conditions.</p>

<p><img src="/aic2024/assets/media/l07_buck_pwm_fig_settled.svg" alt="" width="700" /></p>

<h2 id="real-world-use">Real world use</h2>

<p>DC/DC converters are used when power efficiency is important. Below is a screenshot of the hardware description in the <a href="https://docs.nordicsemi.com/bundle/nRF5340_PS_v1.3.1/resource/nRF5340_PS_v1.3.1.pdf">nRF5340 Product Specification</a>.</p>

<p>We can see 3 inductor/capacitor pairs. One for the “VDDH”, and two for “DECRF” and “DECD”, as such, we can make a good guess there are three DC/DC converters inside the nRF5340.</p>

<p><img src="/aic2024/assets/media/l9_sw_nRF53.png" alt="" width="700" /></p>

<h2 id="pulsed-frequency-mode-pfm">Pulsed Frequency Mode (PFM)</h2>

<p>Power efficiency is key in DC/DC converters. For high loads, PWM, as explained above, is usually the most efficient and practical. For lighter loads, other configurations can be more efficient.</p>

<p>In PWM we continuously switch the NMOS and PMOS, as such, the parasitic capacitance on the $V_1$ node is charged and discharged, consuming power. If the load is close to 0 A, then the parasitic load’s can be significant.</p>

<p>In pulsed-frequency mode we switch the NMOS and PMOS when it’s needed. If there is no load, there is no switching, and $V_1$ or $DCC$ in figure below is high impedant.</p>

<p><img src="/aic2024/assets/media/l9_sw_arch.svg" alt="" width="700" /></p>

<p>Imagine $V_o$ is at 1 V, and we apply a constant output load. According to the integral equations the $V_o$ would decrease linearly.</p>

<p>In the figure above we observe $V_o$ with a comparator that sets $V_{OL}$ high if the $V_o &lt; V_{REF}$. The output from the comparator could be the inputs to a finite state machine (FSM).</p>

<p>Consider the FSM below. On $vol=1$ we transition to “UP” state where turn on the PMOS for a fixed number of clock cycles. The inductor current would increase linearly. From the “UP” state we go to the “DOWN” state, where we turn on the NMOS. The inductor current would decrease roughly linearly.</p>

<p>The “zero-cross” comparator observes the voltage across the NMOS drain/source. As soon as we turn the NMOS on the current direction in the inductor is still from $DCC$ to $V_o$. Since the current is pulled from ground, the $DCC$ must be below ground. As the current in the inductor decreases, the voltage across the NMOS will at some point be equal to zero, at which point the inductor current is zero.</p>

<p>When $vz=1$ happens in the state diagram, or the zero cross comparator triggers, we transition from the “DWN” state back to “IDLE”. Now the FSM wait for the next time $V_o &lt; V_{REF}$.</p>

<p><img src="/aic2024/assets/media/l9_sw_state.svg" alt="" width="700" /></p>

<p>I think the name “pulsed-frequency mode” refers to the fact that the frequency changes according to load current, however, I’m not sure of the origin of the name. The name is not important. What’s important is that you understand that mode 1 (PWM) and mode 2 (PFM) are two different “operation modes” of a DC/DC converter.</p>

<p>I made a jupyter model for the PFM mode. I would encourage you to play with them.</p>

<p>Below you can see a period of the PFM buck. The state can be seen in the bottom plot, the voltage in the middle and the current in the inductor and load in the top plot.</p>

<p><a href="https://github.com/wulffern/aic2024/blob/main/jupyter/buck_pfm.ipynb">Jupyter PFM BUCK model</a></p>

<p><img src="/aic2024/assets/media/l07_buck_pfm_fig_save.svg" alt="" width="700" /></p>

<h1 id="want-to-learn-more">Want to learn more?</h1>

<p><strong>Search terms:</strong> regulator, buck converter, dc/dc converter, boost converter</p>

<h2 id="linear-regulators-1">Linear regulators</h2>

<p><a href="https://ieeexplore.ieee.org/document/9639005">A Scalable High-Current High-Accuracy Dual-Loop Four-Phase Switching LDO for Microprocessors</a> Overview of fancy LDO schemes, digital as well as analog</p>

<p><a href="https://ieeexplore.ieee.org/document/4436075">Development of Single-Transistor-Control LDO Based on Flipped Voltage Follower for SoC</a> In capacitor less LDOs a flipped voltage follower is a common circuit, worth a read.</p>

<p><a href="https://ieeexplore.ieee.org/document/7740906">A 200-mA Digital Low Drop-Out Regulator With Coarse-Fine Dual Loop in Mobile Application Processor</a> Some insights into large power systems.</p>

<h2 id="dc-dc-converters">DC-DC converters</h2>

<p><a href="https://ieeexplore.ieee.org/document/5948387">Design Techniques for Fully Integrated Switched-Capacitor DC-DC Converters</a>
Goes through design of SC DC-DC converters. Good place to start to learn the trade-offs, and the circuits.</p>

<p><a href="https://ieeexplore.ieee.org/document/6998097">High Frequency Buck Converter Design Using Time-Based Control Techniques</a>
I love papers that challenge “this is the way”. Why should we design analog feedback loops for our bucks, why not design digital feedback loops?</p>

<p><a href="https://ieeexplore.ieee.org/document/4804971">Single-Inductor Multi-Output (SIMO) DC-DC Converters With High Light-Load Efficiency and Minimized Cross-Regulation for Portable Devices</a>
Maybe you have many supplies you want to drive, but you don’t want to have many inductors. SIMO is then an option</p>

<p><a href="https://ieeexplore.ieee.org/document/8187654">A 10-MHz 2–800-mA 0.5–1.5-V 90% Peak Efficiency Time-Based Buck Converter With Seamless Transition Between PWM/PFM Modes</a>
Has some lovely illustrations of PFM and PWM and the trade-offs between those two modes.</p>

<p><a href="https://ieeexplore.ieee.org/document/1261283">A monolithic current-mode CMOS DC-DC converter with on-chip current-sensing technique</a>
In bucks converters there are two “religious” camps. One hail to “voltage mode” control loop, another hail to “current mode” control loops. It’s good to read about both and make up your own mind.</p>]]></content><author><name>Carsten Wulff</name><email>carsten@wulff.no</email></author><summary type="html"><![CDATA[If you find an error in what I’ve made, then fork, fix lectures/l07_vreg.md, commit, push and create a pull request. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.]]></summary></entry><entry><title type="html">Lecture 6 - Oversampling and Sigma-Delta ADCs</title><link href="https://wulffern.github.io/aic2024/2024/02/16/Lecture-6-Oversampling-and-Sigma-Delta-ADCs.html" rel="alternate" type="text/html" title="Lecture 6 - Oversampling and Sigma-Delta ADCs" /><published>2024-02-16T00:00:00+00:00</published><updated>2024-02-16T00:00:00+00:00</updated><id>https://wulffern.github.io/aic2024/2024/02/16/Lecture-6---Oversampling-and-Sigma-Delta-ADCs</id><content type="html" xml:base="https://wulffern.github.io/aic2024/2024/02/16/Lecture-6-Oversampling-and-Sigma-Delta-ADCs.html"><![CDATA[<blockquote>
  <p>If you find an error in what I’ve made, then <a href="https://docs.github.com/en/get-started/quickstart/fork-a-repo">fork</a>, fix <a href="https://github.com/wulffern/aic2024/tree/main/lectures/l06_adc.md">lectures/l06_adc.md</a>, <a href="https://git-scm.com/docs/git-commit">commit</a>, <a href="https://git-scm.com/docs/git-push">push</a> and <a href="https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/working-with-your-remote-repository-on-github-or-github-enterprise/creating-an-issue-or-pull-request">create a pull request</a>. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.</p>
</blockquote>

<p><a href="/aic2024/assets/slides/l06_adc.pdf">Slides</a></p>

<ul id="markdown-toc">
  <li><a href="#adc-state-of-the-art" id="markdown-toc-adc-state-of-the-art">ADC state-of-the-art</a>    <ul>
      <li><a href="#what-makes-a-state-of-the-art-adc" id="markdown-toc-what-makes-a-state-of-the-art-adc">What makes a state-of-the-art ADC</a></li>
      <li><a href="#high-resolution-fom" id="markdown-toc-high-resolution-fom">High resolution FOM</a></li>
    </ul>
  </li>
  <li><a href="#quantization" id="markdown-toc-quantization">Quantization</a>    <ul>
      <li><a href="#signal-to-quantization-noise-ratio" id="markdown-toc-signal-to-quantization-noise-ratio">Signal to Quantization noise ratio</a></li>
      <li><a href="#understanding-quantization" id="markdown-toc-understanding-quantization">Understanding quantization</a></li>
      <li><a href="#why-you-should-care-about-quantization-noise" id="markdown-toc-why-you-should-care-about-quantization-noise">Why you should care about quantization noise</a></li>
    </ul>
  </li>
  <li><a href="#oversampling" id="markdown-toc-oversampling">Oversampling</a>    <ul>
      <li><a href="#noise-power" id="markdown-toc-noise-power">Noise power</a></li>
      <li><a href="#signal-power" id="markdown-toc-signal-power">Signal power</a></li>
      <li><a href="#signal-to-noise-ratio" id="markdown-toc-signal-to-noise-ratio">Signal to Noise Ratio</a></li>
      <li><a href="#signal-to-quantization-noise-ratio-1" id="markdown-toc-signal-to-quantization-noise-ratio-1">Signal to Quantization Noise Ratio</a></li>
      <li><a href="#python-oversample" id="markdown-toc-python-oversample">Python oversample</a></li>
    </ul>
  </li>
  <li><a href="#noise-shaping" id="markdown-toc-noise-shaping">Noise Shaping</a>    <ul>
      <li><a href="#the-magic-of-feedback" id="markdown-toc-the-magic-of-feedback">The magic of feedback</a></li>
      <li><a href="#sigma-delta-principle" id="markdown-toc-sigma-delta-principle">Sigma-delta principle</a>        <ul>
          <li><a href="#the-dac-assumption" id="markdown-toc-the-dac-assumption">The DAC assumption</a></li>
          <li><a href="#the-adc-assumption" id="markdown-toc-the-adc-assumption">The ADC assumption</a></li>
          <li><a href="#the-modified-equation" id="markdown-toc-the-modified-equation">The modified equation</a></li>
        </ul>
      </li>
      <li><a href="#signal-transfer-function" id="markdown-toc-signal-transfer-function">Signal transfer function</a></li>
      <li><a href="#noise-transfer-function" id="markdown-toc-noise-transfer-function">Noise transfer function</a></li>
      <li><a href="#combined-transfer-function" id="markdown-toc-combined-transfer-function">Combined transfer function</a></li>
    </ul>
  </li>
  <li><a href="#first-order-noise-shaping" id="markdown-toc-first-order-noise-shaping">First-Order Noise-Shaping</a>    <ul>
      <li><a href="#sqnr-and-enob" id="markdown-toc-sqnr-and-enob">SQNR and ENOB</a></li>
    </ul>
  </li>
  <li><a href="#examples" id="markdown-toc-examples">Examples</a>    <ul>
      <li><a href="#python-noise-shaping" id="markdown-toc-python-noise-shaping">Python noise-shaping</a></li>
      <li><a href="#the-wonderful-world-of-sd-modulators" id="markdown-toc-the-wonderful-world-of-sd-modulators">The wonderful world of SD modulators</a>        <ul>
          <li><a href="#open-loop-sigma-delta" id="markdown-toc-open-loop-sigma-delta">Open-Loop Sigma-Delta</a></li>
          <li><a href="#noise-shaped-sar" id="markdown-toc-noise-shaped-sar">Noise Shaped SAR</a></li>
          <li><a href="#control-bounded-adcs" id="markdown-toc-control-bounded-adcs">Control-Bounded ADCs</a></li>
          <li><a href="#complex-sigma-delta" id="markdown-toc-complex-sigma-delta">Complex Sigma-Delta</a></li>
          <li><a href="#my-first-sigma-delta" id="markdown-toc-my-first-sigma-delta">My first Sigma-Delta</a></li>
        </ul>
      </li>
    </ul>
  </li>
  <li><a href="#want-to-learn-more" id="markdown-toc-want-to-learn-more">Want to learn more?</a></li>
</ul>

<p>Keywords: Quantization, OSR, NEG FB, STF, NTF, SAR, First Order, SC SD, CT SD, INCR, FOM</p>

<iframe width="560" height="315" src="https://www.youtube.com/embed/fdczPHW4jis?si=kqpoggmr_IYkrrs4" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen=""></iframe>

<h1 id="adc-state-of-the-art">ADC state-of-the-art</h1>

<p>The performance of an analog-to-digital converter is determined by the effective number of bits (ENOB), the power consumption, and the maximum bandwidth. 
The effective number of bits contain information on the linearity of the ADC. The power consumption shows 
how efficient the ADC is. The maximum bandwidth limits what signals we can sample and reconstruct in
digital domain.</p>

<p>Many years ago, Robert Walden did a study of ADCs, one of the plot’s is shown below.</p>

<p><a href="https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;arnumber=761034">1999, R. Walden: Analog-to-digital converter survey and analysis</a></p>

<p>There are obvious trends, the faster an ADC is, the less precise the ADC is ( lower SNDR). There are also fundamental limits, Heisenberg tells us that a 20-bit 10 GS/s ADC is 
impossible, according to Walden.</p>

<p><img src="/aic2024/assets/media/l6_walden.png" alt="" width="700" /></p>

<p>The uncertainty principle states that the precision
we can determine position and the momentum of a particle is
\(\sigma_x \sigma_p \ge \frac{\hbar}{2}\). There is a similar relation of energy and time, given by 
\(\Delta E \Delta t &gt; \frac{h}{2 \pi}\)
where $\Delta E$ is the difference in energy, and $\Delta t$ is the difference in time.</p>

<p>You should take these limits with a grain of salt. The plot assumes 50 Ohm and 1 V full-scale. 
As a result, the “Heisenberg” line that appears to be unbreakable certainly is breakable. Just change the voltage to 
100 V, and the number of bits can be much higher. Always check the assumptions.</p>

<p>A more recent survey of ADCs comes from Boris Murmann. He still maintains a list of the best ADCs from ISSCC and VLSI Symposium.</p>

<p><a href="https://github.com/bmurmann/ADC-survey">B. Murmann, ADC Performance Survey 1997-2023</a></p>

<p>A common figure of merit for low-to-medium resolution ADCs is the Walden figure of merit, defined as</p>

\[FOM_W = \frac{P}{2^B f_s}\]

<p>Below 10 fJ/conv.step is good.</p>

<p>Below 1 fJ/conv.step is extreme.</p>

<p>In the plot below you can see the ISSCC and VLSI ADCs.</p>

<p><img src="/aic2024/assets/media/l6_mwald.svg" alt="" width="700" /></p>

<h2 id="what-makes-a-state-of-the-art-adc">What makes a state-of-the-art ADC</h2>

<p>People from NTNU have made some of the worlds best ADCs</p>

<p>If you ever want to make an ADC, and you want to publish the measurements, then you must be better than most. 
A good algorithm for state-of-the-art ADC design is to first pick a sample rate with low number of data (blank spaces in the plot above), then read the papers in the vicinity of the blank space
to understand the application, then set a target FOM which is best in world, then try and find a ADC architecture that can achieve that FOM.</p>

<p>That’s pretty much the algorithm I, and others, have followed to make state-of-the-art ADCs. A few of the NTNU ADCs are:</p>

<p>[1] <a href="https://ieeexplore.ieee.org/document/7906479">A Compiled 9-bit 20-MS/s 3.5-fJ/conv.step SAR ADC in 28-nm FDSOI for Bluetooth Low Energy Receivers</a></p>

<p>[2] <a href="https://ieeexplore.ieee.org/document/9056925">A 68 dB SNDR Compiled Noise-Shaping SAR ADC With On-Chip CDAC
Calibration</a></p>

<p><img src="/aic2024/assets/media/our_work.png" alt="" width="700" /></p>

<p>In order to publish, there must be something new. Preferably a new circuit. 
Below is the circuit from [1]. It’s a standard successive-approximation register (SAR) analog-to-digital converter.</p>

<p>The differential input signal is sampled on a capacitor array where the bottom plate is connected to either VSS or VREF. Once the voltage is sampled,
the comparator will decide whether the differential voltage is larger, or smaller than 0.  Depending on the decision, the MSB capacitors (left-most) in figure
will switch the bottom plate in order to effectively subtract a voltage equivalent to half the VREF voltage.</p>

<p>The comparator makes another decision, and 1/4’th the VREF voltage is subtracted or added. Then 1/8’th and so on implementing a binary search 
to find the input voltage.</p>

<p>The “bit-cycling” (binary-search) loop is self-timed, as such, when the comparator has made a decision, the next cycle starts.</p>

<p>In (b) we can see the enable flip-flop for the next stage. The CK bar is the sample clock, as such, 
A is high during sampling. The output of the comparator (P and N) is low.</p>

<p>As soon as the comparator makes a decision, P or N goes high, A will be pulled low, if EI is enabled.</p>

<p>In (c) we can see that the bottom plate of the capacitors $D_{P0}$, $D_{P1}$, $D_{N0}$, and $D_{N1}$, are controlled by P and N.</p>

<p>In (d) we can see that the bottom plate of the capacitors also used to set the comparator clock low again (CO), resetting the comparator, and 
pulling P and N low, which in (b) enables the next SAR logic state.</p>

<p>How fast the $D_{XX}$ settle depend on the size of the capacitors, as such, the comparator clock will be slow for the MSB, and very fast for the LSB. 
This was my main circuit contribution in the paper. I think it’s quite clever, because both the VDD and the capacitor corner will change the 
settling time. It’s important that the capacitor values fully settle before the next comparator decision, and as a result of the circuit in (c,d) the delay
is automatically adjusted.</p>

<p>For further details see the paper.</p>

<p><img src="/aic2024/assets/media/fig_sar_logic.svg" alt="" width="700" /></p>

<p>For state-of-the-art ADC papers it’s not sufficient with the idea, and simulation. There must be proof that it actually works. 
No-one will really believe that the ADC works until there is measurements of an actual taped out IC.</p>

<p>Below you can see the layout of the IC I made for the paper. Notice that there are 9 ADCs. I had many ideas that I wanted to try out, and 
I was not sure what would actually be state of the art. As a result, I taped out multiple ADCS.</p>

<p><img src="/aic2024/assets/media/l06_fig_layout.svg" alt="" width="700" /></p>

<p>The two ADCs that I ended up using in the paper is shown below. The one on the left was made with 180 nm IO transistors, while the one on the right
was made with core-transistors. Notice that the layout of the two is quite similar.</p>

<p><img src="/aic2024/assets/media/l06_fig_toplevel.svg" alt="" width="700" /></p>

<p>Once taped out, and many months of waiting, a few months of measurement in the lab, I had some results that would be good enough to qualify 
for the best conference, and luckily the best journal.</p>

<p><img src="/aic2024/assets/media/l06_fig_core_meas.svg" alt="" width="700" /></p>

<p>Comparing my ADCs to others, we can see that the FOM is similar to others. Based on the FOM it might not be clear why the paper was 
considered state-of-the-art.</p>

<p>The circuit technique mentioned above would not have been enough to qualify. The big thing was the “Compiled” line. Compared to the 
other “Compiled” mine was 300 times better, and on par with other state-of-the-art.</p>

<p><img src="/aic2024/assets/media/l06_jssc_table.svg" alt="" width="700" /></p>

<p>The big thing was how I made the ADC. I started with a definition of a transistor, as shown below</p>

<p><img src="/aic2024/assets/media/l06_fig_dmos.svg" alt="" width="700" /></p>

<p>And then wrote a compiler (in Perl, later C++ <a href="https://github.com/wulffern/ciccreator">ciccreator</a>) to compile a object definition  file, a SPICE netlist 
and a technology rule file into the full ADC layout.</p>

<p>In (a) you can see one of the cells in the SAR logic, (b) is the spice file, and (c) is the definition of the routing. The numbers
to the right in the routing creates the paths shown in (d).</p>

<p><img src="/aic2024/assets/media/l06_fig_saremx.svg" alt="" width="700" /></p>

<p>The implementation is the <a href="https://github.com/wulffern/sun_sar9b_sky130nm/blob/main/cic/ip.spi">SPICE netlist</a>, and the <a href="https://github.com/wulffern/sun_sar9b_sky130nm/blob/main/cic/ip.json">object definition file</a> (JSON)
and the <a href="https://github.com/wulffern/sun_sar9b_sky130nm/blob/main/cic/sky130.tech">rule file</a>.</p>

<p>What I really like is the fact that the compilation could generate GDSII or SKILL, or these days, Xschem schematics and Magic layout.</p>

<p><img src="/aic2024/assets/media/l06_fig_process.svg" alt="" width="700" /></p>

<p>The cool thing with a compiled ADC is that it’s easy to port between technologies. 
Since the original ADC, I’ve ported the ADC to multiple closed PDKs (22 nm FDSOI, 22 nm, 28 nm, 55 nm, 65 nm and 130nm). 
In the summer of 2022 I made an open source port to skywater 130nm.</p>

<p><a href="https://github.com/wulffern/sun_sar9b_sky130nm/">SUN_SAR9B_SKY130NM</a></p>

<p><img src="/aic2024/assets/media/l00_SAR9B_CV.png" alt="" width="700" /></p>

<p>One of my Ph.D students built on-top on my work, and made a noise-shaped compiled SAR ADC, shown below, more on that later.</p>

<p><img src="/aic2024/assets/media/harald_layout.svg" alt="" width="700" /></p>

<h2 id="high-resolution-fom">High resolution FOM</h2>

<p>For high-resolution ADCs, it’s more common to use the Schreier figure of merit, which can also be found in</p>

<p><a href="https://web.stanford.edu/~murmann/adcsurvey.html">B. Murmann, ADC Performance Survey 1997-2022 (ISSCC &amp; VLSI Symposium)</a></p>

<p>The Walden figure of merit assumes that thermal noise does not constrain the power consumption of the ADC, which is usually true for low-to-medium resolution
ADCs. To keep the Walden FOM you can double the power for a one-bit increase in ENOB. If the ADC is limited by thermal noise, however, then you must
quadruple the capacitance (reduce $kT/C$ noise power) for each 1-bit ENOB increase. Accordingly, the power must also go up four times.</p>

<p>For higher resolution ADC the power consumption is set by thermal noise, and the Schreier FOM allows for a 4x power consumption increase for each added bit.</p>

\[FOM_S = SNDR + 10\log\left(\frac{f_s/2}{P}\right)\]

<p>Above 180 dB is extreme</p>

<p><img src="/aic2024/assets/media/l6_msch.svg" alt="" width="700" /></p>

<h1 id="quantization">Quantization</h1>

<p>Sampling turns continuous time into discrete time. Quantization turns continuous value into discrete value. 
Any complete ADC is always a combination of sampling and quantization.</p>

<p>In our mathematical drawings of quantization we often define $y[n]$ as the output, the quantized signal, and $x[n]$ as the discrete time, continuous value input, 
and we add some “noise”, or “quantization noise” $e[n]$, where $x[n] = y[n] - e[n]$.</p>

<p><img src="/aic2024/assets/media/l6_adc.svg" alt="" width="700" /></p>

<p>Maybe you’ve even heard the phrase “Quantization noise is white” or “Quantization noise is a random Gaussian process”?</p>

<p>I’m here to tell you 
that you’ve been lied to. Quantization noise is not white, nor is it a Gaussian process. 
Those that have lied to you may say “yes, sure, but for high number of bits it can be considered white noise”. 
I would say that’s similar to saying “when you look at the earth from the moon, the surface looks pretty smooth without bumps, so let’s say the earth is smooth
 with no mountains”.</p>

<p>I would claim that it’s an unnecessary simplification. It’s obvious to most that the earth would appear smooth from really far away, 
but they would not be surprised by Mount Everest, since they know it’s not smooth. An Alien that has been told that the earth is smooth, would be surprised to see Mount Everest.</p>

<p>But if Quantization noise is not white, what is it?</p>

<p>The figure below shows the input signal x and the quantized signal y.</p>

<p><img src="/aic2024/assets/media/l6_ct.svg" alt="" width="700" /></p>

<p>To see the quantization noise, first take a look at the sample and held version of $x$ in green in the figure below. The difference between the green ($x$ at time n) and the red ($y$)
would be our quantization noise $e$</p>

<p>The quantization noise is contained between $+\frac{1}{2}$ Least Significant Bit (LSB) and $-\frac{1}{2}$ LSB.</p>

<p>This noise does not look random to me, but I can’t see what it is, and I’m pretty sure I would not be able to work it out either.</p>

<p><img src="/aic2024/assets/media/l6_cten.svg" alt="" width="700" /></p>

<p>Luckily, there are people in this world that love mathematics, and that can delve into the details and figure out what $e[n]$ is. A guy called Blachman wrote
a paper back in 1985 on quantization noise.</p>

<p>See <a href="https://ieeexplore.ieee.org/document/1164729">The intermodulation and distortion due to quantization of sinusoids</a> for details</p>

<p>In short, quantization noise is defined as</p>

\[e_n(t) = \sum_{p=1}^\infty{A_p\sin{p\omega t}}\]

<p>where p is the harmonic index, and</p>

\[A_p = 
\begin{cases}
\delta_{p1}A  + \sum_{m =
  1}^\infty{\frac{2}{m\pi}J_p(2m\pi A)} &amp;, p = \text{ odd} \\
 0 &amp;, p = \text{ even}
\end{cases}\]

\[\delta_{p1}
\begin{cases}
1 &amp;, p=1 \\
0 &amp;, p \neq 1
\end{cases}\]

<p>and \(J_p(x)\) is a Bessel function of the first kind, <em>A</em> is the amplitude of the input signal.</p>

<p>If we approximate the amplitude of the input signal as</p>

\[A = \frac{2^n - 1}{2} \approx 2^{n-1}\]

<p>where n is the number of bits, we can rewrite as</p>

\[e_n(t) = \sum_{p=1}^\infty{A_p\sin{p\omega t}}\]

\[A_p = \delta_{p1}2^{n-1} + \sum_{m=1}^\infty{\frac{2}{m\pi}J_p(2m\pi
  2^{n-1})},  p=odd\]

<p>Obvious, right?</p>

<p>I must admit, it’s not obvious to me. But I do understand the implications. The quantization noise is an infinite sum of input signal odd harmonics, where
the amplitude of the harmonics is determined by a sum of a <a href="https://en.wikipedia.org/wiki/Bessel_function#Bessel_functions_of_the_first_kind">Bessel function</a>.</p>

<p>A Bessel function of the first kind looks like this</p>

<p><img src="/aic2024/assets/media/Bessel.svg" alt="" width="700" /></p>

<p>So I would expect the amplitude to show signs of oscillatory behavior for the harmonics. 
That’s the important thing to remember. The quantization noise is <strong>odd harmonics of the input signal</strong></p>

<p>The mean value is zero</p>

\[\overline{e_n(t)} = 0\]

<p>and variance (mean square, since mean is zero), or noise power, can be approximated as</p>

\[\overline{e_n(t)^2} = \frac{\Delta^2}{12}\]

<h2 id="signal-to-quantization-noise-ratio">Signal to Quantization noise ratio</h2>

<p>Assume we wanted to figure out the resolution, or effective number of bits for an ADC limited by quantization noise. 
A power ratio, like signal-to-quantization noise ratio (SQNR) is one way to represent resolution.</p>

<p>Take the signal power, and divide by the noise power</p>

\[SQNR = 10 \log\left(\frac{A^2/2}{\Delta^2/12}\right) = 10 \log\left(\frac{6 A^2}{\Delta^2}\right)\]

\[\Delta = \frac{2A}{2^B}\]

\[SQNR = 10 \log\left(\frac{6 A^2}{4 A^2/2^B}\right) = 20 B \log 2 + 10 \log 6/4\]

\[SQNR  \approx 6.02 B + 1.76\]

<p>You may have seen the last equation before, now you know where it comes from.</p>

<h2 id="understanding-quantization">Understanding quantization</h2>

<p>Below I’ve tried to visualize the quantization process <a href="https://github.com/wulffern/aic2023/blob/main/ex/q.py">q.py</a>.</p>

<p>The left most plot is a sinusoid signal and random      Gaussian noise. The signal is not a continuous time signal, since that’s not possible on a digital computer, but it’s an approximation.</p>

<p>The plots are FFTs of a sinusoidal signal combined with noise. These are complex FFTs, so they show both negative and positive frequencies. The x-axis is the FFT bin (not the frequency). Notice that there are two spikes, which should not be surprising, since a sinusoidal signal is a combination of two frequencies.</p>

\[sin(x) = \frac{e^{ix} - e^{-ix}}{2i}\]

<p>The second plot from the left is after sampling, notice that the noise level increases. The increase in the noise level should be due to noise folding, and reduced number of points in the FFT, but I have not confirmed (maybe you could confirm?).</p>

<p>The right plot is after quantization, where I’ve used the function below.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">adc</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">bits</span><span class="p">):</span>
    <span class="n">levels</span> <span class="o">=</span> <span class="mi">2</span><span class="o">**</span><span class="n">bits</span>
    <span class="n">y</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="nb">round</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">levels</span><span class="p">)</span><span class="o">/</span><span class="n">levels</span>
    <span class="k">return</span> <span class="n">y</span>
</code></pre></div></div>

<p>I really need you to internalize a few things from the right most plot. Really think through what I’m about to say.</p>

<p>Can you see how the noise (what is not the two spikes) is not white? White noise would be flat in the frequency domain, but the noise is not flat.</p>

<p><img src="/aic2024/assets/media/l6_q_1.svg" alt="" width="700" /></p>

<p>If you run the python script you can zoom in and check the highest spikes. The fundamental is at 127, so odd harmonics would be 381, 635, 889, and from the function of the quantization noise we would expect those to be the highest harmonics (at least when we look at the Bessel function), however, we can see that it’s close, but that bin 396 is the highest. Is the math’s wrong?</p>

<p>No, the math is correct. Never bet against mathematics. If you change the python script to reduce the frequency, <code class="language-plaintext highlighter-rouge">fdivide=2**9</code>, and increase number of points, <code class="language-plaintext highlighter-rouge">N=2**16</code>, as in the plot below, you’ll see it’s the 11’th harmonic that is highest.</p>

<p><img src="/aic2024/assets/media/l6_q_1_fharm.svg" alt="" width="700" /></p>

<p>All the other spikes are the odd harmonics above the sample rate that fold. The infinite sum of harmonics will fold, some in-phase, some out of phase, depending on the sign of the Bessel function.</p>

<p>From the function for the amplitude of the quantization noise for harmonic indices higher than $p=1$</p>

\[A_p =  \sum_{m=1}^\infty{\frac{2}{m\pi}J_p(2m\pi 2^{n-1}  ) }\text{,  p=odd}\]

<p>we can see that the input to the Bessel function increases faster for a higher number of bits $n$. As such, from the Bessel function figure above, I would expect that the sum of the Bessel function is a lower value. Accordingly, the quantization noise reduces at higher number of bits.</p>

<p>A consequence is that the quantization noise becomes more and more uniform, as can be seen from the plot of a 10-bit quantizer below. That’s why people say “Quantization noise is white”, because for a high number of bits, it looks white in the FFT.</p>

<p><img src="/aic2024/assets/media/l6_q_10.svg" alt="" width="700" /></p>

<h2 id="why-you-should-care-about-quantization-noise">Why you should care about quantization noise</h2>

<p>So why should you care whether the quantization noise looks white, or actually is white? A class of ADCs called oversampling and sigma-delta modulators rely on the assumption that quantization noise <strong>is</strong> white. In other words, the cross-correlation between noise components at different time points is zero. As such the noise power sums as a sum of variance, and we can increase the signal-to-noise ratio.</p>

<p><strong>We</strong> know that assumption to be wrong though, <strong>quantization noise is not white</strong>. For noise components at harmonic frequencies the cross-correlation will be high. As such, when <strong>we</strong> design oversampling or sigma-delta based ADC <strong>we</strong> will include some form of dithering (making quantization noise whiter). For example, before the actual quantizer we inject noise, or we make sure that the thermal noise is high enough to dither the quantizer.</p>

<p>Everybody that thinks that quantization noise <strong>is</strong> white will design non-functioning (or sub-optimal) oversampling and sigma-delta ADCs. That’s why you should care about the details around quantization noise.</p>

<h1 id="oversampling">Oversampling</h1>

<p>Assume a signal $x[n] = a[n] + b[n]$ where $a$ is a sampled sinusoid and $b$ is a random process where cross-correlation is zero for any time except for $n=0$. Assume that we sum two (or more) equally spaced signal components, for example</p>

\[y = x[n] + x[n+1]\]

<p>What would the signal to noise ratio be for $y$?</p>

<h2 id="noise-power">Noise power</h2>
<p>Our mathematician friends have looked at this, and as long the noise signal $b$  <strong>is random</strong> then the noise power for the oversampled signal $b_{osr} = b[n] + b[n+1]$ will be</p>

\[\overline{b_{osr}^2} = OSR \times \overline{b^2}\]

<p>where OSR is the oversampling ratio. If we sum two time points the $OSR=2$, if we sum 4 time points the $OSR=4$ and so on.</p>

<p>For fun, let’s go through the mathematics</p>

<p>Define $b_1 = b[n]$ and $b_2 = b[n+1]$ and  compute the noise power</p>

\[\overline{(b_1 + b_2)^2} = \overline{b_1^2 + 2b_1b_2 + b_2^2}\]

<p>Let’s replace the mean with the actual function</p>

\[\frac{1}{N}\sum_{n=0}^N{\left(b_1^2 + 2b_1b_2 + b_2^2\right)}\]

<p>which can be split up into</p>

\[\frac{1}{N}\sum_{n=0}^N{b_1^2} + \frac{1}{N}\sum_{n=0}^N{2b_1b_2} + \frac{1}{N}\sum_{n=0}^N{b_2^2}\]

<p>we’ve defined the cross-correlation to be zero, as such</p>

\[\overline{(b_1 + b_2)^2} = \frac{1}{N}\sum_{n=0}^N{b_1^2} + \frac{1}{N}\sum_{n=0}^N{b_2^2} =  \overline{b_1^2} + \overline{b_2^2}\]

<p>but the noise power of each of the $b$’s must be the same as $b$, so</p>

\[\overline{(b_1 + b_2)^2} = 2\overline{b^2}\]

<h2 id="signal-power">Signal power</h2>

<p>For the signal $a$ we need to calculate the increase in signal power as OSR increases.</p>

<p>I like to think about it like this. $a$ is low frequency, as such, samples $n$ and $n+1$ is pretty much the same value. If the sinusoid has an amplitude of 1, then the amplitude would be 2 if we sum two samples. As such, the amplitude must increase with the OSR.</p>

<p>The signal power of a sinusoid is $A^2/2$, accordingly, the signal power of an oversampled signal must be $(OSR \times A)^2/2$.</p>

<h2 id="signal-to-noise-ratio">Signal to Noise Ratio</h2>

<p>Take the signal power to the noise power</p>

\[\frac{(OSR \times A)^2/2}{OSR \times \overline{b^2}} = OSR \times \frac{A^2/2}{\overline{b^2}}\]

<p>We can see that the signal to noise ratio increases with increased oversampling ratio, <strong>as long as the cross-correlation of the noise is zero</strong></p>

<h2 id="signal-to-quantization-noise-ratio-1">Signal to Quantization Noise Ratio</h2>

<p>The 
in-band quantization noise for a oversampling ratio (OSR)</p>

\[\overline{e_n(t)^2} =\frac{\Delta^2}{12 OSR}\]

<p>And the improvement in SQNR can be calculated as</p>

\[SQNR = 10 \log\left(\frac{6 A^2}{\Delta^2/OSR}\right) = 10 \log\left(\frac{6 A^2}{\Delta^2}\right) + 10 \log(OSR)\]

\[SQNR \approx 6.02B + 1.76 + 10 \log(OSR)\]

<p>For an OSR of 2 and 4 the SQNR improves by</p>

\[10 \log(2) \approx 3 dB\]

<p>and for OSR=4</p>

\[10 \log(4) \approx 6 dB\]

<p>which is roughly equivalent to a 
0.5-bit per doubling of OSR</p>

<h2 id="python-oversample">Python oversample</h2>

<p>There are probably more elegant (and faster) ways of implementing oversampling in python, but I like to write the dumbest code I can, simply because dumb code is easy to understand.</p>

<p>Below you can see an example of oversampling. The <code class="language-plaintext highlighter-rouge">oversample</code> function takes in a 
vector and the OSR. For each index it sums OSR future values.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">oversample</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">OSR</span><span class="p">):</span>
    <span class="n">N</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
    <span class="n">y</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">N</span><span class="p">)</span>

    <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="n">N</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="n">OSR</span><span class="p">):</span>
            <span class="n">m</span> <span class="o">=</span> <span class="n">n</span><span class="o">+</span><span class="n">k</span>
            <span class="k">if</span> <span class="p">(</span><span class="n">m</span> <span class="o">&lt;</span> <span class="n">N</span><span class="p">):</span>
                <span class="n">y</span><span class="p">[</span><span class="n">n</span><span class="p">]</span> <span class="o">+=</span> <span class="n">x</span><span class="p">[</span><span class="n">m</span><span class="p">]</span>
    <span class="k">return</span> <span class="n">y</span>
</code></pre></div></div>

<p>Below we can see the plot for OSR=2, the right most plot is the oversampled version.</p>

<p>The noise has all frequencies, and it’s the high frequency components that start to cancel each other. An average filter (sometimes called a sinc filter due to the shape in the frequency domain) will have zeros at $\pm fs/2$ where the noise power tends towards zero.</p>

<p><img src="/aic2024/assets/media/l6_osr_2.svg" alt="" width="700" /></p>

<p>The low frequency components will add, and we can notice how the noise power increases close to the zero frequency (middle of the x-axis).</p>

<p>For an OSR of 4 we can notice how the noise floor has 4 zero’s.</p>

<p><img src="/aic2024/assets/media/l6_osr_4.svg" alt="" width="700" /></p>

<p>The code for the plots is  <a href="https://github.com/wulffern/aic2023/blob/main/ex/osr.py">osr.py</a>. I would encourage you to play a bit with the code, and make sure you understand oversampling.</p>

<h1 id="noise-shaping">Noise Shaping</h1>

<p>Look at the OSR=4 plot above. The OSR=4 does decrease the noise compared to the discrete time discrete value plot, however, the noise level of the discrete time continuous value is much lower.</p>

<p>What if we could do something, add some circuitry, before the quantization such that the quantization noise was reduced?</p>

<p>That’s what noise shaping is all about. Adding circuits such that we can “shape” the quantization noise. We can’t make the quantization noise disappear, or indeed reduce the total noise power of the quantization noise, but we can reduce the quantization noise power for a certain frequency band.</p>

<p>But what circuitry can we add?</p>

<h2 id="the-magic-of-feedback">The magic of feedback</h2>

<p>A generalized feedback system is shown below, it could be a regulator, a unity-gain buffer, or something else.</p>

<p>The output $V_o$ is subtracted from the input $V_i$, and the error $V_x$ is shaped by a filter $H(s)$.</p>

<p>If we make $H(s)$ infinite, then $V_o = V_i$. If you’ve never seen such a circuit, you might ask “Why would we do this? Could we not just use $V_i$ directly?”. There are many reasons for using a circuit like this, let me explain one instance.</p>

<p>Imagine we have a VDD of 1.8 V, and we want to make a 0.9 V voltage for a CPU. The CPU can consume up to 10 mA. One way to make a divide by two circuit is with two equal resistors connected between VDD and ground. We don’t want the resistive divider to consume a large current, so let’s choose 1 MOhm resistors. The current in the resistor divider would then be about 1 $\mu$A. We can’t connect the CPU directly to the resistor divider, the CPU can draw 10 mA. As such, we need a copy of the voltage at the mid-point of the resistor divider that can drive 10 mA.</p>

<p>Do you see now why a circuit like the one below is useful? If not, you should really come talk to me so I can help you understand.</p>

<p><img src="/aic2024/assets/media/l4_sdloop.svg" alt="" width="700" /></p>

<h2 id="sigma-delta-principle">Sigma-delta principle</h2>

<p>Let’s modify the feedback circuit into the one below. I’ve added an ADC and a DAC to the feedback loop, and the $D_o$ is now the output we’re interested in. The equation for the loop would be</p>

\[D_o = adc\left[H(s)\left(dac(D_o) - V_i\right)\right]\]

<p>But how can we now calculate the transfer function $\frac{D_o}{V_i}$? Both $adc$ and $dac$ could be non-linear functions, so we can’t disentangle the equation. Let’s make assumptions.</p>

<p><img src="/aic2024/assets/media/l4_sd.svg" alt="" width="700" /></p>

<h3 id="the-dac-assumption">The DAC assumption</h3>

<p><strong>Assumption 1:</strong> the $dac$ is linear, such that $V_o = dac(D_o) = A  D_o + B$, where $A$ and $B$ are scalar values.</p>

<p>The DAC must be linear, otherwise our noise-shaping ADC will not work.</p>

<p>One way to force linearity is to use a 1-bit DAC, which has only two points, so should be linear. For example \(V_o = A \times D_o\), where $D_o \in (0,1)$. 
Even a 1-bit DAC could be non-linear if $A$ is time-variant, so $V_o[n] = A(t)\times D_o[n]$,
this could happen if the reference voltage for the DAC changed with time.</p>

<p>I’ve made a couple noise shaping ADCs, and in the first one I made I screwed up the DAC. It turned out that the DAC current had a signal dependent component which lead to a non-linear behavior.</p>

<h3 id="the-adc-assumption">The ADC assumption</h3>

<p><strong>Assumption 2:</strong> the $adc$ can be modeled as a linear function  $D_o = adc(x) = x + e$, where e is <strong>white noise source</strong></p>

<p>We’ve talked about this, the $e$ is not white, especially for low-bit ADCs, so we usually have to add noise. 
Sometimes it’s sufficient with thermal noise, but often it’s necessary to add a random, or pseudo-random noise source at the input of the ADC.</p>

<h3 id="the-modified-equation">The modified equation</h3>

<p>With the assumptions we can change the equation into</p>

\[D_o = adc\left[H(s)\left(V_i - dac(D_o)\right)\right] = H(s)\left( V_i - A D_o\right) + e\]

<p>In noise-shaping texts it’s common to write the above equation as</p>

\[y = H(s)(u - y) + e\]

<p>or in the sample domain</p>

\[y[n] = e[n] + h*(u[n] - y[n])\]

<p>which could be drawn in a signal flow graph as below.</p>

<p><img src="/aic2024/assets/media/l6_sdadc.svg" alt="" width="700" /></p>

<p>in the Z-domain the equation would turn into</p>

\[Y(z) = E(z) + H(z)\left[U(z) - Y(z)\right]\]

<p>The whole point of this exercise was to somehow shape the quantization noise, and we’re almost at the point, but to show how it works we need to look at the transfer function for the signal $U$ and for the noise $E$.</p>

<h2 id="signal-transfer-function">Signal transfer function</h2>

<p>Assume U and E are uncorrelated, and E is zero</p>

\[Y = HU - HY\]

\[STF = \frac{Y}{U} = \frac{H}{1 + H} = \frac{1}{1 + \frac{1}{H}}\]

<p>Imagine what will happen if H is infinite. Then the signal transfer function (STF) is 1, and the output $Y$ is equal to our input $U$. That’s exactly what we wanted from the feedback circuit.</p>

<h2 id="noise-transfer-function">Noise transfer function</h2>

<p>Assume U is zero</p>

\[Y = E + HY \rightarrow NTF = \frac{1}{1 + H}\]

<p>Imagine again what happens when H is infinite. In this case the noise-transfer function becomes zero. In other words, there is no added noise.</p>

<h2 id="combined-transfer-function">Combined transfer function</h2>

<p>In the combined transfer function below, if we make $H(z)$ infinite, then $Y = U$ and there is <strong>no added quantization noise</strong>. I don’t know how to make $H(z)$ infinite everywhere, so we have to choose at what frequencies it’s “infinite”.</p>

\[Y(z) = STF(z) U(z) + NTF(z) E(z)\]

<p>There are a large set of different $H(z)$ and I’m sure engineers will invent new ones. We usually classify the filters based on the number of zeros in the NTF, for example, first-order (one zero), second order (two zeros) etc. There are books written about sigma-delta modulators, and I would encourage you to read those to get a deeper understanding. I would start with <a href="https://ieeexplore.ieee.org/book/5273726">Delta-Sigma Data Converters: Theory, Design, and Simulation</a>.</p>

<h1 id="first-order-noise-shaping">First-Order Noise-Shaping</h1>

<p>We want an infinite $H(z)$. One way to get an infinite function is an accumulator, for example</p>

\[y[n+1] = x[n] + y[n]\]

<p>or in the Z-domain</p>

\[zY = X + Y \rightarrow Y(z-1) = X\]

<p>which has the transfer function</p>

\[H(z) = \frac{1}{z-1}\]

<p>The signal transfer function is</p>

\[STF = \frac{1/(z-1)}{1 + 1/(z-1)} = \frac{1}{z} = z^{-1}\]

<p>and the noise transfer function</p>

\[NFT = \frac{1}{1 + 1/(z-1)} = \frac{z-1}{z} = 1 - z^{-1}\]

<p>In order calculate the Signal to Quantization Noise Ratio we need to have an expression for how the NTF above filters the quantization noise.</p>

<p>In the book they replace the $z$ with the continuous time variable</p>

\[z = e^{sT} \overset{s=j\omega}{\rightarrow}  e^{j\omega T} = e^{j2 \pi f/f_s}\]

<p>inserted into the NTF we get the function below.</p>

\[NTF(f) = 1- e^{-j2 \pi f/f_s}\]

\[= \frac{e^{j \pi f/f_s} -e^{-j \pi f/f_s}}{2j}\times 2j \times e^{-j\pi f/f_s}\]

\[= \sin{\frac{\pi f}{f_s}} \times 2j \times e^{-j \pi f/f_s}\]

<p>The arithmetic magic is really to extract the $2j \times e^{-j \pi f/f_s}$ from the first expression such that the initial part can be translated into a sinusoid.</p>

<p>When we take the absolute value to figure out how the NTF changes with frequency the complex parts disappears (equal to 1)</p>

\[|NFT(f)| = \left|2 \sin\left(\frac{\pi f}{f_s}\right)\right|\]

<p>The signal power for a sinusoid is</p>

\[P_s = A^2/2\]

<p>The in-band noise power for the shaped quantization noise is</p>

\[P_n = \int_{-f_0}^{f_0} \frac{\Delta^2}{12}\frac{1}{f_s}\left[2 \sin\left(\frac{\pi f}{f_s}\right)\right]^2 dt\]

<p>and with a bunch of tedious maths, we can get to the conclusion</p>

\[\vdots\]

\[SQNR = 6.02 B + 1.76 - 5.17 + 30 \log(OSR)\]

<p>If we compare to pure oversampling, where the SQNR improves by $10 \log(OSR)$, a first order sigma-delta improves by $30 \log(OSR)$. That’s a significant improvement.</p>

<h2 id="sqnr-and-enob">SQNR and ENOB</h2>

<p>Below is the signal-to-quantization noise ratio’s for Nyquist up to second order sigma-delta.</p>

\[SQNR_{nyquist} \approx 6.02B + 1.76\]

\[SQNR_{oversample} \approx 6.02B + 1.76 + 10 \log(OSR)\]

\[SQNR_{\Sigma\Delta 1} \approx 6.02 B + 1.76 - 5.17 + 30 \log(OSR)\]

\[SQNR_{\Sigma\Delta 2} \approx 6.02 B + 1.76 - 12.9 + 50 \log(OSR)\]

<p>We could compute an effective number of bits, as shown below.</p>

\[ENOB = (SQNR - 1.76)/6.02\]

<p>The table below shows the effective number of bits for oversampling, and sigma-delta modulators.  For a 1-bit quantizer, pure oversampling
does not make sense at all. For first-order and second-order sigma delta modulators, and a OSR of 1024 we can get high resolution ADCs.</p>

<p>Assume 1-bit quantizer, what would be the maximum ENOB?</p>

<table>
  <thead>
    <tr>
      <th style="text-align: center">OSR</th>
      <th style="text-align: center">Oversampling</th>
      <th style="text-align: center">First-Order</th>
      <th style="text-align: center">Second Order</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: center">4</td>
      <td style="text-align: center">2</td>
      <td style="text-align: center">3.1</td>
      <td style="text-align: center">3.9</td>
    </tr>
    <tr>
      <td style="text-align: center">64</td>
      <td style="text-align: center">4</td>
      <td style="text-align: center">9.1</td>
      <td style="text-align: center">13.9</td>
    </tr>
    <tr>
      <td style="text-align: center">1024</td>
      <td style="text-align: center">6</td>
      <td style="text-align: center">15.1</td>
      <td style="text-align: center">23.9</td>
    </tr>
  </tbody>
</table>

<h1 id="examples">Examples</h1>

<h2 id="python-noise-shaping">Python noise-shaping</h2>

<p>I want to demystify noise-shaping modulators. I think one way to do that is
to show some code. You can find the code at <a href="https://github.com/wulffern/aic2023/blob/main/ex/sd_1st.py">sd_1st.py</a></p>

<p>Below we can see an excerpt. Again pretty stupid code, and I’m sure it’s possible to make a faster version (for loops in python are notoriously slow).</p>

<p>For each sample in the input vector $u$ I compute the input to the quantizer $x$, which is the sum of the previous input to the quantizer and the difference between the current input and the previous output $y_{sd}$.</p>

<p>The quantizer generates the next $y_{sd}$ and I have the option to add dither.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1"># u is discrete time, continuous value input
</span><span class="n">M</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">u</span><span class="p">)</span>
<span class="n">y_sd</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">M</span><span class="p">)</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">M</span><span class="p">)</span>
<span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="n">M</span><span class="p">):</span>
    <span class="n">x</span><span class="p">[</span><span class="n">n</span><span class="p">]</span> <span class="o">=</span> <span class="n">x</span><span class="p">[</span><span class="n">n</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="p">(</span><span class="n">u</span><span class="p">[</span><span class="n">n</span><span class="p">]</span><span class="o">-</span><span class="n">y_sd</span><span class="p">[</span><span class="n">n</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
    <span class="n">y_sd</span><span class="p">[</span><span class="n">n</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="nb">round</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="n">n</span><span class="p">]</span><span class="o">*</span><span class="mi">2</span><span class="o">**</span><span class="n">bits</span>  
    <span class="o">+</span> <span class="n">dither</span><span class="o">*</span><span class="n">np</span><span class="p">.</span><span class="n">random</span><span class="p">.</span><span class="n">randn</span><span class="p">()</span><span class="o">/</span><span class="mi">4</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="o">**</span><span class="n">bits</span>

</code></pre></div></div>

<p>The right-most plot is the one with noise-shaping. We can observe that the noise seems to tend towards zero at zero frequency, as we would expect. 
The accumulator above would have an infinite gain at infinite time (it’s the sum of all previous values), as such, the NTF goes towards zero at 0 frequency.</p>

<p>If we look at the noise we can also see the non-white quantization noise, which will degrade our performance. I hope by now, you’ve grown tired of me harping on the point that <strong>quantization noise is not white</strong></p>

<p><img src="/aic2024/assets/media/l6_sd_d0_b1.svg" alt="" width="700" /></p>

<p>In the figure below I’ve turned on dither, and we can see how the noise looks “better”, which I know is not a qualitative statement, but ask anyone that’s done 1-bit quantizers. It’s important to have enough random noise.</p>

<p><img src="/aic2024/assets/media/l6_sd_d1_b1.svg" alt="" width="700" /></p>

<p>In papers it’s common to use a logarithmic x-axis for the power spectral density, as shown below. In the plot I only show the positive 
frequencies of the FFT. From the shape of the quantization noise we can also see the first order behavior.</p>

<p><img src="/aic2024/assets/media/l6_sdlog_d1_b5.svg" alt="" width="700" /></p>

<h2 id="the-wonderful-world-of-sd-modulators">The wonderful world of SD modulators</h2>

<h3 id="open-loop-sigma-delta">Open-Loop Sigma-Delta</h3>

<p>On my Ph.D I did some work on</p>

<p><a href="https://ieeexplore.ieee.org/document/4783042">Resonators in Open-Loop Sigma-Delta Modulators</a></p>

<p>which was a pure theoretical work. 
The idea was to use  modulo integrators (local control of integrator output swing) in front of large latency multi-bit quantizers to achieve a high SNR.</p>

<p>The plot below shows a fifth order NFT where there are two complex conjugate  zeros, and a zero at zero frequency. With a higher 
order filter one can use a lower OSR, and still achieve high ENOB.</p>

<p><img src="/aic2024/assets/media/l06_osd21.svg" alt="" width="700" /></p>

<h3 id="noise-shaped-sar">Noise Shaped SAR</h3>

<p>One of my Ph.d students made a</p>

<p><a href="https://ieeexplore.ieee.org/document/9056925/">A 68 dB SNDR Compiled Noise-Shaping SAR ADC With On-Chip CDAC Calibration</a></p>

<p>In a SAR ADC, once the bit-cycling is complete, the analog value on the capacitors is the actual quantization error. 
That error can be fed to a loop filter, H(z), and amplified in the next conversion, accordingly a combination of SAR and noise-shaping.</p>

<p>In the paper the SD modulator was also used to calibrate the non-linearity in the CDAC, as the MSB capacitor won’t be exactly N times larger
than the smallest capacitor.</p>

<p><img src="/aic2024/assets/media/l6_harald_arch.gif" alt="" width="700" /></p>

<p>The loop filter was a switched cap loop filter, and we can see the NTF below. The first OTA made use of chopping to reduce the offset.</p>

<p><img src="/aic2024/assets/media/l6_fig_harald_circuit.gif" alt="" width="700" /></p>

<h3 id="control-bounded-adcs">Control-Bounded ADCs</h3>

<p>One of my current Ph.D students is working an even more advanced type of sigma-delta ADC. Actually, it’s more a super-set of SD ADCs called
control-bounded ADCs.</p>

<p><a href="https://ntnuopen.ntnu.no/ntnu-xmlui/handle/11250/2824253">Design Considerations for a Low-Power Control-Bounded A/D Converter</a></p>

<p>A block diagram of a Leapfrog ADC version of a control-bounded ADC is shown below.</p>

<p>Here we’re walking into advanced maths territory, but to simplify, I think it’s correct to say that a control-bounded ADC seeks 
to control the local analog state, $x_n(t)$ such that no voltage is saturated. The digital control signals $s_n(t)$ are used to 
infer the state of the input $u(t)$ using a form of <a href="https://en.wikipedia.org/wiki/Bayesian_statistics">Bayesian Statistics</a>.</p>

<p><img src="/aic2024/assets/media/l6_fredrik_arch.svg" alt="" width="700" /></p>

<p>Below we can see a power spectral density plot of the ADC, and we can observe how the quantization noise is shaped. I think it’s 
a third order NTF with a zero at zero frequency and a complex conjugate pole at 8 MHzish.</p>

<p><img src="/aic2024/assets/media/l6_fredrik_psd.svg" alt="" width="700" /></p>

<h3 id="complex-sigma-delta">Complex Sigma-Delta</h3>

<p>There are cool sigma-delta modulators with crazy configurations 
and that may look like an exercise in “Let’s make something complex”, however, most of them have a reasonable application. One example is the one below for radio recievers</p>

<p><a href="https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&amp;arnumber=4381437">A 56 mW Continuous-Time Quadrature Cascaded Sigma-Delta Modulator With 77 dB DR in a Near Zero-IF
20 MHz Band</a></p>

<p><img src="/aic2024/assets/media/qt_sd.png" alt="" width="700" /></p>

<h3 id="my-first-sigma-delta">My first Sigma-Delta</h3>

<p>The first sigma-delta modulator I made in “real-life”  was similar to the one shown below.</p>

<p>The input voltage is translated into a current, and the current is integrated on capacitor $C$. The $R_{offset}$ is to change the mid-level voltage, while $R_{ref}$ is the 1-bit feedback DAC. The comparator is the quantizer. When the clock strikes the comparator compares the $V_o$ and $V_{ref}/2$ and outputs a 1-bit digital output $D$</p>

<p>The complete ADC is operated in a “incremental mode”, which is a fancy way of saying</p>

<blockquote>
  <p>Reset your sigma-delta modulator, run the sigma delta modulator for a fixed number of cycles (i.e 1024), and count the number of ones at $D$</p>
</blockquote>

<p>The effect of an “incremental mode” is to combine the modulator and a output filter so the ADC appears to be a slow Nyquist ADC.</p>

<p>For more information, ask me, or see the patent at 
<a href="https://patents.google.com/patent/US8947280B2/en?inventor=carsten+wulff&amp;oq=carsten+wulff">Analogue-to-digital converter</a></p>

<p><img src="/aic2024/assets/media/l6_patent.svg" alt="" width="700" /></p>

<h1 id="want-to-learn-more">Want to learn more?</h1>

<p><a href="https://ieeexplore.ieee.org/document/90025">The design of sigma-delta modulation analog-to-digital converters</a></p>

<p><a href="https://ieeexplore.ieee.org/document/229400">Delta-sigma modulation in fractional-N frequency synthesis</a></p>

<p><a href="https://ieeexplore.ieee.org/document/6323049">A CMOS Temperature Sensor With a Voltage-Calibrated Inaccuracy of ± 0.15 C (3sigma) From -55 Cto 125 C</a></p>

<p><a href="https://ieeexplore.ieee.org/document/4014623">A 20-mW 640-MHz CMOS Continuous-Time Sigma-Delta ADC With 20-MHz Signal Bandwidth, 80-dB Dynamic Range and 12-bit ENOB</a></p>

<p><a href="https://ieeexplore.ieee.org/document/7078971">A Micro-Power Two-Step Incremental Analog-to-Digital Converter</a></p>]]></content><author><name>Carsten Wulff</name><email>carsten@wulff.no</email></author><summary type="html"><![CDATA[If you find an error in what I’ve made, then fork, fix lectures/l06_adc.md, commit, push and create a pull request. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.]]></summary></entry><entry><title type="html">Lecture 5 - Switched-Capacitor Circuits</title><link href="https://wulffern.github.io/aic2024/2024/02/09/Lecture-5-Switched-Capacitor-Circuits.html" rel="alternate" type="text/html" title="Lecture 5 - Switched-Capacitor Circuits" /><published>2024-02-09T00:00:00+00:00</published><updated>2024-02-09T00:00:00+00:00</updated><id>https://wulffern.github.io/aic2024/2024/02/09/Lecture-5---Switched-Capacitor-Circuits</id><content type="html" xml:base="https://wulffern.github.io/aic2024/2024/02/09/Lecture-5-Switched-Capacitor-Circuits.html"><![CDATA[<blockquote>
  <p>If you find an error in what I’ve made, then <a href="https://docs.github.com/en/get-started/quickstart/fork-a-repo">fork</a>, fix <a href="https://github.com/wulffern/aic2024/tree/main/lectures/l05_sc.md">lectures/l05_sc.md</a>, <a href="https://git-scm.com/docs/git-commit">commit</a>, <a href="https://git-scm.com/docs/git-push">push</a> and <a href="https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/working-with-your-remote-repository-on-github-or-github-enterprise/creating-an-issue-or-pull-request">create a pull request</a>. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.</p>
</blockquote>

<p><a href="/aic2024/assets/slides/l05_sc.pdf">Slides</a></p>

<ul id="markdown-toc">
  <li><a href="#active-rc" id="markdown-toc-active-rc">Active-RC</a></li>
  <li><a href="#gm-c" id="markdown-toc-gm-c">Gm-C</a></li>
  <li><a href="#switched-capacitor" id="markdown-toc-switched-capacitor">Switched capacitor</a>    <ul>
      <li><a href="#an-example-sc-circuit" id="markdown-toc-an-example-sc-circuit">An example SC circuit</a></li>
    </ul>
  </li>
  <li><a href="#discrete-time-signals" id="markdown-toc-discrete-time-signals">Discrete-Time Signals</a>    <ul>
      <li><a href="#the-mathematics" id="markdown-toc-the-mathematics">The mathematics</a></li>
      <li><a href="#python-discrete-time-example" id="markdown-toc-python-discrete-time-example">Python discrete time example</a></li>
      <li><a href="#aliasing-bandwidth-and-sample-rate-theory" id="markdown-toc-aliasing-bandwidth-and-sample-rate-theory">Aliasing, bandwidth and sample rate theory</a></li>
      <li><a href="#z-transform" id="markdown-toc-z-transform">Z-transform</a></li>
      <li><a href="#pole-zero-plots" id="markdown-toc-pole-zero-plots">Pole-Zero plots</a></li>
      <li><a href="#z-domain" id="markdown-toc-z-domain">Z-domain</a></li>
      <li><a href="#first-order-filter" id="markdown-toc-first-order-filter">First order filter</a></li>
      <li><a href="#finite-impulse-responsefir" id="markdown-toc-finite-impulse-responsefir">Finite-impulse response(FIR)</a></li>
    </ul>
  </li>
  <li><a href="#switched-capacitor-1" id="markdown-toc-switched-capacitor-1">Switched-Capacitor</a>    <ul>
      <li><a href="#switched-capacitor-gain-circuit" id="markdown-toc-switched-capacitor-gain-circuit">Switched capacitor gain circuit</a></li>
      <li><a href="#switched-capacitor-integrator" id="markdown-toc-switched-capacitor-integrator">Switched capacitor integrator</a></li>
      <li><a href="#noise" id="markdown-toc-noise">Noise</a></li>
      <li><a href="#sub-circuits-for-sc-circuits" id="markdown-toc-sub-circuits-for-sc-circuits">Sub-circuits for SC-circuits</a>        <ul>
          <li><a href="#ota" id="markdown-toc-ota">OTA</a></li>
          <li><a href="#switches" id="markdown-toc-switches">Switches</a></li>
          <li><a href="#non-overlapping-clocks" id="markdown-toc-non-overlapping-clocks">Non-overlapping clocks</a></li>
        </ul>
      </li>
      <li><a href="#example" id="markdown-toc-example">Example</a></li>
    </ul>
  </li>
  <li><a href="#want-to-learn-more" id="markdown-toc-want-to-learn-more">Want to learn more?</a></li>
</ul>

<p>Keywords: SC DAC, SC FUND, DT, Alias, Subsample, Z Domain, FIR, IIR, SC MDAC, SC INT, Switch, Non-Overlap, VBE SC, Nyquist</p>

<iframe width="560" height="315" src="https://www.youtube.com/embed/WWwDGFx1Z08?si=GxuhbdTRLbs-ML_1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen=""></iframe>

<h1 id="active-rc">Active-RC</h1>

<p>A general purpose Active-RC bi-quadratic (two-quadratic equations) filter is shown below</p>

<p><img src="/aic2024/assets/media/l4_activebiquad.svg" alt="" width="700" /></p>

<p>If you want to spend a bit of time, then try and calculate the transfer function below.</p>

\[H(s) = \frac{\left[ \frac{C_1}{C_B}s^2 + \frac{G_2}{C_B}s + (\frac{G_1G_3}{C_A C_B})\right]}{\left[ s^2  + \frac{G_5}{C_B}s + \frac{G_3 G_4}{C_A C_B}\right]}\]

<p>Active resistor capacitor filters are made with OTAs (high output impedance) or OPAMP
(low output impedance). Active amplifiers will consume current, and in Active-RC 
the amplifiers are always on, so there is no opportunity to reduce the current
consumption by duty-cycling (turning on and off).</p>

<p>Both resistors and capacitors vary on an integrated circuit, and the
3-sigma variation can easily be 20 %.</p>

<p>The pole or zero frequency of an Active-RC filter is proportional to the inverse of the 
product between R and C</p>

\[\omega_{p|z} \propto \frac{G}{C} = \frac{1}{RC}\]

<p>As a result, the total variation of the pole or zero frequency is can have a 
3-sigma value of</p>

\[\sigma_{RC} = \sqrt{ \sigma_R^2 + \sigma_C^2 } = \sqrt{0.02^2 + 0.02^2} = 0.028 = 28 \text{ \%}\]

<p>On an IC we sometimes need to calibrate the R or C in production 
to get an accurate RC time constant.</p>

<p>We cannot physically change an IC, every single one of the 100 million copies
of an IC is from the same Mask set. That’s why ICs are cheap. To make the Mask set is 
incredibility expensive (think 5 million dollars), but a copy made from the Mask set can cost one dollar or less. To calibrate we need additional circuits.</p>

<p>Imagine we need a resistor of 1 kOhm. We could create that by parallel connection
of larger resistors, or series connection of smaller resistors. Since we know the maximum
variation is 0.02, then we need to be able to calibrate away +- 20 Ohms. We could have
a 980 kOhm resistor, and then add ten 4 Ohm resistors in series that we can short 
with a transistor switch.</p>

<p>But is a resolution of 4 Ohms accurate enough? What if we need a precision of 0.1%?
Then we would need to tune the resistor within +-1 Ohm, so we might need 80 0.5 Ohm
resistors.</p>

<p>But how large is the on-resistance of the transistor switch? Would that 
also affect our precision?</p>

<p>But is the calibration step linear with addition of the transistors? If we have a non-linear 
calibration step, then we cannot use gradient decent calibration algorithms, nor can we
use binary search.</p>

<p>Analog designers need to deal with an almost infinite series of “But”.</p>

<p>The experienced designer will know when to stop, when is the “But what if” not 
a problem anymore.</p>

<p>The most common error in analog integrated circuit design is a “I did not imagine that 
my circuit could fail in this manner” type of problem. Or, not following the line of “But”’s far enough.</p>

<p>But if we follow all the “But”’s we will never tapeout!</p>

<p>Active-RC filters are great for linearity, but if we need accurate time constant, there are better alternatives.</p>

<h1 id="gm-c">Gm-C</h1>

<p><img src="/aic2024/assets/media/l4_gmcbi.svg" alt="" width="700" /></p>

\[H(s) = \frac{\left[ s^2\frac{C_X}{C_X + C_B} + s\frac{G_{m5}}{C_X + C_B} + \frac{G_{m2}G_{m4}}{C_A(C_X + C_B)}\right]}
{\left[s^2 + s\frac{G_{m2}}{C_X + C_B} + \frac{G_{m1}G_{m2}}{C_A(C_X + C_B)} \right]}\]

<p>The pole and zero frequency of a Gm-C filter is</p>

\[\omega_{p|z} \propto \frac{G_m}{C}\]

<p>The transconductance accuracy depends on the circuit, and the bias circuit, so we can’t give a general, applies for all circuits, sigma number. 
Capacitors do have 3-sigma 20 % variation, usually.</p>

<p>Same as Active-RC, Gm-C need calibration to get accurate pole or zero frequency.</p>

<h1 id="switched-capacitor">Switched capacitor</h1>

<p>The first time you encounter Switched Capacitor (SC) circuits, they do require some brain training. So let’s start simple.</p>

<p>Consider the circuit below. Assume that the two transistors are ideal (no-charge injection, no resistance).</p>

<p><img src="/aic2024/assets/media/l05_fund1.svg" alt="" width="700" /></p>

<p>For SC circuits, we need to consider the charge on the capacitors, and how they change with time.</p>

<p>The charge on the capacitor at the end <sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup> of phase 2 is</p>

\[Q_{\phi2\$} = C_1 V_{GND}  = 0\]

<p>while at the end of phase 1</p>

\[Q_{\phi1\$} = C_1 V_{I}\]

<p>The impedance, from <a href="https://en.wikipedia.org/wiki/Ohm%27s_law">Ohm’s law</a> is</p>

\[Z_{I} = (V_{I} - V_{GND})/I_{I}\]

<p>And from <a href="https://analogicus.com/aic2024/2023/10/26/A-refresher.html#there-are-standard-units-of-measurement">SI units</a> units we can see current is</p>

\[I_{I} = \frac{Q}{dt} = Q f_{\phi}\]

<p>Charge cannot disappear, <a href="https://en.wikipedia.org/wiki/Charge_conservation">charge is conserved</a>.  As such, the charge going out from the input must be equal 
to the difference of charge at the end of phase 1 and phase 2.</p>

\[Z_{I} = \frac{V_{I} - V_{GND}}{\left(Q_{\phi1\$} - Q_{\phi2\$}\right) f_{\phi}}\]

<p>Inserting for the charges, we can see that the impedance is</p>

\[Z_{I} = \frac{V_{I}}{\left(V_{I} C  - 0 \right) f_{\phi}} = \frac{1}{C_1 f_\phi}\]

<p>A common confusion with SC circuits is to confuse the impedance of a capacitor $Z = 1/sC$ with the impedance of a SC circuit $Z = 1/fC$.
The impedance of a capacitor is complex (varies with frequency and time), while the SC circuit impedance is real (a resistance).</p>

<p>The main difference between the two is that the impedance of a capacitor is continuous in time, while the SC circuit is a discrete time circuit, and 
has a discrete time impedance.</p>

<p>The circuit below is drawn slightly differently, but the same equation applies.</p>

<p><img src="/aic2024/assets/media/l05_fund2.svg" alt="" width="700" /></p>

<p>If we compute the impedance.</p>

\[Z_{I} = \frac{V_{I} - V_{O}}{\left(Q_{\phi1\$} - Q_{\phi2\$}\right) f_{\phi}}\]

\[Q_{\phi1\$} = C_1 (V_I - V_O)\]

\[Q_{\phi2\$} = 0\]

\[Z_{I} = \frac{V_{I} - V_{O}}{\left(C_1 (V_I - V_O)\right) f_{\phi}} = \frac{1}{C_1 f_\phi}\]

<p>Which should not be surprising, as all I’ve done is to rotate the circuit and call $V_{GND} = V_0$.</p>

<p>Let’s try the circuit below.</p>

<p><img src="/aic2024/assets/media/l05_fund3.svg" alt="" width="700" /></p>

\[Z_{I} = \frac{ V_{I} - V_{O} }{ \left(Q_{\phi1\$} - Q_{\phi2\$}\right) f_{\phi}}\]

\[Q_{\phi1\$} = C_1 V_I )\]

\[Q_{\phi2\$} = C_1 V_O\]

<p>Inserted into the impedance we get the same result.</p>

\[Z_{I} = \frac{V_{I} - V_{O}}{\left(C_1 V_I - C_1 V_O)\right) f_{\phi}} = \frac{1}{C_1 f_\phi}\]

<p>The first time I saw the circuit above it was not obvious to me that the impedance still was $Z = 1/Cf$. It’s one of the cases where 
mathematics is a useful tool. I could follow a set of rules (charge conservation), and as long as I did the mathematics right, then from the equations, I
could see how it worked.</p>

<h2 id="an-example-sc-circuit">An example SC circuit</h2>

<p>An example use of an SC circuit is</p>

<p><a href="https://ieeexplore.ieee.org/document/1052843">A pipelined 5-Msample/s 9-bit analog-to-digital converter</a></p>

<p>Shown in the figure below. You should think of the switched capacitor circuit as 
similar to a an amplifier with constant gain. We can use two resistors and an opamp 
to create a gain. Imagine we create a circuit without the switches, and 
with a resistor of $R$ from input to virtual ground, and $4R$ in the feedback. Our Active-R would 
have a gain of $A = 4$.</p>

<p>The switches disconnect the OTA and capacitors for half the time, but for the other half,
at least for the latter parts of $\phi_2$ the gain is four.</p>

<p><img src="/aic2024/assets/media/lewis.png" alt="" width="700" /></p>

<p>The output is only correct for a finite, but periodic, 
time interval. The circuit is discrete time. As long as all circuits afterwards 
also have a discrete-time input, then it’s fine. An ADC can sample the output from the amplifier
at the right time, and never notice that the output is shorted to a DC voltage in $\phi_1$</p>

<p>We charge the capacitor $4C$ to the 
differential input voltage in $\phi_1$</p>

\[Q_1 = 4 C V_{in}\]

<p>Then we turn off $\phi_1$, which opens all switches. The charge on $4C$ will still be $Q_1$ 
(except for higher order effects like charge injection from switches).</p>

<p>After a short time (non-overlap), we turn on $\phi_2$, closing some of the switches.
The OTA will start to force its two inputs to be the same voltage, and we short the left side of 
$4C$. After some time we would have the same voltage on the left side of $4C$ for the
two capacitors, and another voltage on the right side of the $4C$ capacitors. The two 
capacitors must now have the same charge, so the difference in charge, or differential charge
must be zero.</p>

<p>Physics tell us that charge is conserved, so our differential charge $Q_1$ cannot vanish into thin air.
The difference in electrons that made $Q_1$ must be somewhere in our circuit.</p>

<p>Assume the designer of the circuit has done a proper job, then the $Q_1$ charge 
will be found on the feedback capacitors.</p>

<p>We now have a $Q_1$ charge on smaller capacitors, so the differential output voltage must be</p>

\[Q_1 = 4 C V_{in} = Q_2 = C V_{out}\]

<p>The gain is</p>

\[A = \frac{V_{out}}{V_{in}} = 4\]

<p>Why would we go to all this trouble to get a gain of 4?</p>

<p>In general, we can sum up with the following equation.</p>

\[\omega_{p|z} \propto \frac{C_1}{C_2}\]

<p>We can use these “switched capacitor resistors”  to get pole or zero frequency or gain proportional to a the relative size of capacitors, which is a 
fantastic feature. Assume we make two identical capacitors in our layout. We won’t know the absolute size of the capacitors on the 
integrated circuit, whether the $C_1$ is 100 fF or 80 fF, but 
we can be certain that if $C_1 = 80$ fF, then $C_2 = 80$ fF to a precision of around 0.1 %.</p>

<p>With switched capacitor amplifiers we can set an accurate gain, and we can set an accurate pole and zero frequency (as long as we have an accurate clock and a high
DC gain OTA).</p>

<p>The switched capacitor circuits do have a drawback. They are discrete time circuits.  As such, we must treat them with caution, and they will always need 
some analog filter before to avoid a phenomena we call aliasing.</p>

<h1 id="discrete-time-signals">Discrete-Time Signals</h1>

<p>An random, Gaussian, continuous time, continuous value, signal has infinite information. The frequency can be anywhere from zero to infinity, 
the value have infinite levels, and the time division is infinitely small. We cannot store such a signal. We have to quantize.</p>

<p>If we quantize time to $T = 1\text{ ns}$, such that we only record the value of the signal every 1 ns, 
what happens to all the other information? The stuff that changes at 0.5 ns or 0.1 ns, or 1 ns.</p>

<p>We can always guess, but it helps to know, as in absolutely know, what happens. That’s where mathematics come in. 
With mathematics we can prove things, and know we’re correct.</p>

<h2 id="the-mathematics">The mathematics</h2>

<p>Define \(x_c\) as a continuous time, continuous value signal</p>

<p>Define \(\ell(t) = \begin{cases}
1 &amp; \text{if } t \geq 0 \\
0 &amp; \text{if } t &lt; 0
\end{cases}\)</p>

<p>Define \(x_{sn}(t) = \frac{x_c(nT)}{\tau}[\ell(t-nT) - \ell(t - nT - \tau)]\)</p>

<p>where $x_{sn}(t)$ is a function of the continuous time signal at the time interval $nT$.</p>

<p>Define \(x_s(t) = \sum_{n=-\infty}^{\infty}{x_{sn}(t)}\)</p>

<p>where $x_s(t)$ is the sampled, continuous time, signal.</p>

<p>Think of a sampled version of an analog signal as an infinite sum of pulse trains where the area under the pulse train is equal to the analog signal.</p>

<p><strong>Why do this?</strong></p>

<p>With a exact definition of a sampled signal in the time-domain it’s sometimes possible to find the Laplace transform, and see how the frequency 
spectrum looks.</p>

<p>If \(x_s(t) = \sum_{n=-\infty}^{\infty}{x_{sn}(t)}\)</p>

<p>Then \(X_{sn}(s) = \frac{1}{\tau}\frac{1 - e^{-s\tau}}{s} x_c(nT)e^{-snT}\)</p>

<p>And  \(X_s(s) = \frac{1}{\tau}\frac{1 - e^{-s\tau}}{s} \sum_{n=-\infty}^{\infty}x_c(nT)e^{-snT}\)</p>

<p>Thus \(\lim_{\tau \to 0} \rightarrow X_s(s) = \sum_{n=-\infty}^{\infty}x_c(nT)e^{-snT}\)</p>

<p>Or \(X_s(j\omega) = \frac{1}{T}\sum_{k=-\infty}^{\infty} X_c\left(j\omega - \frac{j k 2 \pi}{T}\right)\)</p>

<p><strong>The spectrum of a sampled signal is an infinite sum of frequency shifted spectra</strong></p>

<p>or equivalently</p>

<p><strong>When you sample a signal, then there will be copies of the input spectrum at every \(nf_s\)</strong></p>

<p>However, if you do an FFT of a sampled signal, then all those infinite spectra will fold down between \(0 \to f_{s1}/2\) or \(- f_{s1}/2 \to f_{s1}/2\) for a complex FFT</p>

<h2 id="python-discrete-time-example">Python discrete time example</h2>

<p>If your signal processing skills are a bit thin, now might be a good time to read up on <a href="https://en.wikipedia.org/wiki/Fast_Fourier_transform">FFT</a>,
<a href="https://en.wikipedia.org/wiki/Laplace_transform">Laplace transform</a> and <a href="https://www.youtube.com/watch?v=spUNpyF58BY">But what is the Fourier Transform?</a></p>

<p>In python we can create a demo and see what happens when we “sample” an “continuous time” signal. Hopefully it’s obvious that it’s impossible to emulate a “continuous time”
signal on a digital computer. After all, it’s digital (ones and zeros), and it has a clock!</p>

<p>We can, however, emulate to any precision we want.</p>

<p>The code below has four main sections. First is the time vector. I use <a href="https://numpy.org">Numpy</a>, which has a bunch of useful 
features for creating ranges, and arrays.</p>

<p>Secondly, I create continuous time signal. The time vector can be used in numpy functions, like <code class="language-plaintext highlighter-rouge">np.sin()</code>, and I combine three sinusoid plus some noise. 
The sampling vector is a repeating pattern of 11001100, so our sample rate should be 1/2’th of the input sample rate. 
FFT’s can be unwieldy beasts. I like to use <a href="https://en.wikipedia.org/wiki/Talk%3ACoherent_sampling">coherent sampling</a>, however, with 
multiple signals and samplerates I did not bother to figure out whether it was possible.</p>

<p>The alternative to coherent sampling is to apply a window function before the FFT, that’s the reason for the 
Hanning window below.</p>

<p><a href="https://github.com/wulffern/aic2024/blob/main/ex/dt.py">dt.py</a></p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">#- Create a time vector
</span><span class="n">N</span> <span class="o">=</span> <span class="mi">2</span><span class="o">**</span><span class="mi">13</span>
<span class="n">t</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="n">linspace</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="n">N</span><span class="p">,</span><span class="n">N</span><span class="p">)</span>

<span class="c1">#- Create the "continuous time" signal with multiple 
#- "sinusoidal signals and some noise
</span><span class="n">f1</span> <span class="o">=</span> <span class="mi">233</span><span class="o">/</span><span class="n">N</span>
<span class="n">fd</span> <span class="o">=</span> <span class="mi">1</span><span class="o">/</span><span class="n">N</span><span class="o">*</span><span class="mi">119</span>
<span class="n">x_s</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">np</span><span class="p">.</span><span class="n">pi</span><span class="o">*</span><span class="n">f1</span><span class="o">*</span><span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="o">/</span><span class="mi">1024</span><span class="o">*</span><span class="n">np</span><span class="p">.</span><span class="n">random</span><span class="p">.</span><span class="n">randn</span><span class="p">(</span><span class="n">N</span><span class="p">)</span> <span class="o">+</span> \
    <span class="mf">0.5</span><span class="o">*</span><span class="n">np</span><span class="p">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">np</span><span class="p">.</span><span class="n">pi</span><span class="o">*</span><span class="p">(</span><span class="n">f1</span><span class="o">-</span><span class="n">fd</span><span class="p">)</span><span class="o">*</span><span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="mf">0.5</span><span class="o">*</span><span class="n">np</span><span class="p">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">np</span><span class="p">.</span><span class="n">pi</span><span class="o">*</span><span class="p">(</span><span class="n">f1</span><span class="o">+</span><span class="n">fd</span><span class="p">)</span><span class="o">*</span><span class="n">t</span><span class="p">)</span>

<span class="c1">#- Create the sampling vector, and the sampled signal
</span><span class="n">t_s_unit</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span>
<span class="n">t_s</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="n">tile</span><span class="p">(</span><span class="n">t_s_unit</span><span class="p">,</span><span class="nb">int</span><span class="p">(</span><span class="n">N</span><span class="o">/</span><span class="nb">len</span><span class="p">(</span><span class="n">t_s_unit</span><span class="p">)))</span>
<span class="n">x_sn</span> <span class="o">=</span> <span class="n">x_s</span><span class="o">*</span><span class="n">t_s</span>

<span class="c1">#- Convert to frequency domain with a hanning window to avoid FFT bin
#- energy spread
</span><span class="n">Hann</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">if</span><span class="p">(</span><span class="n">Hann</span><span class="p">):</span>
    <span class="n">w</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="n">hanning</span><span class="p">(</span><span class="n">N</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
    <span class="n">w</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="n">ones</span><span class="p">(</span><span class="n">N</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span>
<span class="n">X_s</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="n">fft</span><span class="p">.</span><span class="n">fftshift</span><span class="p">(</span><span class="n">np</span><span class="p">.</span><span class="n">fft</span><span class="p">.</span><span class="n">fft</span><span class="p">(</span><span class="n">np</span><span class="p">.</span><span class="n">multiply</span><span class="p">(</span><span class="n">w</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="n">N</span><span class="p">],</span><span class="n">x_s</span><span class="p">)))</span>
<span class="n">X_sn</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="n">fft</span><span class="p">.</span><span class="n">fftshift</span><span class="p">(</span><span class="n">np</span><span class="p">.</span><span class="n">fft</span><span class="p">.</span><span class="n">fft</span><span class="p">(</span><span class="n">np</span><span class="p">.</span><span class="n">multiply</span><span class="p">(</span><span class="n">w</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="n">N</span><span class="p">],</span><span class="n">x_sn</span><span class="p">)))</span>
</code></pre></div></div>

<p>Try to play with the code, and see if you can understand what it does.</p>

<p>Below are the plots. On the left side is the “continuous value, continuous time” emulation, on the right side 
“discrete time, continuous value”.</p>

<p>The top plots are the time domain, while the bottom plots is frequency domain.</p>

<p>The FFT is complex, so that’s why there are six sinusoids bottom left. The “0 Hz” would be at x-axis index 4096 ($2^{13}/2$).</p>

<p>The spectral copies can be seen bottom right. How many spectral copies, and the distance between them will depend on the sample rate (length of <code class="language-plaintext highlighter-rouge">t_s_unit</code>). 
Try to play around with the code and see what happens.</p>

<p><img src="/aic2024/assets/media/l5_dtfig.svg" alt="" width="700" /></p>

<h2 id="aliasing-bandwidth-and-sample-rate-theory">Aliasing, bandwidth and sample rate theory</h2>

<p>I want you to internalize that the spectral copies are real. They are not some “mathematical construct” that we don’t have to deal with.</p>

<p>They are what happens when we sample a signal into discrete time. 
Imagine a signal with a band of interest as shown below in Green. We sample at $f_s$. The pink and red unwanted signals do
not disappear after sampling, even though they are above the Nyquist frequency ($f_s/2$). They fold around $f_s/2$, and in may 
appear in-band. That’s why it’s important to band limit analog signals before they are sampled.</p>

<p><img src="/aic2024/assets/media/l5_sh.svg" alt="" width="700" /></p>

<p>With an anti-alias filter (yellow) we ensure that the unwanted components are low enough before sampling. As a result, 
our wanted signal (green) is undisturbed.</p>

<p><img src="/aic2024/assets/media/l5_shaaf.svg" alt="" width="700" /></p>

<p>Assume that we we’re interested in the red signal. We could still use a sample rate of $f_s$. 
If we bandpass-filtered all but the red signal the red signal would fold on sampling, as shown in the figure below.</p>

<p>Remember that the <a href="https://en.wikipedia.org/wiki/Nyquist–Shannon_sampling_theorem">Nyquist-Shannon</a> states that a sufficient 
no-loss condition is to sample signals with a sample rate of twice the bandwidth of the signal.</p>

<p>Nyquist-Shannon has been extended for sparse signals, compressed sensing, and non-uniform sampling to demonstrate that it’s 
sufficient for the average sample rate to be twice the bandwidth. 
One 2009 paper <a href="https://ieeexplore.ieee.org/document/4749297">Blind Multiband Signal Reconstruction: Compressed Sensing for Analog Signal</a> is 
a good place to start to delve into the latest on signal reconstruction.</p>

<p><img src="/aic2024/assets/media/l5_subsample.svg" alt="" width="700" /></p>

<h2 id="z-transform">Z-transform</h2>

<p>Someone got the idea that writing</p>

\[X_s(s) = \sum_{n=-\infty}^{\infty}x_c(nT)e^{-snT}\]

<p>was cumbersome, and wanted to find something better.</p>

\[X_s(z) = \sum_{n=-\infty}^{\infty}x_c[n]z^{-n}\]

<p>For discrete time signal processing we use Z-transform</p>

<p>If you’re unfamiliar with the Z-transform, read the book or search <a href="https://en.wikipedia.org/wiki/Z-transform">https://en.wikipedia.org/wiki/Z-transform</a></p>

<p>The nice thing with the Z-transform is that the exponent of the z tell’s you how much delayed the sample $x_c[n]$ is. 
A block that delays a signal by 1 sample could be described as $x_c[n] z^{-1}$, and an accumulator</p>

\[y[n] = y[n-1] + x[n]\]

<p>in the Z domain would be</p>

\[Y(z) = z^{-1}Y(z) + X(z)\]

<p>With a Z-domain transfer function of</p>

\[\frac{Y(z)}{X(z)} = \frac{1}{1 - z^{-1}}\]

<h2 id="pole-zero-plots">Pole-Zero plots</h2>

<p>If you’re not comfortable with pole/zero plots, have a look at</p>

<p><a href="https://www.youtube.com/watch?v=n2y7n6jw5d0">What does the Laplace Transform really tell us</a></p>

<p>Think about the pole/zero plot as a surface 
your looking down onto.  At $a = 0$ we have the steady state fourier transform. 
The “x” shows the complex frequency where the fourier transform goes to infinity.</p>

<p>Any real circuit will have complex conjugate, or real, poles/zeros. A combination of two real circuits where one path is shifted 
90 degrees in phase can have non-conjugate complex poles/zeros.</p>

<p>If the “x” is $a&lt;0$, then any perturbation will eventually die out. 
If the “x” is on the $a=0$ line, then we have a oscillator that will ring forever. If the “x” is  $a&gt;0$ then the oscillation amplitude
will grow without bounds, although, only in Matlab. In any physical circuit an oscillation cannot grow without bounds forever.</p>

<p>Growing without bounds is the same as “being unstable”.</p>

<p><img src="/aic2024/assets/media/l5_sdomain.svg" alt="" width="700" /></p>

<h2 id="z-domain">Z-domain</h2>

<p>Spectra repeat every \(2\pi\)</p>

<p>As such, it does not make sense to talk about a plane with a $a$ and a $j\omega$. Rather we use the complex number $z = a + jb$.</p>

<p>As long as the poles (“x”) are within the unit circle, oscillations will die out. If the poles are on the unit-circle, then we 
have an oscillator. Outside the unit circle the oscillation will grow without bounds, or in other words, be unstable.</p>

<p>We can translate between Laplace-domain and Z-domain with the 
Bi-linear transform</p>

\[s = \frac{z -1}{z + 1}\]

<p><sub>Warning: First-order approximation <a href="https://en.wikipedia.org/wiki/Bilinear_transform">https://en.wikipedia.org/wiki/Bilinear_transform</a></sub></p>

<p><img src="/aic2024/assets/media/l5_zdomain.svg" alt="" width="700" /></p>

<h2 id="first-order-filter">First order filter</h2>

<p>Assume a first order filter given by the discrete time equation.</p>

\[y[n+1] = bx[n] + ay[n] \Rightarrow Y z = b X + a Y\]

<p>The “n” index and the “z” exponent can be chosen freely, which sometimes can help the algebra.</p>

\[y[n] = b x[n-1] + ay[n-1] \Rightarrow Y = b X z^{-1} + a Y z^{-1}\]

<p>The transfer function can be computed as</p>

\[H(z) = \frac{b}{z-a}\]

<p>From the discrete time equation we can see that the impulse will never die out. We’re adding the previous output to the current input.
That means the circuit has infinite memory. Accordingly, filters of this type are known as. 
Infinite-impulse response (IIR)</p>

\[h[n] = \begin{cases} k &amp; \text{if } n &lt; 1 \\ a^{n-1}b + a^n k &amp; \text{if } n \geq 1 \end{cases}\]

<p><sub> Head’s up: Fig 13.12 in AIC is wrong </sub></p>

<p>From the impulse response it can be seen that if $a &gt; 1$, then the filter is unstable. Same if $b &gt; 1$. As long as $|a + jb| &lt; 1$
the filter should be stable.</p>

<p><img src="/aic2024/assets/media/l5_zunstable.svg" alt="" width="700" /></p>

<p>The first order filter can be implemented in python, and it’s really not hard. See below. The $x_sn$ vector is from the previous
python example.</p>

<p>There are smarter, and faster ways to do IIR filters (and FIR) in python, see <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.iirfilter.html">scipy.signal.iirfilter</a></p>

<p>From the plot below we can see the sampled time domain and spectra on the left, and the filtered time domain and spectra on the right.</p>

<p><a href="https://github.com/wulffern/aic2024/blob/main/ex/iir.py">iir.py</a></p>

<p><img src="/aic2024/assets/media/l5_iir.svg" alt="" width="700" /></p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">#- IIR filter
</span><span class="n">b</span> <span class="o">=</span> <span class="mf">0.3</span>
<span class="n">a</span> <span class="o">=</span> <span class="mf">0.25</span>
<span class="n">z</span> <span class="o">=</span> <span class="n">a</span> <span class="o">+</span> <span class="mf">1j</span><span class="o">*</span><span class="n">b</span>
<span class="n">z_abs</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="nb">abs</span><span class="p">(</span><span class="n">z</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="s">"|z| = "</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">z_abs</span><span class="p">))</span>
<span class="n">y</span> <span class="o">=</span> <span class="n">np</span><span class="p">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">N</span><span class="p">)</span>
<span class="n">y</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">a</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="n">N</span><span class="p">):</span>
    <span class="n">y</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">b</span><span class="o">*</span><span class="n">x_sn</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">y</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
</code></pre></div></div>

<p>The IIR filter we implemented above is a low-pass filter, and the filter partially rejects the copied spectra, as expected.</p>

<h2 id="finite-impulse-responsefir">Finite-impulse response(FIR)</h2>

<p>FIR filters are unconditionally stable, since the impulse response
will always die out. FIR filters are a linear sum of delayed inputs.</p>

<p>In my humble opinion, there is nothing wrong with an IIR. Yes, the could become unstable, however, they can be designed safely.
I’m not sure there is a theological feud on IIR vs FIR, I suspect there could be. Talk to someone that knows digital filters better than me.</p>

<p>But be wary of rules like “IIR are always better than FIR” or visa versa. Especially if statements are written in books. Remember that 
the book was probably written a decade ago, and based on papers two decades old, which were based on three decades old state of the art. 
Our abilities to use computers for design has improved a bit the last three decades.</p>

\[H(z) = \frac{1}{3}\sum_{i=0}^2 z^{-1}\]

<p><img src="/aic2024/assets/media/l5_fir.svg" alt="" width="700" /></p>

<h1 id="switched-capacitor-1">Switched-Capacitor</h1>

<p>Below is an example of a switched-capacitor circuit during phase 1.
Think of the two phases as two different configurations of a circuit, each with a specific purpose.</p>

<p><img src="/aic2024/assets/media/l5_scintro1.svg" alt="" width="700" /></p>

<p>This is the SC circuit during the sampling phase. Imagine that we somehow have stored a voltage 
$V_1 = \ell$ on capacitor $C_1$ (the switches for
that sampling or storing are not shown). The charge on $C_1$ is</p>

\[Q_{1\phi_1\$} = C_1 V_1\]

<p>The $C_2$ capacitor is shorted, as such, $V_2 = 0$, which must mean that the charge on $C_2$ given by</p>

\[Q_{2\phi_1\$} = 0\]

<p>The voltage at the negative input of the OTA must be 0 V, as the positive input is 0 V, and we assume the circuit has settled all transients.</p>

<p>Imagine we (very carefully) open the circuit around $C_2$ and close the circuit from the negative side of $C_1$ to the OTA negative input, as shown below.</p>

<p><img src="/aic2024/assets/media/l5_scintro2.svg" alt="" width="700" /></p>

<p>It’s the OTA that ensures that the negative input is the same as the positive input, but the OTA cannot be infinitely fast. 
At the same time, the voltage across $C_1$ cannot change instantaneously. 
Neither can the voltage across $C_2$. As such, the voltage at the negative input must immediately go to $-V_1$ (ignoring any parasitic capacitance at the negative input).</p>

<p>The OTA does not like it’s inputs to be different, so it will start to charge $C_2$ to increase the voltage at the negative input to the OTA.
When the negative input reaches 0 V the OTA is happy again.  At that point the charge on $C_1$ is</p>

\[Q_{1\phi_2\$} = 0\]

<p>A key point is, that even the voltages now have changed, there is zero volt across $C_1$, and thus there cannot be any charge across $C_1$ the charge that 
was there cannot have disappeared. The negative input of the OTA is a high impedance node, and cannot supply charge. The charge must have gone somewhere, but where?</p>

<p>In process of changing the voltage at the negative input of the OTA we’ve changed the voltage across $C_2$. The voltage change must exactly match 
the charge that was across $C_1$, as such</p>

\[Q_{2\phi_2\$} = Q_{1\phi_1\$} = C_1 V_1 = C_2 V_2\]

<p>thus</p>

\[\frac{V_2}{V_1} = \frac{C_1}{C_2}\]

<h2 id="switched-capacitor-gain-circuit">Switched capacitor gain circuit</h2>

<p>Redrawing the previous circuit, and adding a few more switches we can create a switched capacitor gain circuit.</p>

<p>There is now a switch to sample the input voltage across $C_1$ during phase 1 and reset $C_2$. 
During phase 2 we configure the circuit to leverage the OTA to do the charge transfer from $C_1$ to $C_2$.</p>

<p><img src="/aic2024/assets/media/l5_scamp.svg" alt="" width="700" /></p>

<p>The discrete time output from the circuit will be as shown below. It’s only at the end of the second phase that the 
output signal is valid. As a result, it’s common to use the sampling phase of the next circuit close to the end of phase 2.</p>

<p>For charge to be conserved the clocks for the switch phases must never be high at the same time.</p>

<p><img src="/aic2024/assets/media/l5_scfig.svg" alt="" width="700" /></p>

<p>The discrete time, Z-domain and transfer function is shown below. The transfer function tells us that the circuit is equivalent to a gain, and a delay 
of one clock cycle. The cool thing about switch capacitor circuits is that the precision of the gain is set by the relative size between two capacitors. 
In most technologies that relative sizing can be better than 0.1 %.</p>

<p>Gain circuits like the one above find use in most Pipelined ADCs, and are common, with some modifications, in Sigma-Delta ADCs.</p>

\[V_o[n+1] = \frac{C_1}{C_2}V_i[n]\]

\[V_o z = \frac{C_1}{C_2} V_i\]

\[\frac{V_o}{V_i} = H(z) = \frac{C_1}{C_2}z^{-1}\]

<h2 id="switched-capacitor-integrator">Switched capacitor integrator</h2>

<p>Removing one switch we can change the function of the switched capacitor gain circuit. If we don’t reset $C_2$ then we 
accumulate the input charge every cycle.</p>

<p><img src="/aic2024/assets/media/l5_scint.svg" alt="" width="700" /></p>

<p>The output now will grow without bounds, so integrators are most often used in filter circuits, or sigma-delta ADCs where there 
is feedback to control the voltage swing at the output of the OTA.</p>

<p><img src="/aic2024/assets/media/l5_scifig.svg" alt="" width="700" /></p>

<p>Make sure you read and understand the equations below, it’s good to realize that discrete time equations, Z-domain and transfer functions
in the Z-domain are actually easy.</p>

\[V_o[n] = V_o[n-1] + \frac{C_1}{C_2}V_i[n-1]\]

\[V_o - z^{-1}V_o = \frac{C_1}{C_2}z^{-1}V_i\]

<p>Maybe one confusing thing is that multiple transfer functions can mean the same thing, as below.</p>

\[H(z) = \frac{C_1}{C_2}\frac{z^{-1}}{1-z^{-1} } =
\frac{C_1}{C_2}\frac{1}{z-1}\]

<h2 id="noise">Noise</h2>

<p>Capacitors don’t make noise, but switched-capacitor circuits do have noise. The noise comes from the thermal, flicker, burst noise in the switches
and OTA’s. Both phases of the switched capacitor circuit contribute noise. As such, the output noise of a SC circuit is usually</p>

\[V_n^2 &gt; \frac{2 k T}{C}\]

<p>I find that sometimes it’s useful with a repeat of mathematics, and since we’re talking about noise.</p>

<p>The mean, or average of a signal is defined as</p>

<p><a href="https://en.wikipedia.org/wiki/Mean">Mean</a>
\(\overline{x(t)} = \lim_{T\to\infty} \frac{1}{T}\int^{+T/2}_{-T/2}{ x(t) dt}\)</p>

<p>Define</p>

<p>Mean Square
\(\overline{x^2(t)} = \lim_{T\to\infty} \frac{1}{T}\int^{+T/2}_{-T/2}{ x^2(t) dt}\)</p>

<p>How much a signal varies can be estimated from the 
<a href="https://en.wikipedia.org/wiki/Variance">Variance</a>
\(\sigma^2 = \overline{x^2(t)} - \overline{x(t)}^2\)</p>

<p>where \(\sigma\) is the standard deviation.
If mean is removed, or is zero, then
\(\sigma^2 = \overline{x^2(t)}\)</p>

<p>Assume two random processes, \(x_1(t)\) and \(x_2(t)\) with mean of zero (or removed).
 \(x_{tot}(t) =  x_1(t) + x_2(t)\)
 \(x_{tot}^2(t) = x_1^2(t) + x_2^2(t) + 2x_1(t)x_2(t)\)</p>

<p>Variance (assuming mean of zero) 
\(\sigma^2_{tot} = \lim_{T\to\infty} \frac{1}{T}\int^{+T/2}_{-T/2}{ x_{tot}^2(t) dt}\)
\(\sigma^2_{tot} = \sigma_1^2 + \sigma_2^2 + \lim_{T\to\infty} \frac{1}{T}\int^{+T/2}_{-T/2}{ 2x_1(t)x_2(t) dt}\)</p>

<p><strong>Assuming uncorrelated processes (covariance is zero), then
\(\sigma^2_{tot} = \sigma_1^2 + \sigma_2^2\)</strong></p>

<p>In other words, if two noises are uncorrelated, then we can sum the variances. If the noise sources are correlated, for example, noise comes from the same transistor, 
but takes two different paths through the circuit, then we cannot sum the variances. We must also add the co-variance.</p>

<h2 id="sub-circuits-for-sc-circuits">Sub-circuits for SC-circuits</h2>

<p>Switched-capacitor circuits are so common that it’s good to delve a bit deeper, and understand the variants of the components that make up SC circuits.</p>

<h3 id="ota">OTA</h3>

<p>At the heart of the SC circuit we usually find an OTA. Maybe a current mirror, folded cascode, recycling cascode, or my favorite: <a href="https://github.com/wulffern/cnr_ota_sky130nm/tree/main">a fully differential current 
mirror OTA with cascoded, gain boosted, output stage using a parallel common mode feedback</a>.</p>

<p>Not all SC circuits use OTAs, there are also <a href="https://link.springer.com/article/10.1007/s10470-010-9576-3">comparator based SC circuits</a>.</p>

<p>Below is a fully-differential two-stage OTA that will work with most SC circuits. The notation “24F1F25” means “the width is 24 F” and “length is 1.25 F”, where “F”
is the minimum gate length in that technology.</p>

<p><img src="/aic2024/assets/media/diff_ota.png" alt="" width="700" /></p>

<p>As bias circuit to make the voltages the below will work</p>

<p><img src="/aic2024/assets/media/diff_ota_bias.png" alt="" width="700" /></p>

<h3 id="switches">Switches</h3>

<p>If your gut reaction is “switches, that’s easy”, then you’re very wrong. Switches can be incredibly complicated. All switches will be made of transistors,
but usually we don’t have enough headroom to use a single NMOS or PMOS. We may need a transmission gate</p>

<p><img src="/aic2024/assets/media/l5_sw1.svg" alt="" width="700" /></p>

<p>The challenge with transmission gates is that when the voltage at the input is in the middle between VDD and ground then both PMOS and NMOS, although they are on
, they might not be that on. Especially in nano-scale CMOS with a 0.8 V supply and 0.5 V threshold voltage.
The resistance mid-rail might be too large.</p>

<p>For switched-capacitor circuits we must settle the voltages to the required accuracy. In general</p>

\[t &gt; -\log(\text{error} ) \tau\]

<p>For example, for a 10-bit ADC we need $t &gt; -\log(1/1024) \tau = 6.9\tau$. This means we need to wait at least 6.9 time constants for the voltage
to settle to 10-bit accuracy in the switched capacitor circuit.</p>

<p>Assume the capacitors are large due to noise, then the switches must be low resistance for a reasonable time constant. Larger switches have 
smaller resistance, however, they also have more charge in the inversion layer, which leads to charge injection when the switches are turned of.
Accordingly, larger switches are not always the solution.</p>

<p>Sometimes it may be sufficient to switch the bulks, as shown on the left below. But more often that one would like, we have to implement bootstrapped switches
as shown on the right.</p>

<p><img src="/aic2024/assets/media/l5_sw2.svg" alt="" width="700" /></p>

<p>The switch I used in my <a href="https://ieeexplore.ieee.org/document/7906479">JSSC SAR</a> is a fully differential boostrapped switch with 
cross coupled dummy transistors. The JSSC SAR I’ve also ported to GF130NM, as shown below. The switch is at the bottom.</p>

<p><a href="https://github.com/wulffern/sun_sar9b_sky130nm">wulffern/sun_sar9b_sky130nm</a></p>

<p><img src="/aic2024/assets/media/l00_SAR9B_CV.png" alt="" width="700" /></p>

<p>looks like the one below.</p>

<p><img src="/aic2024/assets/media/l5_sw3.svg" alt="" width="700" /></p>

<h3 id="non-overlapping-clocks">Non-overlapping clocks</h3>

<p>The non-overlap generator is standard. Use the one shown below. Make sure you simulate that the non-overlap is sufficient in all corners.</p>

<p><img src="/aic2024/assets/media/l5_novl.svg" alt="" width="700" /></p>

<h2 id="example">Example</h2>

<p>In the circuit below there is an example of a switched capacitor circuit used to increase the $\Delta V_{D}$ across the resistor. We can accurately
set the gain, and thus the equation for the differential output will be</p>

\[V_O(z) = 10 \frac{kT}{q} \ln (N)z^{-1}\]

<p><img src="/aic2024/assets/media/l5_scex.svg" alt="" width="700" /></p>

<h1 id="want-to-learn-more">Want to learn more?</h1>

<p><a href="https://ieeexplore.ieee.org/document/4749297">Blind Multiband Signal Reconstruction: Compressed Sensing for Analog Signal</a></p>

<p><a href="https://link.springer.com/article/10.1007/s10470-010-9576-3">Comparator-based switched-capacitor pipelined analog-to-digital converter with comparator preset, and comparator delay compensation</a></p>

<p><a href="https://ieeexplore.ieee.org/document/7906479">A Compiled 9-bit 20-MS/s 3.5-fJ/conv.step SAR ADC in 28-nm FDSOI for Bluetooth Low Energy Receivers</a></p>

<p><a href="https://ieeexplore.ieee.org/document/5437496">A 10-bit 50-MS/s SAR ADC With a Monotonic Capacitor Switching Procedure</a></p>

<p><a href="https://ieeexplore.ieee.org/document/4768910">Low Voltage, Low Power, Inverter-Based Switched-Capacitor Delta-Sigma Modulator</a></p>

<p><a href="https://ieeexplore.ieee.org/document/6373760">Ring Amplifiers for Switched Capacitor Circuits</a></p>

<p><a href="A Switched-Capacitor RF Power Amplifier">A Switched-Capacitor RF Power Amplifier</a></p>

<p><a href="https://ieeexplore.ieee.org/document/6650076">Design of Active N-Path Filters</a></p>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:1" role="doc-endnote">
      <p>I use the $ to mark the end of the period. It comes from <a href="https://en.wikipedia.org/wiki/Regular_expression">Regular Expressions</a>. <a href="#fnref:1" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Carsten Wulff</name><email>carsten@wulff.no</email></author><summary type="html"><![CDATA[If you find an error in what I’ve made, then fork, fix lectures/l05_sc.md, commit, push and create a pull request. That way, we use the global brain power most efficiently, and avoid multiple humans spending time on discovering the same error.]]></summary></entry></feed>