<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Arithmetic on Digital Logic Notebook</title><link>https://applied-ee.github.io/digital-logic-notebook/docs/building-blocks/arithmetic/</link><description>Recent content in Arithmetic on Digital Logic Notebook</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://applied-ee.github.io/digital-logic-notebook/docs/building-blocks/arithmetic/index.xml" rel="self" type="application/rss+xml"/><item><title>Half &amp; Full Adders</title><link>https://applied-ee.github.io/digital-logic-notebook/docs/building-blocks/arithmetic/half-and-full-adders/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://applied-ee.github.io/digital-logic-notebook/docs/building-blocks/arithmetic/half-and-full-adders/</guid><description>&lt;h1 id="half--full-adders"&gt;Half &amp;amp; Full Adders&lt;a class="anchor" href="#half--full-adders"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Binary addition is just a combinational function, and it is built from one small cell repeated. That cell is the adder, and understanding it is understanding how gates do arithmetic.&lt;/p&gt;
&lt;h2 id="the-half-adder"&gt;The Half Adder&lt;a class="anchor" href="#the-half-adder"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A half adder adds two bits and produces a sum and a carry. The sum is 1 when the inputs differ, and the carry is 1 only when both are 1 — which is to say the sum is an &lt;a href="https://applied-ee.github.io/digital-logic-notebook/docs/building-blocks/gates/xor/"&gt;XOR&lt;/a&gt; and the carry is an &lt;a href="https://applied-ee.github.io/digital-logic-notebook/docs/building-blocks/gates/and/"&gt;AND&lt;/a&gt;:&lt;/p&gt;</description></item><item><title>Subtractors</title><link>https://applied-ee.github.io/digital-logic-notebook/docs/building-blocks/arithmetic/subtractors/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://applied-ee.github.io/digital-logic-notebook/docs/building-blocks/arithmetic/subtractors/</guid><description>&lt;link rel="stylesheet" href="https://applied-ee.github.io/digital-logic-notebook/katex/katex.min.css" /&gt;&lt;script defer src="https://applied-ee.github.io/digital-logic-notebook/katex/katex.min.js"&gt;&lt;/script&gt;&lt;script defer src="https://applied-ee.github.io/digital-logic-notebook/katex/auto-render.min.js" onload="renderMathInElement(document.body, {&amp;#34;delimiters&amp;#34;:[{&amp;#34;left&amp;#34;:&amp;#34;$$&amp;#34;,&amp;#34;right&amp;#34;:&amp;#34;$$&amp;#34;,&amp;#34;display&amp;#34;:true},{&amp;#34;left&amp;#34;:&amp;#34;\\(&amp;#34;,&amp;#34;right&amp;#34;:&amp;#34;\\)&amp;#34;,&amp;#34;display&amp;#34;:false},{&amp;#34;left&amp;#34;:&amp;#34;\\[&amp;#34;,&amp;#34;right&amp;#34;:&amp;#34;\\]&amp;#34;,&amp;#34;display&amp;#34;:true}]});"&gt;&lt;/script&gt;
&lt;h1 id="subtractors"&gt;Subtractors&lt;a class="anchor" href="#subtractors"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Hardware rarely builds a dedicated subtractor, because it does not need one. Subtraction is addition of a negative number, and in two&amp;rsquo;s-complement arithmetic negating a number is nearly free — so the same &lt;a href="https://applied-ee.github.io/digital-logic-notebook/docs/building-blocks/arithmetic/half-and-full-adders/"&gt;adder&lt;/a&gt; that adds also subtracts, with a trivial change to its inputs.&lt;/p&gt;
&lt;h2 id="subtraction-is-addition-in-disguise"&gt;Subtraction Is Addition in Disguise&lt;a class="anchor" href="#subtraction-is-addition-in-disguise"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In two&amp;rsquo;s complement, a number is negated by &lt;strong&gt;inverting all its bits and adding 1&lt;/strong&gt;. Therefore:&lt;/p&gt;</description></item><item><title>Magnitude Comparators</title><link>https://applied-ee.github.io/digital-logic-notebook/docs/building-blocks/arithmetic/magnitude-comparators/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://applied-ee.github.io/digital-logic-notebook/docs/building-blocks/arithmetic/magnitude-comparators/</guid><description>&lt;h1 id="magnitude-comparators"&gt;Magnitude Comparators&lt;a class="anchor" href="#magnitude-comparators"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;A magnitude comparator decides the relationship between two binary numbers — whether A equals B, A is greater, or A is less. It answers in logic what a subtraction answers in arithmetic, and it is a distinct, common building block wherever hardware has to make a decision about a value.&lt;/p&gt;
&lt;blockquote class='book-hint '&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; this is the &lt;em&gt;digital&lt;/em&gt; comparator, comparing multi-bit numbers. It shares its name with the analog voltage &lt;a href="https://applied-ee.github.io/digital-logic-notebook/docs/building-blocks/analog-helpers/comparators/"&gt;comparator&lt;/a&gt; in Analog Helpers, which compares two continuous voltages and outputs a single bit — a different device for a different job.&lt;/p&gt;</description></item><item><title>Parity &amp; Error Detection</title><link>https://applied-ee.github.io/digital-logic-notebook/docs/building-blocks/arithmetic/parity-and-error-detection/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://applied-ee.github.io/digital-logic-notebook/docs/building-blocks/arithmetic/parity-and-error-detection/</guid><description>&lt;h1 id="parity--error-detection"&gt;Parity &amp;amp; Error Detection&lt;a class="anchor" href="#parity--error-detection"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Parity is the cheapest integrity check in digital logic: a single extra bit that reveals whether data has been corrupted in the simplest way. It costs almost nothing to compute, which is exactly why it has been used everywhere from memory to serial links for decades.&lt;/p&gt;
&lt;h2 id="one-xor-tree"&gt;One XOR Tree&lt;a class="anchor" href="#one-xor-tree"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The parity of a group of bits is whether the count of 1s among them is odd — and that is precisely what an &lt;a href="https://applied-ee.github.io/digital-logic-notebook/docs/building-blocks/gates/xor/"&gt;XOR&lt;/a&gt; of all the bits computes. A &lt;strong&gt;parity generator&lt;/strong&gt; is therefore just an XOR tree across the data. A parity bit is appended so that the total number of 1s is always even (&lt;strong&gt;even parity&lt;/strong&gt;) or always odd (&lt;strong&gt;odd parity&lt;/strong&gt;), as agreed in advance.&lt;/p&gt;</description></item><item><title>ALU</title><link>https://applied-ee.github.io/digital-logic-notebook/docs/building-blocks/arithmetic/alu/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://applied-ee.github.io/digital-logic-notebook/docs/building-blocks/arithmetic/alu/</guid><description>&lt;h1 id="alu"&gt;ALU&lt;a class="anchor" href="#alu"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The Arithmetic Logic Unit is where the building blocks converge. It is a single combinational block that performs a &lt;em&gt;selected&lt;/em&gt; operation — add, subtract, AND, OR, XOR, compare, shift — on its two operands, with function-select inputs choosing which. It is the computational core of a processor&amp;rsquo;s datapath, and it is assembled almost entirely from the primitives covered elsewhere in this section.&lt;/p&gt;
&lt;h2 id="what-it-combines"&gt;What It Combines&lt;a class="anchor" href="#what-it-combines"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;An ALU is less an invention than an arrangement:&lt;/p&gt;</description></item></channel></rss>