Chapterبەش 9 · Lectureوانە 9.3

Half and Full Addersنیوەکۆکەرەوە و کۆکەرەوەی تەواو

Binary addition built from gates: the half adder (XOR + AND), the full adder, a 4-bit ripple-carry adder, the half and full subtractor, and how one adder also subtracts — then a look back at the course so far and a map of what comes next (sequential logic in the last chapter, then computer architecture).

بە دروست کراو: ⁦(XOR + AND)⁩، ، بە چوار ، نیوەلێدەرکەر و لێدەرکەری تەواو و چۆن یەک لێدەرکردنیش دەکات — پاشان ئاوڕدانەوەیەک لە کۆرسەکە تا ئێستا و نەخشەی ئەوەی دواتر دێت ( لە کۆتا بەشدا، پاشان تەلارسازیی ).

17 min read19 خولەک خوێندنەوە · 18 stepsهەنگاو

What you will learnچی فێر دەبیت

  • Derive the half adder from the binary addition table: S=A⊕BS = A \oplus B, C=ABC = AB.
  • Explain the full adder, its equations and how it is built from two half adders.
  • Add two 4-bit numbers stage by stage in a ripple-carry adder and explain its delay.
  • Build the half and full subtractor and compare them with the adders.
  • Name what comes next: more combinational blocks and sequential logic (the last chapter of this course), then computer architecture.
  • لە خشتەی دەربهێنیت: S=A⊕BS = A \oplus B، C=ABC = AB.
  • ، هاوکێشەکانی و چۆنیەتیی دروستکردنی لە دوو ڕوون بکەیتەوە.
  • دوو ژمارەی چوار قۆناغ بە قۆناغ لە کۆ بکەیتەوە و دواکەوتنەکەی ڕوون بکەیتەوە.
  • نیوەلێدەرکەر و لێدەرکەری تەواو دروست بکەیت و بەراوردیان بکەیت لەگەڵ .
  • ناوی ئەوەی دواتر دێت بزانیت: بلۆکی تێکەڵەیی زیاتر و لۆجیکی زنجیرەیی (کۆتا بەشی ئەم کۆرسە)، پاشان تەلارسازیی .

Binary addition, built from gatesکۆکردنەوەی دووانی، بە گەیتەکان دروست کراو

In binary addition one column of two bits has only four cases: 0+0=00 + 0 = 0, 0+1=10 + 1 = 1, 1+0=11 + 0 = 1 and 1+1=101 + 1 = 10. The answer always fits in two bits: a sum bit S that stays in the column and a carry bit C that moves to the next column. So adding one column is just a truth table with two outputs:

لە کۆکردنەوەی دووانیدا ستوونێک لە دوو تەنها چوار حاڵەتی هەیە: 0+0=00 + 0 = 0، 0+1=10 + 1 = 1، 1+0=11 + 0 = 1 و 1+1=101 + 1 = 10. وەڵامەکە هەمیشە لە دوو جێ دەبێتەوە: کۆ S کە لە ستوونەکەدا دەمێنێتەوە و C کە دەچێتە ستوونی دواتر. کەواتە کۆکردنەوەی یەک ستوون تەنها بە دوو :

Adding two bitsکۆکردنەوەی دوو
AABBA+BA + BA+BA + BCCSS
000000
010101
100101
111010

Now compare the output columns with the gates you know. The S column is 1 when A and B are different — that is XOR. The C column is 1 only when both are 1 — that is AND. Notice that S is not OR: OR would give 1 for 1+11 + 1. This is exactly where the OR-gate report went wrong when it called OR "binary addition".

ئێستا ستوونەکانی بەراورد بکە لەگەڵ کە دەیانناسیت. ستوونی S کاتێک 1ـە کە A و B جیاواز بن — ئەوە XORـە. ستوونی C تەنها کاتێک 1ـە کە هەردووکیان 1 بن — ئەوە ANDـە. سەرنج بدە کە ⁦S OR⁩ نییە: OR بۆ 1+11 + 1 دەیدا 1. ئەمە ڕێک ئەو شوێنەیە کە ڕاپۆرتی گەیتی OR هەڵەی کرد کاتێک ORـی ناو نا «».

Quick checkپشکنینی خێراWhich gate produces the sum bit S of one column?کام کۆی Sـی یەک ستوون دروست دەکات؟

The half adderنیوەکۆکەرەوە

Definitionپێناسە

A circuit that adds two bits A and B and gives a sum bit S=A⊕BS = A \oplus B and a carry bit C=ABC = AB. It cannot take a carry from a previous column.

سووڕێکە کە دوو بیتی A و B کۆ دەکاتەوە و بیتی کۆی S=A⊕BS = A \oplus B و بیتی C=ABC = AB دەدات. ناتوانێت لە ستوونی پێشووەوە وەربگرێت.

So the circuit for one column is an XOR gate and an AND gate side by side, sharing the inputs A and B:

کەواتە یەک ستوون بریتییە لە و لە تەنیشت یەک کە A و B بەکار دەهێنن:

S=A⊕BC=ABS = A \oplus B \qquad C = AB

Check: 2C+S2C + S is always the number A+BA + B (for 1+11 + 1: 2⋅1+0=22\cdot 1 + 0 = 2).

پشکنین: 2C+S2C + S هەمیشە ژمارەی A+BA + Bـە (بۆ 1+11 + 1: 2⋅1+0=22\cdot 1 + 0 = 2).

The half adder circuit: inputs A and B on vertical lines feed an XOR gate, whose output is S = A XOR B (the sum), and an AND gate, whose output is C = AB (the carry). On the right, the same circuit as a block labelled HA with inputs A, B and outputs S, C.سووڕی نیوەکۆکەرەوە: نێوخستەکانی A و B لەسەر هێڵی ستوونی دەچنە ناو گەیتێکی XOR کە دەرخستەکەی S = A XOR Bـە (کۆ) و گەیتێکی AND کە دەرخستەکەی C = ABـە (گواستراوە). لە لای ڕاست، هەمان سووڕ وەک بلۆکێک بە ناوی HA بە نێوخستەکانی A، B و دەرخستەکانی S، C.
Two gates add two bits. The block symbol HA hides the gates. Build it on a breadboard.دوو دوو کۆ دەکەنەوە. بلۆکی HA دەشارێتەوە. لەسەر بریدبۆرد دروستی بکە.CêIT
Quick checkپشکنینی خێراA half adder gets A=1A = 1 and B=1B = 1. What are S and C? A=1A = 1 و B=1B = 1 وەردەگرێت. S و C چین؟

Half Adder in Logic Designhiwa school · Kurdish (Sorani)کوردی (سۆرانی) · 2.1K viewsبینین · 76 likesلایک

A Sorani explanation of the half adder: adding two bits to get a sum bit and a carry bit.

ڕوونکردنەوەیەکی سۆرانی بۆ : کۆکردنەوەی دوو بۆ وەرگرتنی کۆ و .

In Sorani: the half adder.

بە سۆرانی: .

The half adderنیوەکۆکەرەوە

Why only “half”?بۆچی تەنها «نیوە»؟

Why only "half"? A half adder has no input for a carry coming from the column on its right. It can add the rightmost column of a number, but no other column, because every other column may receive a carry.

بۆچی تەنها «نیوە»؟ هیچ نییە بۆ کە لە ستوونەکەی لای ڕاستییەوە دێت. دەتوانێت ستوونی هەرە ڕاستی ژمارەیەک کۆ بکاتەوە، بەڵام هیچ ستوونێکی تر نا، چونکە هەموو ستوونێکی تر لەوانەیە وەربگرێت.

A row of friends countingڕیزێک هاوڕێ کە دەژمێرن

Picture friends standing in a row, one per column, each showing 0 or 1 fingers. When a friend's total reaches 2, he puts his finger down and taps the friend on his left, who must add one more — that tap is the carry. The friend at the right end never gets a tap: he is the half adder. Everyone else must listen to the tap from the right: they are full adders.

وا دابنێ چەند هاوڕێیەک لە ڕیزێکدا وەستاون، بۆ هەر ستوونێک یەکێک، هەر یەکێکیان 0 یان 1 پەنجە نیشان دەدات. کاتێک کۆی هاوڕێیەک دەگاتە 2، پەنجەکەی دادەگرێت و دەست لە شانی هاوڕێکەی لای چەپی دەدات کە دەبێت یەکێکی تر زیاد بکات — ئەو دەستلێدانە . هاوڕێکەی لای ڕاستی کۆتایی هەرگیز دەستی لێ نادرێت: ئەو . هەموو ئەوانی تر دەبێت گوێ لە دەستلێدانەکەی لای ڕاست بگرن: ئەوان .

Where the analogy stops workingسنووری ئەم نموونەیە

Friends can count to any number; a full adder's total is at most 1+1+1=3=111 + 1 + 1 = 3 = 11, so it never passes on more than one carry.

هاوڕێکان دەتوانن تا هەر ژمارەیەک بژمێرن؛ کۆی زۆرترین 1+1+1=3=111 + 1 + 1 = 3 = 11ـە، بۆیە هەرگیز زیاتر لە یەک نانێرێت.

Quick checkپشکنینی خێراIn a 4-bit adder, which column can use a half adder?لە چوار ، کام ستوون دەتوانێت بەکاربهێنێت؟

The full adderکۆکەرەوەی تەواو

Definitionپێناسە

A circuit that adds three bits: A, B and a carry-in from the previous column. It gives a sum bit and a carry-out, and it can be built from two half adders and an OR gate.

سووڕێکە کە سێ بیت کۆ دەکاتەوە: A، B و کە لە ستوونی پێشووەوە دێت. بیتی کۆ و بۆ دەرەوە دەدات و دەتوانرێت لە دوو و دروست بکرێت.

A full adder has three inputs — the two bits A and B and the carry in CinC_{in} from the column on the right — and two outputs, S and the carry out CoutC_{out}. The largest total is 1+1+1=3=111 + 1 + 1 = 3 = 11 in binary, so two output bits are still enough.

سێ هەیە — دوو A و B و هاتوو CinC_{in} لە ستوونەکەی لای ڕاستەوە — و دوو : S و دەرچوو CoutC_{out}. گەورەترین کۆ 1+1+1=3=111 + 1 + 1 = 3 = 11ـە بە ، بۆیە دوو هێشتا بەسن.

Truth table of the full adder
AABBCinC_{in}totalکۆCoutC_{out}SS
000000
001101
010101
011210
100101
101210
110210
111311
S=A⊕B⊕CinCout=AB+ACin+BCin=AB+Cin(A⊕B)\begin{aligned} S &= A \oplus B \oplus C_{in} \\ C_{out} &= AB + AC_{in} + BC_{in} = AB + C_{in}(A \oplus B) \end{aligned}

Reading the table: S is 1 when an odd number of inputs are 1 — a 3-input XOR, the same odd-parity idea as in XOR. CoutC_{out} is 1 when at least two inputs are 1. You can get AB+ACin+BCinAB + AC_{in} + BC_{in} directly from a Karnaugh map of the minterms 3, 5, 6 and 7 (three overlapping pairs).

خوێندنەوەی خشتەکە: S کاتێک 1ـە کە ژمارەیەکی تاک لە 1 بن — XORـێکی سێ ، هەمان بیرۆکەی پاریتیی تاک وەک لە XOR. CoutC_{out} کاتێک 1ـە کە لانیکەم دوو 1 بن. دەتوانیت AB+ACin+BCinAB + AC_{in} + BC_{in} ڕاستەوخۆ بە نەخشەیەکی کارنۆ بۆ 3، 5، 6 و 7 وەربگریت (سێ جووتی یەکتربڕ).

Quick checkپشکنینی خێراA full adder gets A=1A = 1, B=0B = 0 and Cin=1C_{in} = 1. What are S and CoutC_{out}? A=1A = 1، B=0B = 0 و Cin=1C_{in} = 1 وەردەگرێت. S و CoutC_{out} چین؟

The full adderکۆکەرەوەی تەواو

A full adder from two half addersکۆکەرەوەی تەواو لە دوو نیوەکۆکەرەوە

You do not need a new design. The first half adder adds A and B; the second adds CinC_{in} to that partial sum. Each can produce a carry, and an OR gate joins the two carries:

پێویستت بە دیزاینێکی نوێ نییە. یەکەم A و B کۆ دەکاتەوە؛ دووەم CinC_{in} بۆ ئەو کۆ ناتەواوە زیاد دەکات. هەر یەکێکیان دەتوانێت دروست بکات و دوو پێکەوە دەبەستێت:

Full adder made of two half adders and an OR gate. Half adder 1 (an XOR and an AND) takes A and B and gives A XOR B and AB. Half adder 2 (an XOR and an AND) takes A XOR B and Cin and gives S = A XOR B XOR Cin and Cin(A XOR B). An OR gate combines AB and Cin(A XOR B) into Cout.کۆکەرەوەی تەواو لە دوو نیوەکۆکەرەوە و گەیتێکی OR دروست کراوە. نیوەکۆکەرەوەی 1 (XOR و AND) A و B وەردەگرێت و A XOR B و AB دەدات. نیوەکۆکەرەوەی 2 (XOR و AND) A XOR B و Cin وەردەگرێت و S = A XOR B XOR Cin و Cin(A XOR B) دەدات. گەیتێکی OR AB و Cin(A XOR B) پێکەوە دەکات بە Cout.
Five gates: two XOR, two AND, one OR.پێنج : دوو XOR، دوو AND، یەک OR.CêIT

Why is a simple OR enough for the two carries? They can never both be 1: the first carry needs A=B=1A = B = 1, and then A⊕B=0A \oplus B = 0, so the second half adder cannot carry. So the full adder costs 5 gates: 2 XOR, 2 AND and 1 OR.

بۆچی ORـێکی سادە بۆ دوو بەسە؟ هەرگیز هەردووکیان پێکەوە 1 نابن: یەکەم پێویستی بە A=B=1A = B = 1ـە و ئەو کاتە A⊕B=0A \oplus B = 0، بۆیە دووەم ناتوانێت بدات. کەواتە 5 دەخایەنێت: ⁦2 XOR⁩، ⁦2 AND⁩ و ⁦1 OR⁩.

Quick checkپشکنینی خێراIn the two-half-adder design, which inputs make the first half adder produce the carry?لە دیزاینی دوو ، کام وا دەکەن یەکەم بدات؟

A 4-bit ripple-carry adderکۆکەرەوەیەکی زنجیرەیی بە چوار بیت

Definitionپێناسە

Several full adders in a row, where each carry-out feeds the next carry-in, so n full adders add two n-bit numbers. The carry 'ripples' from right to left, which takes time.

چەند لە ڕیزێکدا کە دەرچووی هەر یەکێکیان دەچێتە ناو کۆکەرەوەی دواتر، بۆیە n کۆکەرەوەی تەواو دوو ژمارەی n بیتی کۆ دەکەنەوە. لە ڕاستەوە بۆ چەپ دەڕوات و ئەمەش کاتی دەوێت.

To add two 4-bit numbers A3A2A1A0A_3A_2A_1A_0 and B3B2B1B0B_3B_2B_1B_0, put four full adders side by side, one per column, and connect the carry out of each stage to the carry in of the stage on its left — exactly like carrying by hand. The first carry in, C0C_0, is 0 (that stage could even be a half adder). The last carry out, C4C_4, is the fifth bit of the answer.

بۆ کۆکردنەوەی دوو ژمارەی چوار A3A2A1A0A_3A_2A_1A_0 و B3B2B1B0B_3B_2B_1B_0، چوار لە تەنیشت یەک دابنێ (بۆ هەر ستوونێک یەکێک) و دەرچووی هەر قۆناغێک ببەستە بە هاتووی قۆناغەکەی لای چەپی — ڕێک وەک گواستنەوە بە دەست. یەکەم هاتوو، C0C_0، 0ـە (ئەو قۆناغە تەنانەت دەتوانێت بێت). دوایین دەرچوو، C4C_4، پێنجەمین وەڵامەکەیە.

Block diagram of a 4-bit ripple-carry adder: four full-adder blocks FA in a row, stage 0 on the right and stage 3 on the left. Each block takes A_i and B_i from the top and gives S_i at the bottom. Carry C0 = 0 enters stage 0 from the right; carries C1, C2, C3 flow leftwards between the stages and C4 leaves stage 3 on the left.هێڵکاریی بلۆکیی کۆکەرەوەیەکی زنجیرەیی بە چوار بیت: چوار بلۆکی FA لە ڕیزێکدا، قۆناغی 0 لە ڕاست و قۆناغی 3 لە چەپ. هەر بلۆکێک A_i و B_i لە سەرەوە وەردەگرێت و S_i لە خوارەوە دەدات. گواستراوەی C0 = 0 لە ڕاستەوە دەچێتە قۆناغی 0؛ گواستراوەکانی C1، C2، C3 بەرەو چەپ لە نێوان قۆناغەکاندا دەڕۆن و C4 لە لای چەپەوە لە قۆناغی 3 دەردەچێت.
Four full adders, one carry chain.چوار ، یەک زنجیرەی .CêIT

Example: 1011+01101011 + 0110 (11+611 + 6). Each stage adds its two bits and the carry it receives:

نموونە: 1011+01101011 + 0110 (11+611 + 6). هەر قۆناغێک دوو و ئەو وەری دەگرێت کۆ دەکاتەوە:

1011+01101011 + 0110, stage by stage1011+01101011 + 0110، قۆناغ بە قۆناغ
StageقۆناغAiA_iBiB_iCiC_iCi+1C_{i+1}SiS_i
010001
111010
201110
310110

Reading S from stage 3 down to stage 0 and putting C4=1C_4 = 1 in front gives 1 00012=171\,0001_2 = 17 — the same result as adding by hand.

خوێندنەوەی S لە قۆناغی 3ـەوە بۆ قۆناغی 0 و دانانی C4=1C_4 = 1 لە پێشەوە 1 00012=171\,0001_2 = 17 دەدات — هەمان ئەنجامی کۆکردنەوە بە دەست.

Quick checkپشکنینی خێراIn a 4-bit ripple-carry adder, where does stage 2 get its carry in?لە بە چوار ، قۆناغی 2 هاتووی خۆی لە کوێوە وەردەگرێت؟

A 4-bit ripple-carry adderکۆکەرەوەیەکی زنجیرەیی بە چوار بیت

Why it is called “ripple”بۆچی پێی دەوترێت «زنجیرەیی»

Watch 0111+00010111 + 0001. Stage 1 cannot finish until stage 0 has produced its carry, stage 2 waits for stage 1, and so on: the carry travels along the chain like a ripple on water.

سەیری 0111+00010111 + 0001 بکە. قۆناغی 1 ناتوانێت تەواو بێت تا قۆناغی 0 دروست نەکات، قۆناغی 2 چاوەڕێی قۆناغی 1 دەکات و بەم شێوەیە: بە درێژایی زنجیرەکە دەڕوات وەک شەپۆلێک لەسەر ئاو.

Animation of a 4-bit ripple-carry adder adding 0111 and 0001. Stage by stage from the right, the active full adder is highlighted: stage 0 computes 1 + 1 + 0 = 10, giving S0 = 0 and carry 1; stages 1 and 2 compute 1 + 0 + 1 = 10, giving 0 and carry 1; stage 3 computes 0 + 0 + 1 = 01, giving S3 = 1 and carry 0. The last frame shows the result 1000 (7 + 1 = 8).
Animation of a 4-bit ripple-carry adder adding 0111 and 0001. Stage by stage from the right, the active full adder is highlighted: stage 0 computes 1 + 1 + 0 = 10, giving S0 = 0 and carry 1; stages 1 and 2 compute 1 + 0 + 1 = 10, giving 0 and carry 1; stage 3 computes 0 + 0 + 1 = 01, giving S3 = 1 and carry 0. The last frame shows the result 1000 (7 + 1 = 8).
The carry passes through every stage before the answer is ready. بە هەموو قۆناغێکدا تێدەپەڕێت پێش ئەوەی وەڵامەکە ئامادە بێت.CêIT

Each stage needs a little time, so the delay grows with the number of bits: a 64-bit ripple-carry adder must wait for the carry to pass 64 stages. Real processors therefore use faster adders that work out the carries in advance (called carry-lookahead adders). The idea of adding with full adders stays the same.

هەر قۆناغێک کەمێک کاتی پێویستە، بۆیە دواکەوتنەکە لەگەڵ ژمارەی زیاد دەبێت: بە ⁦64⁩ دەبێت چاوەڕێ بکات تا بە ⁦64⁩ قۆناغدا تێدەپەڕێت. بۆیە پرۆسێسەرە ڕاستەقینەکان خێراتر بەکار دەهێنن کە پێشوەختە هەژمار دەکەن (پێیان دەوترێت ⁦carry-lookahead⁩). بیرۆکەی کۆکردنەوە بە وەک خۆی دەمێنێتەوە.

Quick checkپشکنینی خێراWhy is a 32-bit ripple-carry adder slower than a 4-bit one?بۆچی بە ⁦32⁩ هێواشترە لە یەکێکی 4 ؟

How do computers add numbers so quickly?Spanning Tree · Englishئینگلیزی · 129K viewsبینین · 6.4K likesلایک

Animated robots show how a ripple-carry adder waits for each carry, and how carry-lookahead adders avoid the wait.

لە پیشان دەدەن چۆن چاوەڕێی هەر دەکات و ⁦carry-lookahead⁩ چۆن ئەو چاوەڕێکردنە لادەبەن.

0:00–2:40: why each stage of a ripple-carry adder waits for its carry; then the carry-lookahead adder this screen mentions.

⁦0:00⁩ تا ⁦2:40⁩: بۆچی هەر قۆناغێکی چاوەڕێی دەکات؛ پاشان ⁦carry-lookahead⁩، کە ئەم بەشە ناوی دەهێنێت.

Half and full subtractorsنیوەلێدەرکەر و لێدەرکەری تەواو

Subtraction can also be built straight from gates. One column of A−BA - B has four cases (the subtraction rules): 0−0=00 - 0 = 0, 1−0=11 - 0 = 1, 1−1=01 - 1 = 0, and 0−10 - 1, which gives 1 and a borrow from the next column. A half subtractor has two outputs: the difference D and the borrow for the next column, BoutB_{out}.

لێدەرکردنیش دەتوانرێت ڕاستەوخۆ بە دروست بکرێت. یەک ستوونی A−BA - B چوار حاڵەتی هەیە (یاساکانی لێدەرکردن): 0−0=00 - 0 = 0، 1−0=11 - 0 = 1، 1−1=01 - 1 = 0 و 0−10 - 1 کە 1 دەدات لەگەڵ لە ستوونی دواتر. نیوەلێدەرکەر دوو هەیە: جیاوازی D و بۆ ستوونی دواتر، BoutB_{out}.

Half subtractorنیوەلێدەرکەر
AABBA−BA - BDDBoutB_{out}
00000
01−1-111
10110
11000
D=A⊕BBout=A‾BD=A⊕B⊕BinBout=A‾B+A‾Bin+BBin\begin{aligned} D &= A \oplus B & B_{out} &= \overline{A}B \\ D &= A \oplus B \oplus B_{in} & B_{out} &= \overline{A}B + \overline{A}B_{in} + BB_{in} \end{aligned}

Top: half subtractor. Bottom: full subtractor, which also takes a borrow in, BinB_{in}, from the column on the right.

سەرەوە: نیوەلێدەرکەر. خوارەوە: لێدەرکەری تەواو، کە لە ستوونەکەی لای ڕاستەوە وەردەگرێت، BinB_{in}.

D is the same XOR as the adder's sum bit; only the borrow is new, and it is 1 only for 0−10 - 1. Like the full adder, a full subtractor can be built from two half subtractors and an OR gate. Processors seldom use them: the next screen shows how one adder does both jobs with the 2's complement.

D هەمان XORـی کۆی ؛ تەنها نوێیە و تەنها بۆ 0−10 - 1 یەکسانە بە 1. وەک ، لێدەرکەری تەواو دەتوانرێت لە دوو نیوەلێدەرکەر و دروست بکرێت. پرۆسێسەرەکان کەم بەکاریان دەهێنن: پەڕەی دواتر نیشان دەدات چۆن یەک بە هەردوو کارەکە دەکات.

Quick checkپشکنینی خێراA half subtractor gets A=0A = 0 and B=1B = 1. What are D and BoutB_{out}?نیوەلێدەرکەرێک A=0A = 0 و B=1B = 1 وەردەگرێت. D و BoutB_{out} چین؟

One adder can also subtractیەک کۆکەرەوە دەتوانێت لێدەرکردنیش بکات

From signed arithmetic you know that A−BA - B is AA plus the 2's complement of B, and the 2's complement is "invert every bit, then add 1". A ripple-carry adder can do both with one extra control input, SUB:

لە ژمێرکاریی ژمارە نیشانەدارەکان دەزانیت کە A−BA - B یەکسانە بە AA زائید تەواوکەری دووی B و واتە «هەموو پێچەوانە بکەرەوە، پاشان 1 زیاد بکە». دەتوانێت هەردووکیان بکات بە یەک کۆنترۆڵی زیادە، SUB:

  • Each bit BiB_i passes through an XOR gate with SUB: Bi⊕0=BiB_i \oplus 0 = B_i (unchanged) and Bi⊕1=Bi‾B_i \oplus 1 = \overline{B_i} (inverted).
  • SUB is also connected to C0C_0, so SUB=1SUB = 1 adds the extra 1.
  • SUB=0SUB = 0: the circuit computes A+BA + B. SUB=1SUB = 1: it computes A+B‾+1=A−BA + \overline{B} + 1 = A - B.
  • هەر BiB_i لەگەڵ SUB دەچێتە ناو : Bi⊕0=BiB_i \oplus 0 = B_i (نەگۆڕاو) و Bi⊕1=Bi‾B_i \oplus 1 = \overline{B_i} (پێچەوانەکراو).
  • SUB هەروەها بە C0C_0ـەوە بەستراوە، بۆیە SUB=1SUB = 1 ئەو 1ـە زیادەیە زیاد دەکات.
  • SUB=0SUB = 0: A+BA + B هەژمار دەکات. SUB=1SUB = 1: A+B‾+1=A−BA + \overline{B} + 1 = A - B هەژمار دەکات.
0110−0010=0110+1101+1=1 0100  ⇒  0100=40110 - 0010 = 0110 + 1101 + 1 = 1\,0100 \;\Rightarrow\; 0100 = 4

The final carry is discarded, as in 2's-complement addition.

کۆتایی فڕێ دەدرێت، وەک لە کۆکردنەوە بە تەواوکەری دوو.

This is how a processor's arithmetic unit does both + and − with one adder. Overflow is checked with the rule of the signed arithmetic lesson: it happens when the carry into the last stage differs from the carry out of it.

ئەمە ئەو ڕێگایەیە کە یەکەی ژمێرکاریی پرۆسێسەرێک بە یەک هەم + و هەم − دەکات. بە ڕێسای وانەی ژمێرکاریی ژمارە نیشانەدارەکان دەپشکنرێت: ڕوو دەدات کاتێک هاتوو بۆ دوایین قۆناغ جیاواز بێت لە دەرچوو لێی.

Quick checkپشکنینی خێراWith SUB=1SUB = 1, what does each XOR gate do to its B bit?بە SUB=1SUB = 1، هەر چی بە Bـی خۆی دەکات؟

Common mistakesهەڵە باوەکان

MistakeهەڵەFixچارەسەر
Using OR for the sum bit.بەکارهێنانی OR بۆ کۆ.The sum bit is XOR: OR gives the wrong answer for 1+11 + 1. کۆ XORـە: OR بۆ 1+11 + 1 وەڵامی هەڵە دەدات.
Using half adders for every column.بەکارهێنانی بۆ هەموو ستوونێک.Only the rightmost column can be a half adder; the others must accept a carry in.تەنها ستوونی هەرە ڕاست دەتوانێت بێت؛ ئەوانی تر دەبێت هاتوو وەربگرن.
Chaining carries from left to right.بەستنی لە چەپەوە بۆ ڕاست.Carries go from bit 0 (right) towards bit 3 (left), like carrying by hand. لە 0ـەوە (ڕاست) بەرەو 3 (چەپ) دەڕۆن، وەک گواستنەوە بە دەست.
Forgetting the final carry C4C_4.لەبیرکردنی کۆتایی C4C_4.For unsigned numbers it is the fifth bit of the sum (1011+0110=1 00011011 + 0110 = 1\,0001).بۆ پێنجەمین کۆکەیە (1011+0110=1 00011011 + 0110 = 1\,0001).
Thinking 2C+S2C + S is a typo for C+SC + S.وا بیرکردنەوە کە 2C+S2C + S هەڵەی نووسینە بۆ C+SC + S.The carry is worth 2 in its column: 1+1=2=2⋅1+01 + 1 = 2 = 2 \cdot 1 + 0. لە ستوونەکەی خۆیدا بەهای 2ـە: 1+1=2=2⋅1+01 + 1 = 2 = 2 \cdot 1 + 0.
Using the adder's carry rule for a subtractor's borrow.بەکارهێنانی یاسای بۆ لێدەرکەر.The borrow of a half subtractor is A‾B\overline{A}B (only 0−10 - 1), not ABAB. نیوەلێدەرکەر A‾B\overline{A}Bـە (تەنها 0−10 - 1)، نەک ABAB.

Exercisesڕاهێنانەکان

ExerciseڕاهێنانRipple it by handبە دەست بیگوازەرەوە

Add 1101+01111101 + 0111 with a 4-bit ripple-carry adder. Give every carry C1C_1 to C4C_4 and the sum.

1101+01111101 + 0111 بە بە چوار کۆ بکەرەوە. هەموو C1C_1 تا C4C_4 و کۆکە بدە.

Show answerوەڵامەکە پیشان بدە
StageقۆناغAiA_iBiB_iCiC_iCi+1C_{i+1}SiS_i
011010
101110
211111
310110

C1=C2=C3=C4=1C_1 = C_2 = C_3 = C_4 = 1, sum 1 01002=201\,0100_2 = 20 (13+7=2013 + 7 = 20).

C1=C2=C3=C4=1C_1 = C_2 = C_3 = C_4 = 1، کۆ 1 01002=201\,0100_2 = 20 (13+7=2013 + 7 = 20).

ExerciseڕاهێنانThree onesسێ یەک

A full adder gets A=1A = 1, B=1B = 1 and Cin=1C_{in} = 1. Find S and CoutC_{out} from the equations and check with 2Cout+S2C_{out} + S.

A=1A = 1، B=1B = 1 و Cin=1C_{in} = 1 وەردەگرێت. S و CoutC_{out} لە هاوکێشەکانەوە بدۆزەوە و بە 2Cout+S2C_{out} + S پشکنین بکە.

Show answerوەڵامەکە پیشان بدە
S=1⊕1⊕1=1Cout=1⋅1+1⋅1+1⋅1=12Cout+S=2+1=3=1+1+1\begin{aligned} S &= 1 \oplus 1 \oplus 1 = 1 \\ C_{out} &= 1\cdot1 + 1\cdot1 + 1\cdot1 = 1 \\ 2C_{out} + S &= 2 + 1 = 3 = 1 + 1 + 1 \end{aligned}
ExerciseڕاهێنانThe carry from a K-mapگواستراوە لە نەخشەیەکی کارنۆوە

Draw the K-map of CoutC_{out} (minterms 3, 5, 6, 7 of A, B, CinC_{in}) and simplify it.

CoutC_{out} بکێشە ( 3، 5، 6، 7 ی A، B، CinC_{in}) و کورتی بکەرەوە.

Show answerوەڵامەکە پیشان بدە
A\BCinA \backslash BC_{in}00011110
00010
10111

Three overlapping pairs around cell 7: BCinBC_{in} (cells 3, 7), ACinAC_{in} (cells 5, 7) and ABAB (cells 7, 6). Cout=AB+ACin+BCinC_{out} = AB + AC_{in} + BC_{in}.

سێ جووتی یەکتربڕ بە دەوری خانەی 7دا: BCinBC_{in} (خانەکانی 3، ⁦7⁩)، ACinAC_{in} (خانەکانی 5، ⁦7⁩) و ABAB (خانەکانی 7، ⁦6⁩). Cout=AB+ACin+BCinC_{out} = AB + AC_{in} + BC_{in}.

ExerciseڕاهێنانCounting gatesژماردنی گەیتەکان

A full adder uses 5 gates and a half adder 2. How many gates does a 4-bit ripple-carry adder need (a) with four full adders, (b) with a half adder in stage 0? How many for 32 bits with full adders only?

5 بەکار دەهێنێت و 2. بە چوار پێویستی بە چەند هەیە (أ) بە چوار ، (ب) بە لە قۆناغی 0دا؟ بۆ ⁦32⁩ تەنها بە چەندە؟

Show answerوەڵامەکە پیشان بدە

(a) 4×5=204 \times 5 = 20. (b) 3×5+2=173 \times 5 + 2 = 17. 32 bits: 32×5=16032 \times 5 = 160 gates.

(أ) 4×5=204 \times 5 = 20. (ب) 3×5+2=173 \times 5 + 2 = 17. بۆ ⁦32⁩ : 32×5=16032 \times 5 = 160 .

ExerciseڕاهێنانSubtract with the adderبە کۆکەرەوەکە لێدەربکە

With SUB=1SUB = 1, what does the 4-bit adder–subtractor output for A=0011A = 0011, B=0101B = 0101? Read the result as a signed number.

بە SUB=1SUB = 1، و لێدەرکەری چوار بۆ A=0011A = 0011، B=0101B = 0101 چی دەدات؟ ئەنجامەکە وەک بخوێنەوە.

Show answerوەڵامەکە پیشان بدە
0011+1010+1=1110  (C4=0)0011 + 1010 + 1 = 1110 \;(C_4 = 0)

11101110 in 2's complement is −2-2, and indeed 3−5=−23 - 5 = -2.

11101110 بە یەکسانە بە −2-2 و بەڕاستی 3−5=−23 - 5 = -2.

ExerciseڕاهێنانThe OR mistakeهەڵەی OR

Someone builds a "half adder" with an OR gate for S and an AND gate for C. For which input is it wrong, and what does it output there?

کەسێک «»ـێک دروست دەکات بە بۆ S و بۆ C. بۆ کام هەڵەیە و لەوێدا چی دەدات؟

Show answerوەڵامەکە پیشان بدە

Only for A=B=1A = B = 1: it outputs C=1C = 1, S=1S = 1, which means 112=311_2 = 3. The right answer is 1+1=101 + 1 = 10 (C=1C = 1, S=0S = 0). Use XOR for S.

تەنها بۆ A=B=1A = B = 1: C=1C = 1، S=1S = 1 دەدات کە واتە 112=311_2 = 3. وەڵامی ڕاست 1+1=101 + 1 = 10ـە (C=1C = 1، S=0S = 0). XOR بۆ S بەکاربهێنە.

ExerciseڕاهێنانThe full subtractor tableخشتەی ڕاستیی لێدەرکەری تەواو

Complete the truth table of a full subtractor (inputs A, B and the borrow in BinB_{in}; outputs D and BoutB_{out}). Then check the row 0−1−10 - 1 - 1.

لێدەرکەری تەواو تەواو بکە (: A، B و هاتوو BinB_{in}؛ : D و BoutB_{out}). پاشان ڕیزی 0−1−10 - 1 - 1 بپشکنە.

Hintئاماژە

Compute A−B−BinA - B - B_{in}. If it is negative, borrow: add 2 and set Bout=1B_{out} = 1.

A−B−BinA - B - B_{in} هەژمار بکە. ئەگەر سالب بوو، بخوازە: 2 زیاد بکە و Bout=1B_{out} = 1 دابنێ.

Show answerوەڵامەکە پیشان بدە
AABBBinB_{in}A−B−BinA - B - B_{in}DDBoutB_{out}
000000
001−1-111
010−1-111
011−2-201
100110
101000
110000
111−1-111

D is 1 when an odd number of inputs are 1 (a 3-input XOR, like the sum bit). BoutB_{out} is 1 whenever the result is negative. Row 0−1−1=−20 - 1 - 1 = -2: borrow 2, so D=0D = 0 and Bout=1B_{out} = 1.

D کاتێک 1ـە کە ژمارەیەکی تاک لە 1 بن (XORـێکی سێ ، وەک کۆ). BoutB_{out} هەر کاتێک ئەنجامەکە سالب بێت 1ـە. ڕیزی 0−1−1=−20 - 1 - 1 = -2: 2 بخوازە، بۆیە D=0D = 0 و Bout=1B_{out} = 1.

Summaryپوختە

  • Adding one column gives two bits: the sum S=A⊕BS = A \oplus B and the carry C=ABC = AB — a half adder.
  • A full adder also takes a carry in: S=A⊕B⊕CinS = A \oplus B \oplus C_{in}, Cout=AB+ACin+BCinC_{out} = AB + AC_{in} + BC_{in}; it is two half adders and an OR (5 gates).
  • A ripple-carry adder chains n full adders; the carry travels from bit 0 to bit n−1n-1, so the delay grows with n.
  • A half subtractor gives D=A⊕BD = A \oplus B and the borrow Bout=A‾BB_{out} = \overline{A}B; a full subtractor adds a borrow in.
  • XOR gates on the B inputs and C0=SUBC_0 = \text{SUB} turn the adder into an adder–subtractor (A−B=A+B‾+1A - B = A + \overline{B} + 1).
  • کۆکردنەوەی یەک ستوون دوو دەدات: کۆی S=A⊕BS = A \oplus B و C=ABC = AB — .
  • هاتووش وەردەگرێت: S=A⊕B⊕CinS = A \oplus B \oplus C_{in}، Cout=AB+ACin+BCinC_{out} = AB + AC_{in} + BC_{in}؛ دوو و ORـێکە (⁦5⁩ ).
  • n بە زنجیرە دەبەستێت؛ لە 0ـەوە بۆ n−1n-1 دەڕوات، بۆیە دواکەوتنەکە لەگەڵ n زیاد دەبێت.
  • نیوەلێدەرکەر D=A⊕BD = A \oplus B و Bout=A‾BB_{out} = \overline{A}B دەدات؛ لێدەرکەری تەواو هاتووش وەردەگرێت.
  • لەسەر B و C0=SUBC_0 = \text{SUB} دەکەن بە و لێدەرکەر (A−B=A+B‾+1A - B = A + \overline{B} + 1).
Review questionsپرسیارەکانی پێداچوونەوە
Why is the sum bit XOR and not OR?بۆچی بیتی کۆ XORـە نەک OR؟

Because 1+1=101 + 1 = 10: the sum bit must be 0 when both inputs are 1.

چونکە 1+1=101 + 1 = 10: کۆ دەبێت 0 بێت کاتێک هەردوو 1ن.

What is the difference between a half adder and a full adder?جیاوازیی نێوان نیوەکۆکەرەوە و کۆکەرەوەی تەواو چییە؟

The full adder has a third input, the carry in from the column on its right.

سێیەمی هەیە، هاتوو لە ستوونەکەی لای ڕاستییەوە.

What limits the speed of a ripple-carry adder?چی خێرایی کۆکەرەوەی زنجیرەیی سنووردار دەکات؟

The carry must pass through the stages one after another.

دەبێت یەک لە دوای یەک بە قۆناغەکاندا تێپەڕێت.

The course so far in one screenکۆرسەکە تا ئێستا لە یەک پەڕەدا

With adders you have built a circuit that calculates. Here is the road so far, chapter by chapter:

بە دروست کرد کە ژمێرکاری دەکات. ئەمە ئەو ڕێگایەیە کە تا ئێستا بڕیوتە، بەش بە بەش:

Notice how this lesson ties the course together: binary addition became a circuit of logic gates, described with Boolean algebra.

سەرنج بدە چۆن ئەم وانەیە کۆرسەکە پێکەوە دەبەستێتەوە: بوو بە لە کە بە وەسف دەکرێت.

Quick checkپشکنینی خێراWhich chapter's idea let you replace the OR in the report by the right gate for the sum bit?بیرۆکەی کام بەش ڕێگەی دا ORـەکەی ناو ڕاپۆرتەکە بە دروست بۆ کۆ بگۆڕیت؟

What comes nextدواتر چی دێت

Every circuit so far is combinational: same inputs, same outputs, no memory. The course goes on. The next lesson, Simulating and Testing Logic Circuits, lets a computer check your circuits, and the last chapter, Building Blocks and Sequential Logic, adds bigger building blocks and circuits with memory. Here is the map of the road ahead.

هەموو تا ئێستا تێکەڵەییـە: هەمان ، هەمان ، بێ . کۆرسەکە بەردەوامە. وانەی دواتر فێرت دەکات چۆن تاقی بکاتەوە ⁦(simulation)⁩ و کۆتا بەش، بلۆکە بنیاتنەرەکان و سووڕە زنجیرەییەکان، بلۆکی گەورەتر و خاوەن زیاد دەکات. ئەمە نەخشەی ڕێگای داهاتووە.

A four-column road map from gates to a computer. Column 1, "so far", highlighted as "you are here": number systems and codes, logic gates, Boolean algebra and K-maps, adders. Column 2, more combinational blocks: comparators, decoders and encoders, multiplexers, code converters and parity. Column 3, sequential logic with memory: latches, flip-flops, registers, counters. Column 4, computer architecture: ALU, registers and buses, control unit, CPU. Arrows lead from each column to the next. Under columns 2 and 3: "next: the last chapter of this course"; under column 4: "IT course: CPU lessons".نەخشەیەکی چوار ستوونی لە گەیتەکانەوە بۆ کۆمپیوتەر. ستوونی 1، «تا ئێستا»، کە نیشانەی «تۆ لێرەیت»ـی لەسەرە: سیستەمە ژمارەییەکان و کۆدەکان، گەیتە لۆجیکییەکان، جەبری بوول و نەخشەی کارنۆ، کۆکەرەوەکان. ستوونی 2، بلۆکی تێکەڵەیی زیاتر: بەراوردکەرەکان، کۆدهەڵوەشێنەرەکان و کۆدکەرەکان، مەڵتیپلێکسەرەکان، گۆڕەری کۆد و پاریتی. ستوونی 3، لۆجیکی زنجیرەیی بە بیرگە: لاچەکان، فلیپ-فلۆپەکان، تۆمارگەکان، ژمێرەرە دیجیتاڵەکان. ستوونی 4، تەلارسازیی کۆمپیوتەر: ALU، تۆمارگەکان و تێپەڕگەکان، یەکەی جڵەوکردن، CPU. تیرەکان لە هەر ستوونێکەوە بۆ ستوونی دواتر دەچن. لە ژێر ستوونەکانی 2 و 3: «دواتر: کۆتا بەشی ئەم کۆرسە»؛ لە ژێر ستوونی 4: «کۆرسی تەکنەلۆژیای زانیاری».
Each step is built from the one before it; the next two are taught in the last chapter.هەر هەنگاوێک لە هەنگاوی پێشووتری دروست دەکرێت؛ دوو هەنگاوی دواتر لە کۆتا بەشدا فێر دەکرێن.CêIT
Quick checkپشکنینی خێراWhat is the main difference between a combinational and a sequential circuit?جیاوازیی سەرەکیی نێوان و چییە؟

What comes nextدواتر چی دێت

More combinational building blocksبلۆکی تێکەڵەیی زیاتر

  • Comparators decide whether two binary numbers are equal, or which one is larger.
  • Decoders turn an n-bit code into one active output out of 2n2^n; encoders do the reverse. (Taught in the last chapter.)
  • Code converters change one code into another, for example binary to BCD or to Gray code.
  • Multiplexers select one of several inputs with select lines; demultiplexers send one input to one of several outputs. (Taught in the last chapter.)
  • Parity generators and checkers compute the parity bit with XOR gates.
  • بەراوردکەرەکان بڕیار دەدەن ئایا دوو ژمارەی یەکسانن، یان کامیان گەورەترە.
  • کۆدهەڵوەشێنەرەکان کۆدێکی n دەکەن بە یەک چالاک لە 2n2^n؛ کۆدکەرەکان پێچەوانەکەی دەکەن. (لە کۆتا بەشدا فێر دەکرێت.)
  • گۆڕەرەکانی کۆد کۆدێک دەگۆڕن بۆ کۆدێکی تر، بۆ نموونە بۆ یان بۆ .
  • مەڵتیپلێکسەرەکان بە هێڵی هەڵبژاردن یەکێک لە چەند هەڵدەبژێرن؛ دیمەڵتیپلێکسەرەکان ⁦(DEMUX)⁩ یەک دەنێرن بۆ یەکێک لە چەند . (لە کۆتا بەشدا فێر دەکرێت.)
  • دروستکەر و پشکنەری بیتی پاریتی بە هەژمار دەکەن.
Quick checkپشکنینی خێراWhich block chooses one of several inputs and passes it to its single output?کام بلۆک یەکێک لە چەند هەڵدەبژێرێت و دەینێرێت بۆ تاکە ؟

What comes nextدواتر چی دێت

Sequential logic: circuits with memoryلۆجیکی زنجیرەیی: سووڕی خاوەن بیرگە

  • A sequential circuit has outputs that depend on the present inputs and on what happened before. It usually follows a clock signal.
  • Latches and flip-flops store one bit each — the smallest memory.
  • Registers are groups of flip-flops that hold a whole binary word; shift registers move the bits along.
  • Counters step through a sequence of binary numbers on each clock pulse; timers produce pulses of a chosen length.
  • هەیە کە بەندن بە ئێستا و بەوەی پێشتر ڕوویداوە. زۆرجار سیگناڵی کاتژمێر پەیڕەو دەکات.
  • لاچەکان و فلیپ-فلۆپەکان هەر یەکەیان یەک هەڵدەگرن — بچووکترین .
  • تۆمارگەکان کۆمەڵێک کە تەواو هەڵدەگرن؛ جووڵاندن دەجووڵێنن.
  • ژمێرەرە دیجیتاڵەکان لە هەر بە زنجیرەیەک ژمارەی دەڕۆن؛ تایمەرەکان درێژیی دیاریکراو دروست دەکەن.

What comes nextدواتر چی دێت

Computer architectureتەلارسازیی کۆمپیوتەر

Put an adder–subtractor, a few logic operations (AND, OR, XOR) and a multiplexer together and you have an . An ALU, registers and a control unit that follows a clock form a CPU. CêIT's Information Technology course continues from here: the CPU and its ALU, registers and buses and how a computer runs a program. For the English words of the parts inside a computer see Inside the computer.

و لێدەرکەرێک، چەند (AND، OR، XOR) و پێکەوە دابنێ و دەبێت. ALU، و کە پەیڕەو دەکات پێک دەهێنن. کۆرسی لە CêIT لێرەوە بەردەوام دەبێت: CPU و ALU، تۆمارگەکان و تێپەڕگەکان و کۆمپیوتەر چۆن بەرنامەیەک جێبەجێ دەکات. بۆ وشە ئینگلیزییەکانی بەشەکانی ناو بڕوانە ناو کۆمپیوتەر.

Quick checkپشکنینی خێراAn adder–subtractor, a few logic operations and a multiplexer together form which part of a CPU? و لێدەرکەرێک، چەند و پێکەوە کام بەشی پێک دەهێنن؟

Videoڤیدیۆ

Watch a videoسەیری ڤیدیۆیەک بکە

A video that viewers liked a lot and praised in their comments, chosen for this lesson.ڤیدیۆیەک کە بینەران زۆریان پێ خۆش بووە و لە کۆمێنتەکانیاندا ستایشیان کردووە، بۆ ئەم وانەیە هەڵبژێردراوە.

Half Adders and Full Adders Beginner's TutorialLearn Learn Scratch Tutorials · Englishئینگلیزی · 255K viewsبینین · 4.9K likesلایک

Builds binary addition from gates: half adder, full adder and chaining full adders to add longer numbers, with a light circuit.

لە دروست دەکات: ، و بەستنەوەی بە یەکەوە بۆ کۆکردنەوەی ژمارەی درێژتر، لەگەڵ گڵۆپدار.

Chapters: 2:03 truth table, 4:35 half adders, 7:34 full adder logic, 9:44 full adder circuit.

بەشەکان: ⁦2:03⁩ ، ⁦4:35⁩ ، ⁦7:34⁩ لۆجیکی ، ⁦9:44⁩ .

Lesson complete!وانەکە تەواو بوو!

Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.

Key termsزاراوە سەرەکییەکان

Next lessonوانەی داهاتوو

Simulating and Testing Logic Circuitsهاوشێوەکردن و تاقیکردنەوەی سووڕە لۆجیکییەکان

References and further readingسەرچاوەکان و خوێندنەوەی زیاتر

This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.