<script data-pm-proxy="intercept"></script><?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[Bit Banging Bytes]]></title><description><![CDATA[Low Level Engineering]]></description><link>https://bitbangingbytes.substack.com</link><image><url>https://substackcdn.com/image/fetch/$s_!u3a5!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbitbangingbytes.substack.com%2Fimg%2Fsubstack.png</url><title>Bit Banging Bytes</title><link>https://bitbangingbytes.substack.com</link></image><generator>Substack</generator><lastBuildDate>Tue, 01 Sep 2026 11:32:56 GMT</lastBuildDate><atom:link href="/__u/bitbangingbytes.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Rohan Verma]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[bitbangingbytes@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[bitbangingbytes@substack.com]]></itunes:email><itunes:name><![CDATA[always_ff_rohan]]></itunes:name></itunes:owner><itunes:author><![CDATA[always_ff_rohan]]></itunes:author><googleplay:owner><![CDATA[bitbangingbytes@substack.com]]></googleplay:owner><googleplay:email><![CDATA[bitbangingbytes@substack.com]]></googleplay:email><googleplay:author><![CDATA[always_ff_rohan]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[From Taylor Series to Silicon: Building and Debugging a ROM-less CORDIC]]></title><description><![CDATA[How we fixed our chip by lying to it]]></description><link>https://bitbangingbytes.substack.com/p/from-taylor-series-to-silicon-building</link><guid isPermaLink="false">https://bitbangingbytes.substack.com/p/from-taylor-series-to-silicon-building</guid><dc:creator><![CDATA[always_ff_rohan]]></dc:creator><pubDate>Sun, 16 Aug 2026 21:54:30 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!ZW59!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5279ef35-d66d-441d-bacf-eb9c046fa67e_3072x4096.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Last year we taped out a ROM-less CORDIC engine on the Tiny Tapeout sky25a shuttle: a 2&#215;2 tile on SkyWater&#8217;s sky130 process, computing sin and cos of a 16-bit fixed-point angle over SPI. The silicon is back and it works. First full 0&#8211;360&#176; sweep, 100 out of 100 angles passed.</p><p>This project started with a fairly simple goal: build a <strong>CORDIC engine small enough to fit comfortably into a Tiny Tapeout ASIC</strong>, without spending silicon area on a ROM full of arctangent constants.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://bitbangingbytes.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Bit Banging Bytes! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!ZW59!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5279ef35-d66d-441d-bacf-eb9c046fa67e_3072x4096.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!ZW59!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5279ef35-d66d-441d-bacf-eb9c046fa67e_3072x4096.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!ZW59!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5279ef35-d66d-441d-bacf-eb9c046fa67e_3072x4096.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!ZW59!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5279ef35-d66d-441d-bacf-eb9c046fa67e_3072x4096.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!ZW59!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5279ef35-d66d-441d-bacf-eb9c046fa67e_3072x4096.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!ZW59!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5279ef35-d66d-441d-bacf-eb9c046fa67e_3072x4096.jpeg" width="1456" height="1941" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5279ef35-d66d-441d-bacf-eb9c046fa67e_3072x4096.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1941,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:507602,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://bitbangingbytes.substack.com/i/210915006?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5279ef35-d66d-441d-bacf-eb9c046fa67e_3072x4096.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!ZW59!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5279ef35-d66d-441d-bacf-eb9c046fa67e_3072x4096.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!ZW59!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5279ef35-d66d-441d-bacf-eb9c046fa67e_3072x4096.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!ZW59!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5279ef35-d66d-441d-bacf-eb9c046fa67e_3072x4096.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!ZW59!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5279ef35-d66d-441d-bacf-eb9c046fa67e_3072x4096.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>There is something deeply satisfying about making a mathematical function run in hardware. You start with an equation. Then you turn it into an algorithm. Then RTL. Then gates. Then, eventually, you are staring at a physical chip wondering whether the thing you wrote almost an year ago actually works.</p><p>On a software project you find the bug, patch it, move on. On silicon the bug is printed. You live with it, you re-spin (months, real money), or you find a back door.</p><p>This post is about the back door, but it starts with the design, because the back door only exists thanks to one decision made at design time. The fix that shipped is two constants in the SPI packet. Mean error down 7.9&#215;, RMS down 6.8&#215;. Getting there took some careful error decomposition, plus a detour through an unrelated SPI problem where every value the chip returned was exactly half of the right answer.</p><div><hr></div><h2>Why CORDIC?</h2><p>CORDIC&#8212;Coordinate Rotation Digital Computer is one of those algorithms that looks almost suspiciously well suited to hardware.</p><p>Instead of calculating sine and cosine using multipliers, divisions, or large lookup tables, CORDIC repeatedly performs very simple operations:</p><ul><li><p>add/subtract</p></li><li><p>arithmetic shifts</p></li><li><p>compare the accumulated angle</p></li></ul><p>At each iteration, the vector is rotated by an elementary angle: atan(2&#8315;&#8305;)</p><p>The corresponding iteration can be written approximately as:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\nx_{i+1}=x_i-\\sigma_i(y_i >> i)\n\n&quot;,&quot;id&quot;:&quot;XRXYZSTKBM&quot;}" data-component-name="LatexBlockToDOM"></div><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\n\n\ny_{i+1}=y_i+\\sigma_i(x_i >> i)\n\n&quot;,&quot;id&quot;:&quot;BCDVGCXDYL&quot;}" data-component-name="LatexBlockToDOM"></div><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\n\n\nz_{i+1}=z_i-\\sigma_i\\theta_i\n&quot;,&quot;id&quot;:&quot;LWMTCAFJQZ&quot;}" data-component-name="LatexBlockToDOM"></div><p>where &#952;&#7522; = atan(2&#8315;&#8305;) and &#963;&#7522; determines the direction of rotation. This is exactly the kind of arithmetic digital hardware likes</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!7LcU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca104d4a-f701-4983-9aa6-84ef9cd91287_4200x3000.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!7LcU!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca104d4a-f701-4983-9aa6-84ef9cd91287_4200x3000.png 424w, /__u/substackcdn.com/image/fetch/$s_!7LcU!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca104d4a-f701-4983-9aa6-84ef9cd91287_4200x3000.png 848w, /__u/substackcdn.com/image/fetch/$s_!7LcU!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca104d4a-f701-4983-9aa6-84ef9cd91287_4200x3000.png 1272w, /__u/substackcdn.com/image/fetch/$s_!7LcU!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca104d4a-f701-4983-9aa6-84ef9cd91287_4200x3000.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!7LcU!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca104d4a-f701-4983-9aa6-84ef9cd91287_4200x3000.png" width="1200" height="857.1428571428571" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ca104d4a-f701-4983-9aa6-84ef9cd91287_4200x3000.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:1040,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:844220,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://bitbangingbytes.substack.com/i/210915006?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca104d4a-f701-4983-9aa6-84ef9cd91287_4200x3000.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-large" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!7LcU!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca104d4a-f701-4983-9aa6-84ef9cd91287_4200x3000.png 424w, /__u/substackcdn.com/image/fetch/$s_!7LcU!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca104d4a-f701-4983-9aa6-84ef9cd91287_4200x3000.png 848w, /__u/substackcdn.com/image/fetch/$s_!7LcU!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca104d4a-f701-4983-9aa6-84ef9cd91287_4200x3000.png 1272w, /__u/substackcdn.com/image/fetch/$s_!7LcU!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca104d4a-f701-4983-9aa6-84ef9cd91287_4200x3000.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Figure 1: Six micro-rotations converging on 30&#176;. Each arc is one atan(2&#8315;&#8305;) step; the chip runs 13.</figcaption></figure></div><p>Each micro-rotation is by a fixed elementary angle atan(2&#8315;&#8305;), chosen because rotating by that particular angle costs only shifts and adds, no multipliers. Pick the direction of each rotation from the sign of the remaining angle, run the iterations, and the vector converges onto (cos &#952;, sin &#952;). It&#8217;s the algorithm inside decades of calculators and DDS chips, and it needs exactly one lookup table: the list of elementary angles.</p><p>But there is a catch.</p><p>The algorithm needs the elementary angles.</p><p>The conventional implementation therefore has a small lookup table containing values such as:</p><pre><code><code>atan(1)       = 0.785398...
atan(1/2)     = 0.463647...
atan(1/4)     = 0.244979...
atan(1/8)     = 0.124355...
...</code></code></pre><p>On an FPGA, throwing a ROM at this problem is easy.</p><p>On a tiny ASIC?</p><p>Every bit of storage matters.</p><p>So we asked a slightly annoying question:</p><p><strong>Can we get rid of the ROM entirely?</strong></p><div><hr></div><h1>The ROM-less idea</h1><p>The key observation is that the elementary angles become extremely well behaved as the iteration number increases.</p><p>For small (x),</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\arctan(x)=x-\\frac{x^3}{3}+\\frac{x^5}{5}-\\cdots&quot;,&quot;id&quot;:&quot;MWWMJWRHIG&quot;}" data-component-name="LatexBlockToDOM"></div><p>and our CORDIC only needs:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;x=2^{-i}&quot;,&quot;id&quot;:&quot;GEVJRFWXOV&quot;}" data-component-name="LatexBlockToDOM"></div><p></p><p>So instead of storing a table, we can generate the elementary angles mathematically.</p><p>The first few values are the difficult ones.</p><p>After that, 2&#8315;&#8305; becomes such a good approximation to atan(2&#8315;&#8305;) at our 12-bit fractional precision that the difference effectively disappears after quantization.</p><p>The exact values used for comparison are:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!9C8B!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff87fe39a-4cfd-4d74-8e1c-f9b2b140142d_1240x846.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!9C8B!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff87fe39a-4cfd-4d74-8e1c-f9b2b140142d_1240x846.png 424w, /__u/substackcdn.com/image/fetch/$s_!9C8B!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff87fe39a-4cfd-4d74-8e1c-f9b2b140142d_1240x846.png 848w, /__u/substackcdn.com/image/fetch/$s_!9C8B!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff87fe39a-4cfd-4d74-8e1c-f9b2b140142d_1240x846.png 1272w, /__u/substackcdn.com/image/fetch/$s_!9C8B!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff87fe39a-4cfd-4d74-8e1c-f9b2b140142d_1240x846.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!9C8B!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff87fe39a-4cfd-4d74-8e1c-f9b2b140142d_1240x846.png" width="1240" height="846" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f87fe39a-4cfd-4d74-8e1c-f9b2b140142d_1240x846.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:846,&quot;width&quot;:1240,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:88639,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://bitbangingbytes.substack.com/i/210915006?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff87fe39a-4cfd-4d74-8e1c-f9b2b140142d_1240x846.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!9C8B!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff87fe39a-4cfd-4d74-8e1c-f9b2b140142d_1240x846.png 424w, /__u/substackcdn.com/image/fetch/$s_!9C8B!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff87fe39a-4cfd-4d74-8e1c-f9b2b140142d_1240x846.png 848w, /__u/substackcdn.com/image/fetch/$s_!9C8B!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff87fe39a-4cfd-4d74-8e1c-f9b2b140142d_1240x846.png 1272w, /__u/substackcdn.com/image/fetch/$s_!9C8B!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff87fe39a-4cfd-4d74-8e1c-f9b2b140142d_1240x846.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Figure 2: arctangent v/s LSB codes</figcaption></figure></div><p>The important part is that we don&#8217;t need to store these numbers.</p><p>We can generate them.</p><p>That is the trick behind the ROM-less implementation. </p><div><hr></div><h1>Designing for a Tiny Tapeout</h1><p>ROM-less implementation doesn&#8217;t have the table. What it has instead is four small Verilog modules behind five wires: an SPI slave, a transaction FSM, an angle generator, and a single CORDIC processing element that gets reused for every iteration. </p><p>Numbers are Q3.12 fixed point throughout, 12 fractional bits, 1 LSB = 1/4096 &#8776; 2.44e-4.</p><p>The CORDIC uses signed fixed-point values with 12 fractional bits&#8212;effectively a Q3.12 representation.</p><p>The ASIC interface is deliberately minimal:</p><p><strong>Inputs</strong></p><ul><li><p>SCLK</p></li><li><p>MOSI</p></li><li><p>CS_N</p></li></ul><p><strong>Outputs</strong></p><ul><li><p>MISO</p></li><li><p>INTERRUPT</p></li></ul><p></p><h4>How RTL works</h4><p><span>ROM-less CORDIC implementation with 16-bit signed fixed-point input Q3.16 (1 sign bit, 3 integer bits, and 12 fraction bits). This core comprises mainly (i) a single-stage CORDIC engine that operates in rotation mode for computing </span>cos<span> and </span>sin<span> of input angle </span>&#952;<span>, and (ii) an </span>arctan<span> generator that generates the micro-rotation angles dynamically in each clock cycle for the corresponding iteration.</span></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!d_V8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F656ab109-3561-43c5-885e-62a7ae7a0182_3040x2800.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!d_V8!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F656ab109-3561-43c5-885e-62a7ae7a0182_3040x2800.png 424w, /__u/substackcdn.com/image/fetch/$s_!d_V8!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F656ab109-3561-43c5-885e-62a7ae7a0182_3040x2800.png 848w, /__u/substackcdn.com/image/fetch/$s_!d_V8!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F656ab109-3561-43c5-885e-62a7ae7a0182_3040x2800.png 1272w, /__u/substackcdn.com/image/fetch/$s_!d_V8!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F656ab109-3561-43c5-885e-62a7ae7a0182_3040x2800.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!d_V8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F656ab109-3561-43c5-885e-62a7ae7a0182_3040x2800.png" width="1456" height="1341" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/656ab109-3561-43c5-885e-62a7ae7a0182_3040x2800.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1341,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:506990,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://bitbangingbytes.substack.com/i/210915006?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F656ab109-3561-43c5-885e-62a7ae7a0182_3040x2800.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!d_V8!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F656ab109-3561-43c5-885e-62a7ae7a0182_3040x2800.png 424w, /__u/substackcdn.com/image/fetch/$s_!d_V8!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F656ab109-3561-43c5-885e-62a7ae7a0182_3040x2800.png 848w, /__u/substackcdn.com/image/fetch/$s_!d_V8!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F656ab109-3561-43c5-885e-62a7ae7a0182_3040x2800.png 1272w, /__u/substackcdn.com/image/fetch/$s_!d_V8!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F656ab109-3561-43c5-885e-62a7ae7a0182_3040x2800.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Figure 3: CORDIC in RTL</figcaption></figure></div><p>The host sends four 16-bit values to design:  atan_0<code>,</code>alpha<code>,</code>x<code>,</code>y<code> </code>and receives:  alpha<code>,</code>cos(theta)<code>,</code>sin(theta)</p><p>The core itself runs at 50 MHz.</p><p>The resulting layout occupies roughly: <strong>334.88 &#181;m &#215; 225.76 &#181;m, </strong>with <strong>4042 standard cells</strong>, excluding fill and tap cells, and approximately <strong>41.2% routing utilization</strong>. The design&#8217;s specified maximum clock frequency is 50 MHz.</p><p>For a mathematical accelerator that started life as an equation on a whiteboard, seeing an actual piece of silicon emerge from it is pretty cool.</p><p>But the real test was still ahead.</p><h4>Angles generated, not stored</h4><p>The angle generator, `dynamic_atan`, produces one coefficient per iteration in lockstep with the engine, and it treats the iterations in three regimes.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!fO-c!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec566d08-b150-446a-af64-9939feeca2fe_1597x1165.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!fO-c!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec566d08-b150-446a-af64-9939feeca2fe_1597x1165.png 424w, /__u/substackcdn.com/image/fetch/$s_!fO-c!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec566d08-b150-446a-af64-9939feeca2fe_1597x1165.png 848w, /__u/substackcdn.com/image/fetch/$s_!fO-c!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec566d08-b150-446a-af64-9939feeca2fe_1597x1165.png 1272w, /__u/substackcdn.com/image/fetch/$s_!fO-c!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec566d08-b150-446a-af64-9939feeca2fe_1597x1165.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!fO-c!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec566d08-b150-446a-af64-9939feeca2fe_1597x1165.png" width="1456" height="1062" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ec566d08-b150-446a-af64-9939feeca2fe_1597x1165.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1062,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:161443,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://bitbangingbytes.substack.com/i/210915006?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec566d08-b150-446a-af64-9939feeca2fe_1597x1165.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!fO-c!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec566d08-b150-446a-af64-9939feeca2fe_1597x1165.png 424w, /__u/substackcdn.com/image/fetch/$s_!fO-c!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec566d08-b150-446a-af64-9939feeca2fe_1597x1165.png 848w, /__u/substackcdn.com/image/fetch/$s_!fO-c!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec566d08-b150-446a-af64-9939feeca2fe_1597x1165.png 1272w, /__u/substackcdn.com/image/fetch/$s_!fO-c!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec566d08-b150-446a-af64-9939feeca2fe_1597x1165.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Figure 4: The three regimes of the angle generator, and the per-stage cost of the approximation. Stage 1 is the outlier; part two of this post is about that bar.</figcaption></figure></div><p>Iteration 0 doesn&#8217;t compute anything. atan(2&#8304;) = 45&#176; is where a short Taylor series is at its worst, so the design sidesteps the problem entirely: the value arrives from outside, over SPI, as `i_atan_0`, packed into every transaction next to x, y and the target angle. At design time this was a convenience. Remember it; it turns out to be the whole story.</p><p>Iterations 1 through 5 use the two-term expansion atan(x) &#8776; x &#8722; x&#179;/3, and the 1/3 is itself built from shifts:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!5I0q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd473852a-28a8-4971-9d9c-6edd14365527_2604x1016.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!5I0q!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd473852a-28a8-4971-9d9c-6edd14365527_2604x1016.png 424w, /__u/substackcdn.com/image/fetch/$s_!5I0q!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd473852a-28a8-4971-9d9c-6edd14365527_2604x1016.png 848w, /__u/substackcdn.com/image/fetch/$s_!5I0q!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd473852a-28a8-4971-9d9c-6edd14365527_2604x1016.png 1272w, /__u/substackcdn.com/image/fetch/$s_!5I0q!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd473852a-28a8-4971-9d9c-6edd14365527_2604x1016.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!5I0q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd473852a-28a8-4971-9d9c-6edd14365527_2604x1016.png" width="1456" height="568" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d473852a-28a8-4971-9d9c-6edd14365527_2604x1016.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:568,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:166273,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://bitbangingbytes.substack.com/i/210915006?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd473852a-28a8-4971-9d9c-6edd14365527_2604x1016.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!5I0q!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd473852a-28a8-4971-9d9c-6edd14365527_2604x1016.png 424w, /__u/substackcdn.com/image/fetch/$s_!5I0q!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd473852a-28a8-4971-9d9c-6edd14365527_2604x1016.png 848w, /__u/substackcdn.com/image/fetch/$s_!5I0q!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd473852a-28a8-4971-9d9c-6edd14365527_2604x1016.png 1272w, /__u/substackcdn.com/image/fetch/$s_!5I0q!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd473852a-28a8-4971-9d9c-6edd14365527_2604x1016.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Figure 5: Taylor series approximation in RTL</figcaption></figure></div><p>A geometric-series approximation of the coefficient, inside a Taylor approximation of the function. There is no multiplier anywhere in this chip.</p><p>From iteration 6 onward there&#8217;s no series at all, because at 12 fractional bits atan(2&#8315;&#8305;) and 2&#8315;&#8305; round to the same code. The generator just emits the shift. The design docs quantify what all this approximating costs: a MATLAB model over 1000 samples put the mean absolute output error at 0.003. Hold that number for later.</p><p></p><h4>One engine, thirteen passes</h4><p>This design instantiates the element once and iterates in place. The inner loop is three registered shift-adds:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!bga9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58bdae65-ce85-4418-b72a-fb81408c38b7_2676x836.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!bga9!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58bdae65-ce85-4418-b72a-fb81408c38b7_2676x836.png 424w, /__u/substackcdn.com/image/fetch/$s_!bga9!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58bdae65-ce85-4418-b72a-fb81408c38b7_2676x836.png 848w, /__u/substackcdn.com/image/fetch/$s_!bga9!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58bdae65-ce85-4418-b72a-fb81408c38b7_2676x836.png 1272w, /__u/substackcdn.com/image/fetch/$s_!bga9!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58bdae65-ce85-4418-b72a-fb81408c38b7_2676x836.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!bga9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58bdae65-ce85-4418-b72a-fb81408c38b7_2676x836.png" width="1456" height="455" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/58bdae65-ce85-4418-b72a-fb81408c38b7_2676x836.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:455,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:143232,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://bitbangingbytes.substack.com/i/210915006?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58bdae65-ce85-4418-b72a-fb81408c38b7_2676x836.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!bga9!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58bdae65-ce85-4418-b72a-fb81408c38b7_2676x836.png 424w, /__u/substackcdn.com/image/fetch/$s_!bga9!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58bdae65-ce85-4418-b72a-fb81408c38b7_2676x836.png 848w, /__u/substackcdn.com/image/fetch/$s_!bga9!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58bdae65-ce85-4418-b72a-fb81408c38b7_2676x836.png 1272w, /__u/substackcdn.com/image/fetch/$s_!bga9!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F58bdae65-ce85-4418-b72a-fb81408c38b7_2676x836.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Figure 6: shift-add micro-rotations in RTL</figcaption></figure></div><p>with all three signs flipping together when the direction bit says rotate the other way. A result costs the 13 iterations plus a few cycles of housekeeping, under twenty core clocks, roughly 350 ns at 50 MHz. On a 2&#215;2 Tiny Tapeout tile the trade is obvious: latency is irrelevant next to the SPI transaction wrapping it, and area is what you actually pay for. Unrolling would multiply the datapath thirteen-fold to gain throughput that nothing downstream could use.</p><p></p><h4>Folding the circle</h4><p>A rotation CORDIC only converges within the sum of its elementary angles, which for this configuration is &#931; atan(2&#8315;&#8305;) &#8776; 99.9&#176;. Feed it 200&#176; and the angle accumulator saturates, the direction bits stop carrying information, and the output is garbage. Not gracefully degraded garbage, either. So the full circle gets folded into the first quadrant before the rotator sees it, and unfolded after.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!z_4k!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe05a53ce-5fe6-4f81-ac88-2e0a885c8238_2054x1034.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!z_4k!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe05a53ce-5fe6-4f81-ac88-2e0a885c8238_2054x1034.png 424w, /__u/substackcdn.com/image/fetch/$s_!z_4k!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe05a53ce-5fe6-4f81-ac88-2e0a885c8238_2054x1034.png 848w, /__u/substackcdn.com/image/fetch/$s_!z_4k!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe05a53ce-5fe6-4f81-ac88-2e0a885c8238_2054x1034.png 1272w, /__u/substackcdn.com/image/fetch/$s_!z_4k!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe05a53ce-5fe6-4f81-ac88-2e0a885c8238_2054x1034.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!z_4k!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe05a53ce-5fe6-4f81-ac88-2e0a885c8238_2054x1034.png" width="728" height="366.5" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e05a53ce-5fe6-4f81-ac88-2e0a885c8238_2054x1034.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;normal&quot;,&quot;height&quot;:733,&quot;width&quot;:1456,&quot;resizeWidth&quot;:728,&quot;bytes&quot;:200928,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://bitbangingbytes.substack.com/i/210915006?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe05a53ce-5fe6-4f81-ac88-2e0a885c8238_2054x1034.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!z_4k!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe05a53ce-5fe6-4f81-ac88-2e0a885c8238_2054x1034.png 424w, /__u/substackcdn.com/image/fetch/$s_!z_4k!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe05a53ce-5fe6-4f81-ac88-2e0a885c8238_2054x1034.png 848w, /__u/substackcdn.com/image/fetch/$s_!z_4k!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe05a53ce-5fe6-4f81-ac88-2e0a885c8238_2054x1034.png 1272w, /__u/substackcdn.com/image/fetch/$s_!z_4k!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe05a53ce-5fe6-4f81-ac88-2e0a885c8238_2054x1034.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Figure 7: Fold in with three fixed-point comparisons, unfold out with swap-and-negate. The dashed wedge is the engine&#8217;s convergence range.</figcaption></figure></div><p>The fold costs three subtractions and some wiring. The input angle is compared against &#960;/2, &#960; and 3&#960;/2 (0x1922, 0x3244, 0x4B66 in Q3.12) by checking the sign bits of the three differences. Two small boolean equations turn those sign bits into a 2-bit quadrant code, and the matching difference becomes the folded angle. On the way out, the quadrant code selects a swap-and-negate of the cos/sin pair: Q2 returns (&#8722;sin, cos), Q3 returns (&#8722;cos, &#8722;sin), Q4 returns (sin, &#8722;cos). Swapping is wiring and negation is a two&#8217;s complement, so the unfold introduces no rounding at all. Silicon later confirmed this directly: across a fine sweep, the sin output is the cos sequence displaced by exactly 90&#176;, code for code.</p><h4>Five wires and a byte protocol</h4><p>The entire chip interface is SPI plus one interrupt: SCLK, MOSI and CS in, MISO and a data-ready line out. Five wires. </p><p>Below shows the four steps as they appear on the wire -</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!x6dy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffdb17a0-ac32-4708-934e-500ad26787ac_2460x1500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!x6dy!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffdb17a0-ac32-4708-934e-500ad26787ac_2460x1500.png 424w, /__u/substackcdn.com/image/fetch/$s_!x6dy!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffdb17a0-ac32-4708-934e-500ad26787ac_2460x1500.png 848w, /__u/substackcdn.com/image/fetch/$s_!x6dy!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffdb17a0-ac32-4708-934e-500ad26787ac_2460x1500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!x6dy!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffdb17a0-ac32-4708-934e-500ad26787ac_2460x1500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!x6dy!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffdb17a0-ac32-4708-934e-500ad26787ac_2460x1500.png" width="1200" height="731.8681318681319" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ffdb17a0-ac32-4708-934e-500ad26787ac_2460x1500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:888,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:315534,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://bitbangingbytes.substack.com/i/210915006?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffdb17a0-ac32-4708-934e-500ad26787ac_2460x1500.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:&quot;center&quot;,&quot;offset&quot;:false}" class="sizing-large" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!x6dy!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffdb17a0-ac32-4708-934e-500ad26787ac_2460x1500.png 424w, /__u/substackcdn.com/image/fetch/$s_!x6dy!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffdb17a0-ac32-4708-934e-500ad26787ac_2460x1500.png 848w, /__u/substackcdn.com/image/fetch/$s_!x6dy!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffdb17a0-ac32-4708-934e-500ad26787ac_2460x1500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!x6dy!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fffdb17a0-ac32-4708-934e-500ad26787ac_2460x1500.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Figure 8: Everything on the chip, with one computation traced &#9312;&#8211;&#9315;: operands in over MOSI, the folded engine&#8217;s 13 passes fed by dynamic_atan, the interrupt, results back over MISO. Below shows the same four steps as they appear on the wire.</figcaption></figure></div><p>The SPI slave is deliberately boring, in the good way. Nothing inside the design runs on SCLK. The slave treats SCLK and CS as asynchronous data, passes each through a three-flop synchronizer clocked at the 50 MHz core clock, detects edges, and does all its shifting in the core domain:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!kdcZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b389a10-62f0-4062-85e0-d3671ad6c362_2604x656.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!kdcZ!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b389a10-62f0-4062-85e0-d3671ad6c362_2604x656.png 424w, /__u/substackcdn.com/image/fetch/$s_!kdcZ!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b389a10-62f0-4062-85e0-d3671ad6c362_2604x656.png 848w, /__u/substackcdn.com/image/fetch/$s_!kdcZ!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b389a10-62f0-4062-85e0-d3671ad6c362_2604x656.png 1272w, /__u/substackcdn.com/image/fetch/$s_!kdcZ!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b389a10-62f0-4062-85e0-d3671ad6c362_2604x656.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!kdcZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b389a10-62f0-4062-85e0-d3671ad6c362_2604x656.png" width="1456" height="367" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3b389a10-62f0-4062-85e0-d3671ad6c362_2604x656.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:367,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:119697,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://bitbangingbytes.substack.com/i/210915006?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b389a10-62f0-4062-85e0-d3671ad6c362_2604x656.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!kdcZ!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b389a10-62f0-4062-85e0-d3671ad6c362_2604x656.png 424w, /__u/substackcdn.com/image/fetch/$s_!kdcZ!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b389a10-62f0-4062-85e0-d3671ad6c362_2604x656.png 848w, /__u/substackcdn.com/image/fetch/$s_!kdcZ!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b389a10-62f0-4062-85e0-d3671ad6c362_2604x656.png 1272w, /__u/substackcdn.com/image/fetch/$s_!kdcZ!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3b389a10-62f0-4062-85e0-d3671ad6c362_2604x656.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Figure 9: 3-flop synchronizer in RTL</figcaption></figure></div><p>One clock domain, no gated clocks, no metastability windows, fixed SPI mode-0 behaviour. This is the textbook-safe way to build an SPI slave in an ASIC. Hold this for later.</p><p>On top of the slave sits a six-state transaction FSM: idle, receive, wait, load, transmit, done. Eight bytes in (x, y, angle, &#945;&#8320;, low byte first), then the engine runs, then the data-ready pin goes high so the host doesn&#8217;t have to poll, then six bytes clock back out: sin, cos, and the converged angle accumulator, which should come back near zero and doubles as a health check. CS going high resets the FSM for the next transaction.</p><p></p><h4>From MATLAB to GDS</h4><p>Verification before tape-out ran four rungs. A MATLAB model established the math and the 0.003 error budget. An Icarus/GTKWave testbench swept 999 angles from a stimulus file through the RTL and diffed the cos/sin outputs against golden values. The standard Tiny Tapeout cocotb bench ran the design at RTL and again at gate level after hardening. <span>As said, micro-rotation angles were generated using Taylor's series approximation; it is found that the mean absolute error between actual and computed value is </span>0.003<span> for </span>1000<span> samples</span></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!RrxJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48ea4eaa-9b90-4ca6-b623-bb548bdbf7be_1918x1021.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!RrxJ!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48ea4eaa-9b90-4ca6-b623-bb548bdbf7be_1918x1021.png 424w, /__u/substackcdn.com/image/fetch/$s_!RrxJ!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48ea4eaa-9b90-4ca6-b623-bb548bdbf7be_1918x1021.png 848w, /__u/substackcdn.com/image/fetch/$s_!RrxJ!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48ea4eaa-9b90-4ca6-b623-bb548bdbf7be_1918x1021.png 1272w, /__u/substackcdn.com/image/fetch/$s_!RrxJ!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48ea4eaa-9b90-4ca6-b623-bb548bdbf7be_1918x1021.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!RrxJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48ea4eaa-9b90-4ca6-b623-bb548bdbf7be_1918x1021.png" width="1456" height="775" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/48ea4eaa-9b90-4ca6-b623-bb548bdbf7be_1918x1021.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:775,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;MATLAB_comparison_result.png&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="MATLAB_comparison_result.png" title="MATLAB_comparison_result.png" srcset="/__u/substackcdn.com/image/fetch/$s_!RrxJ!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48ea4eaa-9b90-4ca6-b623-bb548bdbf7be_1918x1021.png 424w, /__u/substackcdn.com/image/fetch/$s_!RrxJ!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48ea4eaa-9b90-4ca6-b623-bb548bdbf7be_1918x1021.png 848w, /__u/substackcdn.com/image/fetch/$s_!RrxJ!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48ea4eaa-9b90-4ca6-b623-bb548bdbf7be_1918x1021.png 1272w, /__u/substackcdn.com/image/fetch/$s_!RrxJ!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F48ea4eaa-9b90-4ca6-b623-bb548bdbf7be_1918x1021.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Figure 10: MATLAB simulation with Mean absolute error 0.003 </figcaption></figure></div><p>Then, before committing to a shuttle, the design went onto three FPGAs. A Digilent CMOD A7 (Artix-7), driven over Linux spidev. A ULX3S 85F (ECP5), built with a fully open yosys &#8594; nextpnr &#8594; ecppack flow, with a Pico as the SPI master at a gentle 20 kHz and timestamped regression JSONs committed to the repo. And Vaaman, Vicharak&#8217;s Efinix Trion T120 + RK3399 board, which is fitting given how much of the math and RTL came from their team. Same byte protocol, essentially the same Python regression script on all three. That script is the direct ancestor of the silicon harness in the rest of this post.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!nzX4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9695f635-06ef-4fdd-86bb-aac776953cb9_3349x2258.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!nzX4!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9695f635-06ef-4fdd-86bb-aac776953cb9_3349x2258.png 424w, /__u/substackcdn.com/image/fetch/$s_!nzX4!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9695f635-06ef-4fdd-86bb-aac776953cb9_3349x2258.png 848w, /__u/substackcdn.com/image/fetch/$s_!nzX4!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9695f635-06ef-4fdd-86bb-aac776953cb9_3349x2258.png 1272w, /__u/substackcdn.com/image/fetch/$s_!nzX4!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9695f635-06ef-4fdd-86bb-aac776953cb9_3349x2258.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!nzX4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9695f635-06ef-4fdd-86bb-aac776953cb9_3349x2258.png" width="1456" height="982" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9695f635-06ef-4fdd-86bb-aac776953cb9_3349x2258.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:982,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1303440,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://bitbangingbytes.substack.com/i/210915006?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9695f635-06ef-4fdd-86bb-aac776953cb9_3349x2258.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!nzX4!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9695f635-06ef-4fdd-86bb-aac776953cb9_3349x2258.png 424w, /__u/substackcdn.com/image/fetch/$s_!nzX4!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9695f635-06ef-4fdd-86bb-aac776953cb9_3349x2258.png 848w, /__u/substackcdn.com/image/fetch/$s_!nzX4!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9695f635-06ef-4fdd-86bb-aac776953cb9_3349x2258.png 1272w, /__u/substackcdn.com/image/fetch/$s_!nzX4!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9695f635-06ef-4fdd-86bb-aac776953cb9_3349x2258.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Hardening was the near-stock Tiny Tapeout OpenLane flow: 20 ns clock constraint, 60% placement density target, routing capped at met4. The result is a 2&#215;2 tile, 334.88 &#215; 225.76 &#181;m, 4,042 standard cells, 41.2% routing utilization, closing timing at 50 MHz.</p><div><hr></div><h1>Don&#8217;t trust simulation</h1><p>One of the things that became important after this project was separating three different questions:</p><ol><li><p>Does the mathematics work?</p></li><li><p>Does the RTL work?</p></li><li><p>Does the physical chip work?</p></li></ol><p>They are not the same question. For silicon bring-up, we built a dedicated test harness around an <strong>RP2350</strong>. The host runs MicroPython and acts as the SPI master.</p><p>For every test angle, it:</p><ol><li><p>generates the input vector,</p></li><li><p>sends the CORDIC transaction,</p></li><li><p>waits for the data-ready interrupt,</p></li><li><p>reads back sine and cosine,</p></li><li><p>converts the fixed-point result,</p></li><li><p>compares it against a double-precision software reference.</p></li></ol><p>And then we sweep the angle. Not just five test vectors. A full sweep of 250 angles</p><p>The harness repository contains the characterization scripts, measurement data, reports, plots, and logic-analyzer decoding tools.</p><div><hr></div><h1>First silicon: it works... but badly</h1><p>The first characterization run was actually encouraging.</p><p>The chip worked. SPI interface worked (with SPI Master@4-6 MHz). CORDIC converged. The outputs looked like sine and cosine.</p><p>100/100 angles functionally passed the regression test in 0.746 seconds.</p><p>The baseline numbers were:</p><pre><code><code>Mean absolute error : 3.292e-3
RMS error           : 3.553e-3
Peak error          : 5.741e-3</code></code></pre><p>In Q3.12 terms, that is roughly:</p><pre><code><code>Mean absolute error : 13.5 LSB
RMS                  : 14.6 LSB
Peak                 : 23.5 LSB</code></code></pre><p>The quantization floor of a 12-bit fractional representation is only 0.5 LSB. We were sitting around <strong>47&#215; above the theoretical quantization floor</strong>.</p><p>Before calling that a defect, look back at the design section (Figure 10) . The MATLAB model simulated the Taylor generation at 0.003 mean absolute error, and the silicon measured 0.00329. The chip was doing almost exactly what its own documentation said it would. </p><p>The real question was whether the SPI host could beat the documentation, and answering it starts with a change of coordinates, because raw error-vs-angle plots are where debugging goes to die.</p><div><hr></div><h1>Separate gain error from phase error</h1><p>The first useful debugging step was to stop looking at &#8220;CORDIC error&#8221; as one number.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!cwJG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75e49bc5-4614-4bd7-884c-6988fd537f1a_3000x4000.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!cwJG!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75e49bc5-4614-4bd7-884c-6988fd537f1a_3000x4000.png 424w, /__u/substackcdn.com/image/fetch/$s_!cwJG!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75e49bc5-4614-4bd7-884c-6988fd537f1a_3000x4000.png 848w, /__u/substackcdn.com/image/fetch/$s_!cwJG!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75e49bc5-4614-4bd7-884c-6988fd537f1a_3000x4000.png 1272w, /__u/substackcdn.com/image/fetch/$s_!cwJG!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75e49bc5-4614-4bd7-884c-6988fd537f1a_3000x4000.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!cwJG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75e49bc5-4614-4bd7-884c-6988fd537f1a_3000x4000.png" width="1456" height="1941" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/75e49bc5-4614-4bd7-884c-6988fd537f1a_3000x4000.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1941,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:17214420,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://bitbangingbytes.substack.com/i/210915006?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75e49bc5-4614-4bd7-884c-6988fd537f1a_3000x4000.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!cwJG!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75e49bc5-4614-4bd7-884c-6988fd537f1a_3000x4000.png 424w, /__u/substackcdn.com/image/fetch/$s_!cwJG!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75e49bc5-4614-4bd7-884c-6988fd537f1a_3000x4000.png 848w, /__u/substackcdn.com/image/fetch/$s_!cwJG!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75e49bc5-4614-4bd7-884c-6988fd537f1a_3000x4000.png 1272w, /__u/substackcdn.com/image/fetch/$s_!cwJG!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75e49bc5-4614-4bd7-884c-6988fd537f1a_3000x4000.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Debugging Error vs Angle | *MISO and MOSI are mistakenly swapped on Logic Analyzer</figcaption></figure></div><p>We reconstructed:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;magnitude=\\sqrt{\\cos^2+\\sin^2}&quot;,&quot;id&quot;:&quot;WWZXKNRMXZ&quot;}" data-component-name="LatexBlockToDOM"></div><p>and</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;phase=\\operatorname{atan2}(\\sin,\\cos)&quot;,&quot;id&quot;:&quot;RYZYGMWACN&quot;}" data-component-name="LatexBlockToDOM"></div><p>from each returned pair, and the mess separates into two independent defects. There&#8217;s a small constant gain bias, meaning that the output vectors are slightly too long</p><pre><code><code>Mean magnitude error : +1.69 LSB
Maximum              : +3.81 LSB</code></code></pre><p>The resulting phase error can be expressed as:</p><p>phase error = &#934; &#8722; &#952; = &#8722;&#931; &#963;&#7522; (&#265;&#7522; &#8722; atan(2&#8315;&#8305;)) </p><p>where &#265;&#7522;, the elementary angle for that pass&#8217;s iteration index i. The hat is doing real work in the notation: c&#7522; = atan(2&#8315;&#8305;) is the true elementary angle, &#265;&#7522; is whatever the chip <em>produces</em> as its stand-in</p><p>And there's a much larger phase error of &#177;0.28&#176; that is equal and opposite on either side of 45&#176;: below 45&#176; (mod 90) the phase reads &#8722;0.279&#176;, above it +0.290&#176;. A square wave, flipping at every 45&#176; line  i.e. it changed sign around <strong>45&#176;</strong>, and then repeated every quadrant. </p><p>More interestingly, the phase error wasn&#8217;t random. It had a very obvious structure. That is a huge clue.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!tw57!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21599e83-1b27-4f29-9ab1-38dc3bc9ddc7_1297x516.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!tw57!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21599e83-1b27-4f29-9ab1-38dc3bc9ddc7_1297x516.png 424w, /__u/substackcdn.com/image/fetch/$s_!tw57!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21599e83-1b27-4f29-9ab1-38dc3bc9ddc7_1297x516.png 848w, /__u/substackcdn.com/image/fetch/$s_!tw57!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21599e83-1b27-4f29-9ab1-38dc3bc9ddc7_1297x516.png 1272w, /__u/substackcdn.com/image/fetch/$s_!tw57!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21599e83-1b27-4f29-9ab1-38dc3bc9ddc7_1297x516.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!tw57!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21599e83-1b27-4f29-9ab1-38dc3bc9ddc7_1297x516.png" width="1297" height="516" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/21599e83-1b27-4f29-9ab1-38dc3bc9ddc7_1297x516.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:516,&quot;width&quot;:1297,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;fig2_sigma1_mechanism.png&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="fig2_sigma1_mechanism.png" title="fig2_sigma1_mechanism.png" srcset="/__u/substackcdn.com/image/fetch/$s_!tw57!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21599e83-1b27-4f29-9ab1-38dc3bc9ddc7_1297x516.png 424w, /__u/substackcdn.com/image/fetch/$s_!tw57!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21599e83-1b27-4f29-9ab1-38dc3bc9ddc7_1297x516.png 848w, /__u/substackcdn.com/image/fetch/$s_!tw57!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21599e83-1b27-4f29-9ab1-38dc3bc9ddc7_1297x516.png 1272w, /__u/substackcdn.com/image/fetch/$s_!tw57!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F21599e83-1b27-4f29-9ab1-38dc3bc9ddc7_1297x516.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Figure 11: the &#963;&#8321; collapse</figcaption></figure></div><div><hr></div><h1>The error had a fingerprint</h1><p>A CORDIC iteration makes a directional decision, the angle where its direction bit &#963;&#7522; changes sign: </p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\\sigma_i \\in {-1,+1}&quot;,&quot;id&quot;:&quot;PBUSVLDOEF&quot;}" data-component-name="LatexBlockToDOM"></div><p> </p><p>Stage 1&#8217;s boundary is 45&#176;. Stage 2&#8217;s are 18.4&#176; and 71.6&#176;.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!zX09!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8b4b6ac-e487-4248-b8d9-f09a9ae87263_1220x412.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!zX09!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8b4b6ac-e487-4248-b8d9-f09a9ae87263_1220x412.png 424w, /__u/substackcdn.com/image/fetch/$s_!zX09!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8b4b6ac-e487-4248-b8d9-f09a9ae87263_1220x412.png 848w, /__u/substackcdn.com/image/fetch/$s_!zX09!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8b4b6ac-e487-4248-b8d9-f09a9ae87263_1220x412.png 1272w, /__u/substackcdn.com/image/fetch/$s_!zX09!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8b4b6ac-e487-4248-b8d9-f09a9ae87263_1220x412.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!zX09!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8b4b6ac-e487-4248-b8d9-f09a9ae87263_1220x412.png" width="1220" height="412" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c8b4b6ac-e487-4248-b8d9-f09a9ae87263_1220x412.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:412,&quot;width&quot;:1220,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:33835,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://bitbangingbytes.substack.com/i/210915006?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8b4b6ac-e487-4248-b8d9-f09a9ae87263_1220x412.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!zX09!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8b4b6ac-e487-4248-b8d9-f09a9ae87263_1220x412.png 424w, /__u/substackcdn.com/image/fetch/$s_!zX09!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8b4b6ac-e487-4248-b8d9-f09a9ae87263_1220x412.png 848w, /__u/substackcdn.com/image/fetch/$s_!zX09!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8b4b6ac-e487-4248-b8d9-f09a9ae87263_1220x412.png 1272w, /__u/substackcdn.com/image/fetch/$s_!zX09!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc8b4b6ac-e487-4248-b8d9-f09a9ae87263_1220x412.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Only &#963;&#8321; flips where the error flips. Multiply the phase error by &#963;&#8321; sample by sample and the square wave collapses to a flat offset of +0.284&#176;(about 20 codes). </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!37Hj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44906f62-16ea-4bdc-8812-955b8c6c68bf_1297x516.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!37Hj!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44906f62-16ea-4bdc-8812-955b8c6c68bf_1297x516.png 424w, /__u/substackcdn.com/image/fetch/$s_!37Hj!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44906f62-16ea-4bdc-8812-955b8c6c68bf_1297x516.png 848w, /__u/substackcdn.com/image/fetch/$s_!37Hj!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44906f62-16ea-4bdc-8812-955b8c6c68bf_1297x516.png 1272w, /__u/substackcdn.com/image/fetch/$s_!37Hj!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44906f62-16ea-4bdc-8812-955b8c6c68bf_1297x516.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!37Hj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44906f62-16ea-4bdc-8812-955b8c6c68bf_1297x516.png" width="1297" height="516" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/44906f62-16ea-4bdc-8812-955b8c6c68bf_1297x516.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:516,&quot;width&quot;:1297,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;fig1_phase_before_after.png&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="fig1_phase_before_after.png" title="fig1_phase_before_after.png" srcset="/__u/substackcdn.com/image/fetch/$s_!37Hj!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44906f62-16ea-4bdc-8812-955b8c6c68bf_1297x516.png 424w, /__u/substackcdn.com/image/fetch/$s_!37Hj!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44906f62-16ea-4bdc-8812-955b8c6c68bf_1297x516.png 848w, /__u/substackcdn.com/image/fetch/$s_!37Hj!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44906f62-16ea-4bdc-8812-955b8c6c68bf_1297x516.png 1272w, /__u/substackcdn.com/image/fetch/$s_!37Hj!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F44906f62-16ea-4bdc-8812-955b8c6c68bf_1297x516.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Figure 12: Same vertical scale on both panels</figcaption></figure></div><p>So we asked:</p><p><strong>What happens if we correlate the phase error with each iteration&#8217;s direction bit?</strong></p><p>Regressing phase error against every stage&#8217;s direction bit at once achieved the breakthrough: &#963;&#8321; (first stage) carried +20.01 codes. Every other stage were comparatively tiny, under 2 codes and isn&#8217;t stable between runs (recall Figure 4).</p><p>The regression looked roughly like:</p><pre><code><code>&#963;1 : +20.01 codes
&#963;2 :  +0.40
&#963;3 :  -1.83
&#963;4 :  -0.87
&#963;5 :  -1.06</code></code></pre><div><hr></div><h1>The Fix and the subtle distinction </h1><p>Here&#8217;s the distinction the whole fix rests on. </p><p>The rotation each stage physically performs is set by its shift amount. It rotates by exactly atan(2&#8315;&#8305;) whether the generated constant is right or not, that part is geometry.</p><p>As Figure 6 shows, the Taylor series feeds only the angle accumulator, the <code>r_alpha</code> register in the inner loop. So when the generated constant is short, the datapath still rotates correctly. The accumulator just records the wrong amount, and drives that wrong number to zero, which means it stops early. The vector ends up 0.28&#176; from where the chip thinks it is.</p><p>The chip was never wrong about the rotation. It was wrong about what it had rotated.</p><div><hr></div><h1>The culprit: atan(0.5)</h1><p>The first elementary angle was fine. Stage 0 arrives over SPI. It&#8217;s atan(1), and the exact Q3.12 code is:</p><pre><code><code>3216.99 &#8594; 3217 = 0x0C91</code></code></pre><p>which is correct to a hundredth of a code. That's the whole reason it was made an input: the Taylor series is at its worst at x = 1, so rather than generate that value, the design takes it from the host. Stage 0 was never the problem.</p><p>At stage 1, <strong>x = 0.5</strong>, the two-term expansion produces code 1877 against the true atan(0.5) = 1899.1.</p><p>But the Taylor approximation used by the ROM-less generator was low.</p><p>A simple two-term approximation,</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;x-\\frac{x^3}{3}&quot;,&quot;id&quot;:&quot;ZSPWDXDFKS&quot;}" data-component-name="LatexBlockToDOM"></div><p>at (x=0.5), produces approximately 1877 instead of 1899<code>.</code></p><p>That&#8217;s a difference of roughly <strong>22 codes</strong>. A 22-code deficit, matching the measured 19.9 in sign and nearly in magnitude</p><p>Our measured phase bias? Approximately <strong>20 codes</strong>.</p><p>Stage 2, at x = 0.25, is already within 0.011&#176;, and the approximation improves roughly 30&#215; per stage after that. From stage 4 down it&#8217;s bit-exact at this word length.</p><p>Stage 1 sits in the only gap: stage 0 is exact because it comes from the host, and stages 2 onward are small enough not to matter. Stage 1 is neither.</p><p>The silicon was telling us what the maths had already predicted.</p><div><hr></div><h1>The beauty of exposing the constants over SPI</h1><p>There was one architectural decision that suddenly became extremely valuable: <strong>the first elementary angle was an input to the core.</strong></p><p>The SPI transaction already carried atan_0. That meant the host could supply a calibrated value without changing the RTL.</p><p>Biggest takeaway:</p><blockquote><p>Sometimes the best calibration mechanism is simply leaving yourself a parameter you can reach from outside the chip.</p></blockquote><p>We then attacked the two main errors separately.</p><div><hr></div><h1>Fixing the gain</h1><p>The CORDIC introduces a scale factor:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;K=\\prod_i\\sqrt{1+2^{-2i}}&quot;,&quot;id&quot;:&quot;LPHJOGUCHQ&quot;}" data-component-name="LatexBlockToDOM"></div><p>For our configuration, the reciprocal scale factor is approximately:</p><div class="latex-rendered" data-attrs="{&quot;persistentExpression&quot;:&quot;\n1/K=0.607252935\n&quot;,&quot;id&quot;:&quot;TDJZWCJQEL&quot;}" data-component-name="LatexBlockToDOM"></div><p>In Q3.12:<code> </code>0.607252935 &#215; 4096 &#8776; 2487.31</p><p>So the correct code is: 2487 = 0x09B7<code>.</code>The original value was one code too high: 0x09B8 &#8594; 0x09B7. That immediately moved the mean magnitude error from: +1.69<code> </code>LSB<code> </code>to approximately: -0.54 LSB<code>.</code></p><p>The calculation predicted about &#8722;0.51 LSB.</p><p>Measured silicon: &#8722;0.54 LSB.</p><p>That&#8217;s a very satisfying agreement.</p><div><hr></div><h1>Fixing phase without changing the chip</h1><p>Now that we know cultprit is stage-1 angle. The stage-1 constant is generated inside the chip via Taylor generator and cannot be changed. But its error enters the accumulator. we take that and multipy it by &#963;&#8321;.</p><p>&#963;&#8321; is just which side of 45&#176; the angle falls on, which the host knows before it sends the packet. So while stage 1 is out of reach, i_atan_0 is not. It arrives in every packet. Shifting it by the right amount, in the right direction for each half, cancels the stage-1 error exactly.</p><p>So the host sends a slightly different atan_0 depending on the angular half:</p><pre><code><code>if degrees(angle) % 90 &lt; 45:
    atan_0 = 0x0C7F
else:
    atan_0 = 0x0CA4</code></code></pre><p>That is 3199, 3236 respectively.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!ii6Q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5fbc86b-cf44-458b-bb50-f9c1d1f3e8f9_1892x1212.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!ii6Q!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5fbc86b-cf44-458b-bb50-f9c1d1f3e8f9_1892x1212.png 424w, /__u/substackcdn.com/image/fetch/$s_!ii6Q!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5fbc86b-cf44-458b-bb50-f9c1d1f3e8f9_1892x1212.png 848w, /__u/substackcdn.com/image/fetch/$s_!ii6Q!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5fbc86b-cf44-458b-bb50-f9c1d1f3e8f9_1892x1212.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ii6Q!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5fbc86b-cf44-458b-bb50-f9c1d1f3e8f9_1892x1212.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!ii6Q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5fbc86b-cf44-458b-bb50-f9c1d1f3e8f9_1892x1212.png" width="1456" height="933" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b5fbc86b-cf44-458b-bb50-f9c1d1f3e8f9_1892x1212.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:933,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:181594,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://bitbangingbytes.substack.com/i/210915006?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5fbc86b-cf44-458b-bb50-f9c1d1f3e8f9_1892x1212.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!ii6Q!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5fbc86b-cf44-458b-bb50-f9c1d1f3e8f9_1892x1212.png 424w, /__u/substackcdn.com/image/fetch/$s_!ii6Q!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5fbc86b-cf44-458b-bb50-f9c1d1f3e8f9_1892x1212.png 848w, /__u/substackcdn.com/image/fetch/$s_!ii6Q!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5fbc86b-cf44-458b-bb50-f9c1d1f3e8f9_1892x1212.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ii6Q!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5fbc86b-cf44-458b-bb50-f9c1d1f3e8f9_1892x1212.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Figure 13: Why the fix works. Rotation uses exact angles; only the accumulator uses generated ones, and the accumulator is a sum, so an equal-and-opposite error injected at the &#945;&#8320; input balances the ledger. The two panels are the two half-octant cases with the actual constants.</figcaption></figure></div><p>In other words, we effectively performed a <strong>host-side compensation for a deterministic silicon error</strong></p><blockquote><p>The chip adds our wrong number to its wrong number and lands on the truth.</p></blockquote><p>No RTL modification. No new mask. No submission to foundry again.</p><p>Just two different values in the SPI packet.</p><div><hr></div><h1>Then we made the test harder</h1><p>A 100-point sweep was good enough to find the bug. It wasn&#8217;t good enough to characterize the final residual. So we went to 250 points.</p><p>The corrected design produced: 250 / 250 angles passed with 0 timeouts.</p><p>Final results: </p><pre><code><code>Mean absolute error for cosine : 3.896e-4
Mean absolute error for sine : 4.476e-4
Mean absolute error for overall : 4.186e-4
RMS error : 5.196e-4
Peak error : 1.352e-3
Maximum phase error : 0.0872&#176;</code></code></pre><p>In terms of LSBs:</p><pre><code><code>Mean absolute error : 1.71 LSB
RMS                  : 2.13 LSB
Peak                 : 5.54 LSB</code></code></pre><p>The mean absolute error went from <strong>13.5 LSB to 1.71 LSB</strong>. That&#8217;s a <strong>7.9&#215; improvement</strong>.</p><p>RMS improved by <strong>6.8&#215;</strong>. Maximum phase error dropped from approximately <strong>0.343&#176; to 0.087&#176;</strong>. And about <strong>66% of the final samples were within 2 LSB</strong>.  The cardinal angles return cos 0&#176; = 1.0002 and sin 0&#176; = 0.0002, one code each. Worth restating against the design section: the MATLAB budget said 0.003, and calibrated silicon runs at 0.0004, roughly 8&#215; better than the design&#8217;s own predicted accuracy, using nothing but the input the designers happened to route out. </p><p>All of it was independently confirmed from the wire: decoding the raw logic-analyzer capture with the host software removed from the loop gives a median error of 5.16e-4 against the host&#8217;s 5.20e-4 RMS, and a max of 1.340e-3 against 1.352e-3.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!UQmm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9439743-dbf1-41f8-8a0b-1dc0c6ebef1c_1276x514.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!UQmm!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9439743-dbf1-41f8-8a0b-1dc0c6ebef1c_1276x514.png 424w, /__u/substackcdn.com/image/fetch/$s_!UQmm!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9439743-dbf1-41f8-8a0b-1dc0c6ebef1c_1276x514.png 848w, /__u/substackcdn.com/image/fetch/$s_!UQmm!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9439743-dbf1-41f8-8a0b-1dc0c6ebef1c_1276x514.png 1272w, /__u/substackcdn.com/image/fetch/$s_!UQmm!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9439743-dbf1-41f8-8a0b-1dc0c6ebef1c_1276x514.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!UQmm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9439743-dbf1-41f8-8a0b-1dc0c6ebef1c_1276x514.png" width="1276" height="514" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a9439743-dbf1-41f8-8a0b-1dc0c6ebef1c_1276x514.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:514,&quot;width&quot;:1276,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;fig3_error_stages.png&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="fig3_error_stages.png" title="fig3_error_stages.png" srcset="/__u/substackcdn.com/image/fetch/$s_!UQmm!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9439743-dbf1-41f8-8a0b-1dc0c6ebef1c_1276x514.png 424w, /__u/substackcdn.com/image/fetch/$s_!UQmm!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9439743-dbf1-41f8-8a0b-1dc0c6ebef1c_1276x514.png 848w, /__u/substackcdn.com/image/fetch/$s_!UQmm!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9439743-dbf1-41f8-8a0b-1dc0c6ebef1c_1276x514.png 1272w, /__u/substackcdn.com/image/fetch/$s_!UQmm!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa9439743-dbf1-41f8-8a0b-1dc0c6ebef1c_1276x514.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Figure 14: Cosine error magnitude across the sweep at each stage. The seed correction (orange) shifts the curve down slightly, gain was a small part of the total.</figcaption></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!tsLx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef50196a-3239-445e-a0ab-aa5b830b83c0_1006x557.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!tsLx!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef50196a-3239-445e-a0ab-aa5b830b83c0_1006x557.png 424w, /__u/substackcdn.com/image/fetch/$s_!tsLx!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef50196a-3239-445e-a0ab-aa5b830b83c0_1006x557.png 848w, /__u/substackcdn.com/image/fetch/$s_!tsLx!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef50196a-3239-445e-a0ab-aa5b830b83c0_1006x557.png 1272w, /__u/substackcdn.com/image/fetch/$s_!tsLx!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef50196a-3239-445e-a0ab-aa5b830b83c0_1006x557.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!tsLx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef50196a-3239-445e-a0ab-aa5b830b83c0_1006x557.png" width="1006" height="557" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ef50196a-3239-445e-a0ab-aa5b830b83c0_1006x557.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:557,&quot;width&quot;:1006,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;fig5_unit_circle.png&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="fig5_unit_circle.png" title="fig5_unit_circle.png" srcset="/__u/substackcdn.com/image/fetch/$s_!tsLx!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef50196a-3239-445e-a0ab-aa5b830b83c0_1006x557.png 424w, /__u/substackcdn.com/image/fetch/$s_!tsLx!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef50196a-3239-445e-a0ab-aa5b830b83c0_1006x557.png 848w, /__u/substackcdn.com/image/fetch/$s_!tsLx!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef50196a-3239-445e-a0ab-aa5b830b83c0_1006x557.png 1272w, /__u/substackcdn.com/image/fetch/$s_!tsLx!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef50196a-3239-445e-a0ab-aa5b830b83c0_1006x557.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Figure 15: The unit circle plot exaggerates deviation &#215;300, which makes the &#963;&#8321; lobes visible by eye.</figcaption></figure></div><p>For a first silicon implementation of a ROM-less fixed-point CORDIC, that was a pretty good place to land.</p><p>But then the SPI started arguing with us.</p><div><hr></div><h1>The chip was right. We were reading it wrong.</h1><p>At one point we tried pushing the SPI interface to 12 MHz with CORDIC system clock at 100MHz.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!SfXN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb84de0-ccb8-4508-a4d1-44ef6194dc54_4000x2790.bin" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!SfXN!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb84de0-ccb8-4508-a4d1-44ef6194dc54_4000x2790.bin 424w, /__u/substackcdn.com/image/fetch/$s_!SfXN!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb84de0-ccb8-4508-a4d1-44ef6194dc54_4000x2790.bin 848w, /__u/substackcdn.com/image/fetch/$s_!SfXN!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb84de0-ccb8-4508-a4d1-44ef6194dc54_4000x2790.bin 1272w, /__u/substackcdn.com/image/fetch/$s_!SfXN!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb84de0-ccb8-4508-a4d1-44ef6194dc54_4000x2790.bin 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!SfXN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb84de0-ccb8-4508-a4d1-44ef6194dc54_4000x2790.bin" width="1456" height="1016" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dfb84de0-ccb8-4508-a4d1-44ef6194dc54_4000x2790.bin&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1016,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;spi_link_analysis.png&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="spi_link_analysis.png" title="spi_link_analysis.png" srcset="/__u/substackcdn.com/image/fetch/$s_!SfXN!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb84de0-ccb8-4508-a4d1-44ef6194dc54_4000x2790.bin 424w, /__u/substackcdn.com/image/fetch/$s_!SfXN!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb84de0-ccb8-4508-a4d1-44ef6194dc54_4000x2790.bin 848w, /__u/substackcdn.com/image/fetch/$s_!SfXN!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb84de0-ccb8-4508-a4d1-44ef6194dc54_4000x2790.bin 1272w, /__u/substackcdn.com/image/fetch/$s_!SfXN!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdfb84de0-ccb8-4508-a4d1-44ef6194dc54_4000x2790.bin 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The returned values suddenly looked suspicious. Everything was almost exactly half-scale. Not approximately half. <strong>Exactly half. </strong>That is a very specific failure mode.</p><p>We captured the SPI bus using a logic analyzer.</p><p>And there it was. At 12 MHz with CPHA=0, the master was sampling the data one bit too early. The resulting magnitude was effectively divided by two.</p><p>The same wire capture, decoded on the correct edge, produced the correct values.</p><p>Decoded on the wrong edge:</p><pre><code><code>cos(0&#176;) = 0.50000</code></code></pre><p>Decoded on the correct edge:</p><pre><code><code>cos(0&#176;) = 1.00024</code></code></pre><p>The ratio was exactly:</p><pre><code><code>0.500</code></code></pre><p>across the samples. This wasn&#8217;t signal integrity or random corruption. It was a deterministic timing problem.</p><div><hr></div><h1>Why CPHA mattered</h1><p>The CORDIC core is clocked at 100 MHz. The SPI clock is asynchronous to it.</p><p>The SPI input is synchronized internally:</p><pre><code><code>sclk_sync &lt;= {sclk_sync[1:0], sclk};
sclk_prev &lt;= sclk_sync[2];
miso      &lt;= tx_shift_reg[6];</code></code></pre><p>So a change on SCLK doesn&#8217;t instantly cause MISO to change.</p><p>The logic analyzer measured MISO clock-to-out roughly ~50&#8211;60 ns</p><p>That matched the RTL structure surprisingly well. At 100 MHz, one core clock is 10 ns. The synchronizer and edge-detection path therefore naturally introduce several cycles of latency.</p><p>The measurement showed roughly 4&#8211;5 core clocks from the SPI edge to the corresponding MISO transition.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!4Qv2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7c3848-5b2c-46c6-bae1-a2f349bc7c32_4000x2000.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!4Qv2!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7c3848-5b2c-46c6-bae1-a2f349bc7c32_4000x2000.png 424w, /__u/substackcdn.com/image/fetch/$s_!4Qv2!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7c3848-5b2c-46c6-bae1-a2f349bc7c32_4000x2000.png 848w, /__u/substackcdn.com/image/fetch/$s_!4Qv2!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7c3848-5b2c-46c6-bae1-a2f349bc7c32_4000x2000.png 1272w, /__u/substackcdn.com/image/fetch/$s_!4Qv2!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7c3848-5b2c-46c6-bae1-a2f349bc7c32_4000x2000.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!4Qv2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7c3848-5b2c-46c6-bae1-a2f349bc7c32_4000x2000.png" width="1456" height="728" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2c7c3848-5b2c-46c6-bae1-a2f349bc7c32_4000x2000.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:728,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:385900,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://bitbangingbytes.substack.com/i/210915006?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7c3848-5b2c-46c6-bae1-a2f349bc7c32_4000x2000.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!4Qv2!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7c3848-5b2c-46c6-bae1-a2f349bc7c32_4000x2000.png 424w, /__u/substackcdn.com/image/fetch/$s_!4Qv2!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7c3848-5b2c-46c6-bae1-a2f349bc7c32_4000x2000.png 848w, /__u/substackcdn.com/image/fetch/$s_!4Qv2!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7c3848-5b2c-46c6-bae1-a2f349bc7c32_4000x2000.png 1272w, /__u/substackcdn.com/image/fetch/$s_!4Qv2!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2c7c3848-5b2c-46c6-bae1-a2f349bc7c32_4000x2000.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Figure 16: The race at 12 MHz. CPHA = 0 samples 41.7 ns after the requesting edge; the bit arrives 50&#8211;60 ns after it. CPHA = 1 waits the full period.</figcaption></figure></div><p>This is where having a real logic analyzer capture was incredibly useful.</p><p>We could stop arguing about what the RTL <em>should</em> do and simply look at what the silicon actually did.</p><div><hr></div><h1>The recommended SPI speed became 8 MHz</h1><p>Although 12 MHz could sometimes appear to work, it wasn&#8217;t something we&#8217;d want to call qualified.</p><p><strong>8 MHz was the sensible operating point.</strong></p><div><hr></div><h1>And then we checked the wire independently</h1><p>This part matters.It is very easy to build a test harness that accidentally proves itself correct.</p><p>The host software says the chip returned: 0.9987</p><p>But how do we know the software actually decoded the SPI stream correctly?</p><p>So we decoded the raw logic-analyzer capture independently. The results matched.</p><p>The host-side analysis reported an RMS error of approximately: 5.20e-4</p><p>The independent logic-analyzer decoding reported: 5.16e-4</p><p>Maximum error:</p><pre><code><code>Host : 1.352e-3
Wire : 1.340e-3</code></code></pre><p>The MOSI stream was also decoded independently to verify that the calibration constants actually sent by the host were the ones we thought we were sending.</p><p>That gave us two independent paths to the same answer:</p><pre><code><code>RP2350B host software &#8594; silicon &#8594; RP2350B host decoder
logic analyzer &#8594; raw bits &#8594; SPI soft decoder</code></code></pre><p>When both agree, you can start trusting the result.</p><div><hr></div><h1>What I like most about this project</h1><p>The CORDIC itself isn&#8217;t particularly exotic. CORDIC has been around for decades.</p><p>The interesting part, at least to me, was everything around it.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!n2tt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95298ae4-12bb-43f2-b08d-86a550df98ba_4040x3160.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!n2tt!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95298ae4-12bb-43f2-b08d-86a550df98ba_4040x3160.png 424w, /__u/substackcdn.com/image/fetch/$s_!n2tt!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95298ae4-12bb-43f2-b08d-86a550df98ba_4040x3160.png 848w, /__u/substackcdn.com/image/fetch/$s_!n2tt!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95298ae4-12bb-43f2-b08d-86a550df98ba_4040x3160.png 1272w, /__u/substackcdn.com/image/fetch/$s_!n2tt!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95298ae4-12bb-43f2-b08d-86a550df98ba_4040x3160.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!n2tt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95298ae4-12bb-43f2-b08d-86a550df98ba_4040x3160.png" width="1456" height="1139" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/95298ae4-12bb-43f2-b08d-86a550df98ba_4040x3160.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1139,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:769972,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://bitbangingbytes.substack.com/i/210915006?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95298ae4-12bb-43f2-b08d-86a550df98ba_4040x3160.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!n2tt!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95298ae4-12bb-43f2-b08d-86a550df98ba_4040x3160.png 424w, /__u/substackcdn.com/image/fetch/$s_!n2tt!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95298ae4-12bb-43f2-b08d-86a550df98ba_4040x3160.png 848w, /__u/substackcdn.com/image/fetch/$s_!n2tt!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95298ae4-12bb-43f2-b08d-86a550df98ba_4040x3160.png 1272w, /__u/substackcdn.com/image/fetch/$s_!n2tt!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F95298ae4-12bb-43f2-b08d-86a550df98ba_4040x3160.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Figure 17: Saga of ASICs</figcaption></figure></div><p>Each step exposed a different class of failure.</p><p>The simulation could tell us whether the RTL behaved as expected.</p><p>It couldn&#8217;t tell us whether our Taylor approximation was good enough at the actual fixed-point precision.</p><p>The silicon could tell us that.</p><p>The host could tell us the numerical error.</p><p>But it couldn&#8217;t prove that the SPI decoder itself wasn&#8217;t wrong.</p><p>The logic analyzer could tell us what physically happened on the pins.</p><p>And the mathematical regression could tell us <em>why</em> the error happened.</p><p>That&#8217;s the part of hardware engineering that is difficult to appreciate until you&#8217;ve actually done it.</p><div><hr></div><h1>A tiny ASIC teaches you a lot</h1><p>The final design is small.</p><p>But the debugging wasn&#8217;t.</p><p>A 20-code phase error sounds trivial until you discover that it has a very recognizable structure.</p><p>A one-code scale-factor error sounds trivial until you can predict its effect to within 0.03 LSB.</p><p>An SPI timing problem sounds like a protocol bug until you discover that the wrong sampling edge produces exactly half the expected amplitude.</p><p>And a &#8220;working&#8221; testbench isn&#8217;t enough when the thing you&#8217;re testing is now sitting behind silicon, pads, synchronizers, clocks, and an actual physical wire.</p><p>That&#8217;s probably the biggest lesson we took away from this project:</p><blockquote><p><strong>ASIC debugging is less about finding the bug and more about finding measurements that make the bug impossible to hide.</strong></p></blockquote><div><hr></div><h1>The final numbers</h1><p>The ROM-less CORDIC now runs with:</p><pre><code><code>Process / platform : SKY130 / Tiny Tapeout
Core clock         : 50 MHz
Recommended SPI    : 8 MHz
Format             : signed Q3.12</code></code></pre><p>Final characterization:</p><pre><code><code>Mean absolute error : 1.71 LSB
RMS error           : 2.13 LSB
Peak error          : 5.54 LSB
Maximum phase error : 0.087&#176;</code></code></pre><p>And the most satisfying statistic:</p><pre><code><code>250 / 250 tests passed.</code></code></pre><p>No RTL modification. No new mask. No submission to foundry again.</p><p>Just a better understanding of what the silicon was actually doing.</p><div><hr></div><h2>The code</h2><p>The complete RTL and Tiny Tapeout project are available here:</p><p><a href="https://github.com/rohanverma94/ttsky-romless-cordic-engine">ROM-less CORDIC Engine &#8212; GitHub</a></p><p>The silicon characterization and RP2350 test harness are here:</p><p><a href="https://github.com/rohanverma94/cordic_romless_v1_test_harness">CORDIC ROM-less V1 Test Harness &#8212; GitHub</a></p><p>The second repository also contains the characterization data, reports, plots and logic-analyzer decoding utilities used to reproduce the analysis.</p><div><hr></div><h2>Acknowledgements</h2><p>This project was a team effort.</p><p>Rohan Sundar and I worked on the CORDIC architecture and the ROM-less mathematical approach, with Kasetty Praveen Kumar instrumental in designing RTL for the mathematics that made the ROM-less implementation practical.</p><p>The Vicharak engineering team contributed heavily to the RTL, verification and ASIC flow.</p><p><a href="https://github.com/djkabutar">Devang Kabutarwala</a><span>, </span><a href="https://github.com/Kasetty-Praveen-Kumar">Kasetty Praveen Kumar</a><span>, </span><a href="https://github.com/Marcvi19">Rishik Ram Jallarapu</a><span>, </span><a href="https://github.com/dpks2003">Deepak Sharda</a><span>, </span><a href="https://github.com/tejdabhankar">Tejas Dabhankar</a><span>, </span><a href="https://github.com/akshar001">Akshar Vastarpara</a></p><p>Rishik Ram Jallarapu contributed extensively to verification, GDS generation and gate-level simulation.</p><p>Kudos to them</p><p>And of course, none of this would have made it through the tapeout process without the Tiny Tapeout community and the people who helped us navigate the practical realities of getting a real ASIC out the door.</p><p>The chip may only be a tiny mathematical accelerator.</p><p>But debugging it was a full-sized engineering project.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://bitbangingbytes.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Bit Banging Bytes! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Bit Banging Bytes]]></title><description><![CDATA[A Compiler Dev's musings on Modern Systems!]]></description><link>https://bitbangingbytes.substack.com/p/bit-banging-bytes</link><guid isPermaLink="false">https://bitbangingbytes.substack.com/p/bit-banging-bytes</guid><dc:creator><![CDATA[always_ff_rohan]]></dc:creator><pubDate>Sat, 26 Aug 2023 18:42:32 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!eiec!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a9b080-202e-48a8-96a0-784446310223_4800x2700.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1>A Compiler Dev's musings on Modern Systems! </h1><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!eiec!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a9b080-202e-48a8-96a0-784446310223_4800x2700.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!eiec!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a9b080-202e-48a8-96a0-784446310223_4800x2700.png 424w, /__u/substackcdn.com/image/fetch/$s_!eiec!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a9b080-202e-48a8-96a0-784446310223_4800x2700.png 848w, /__u/substackcdn.com/image/fetch/$s_!eiec!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a9b080-202e-48a8-96a0-784446310223_4800x2700.png 1272w, /__u/substackcdn.com/image/fetch/$s_!eiec!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_webp, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a9b080-202e-48a8-96a0-784446310223_4800x2700.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!eiec!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a9b080-202e-48a8-96a0-784446310223_4800x2700.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f7a9b080-202e-48a8-96a0-784446310223_4800x2700.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:4744295,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!eiec!, /__u/bitbangingbytes.substack.com/w_424, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a9b080-202e-48a8-96a0-784446310223_4800x2700.png 424w, /__u/substackcdn.com/image/fetch/$s_!eiec!, /__u/bitbangingbytes.substack.com/w_848, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a9b080-202e-48a8-96a0-784446310223_4800x2700.png 848w, /__u/substackcdn.com/image/fetch/$s_!eiec!, /__u/bitbangingbytes.substack.com/w_1272, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a9b080-202e-48a8-96a0-784446310223_4800x2700.png 1272w, /__u/substackcdn.com/image/fetch/$s_!eiec!, /__u/bitbangingbytes.substack.com/w_1456, /__u/bitbangingbytes.substack.com/c_limit, /__u/bitbangingbytes.substack.com/f_auto, /__u/bitbangingbytes.substack.com/q_auto:good, /__u/bitbangingbytes.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7a9b080-202e-48a8-96a0-784446310223_4800x2700.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg aria-hidden="true" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p></p><h2>The Essence of Bit Banging</h2><blockquote><p>At its core, bit banging is the art of driving individual signal lines from software, timing each edge yourself, without leaning on a dedicated peripheral to do it for you. No UART block, no SPI controller, no hard macro quietly handling the protocol behind an APB register, just your code, a GPIO, and a cycle counter. It's the software equivalent of writing your own RTL instead of instantiating someone else's IP: slower, fussier, and the only way you'll ever actually know what the waveform looks like. Bang a few bits by hand and a datasheet timing diagram stops being a picture and starts being something you can feel.</p></blockquote><h2>To follow my journey, please subscribe! </h2><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://bitbangingbytes.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Bit Banging Bytes! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Coming soon]]></title><description><![CDATA[This is Bit Banging Bytes, a newsletter about Low Level Engineering.]]></description><link>https://bitbangingbytes.substack.com/p/coming-soon</link><guid isPermaLink="false">https://bitbangingbytes.substack.com/p/coming-soon</guid><dc:creator><![CDATA[always_ff_rohan]]></dc:creator><pubDate>Wed, 30 Mar 2022 14:22:38 GMT</pubDate><content:encoded><![CDATA[<p><strong>This is Bit Banging Bytes</strong>, a newsletter about Low Level Engineering.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://bitbangingbytes.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/bitbangingbytes.substack.com/subscribe"><span>Subscribe now</span></a></p>]]></content:encoded></item></channel></rss>