ViewWiki

Answer key · Unit 2

Logic gates.

Each lesson’s practice questions, their correct answers and the mistakes they spot. Answers read off the Scene use the same setting the learner sees.

Lesson 1 of 4 · About 20 minutes

AND, OR and NOT

The three basic gates: AND needs both inputs, OR settles for one, NOT flips; and how to choose a gate for what a circuit has to do.

Open the lesson

The 5 steps and their answers
  1. Step 1 of 5

    Open this step

    AND

    Practice · Predict, then look

    Question

    Both switches are down, and the AND and OR lights are dark. What will happen to the A AND B light when A goes up to 1 and B stays down?

    Correct answer

    • Correct It stays dark

    Setup, choices and feedback

    The Scene at this step

    Input bits
    0fixed
    Three gates / Half adder
    Three gateshidden

    Choices

    • Correct It stays dark

    • Wrong It lights, because A is on

      Misconception: Thinks AND outputs 1 when either input is 1.

      Feedback from the catalogue

      AND gives 11⁠ only when both inputs are 11⁠, like a door that opens only with a card and a code. A single 0 at an input is enough to make the output 0. The gate that gives 1 when at least one input is 1 is OR.

    Once the prediction is locked in, the Scene changes

    Input bits
    2fixed

    The Scene then shows: 0 · Logic: A AND B, the first LED (and the carry)/nodes/board/outputs/andOut

    A prediction is never marked as a failure: the learner sees the outcome and the explanation either way.

    Feedback for a right answer

    1 AND 0 is 0: AND needs both inputs. The OR light, though, has come on: one is enough for it.

    Worked solution

    1. AND gives 1 only when both inputs are 1.
    2. After the change A = 1 and B = 0.
    3. One input is 0, so 1 AND 0 = 0: the light stays dark.
  2. Step 2 of 5

    Open this step

    OR

    Practice · Predict, then look

    Question

    A is up and B is down, and the A OR B light is on. What will happen to it when B goes up as well?

    Correct answer

    • Correct It stays on

    Setup, choices and feedback

    The Scene at this step

    Input bits
    2fixed
    Three gates / Half adder
    Three gateshidden

    Choices

    • Correct It stays on

    • Wrong It goes off, since OR means one of the two, not both

      Misconception: Takes OR to be 0 when both inputs are 1, as the everyday "or" (one or the other, not both).

      Feedback from the catalogue

      In everyday speech “or” sometimes means “one of the two, not both”: tea or coffee. A logic gate’s OR includes both: it gives 1 when at least one input is 1, so 1 OR 1 is 1. The gate that gives 0 when both inputs are on is XOR, “exclusive or”.

    Once the prediction is locked in, the Scene changes

    Input bits
    3fixed

    The Scene then shows: 1 · Logic: A OR B, the second LED/nodes/board/outputs/orOut

    A prediction is never marked as a failure: the learner sees the outcome and the explanation either way.

    Feedback for a right answer

    1 OR 1 is 1: OR gives 1 when at least one input is 1, and two is at least one. Now the AND light is on too.

    Worked solution

    1. OR gives 0 only when both inputs are 0.
    2. After the change A = 1 and B = 1.
    3. At least one input is 1, so 1 OR 1 = 1.

    The everyday “or”, only one of the two, is another gate: XOR.

  3. Step 3 of 5

    Open this step

    NOT

    Practice · Reach the target

    Question

    The NOT A light is on. Change Input bits until it goes dark, and press Check.

    Goal

    • 0 ± 0.01

      At the start of the step: 1

    Setup, choices and feedback

    The Scene at this step

    Input bits
    0
    Three gates / Half adder
    Three gateshidden
    Read from the Scene at
    Logic: NOT A, the third LED/nodes/board/outputs/notOut

    One setting that reaches it

    Input bits
    2

    Feedback for a right answer

    NOT flips A: with A = 1 the output is 0. B makes no difference to it: it is not connected at all.

    Feedback for a wrong answer

    Not yet. NOT is on while A is down; raise A.

    Hint

    NOT has one input, A. What does it do to it?

    Worked solution

    1. NOT A is the opposite of A.
    2. For the output to be 0, A must be 1.
    3. Choose 1 0 or 1 1: B makes no difference.
  4. Step 4 of 5

    Open this step

    Only AND

    Practice · Reach the target

    Question

    Light the A AND B light, and press Check.

    Goal

    • 1 ± 0.01

      At the start of the step: 0

    Setup, choices and feedback

    The Scene at this step

    Input bits
    1
    Three gates / Half adder
    Three gateshidden
    Read from the Scene at
    Logic: A AND B, the first LED (and the carry)/nodes/board/outputs/andOut

    One setting that reaches it

    Input bits
    3

    Feedback for a right answer

    Only 1 1 lights AND: it is the one row of its table with a 1. Notice that in the same state NOT A is dark.

    Feedback for a wrong answer

    Not yet. AND needs both inputs up.

    Worked solution

    1. AND gives 1 only when A = 1 and B = 1.
    2. Choose 1 1.
  5. Step 5 of 5

    Open this step

    Choosing a gate

    Practice · Choose

    Question

    An alarm should ring if the window opens, if the door opens, or if both do. Each sensor gives 1 when what it guards is open. Which gate joins the two sensors to the alarm?

    Correct answer

    • Correct OR

    Setup, choices and feedback

    The Scene at this step

    Input bits
    0
    Three gates / Half adder
    Three gateshidden

    Choices

    Shown in a random order.

    • Correct OR

    • Wrong AND

      Misconception: Mixes up AND and OR.

      Feedback from the catalogue

      AND is strict: it needs every input at 1. OR is lenient: one is enough. In a two-input truth table AND gives 1 on only one row, 11, and OR gives 0 on only one row, 00. The symbols help: the AND gate has a flat back, and OR a curved back and a pointed nose.

    • Wrong XOR

      Misconception: Takes OR to be 0 when both inputs are 1, as the everyday "or" (one or the other, not both).

      Feedback from the catalogue

      In everyday speech “or” sometimes means “one of the two, not both”: tea or coffee. A logic gate’s OR includes both: it gives 1 when at least one input is 1, so 1 OR 1 is 1. The gate that gives 0 when both inputs are on is XOR, “exclusive or”.

    • Wrong NOT

      Feedback

      NOT has only one input, and here two must be combined.

    Feedback for a right answer

    OR: one sensor at 1 is enough to ring the alarm, and it rings when both are open too. AND would ring only when both are open, and XOR would go quiet exactly then.

    Worked solution

    1. Write the table: alarm on 01, 10 and 11, silence only on 00.
    2. That is exactly the table of OR.

    XOR gives 0 on the row 11: a burglar who opened both the window and the door would not set it off.

Lesson 2 of 4 · About 25 minutes

Truth tables

A table that describes a gate completely: a row for every combination of inputs, the columns of AND, OR and XOR, gates built from gates, and how many different gates there are at all.

Open the lesson

The 6 steps and their answers
  1. Step 1 of 6

    Open this step

    A row for every combination

    Practice · Calculate

    Question

    A truth table has a row for every combination of the inputs. How many rows does the truth table of a gate with three inputs have?

    Correct answer

    8 ± 0.01

    Setup, choices and feedback

    The Scene at this step

    Input bits
    0
    Three gates / Half adder
    Three gateshidden
    Accepted within
    ± 0.01
    A fixed value in the question

    Wrong answers it recognises

    Feedback for a right answer

    23=82^3 = 8⁠: the rows 000 to 111, the numbers 00⁠ to 77⁠ in base 2.

    Hint

    On the board, two inputs have four rows. What does a third input do?

    Worked solution

    1. Each input has two values, 0 or 1.
    2. Three inputs: 2×2×2=82 \times 2 \times 2 = 8⁠ combinations.
    3. The rows are 000,001,…,111000, 001, \ldots, 111⁠.
  2. Step 2 of 6

    Open this step

    The OR column

    Practice · Choose

    Question

    A truth table lists the rows in the order 00, 01, 10, 11 (A then B). What is the column of A OR B, from top to bottom? Step through the four Input bits and check.

    Correct answer

    • Correct 0, 1, 1, 1

    Setup, choices and feedback

    The Scene at this step

    Input bits
    0
    Three gates / Half adder
    Three gateshidden

    Choices

    Shown in a random order.

    • Correct 0, 1, 1, 1

    • Wrong 0, 0, 0, 1

      Misconception: Mixes up AND and OR.

      Feedback from the catalogue

      AND is strict: it needs every input at 1. OR is lenient: one is enough. In a two-input truth table AND gives 1 on only one row, 11, and OR gives 0 on only one row, 00. The symbols help: the AND gate has a flat back, and OR a curved back and a pointed nose.

    • Wrong 0, 1, 1, 0

      Misconception: Takes OR to be 0 when both inputs are 1, as the everyday "or" (one or the other, not both).

      Feedback from the catalogue

      In everyday speech “or” sometimes means “one of the two, not both”: tea or coffee. A logic gate’s OR includes both: it gives 1 when at least one input is 1, so 1 OR 1 is 1. The gate that gives 0 when both inputs are on is XOR, “exclusive or”.

    • Wrong 1, 0, 0, 0

      Feedback

      That is the column of NOR, the opposite of OR: 1 only when both inputs are 0.

    Feedback for a right answer

    OR is 0 only on the row 00, and 1 on the other three.

    Worked solution

    1. 00: no input at 1, so 0.
    2. 01 and 10: one input at 1, so 1.
    3. 11: both, so 1.
    4. The column: 0, 1, 1, 1.

    0, 0, 0, 1 is the column of AND, and 0, 1, 1, 0 that of XOR.

  3. Step 3 of 6

    Open this step

    OR but not AND

    Practice · Reach the target

    Question

    Find inputs at which the A OR B light is on and the A AND B light is dark, and press Check.

    Goal

    • 1 ± 0.01

      At the start of the step: 0

    • 0 ± 0.01

      At the start of the step: 0

    Setup, choices and feedback

    The Scene at this step

    Input bits
    0
    Three gates / Half adder
    Three gateshidden
    Read from the Scene at
    Logic: A OR B, the second LED/nodes/board/outputs/orOut
    Read from the Scene at
    Logic: A AND B, the first LED (and the carry)/nodes/board/outputs/andOut

    One setting that reaches it

    Input bits
    1

    Feedback for a right answer

    Both 0 1 and 1 0 work: exactly one input is on. “OR but not AND” is XOR, the gate the next Lesson builds an adder from.

    Feedback for a wrong answer

    Not yet. OR needs at least one input up, and AND needs them not both up.

    Worked solution

    1. OR is on at 01, 10, 11.
    2. AND is dark at 00, 01, 10.
    3. Both hold at 01 and 10: choose either.
  4. Step 4 of 6

    Open this step

    XOR

    Practice · Choose

    Question

    XOR, “exclusive or”, gives 1 when exactly one input is 1. What is its column in the order 00, 01, 10, 11?

    Correct answer

    • Correct 0, 1, 1, 0

    Setup, choices and feedback

    The Scene at this step

    Input bits
    0
    Three gates / Half adder
    Three gateshidden

    Choices

    Shown in a random order.

    • Correct 0, 1, 1, 0

    • Wrong 0, 1, 1, 1

      Feedback

      That is the column of OR. XOR differs from it exactly on the row 11.

    • Wrong 1, 0, 0, 1

      Feedback

      That is the column of XNOR, “equal”: 1 when the two inputs match.

    Feedback for a right answer

    0, 1, 1, 0: XOR asks whether the inputs differ. And if you see the two inputs as two one-bit numbers, it is exactly the right-hand digit of their sum.

    Worked solution

    1. 00 and 11: none or both on, not exactly one: 0.
    2. 01 and 10: exactly one: 1.
    3. The column: 0, 1, 1, 0.
  5. Step 5 of 6

    Open this step

    Gates from gates

    Practice · Choose

    Question

    The expression (A OR B) AND NOT (A AND B)(A \text{ OR } B) \text{ AND NOT } (A \text{ AND } B)⁠ is built from the board’s three kinds of gate. At which inputs is it 1? Mark them all.

    Correct answer

    • Correct 0 1

    • Correct 1 0

    Setup, choices and feedback

    The Scene at this step

    Input bits
    0
    Three gates / Half adder
    Three gateshidden

    Choices

    Shown in a random order. More than one choice is correct: every one must be selected.

    • Wrong 0 0

      No feedback of its own; the learner sees the standard message

      Not yet. Look again and try once more.

    • Correct 0 1

    • Correct 1 0

    • Wrong 1 1

      Misconception: Takes OR to be 0 when both inputs are 1, as the everyday "or" (one or the other, not both).

      Feedback from the catalogue

      In everyday speech “or” sometimes means “one of the two, not both”: tea or coffee. A logic gate’s OR includes both: it gives 1 when at least one input is 1, so 1 OR 1 is 1. The gate that gives 0 when both inputs are on is XOR, “exclusive or”.

    Feedback for a right answer

    Only 01 and 10. It is the table of XOR, built from AND, OR and NOT alone: with those three you can build any gate.

    Hint

    Work each row in stages: first OR, then AND, then NOT, and finally the AND joining them.

    Worked solution

    1. 00: OR is 0, so the whole thing is 0.
    2. 01, 10: OR is 1, AND is 0, its NOT is 1, and 1 AND 1 = 1.
    3. 11: OR is 1, but AND is 1 and its NOT is 0, so 1 AND 0 = 0.
  6. Step 6 of 6

    Open this step

    Every gate

    Practice · Calculate

    Question

    A two-input gate is decided entirely by its output column in the truth table. How many different two-input gates can be defined?

    Correct answer

    16 ± 0.01

    Setup, choices and feedback

    The Scene at this step

    Input bits
    0
    Three gates / Half adder
    Three gateshidden
    Accepted within
    ± 0.01
    A fixed value in the question

    Wrong answers it recognises

    Feedback for a right answer

    24=162^4 = 16⁠ different columns, from 0000 to 1111. Among them AND, OR, XOR, NAND, NOR, and even dull gates that always give 0 or always 1.

    Hint

    The column has four rows, each 0 or 1.

    Worked solution

    1. A two-input table has 4 rows.
    2. On each row the output is 0 or 1: 2 choices.
    3. 2×2×2×2=162 \times 2 \times 2 \times 2 = 16⁠.

    44⁠ is the number of rows, not of tables.

Lesson 3 of 4 · About 20 minutes

A half adder

Gates that compute: adding two bits, a carry that is AND and a sum that is XOR, how the NOT blocks the sum at 1 + 1, and why it is only half an adder.

Open the lesson

The 5 steps and their answers
  1. Step 1 of 5

    Open this step

    Adding two bits

    Practice · Predict, then look

    Question

    The gates are rewired into a half adder, and both inputs are 0. What will the Carry and Sum lights show when we add 1+11 + 1⁠?

    Correct answer

    • Correct Carry 1, sum 0

    Setup, choices and feedback

    The Scene at this step

    Input bits
    0fixed
    Three gates / Half adder
    Half adderfixed

    Choices

    • Correct Carry 1, sum 0

    • Wrong Carry 0, sum 1

      Misconception: Takes the half adder's sum bit to be A OR B, so that 1 + 1 gives a sum of 1.

      Feedback from the catalogue

      The sum bit is XOR, not OR. 1+1=21 + 1 = 2⁠, and in base 2 two is written 10: sum bit 0, and a carry of 1 into the next place, just as 5+5=105 + 5 = 10⁠ in base ten. So the sum is 1 only when exactly one input is 1, and in the half adder the NOT after the AND blocks it when both are on.

    • Wrong Carry 1, sum 1

      Misconception: Takes the half adder's sum bit to be A OR B, so that 1 + 1 gives a sum of 1.

      Feedback from the catalogue

      The sum bit is XOR, not OR. 1+1=21 + 1 = 2⁠, and in base 2 two is written 10: sum bit 0, and a carry of 1 into the next place, just as 5+5=105 + 5 = 10⁠ in base ten. So the sum is 1 only when exactly one input is 1, and in the half adder the NOT after the AND blocks it when both are on.

    Once the prediction is locked in, the Scene changes

    Input bits
    3fixed

    The Scene then shows: 2 · Logic: carry and sum read as a binary number, carry × 2 + sum (equals A + B)/nodes/board/outputs/total

    A prediction is never marked as a failure: the learner sees the outcome and the explanation either way.

    Feedback for a right answer

    1+1=2=1021 + 1 = 2 = 10_2⁠: the carry is the 2s digit and the sum the 1s digit. The board reads the two lights together as a binary number.

    Worked solution

    1. 1+1=21 + 1 = 2⁠.
    2. In base 2, 2=1022 = 10_2⁠: the 2s digit is 1 and the 1s digit is 0.
    3. The carry is the 2s digit: 1. The sum is the 1s digit: 0.

    A sum of 1 would be right if the sum were OR. It is XOR.

  2. Step 2 of 5

    Open this step

    A sum with no carry

    Practice · Reach the target

    Question

    The carry is on and the sum is dark. Find inputs at which the Sum light is on and the Carry light is dark, and press Check.

    Goal

    • 1 ± 0.01

      At the start of the step: 0

    • 0 ± 0.01

      At the start of the step: 1

    Setup, choices and feedback

    The Scene at this step

    Input bits
    3
    Three gates / Half adder
    Half adderfixed
    Read from the Scene at
    Logic: the half adder's sum bit, A XOR B/nodes/board/outputs/sum
    Read from the Scene at
    Logic: the half adder's carry, A AND B/nodes/board/outputs/carry

    One setting that reaches it

    Input bits
    1

    Feedback for a right answer

    0+10 + 1⁠ and 1+01 + 0⁠ are both 1=0121 = 01_2⁠: a sum with no carry.

    Feedback for a wrong answer

    Not yet. Which sum of two bits gives exactly 1?

    Worked solution

    1. Sum 1 and carry 0 are 012=101_2 = 1⁠.
    2. A+B=1A + B = 1⁠ when exactly one input is 1.
    3. Choose 0 1 or 1 0.
  3. Step 3 of 5

    Open this step

    The carry

    Practice · Choose

    Question

    The carry light is on only for 1+11 + 1⁠. Which gate on its own computes the carry?

    Correct answer

    • Correct AND

    Setup, choices and feedback

    The Scene at this step

    Input bits
    3
    Three gates / Half adder
    Half adderfixed

    Choices

    Shown in a random order.

    • Correct AND

    • Wrong OR

      Misconception: Mixes up AND and OR.

      Feedback from the catalogue

      AND is strict: it needs every input at 1. OR is lenient: one is enough. In a two-input truth table AND gives 1 on only one row, 11, and OR gives 0 on only one row, 00. The symbols help: the AND gate has a flat back, and OR a curved back and a pointed nose.

    • Wrong XOR

      Misconception: Takes the half adder's sum bit to be A OR B, so that 1 + 1 gives a sum of 1.

      Feedback from the catalogue

      The sum bit is XOR, not OR. 1+1=21 + 1 = 2⁠, and in base 2 two is written 10: sum bit 0, and a carry of 1 into the next place, just as 5+5=105 + 5 = 10⁠ in base ten. So the sum is 1 only when exactly one input is 1, and in the half adder the NOT after the AND blocks it when both are on.

    Feedback for a right answer

    The carry is 1 only when both inputs are 1: the table of AND. On the board the AND’s output goes straight to the carry light, and also to the NOT on the way.

    Worked solution

    1. The carry column: 0, 0, 0, 1.
    2. That is the column of AND.

    OR would carry for 0+10 + 1⁠ too, and XOR is the sum digit.

  4. Step 4 of 5

    Open this step

    The sum

    Practice · Predict, then look

    Question

    The sum is built as (A OR B) AND NOT (A AND B)(A \text{ OR } B) \text{ AND NOT } (A \text{ AND } B)⁠. Now A = 1 and B = 0, and the sum is on. When B goes up too, the sum will go dark. What will the NOT’s output, NOT(A AND B)\text{NOT}(A \text{ AND } B)⁠, be then?

    Correct answer

    • Correct 0: it blocks the sum

    Setup, choices and feedback

    The Scene at this step

    Input bits
    2fixed
    Three gates / Half adder
    Half adderfixed

    Choices

    • Correct 0: it blocks the sum

    • Wrong 1: it is the OR that goes off and blocks

      Misconception: Takes OR to be 0 when both inputs are 1, as the everyday "or" (one or the other, not both).

      Feedback from the catalogue

      In everyday speech “or” sometimes means “one of the two, not both”: tea or coffee. A logic gate’s OR includes both: it gives 1 when at least one input is 1, so 1 OR 1 is 1. The gate that gives 0 when both inputs are on is XOR, “exclusive or”.

    Once the prediction is locked in, the Scene changes

    Input bits
    3fixed

    The Scene then shows: 0 · Logic: NOT (A AND B), the half adder's inner NOT/nodes/board/outputs/nandOut

    A prediction is never marked as a failure: the learner sees the outcome and the explanation either way.

    Feedback for a right answer

    At 1 1 the AND gives 1, the NOT turns it into 0, and the last AND, which needs both its inputs, shuts. The OR stays at 1 throughout.

    Worked solution

    1. A AND BA \text{ AND } B⁠ = 1 AND 1 = 1.
    2. NOT(1) = 0.
    3. A OR BA \text{ OR } B⁠ = 1, so the sum is 1 AND 0 = 0: it is the NOT that blocks.
  5. Step 5 of 5

    Open this step

    Half an adder

    Practice · Choose

    Question

    Why is this circuit called a half adder?

    Correct answer

    • Correct Because it has no input for a carry coming from the column to its right, so it suits only the rightmost column

    Setup, choices and feedback

    The Scene at this step

    Input bits
    1
    Three gates / Half adder
    Half adder

    Choices

    Shown in a random order.

    • Correct Because it has no input for a carry coming from the column to its right, so it suits only the rightmost column

    • Wrong Because it adds only half the numbers

      Feedback

      It adds any two bits correctly. What it lacks is a third bit, the carry from the column before.

    • Wrong Because it has only half the gates it needs

      Feedback

      The name comes not from the number of gates but from what it can add: two bits, not three.

    Feedback for a right answer

    In column addition every column but the rightmost must add three bits: the two digits and the carry. A full adder does that, and is built from two half adders and an OR gate.

    Worked solution

    1. When adding long numbers, a carry passes from each column to the one on its left.
    2. A half adder adds only two bits.
    3. So it suits the rightmost column, which has no carry in, and the others need a full adder.

Lesson 4 of 4 · About 25 minutes

A full adder and the processor

Three bits in a column: the full adder, eight of them in a row in a processor's arithmetic unit, binary addition with carries, and what happens when the sum does not fit in a byte.

Open the lesson

The 5 steps and their answers
  1. Step 1 of 5

    Open this step

    A full adder

    Practice · Predict, then look

    Question

    The processor is about to add 28+1428 + 14⁠. The Zoom into the chip loupe will hold bit 3 of the arithmetic unit: a full adder receiving a=1a = 1⁠, b=1b = 1⁠ and a carry in of 1 from the bit to its right. What will it give?

    Correct answer

    • Correct Sum 1, carry out 1

    Setup, choices and feedback

    The Scene at this step

    Clock tick
    7fixed
    First number
    28fixed
    Second number
    14fixed
    Zoom into the chip
    Blocksfixed
    Other settings
    Loupe bit/nodes/cpu/props/loupeBit = 3

    Choices

    • Correct Sum 1, carry out 1

    • Wrong Sum 0, carry out 1

      Misconception: Adds only a and b in a full adder, ignoring the carry coming in from the bit to its right.

      Feedback from the catalogue

      A full adder adds three bits: aa⁠, bb⁠, and the carry from the column to its right, just as in column addition at school. 1+1+1=3=1121 + 1 + 1 = 3 = 11_2⁠: sum bit 1 and carry 1. Without the carry in, each column would ignore what happened in the columns before it.

    • Wrong Sum 1, carry out 0

      Feedback

      1+1+1=31 + 1 + 1 = 3⁠, more than 1, so there must be a carry out.

    Once the prediction is locked in, the Scene changes

    Zoom into the chip
    Transistorsfixed

    A prediction is never marked as a failure: the learner sees the outcome and the explanation either way.

    Feedback for a right answer

    1+1+1=3=1121 + 1 + 1 = 3 = 11_2⁠: sum digit 1 and a carry of 1 into bit 4. The loupe shows the three bits going in and the two coming out, with transistors switching to match.

    Worked solution

    1. A full adder adds three bits: 1+1+1=31 + 1 + 1 = 3⁠.
    2. 3=1123 = 11_2⁠: the 1s digit is 1 and the 2s digit is 1.
    3. Sum 1, carry out 1.

    Sum 0 comes from ignoring the carry in and adding only 1+11 + 1⁠.

  2. Step 2 of 5

    Open this step

    Column addition

    Practice · Calculate

    Question

    The first number is 0001 110020001\,1100_2⁠ and the second 0000 111020000\,1110_2⁠. Add them in base 2, column by column with carries, as the arithmetic unit does. What is the result in base ten?

    Correct answer

    42 ± 0.01

    Setup, choices and feedback

    The Scene at this step

    Clock tick
    7
    First number
    28
    Second number
    14
    Zoom into the chip
    Transistors
    Other settings
    Loupe bit/nodes/cpu/props/loupeBit = 3
    Accepted within
    ± 0.01
    A fixed value in the question

    Wrong answers it recognises

    • 18 ± 0.01

      Misconception: Adds binary numbers column by column without carrying.

      Feedback from the catalogue

      When a column gives 1+11 + 1⁠, its sum is 0 and a 1 carries to the next column. Dropping the carry gives the XOR of the two numbers, not their sum: 0001 110020001\,1100_2⁠ and 0000 111020000\,1110_2⁠ give 0001 00102=180001\,0010_2 = 18⁠ instead of 4242⁠. Correct addition carries as in base ten.

    Feedback for a right answer

    0010 10102=32+8+2=420010\,1010_2 = 32 + 8 + 2 = 42⁠, and 28+14=4228 + 14 = 42⁠. Run the processor until it stores the result in cell 13, and it will appear there.

    Hint

    Start on the right. In a column with 1+11 + 1⁠, write 0 and carry 1 to the left.

    Worked solution

    1. Bits 0 and 1: 0+0=00 + 0 = 0⁠, 0+1=10 + 1 = 1⁠, no carry.
    2. Bit 2: 1+1=1021 + 1 = 10_2⁠: write 0, carry 1.
    3. Bit 3: 1+1+1=1121 + 1 + 1 = 11_2⁠: write 1, carry 1.
    4. Bit 4: 1+0+1=1021 + 0 + 1 = 10_2⁠: write 0, carry 1. Bit 5: 0+0+1=10 + 0 + 1 = 1⁠.
    5. The result is 0010 10102=32+8+2=420010\,1010_2 = 32 + 8 + 2 = 42⁠.

    If you got 1818⁠, you dropped the carries.

  3. Step 3 of 5

    Open this step

    Eight adders

    Practice · Choose

    Question

    This processor’s arithmetic unit adds two bytes. How is it built?

    Correct answer

    • Correct Eight full adders in a row, each passing its carry to the next

    Setup, choices and feedback

    The Scene at this step

    Clock tick
    7
    First number
    28
    Second number
    14
    Zoom into the chip
    Transistors
    Other settings
    Loupe bit/nodes/cpu/props/loupeBit = 3

    Choices

    Shown in a random order.

    • Correct Eight full adders in a row, each passing its carry to the next

    • Wrong A table in memory with the answer for every pair of numbers

      Misconception: Thinks the processor adds by looking up memorised answers rather than computing them with gates.

      Feedback from the catalogue

      There is no table of every sum in the processor: two bytes have 256×256=65,536256 \times 256 = 65{,}536⁠ combinations, and such a table would be huge. The arithmetic unit computes the sum: eight full adders in a row, each made of a few gates, each passing its carry to the next. The same simple gates add any pair of numbers.

    • Wrong One big gate per bit, with no link between the bits

      Misconception: Adds binary numbers column by column without carrying.

      Feedback from the catalogue

      When a column gives 1+11 + 1⁠, its sum is 0 and a 1 carries to the next column. Dropping the carry gives the XOR of the two numbers, not their sum: 0001 110020001\,1100_2⁠ and 0000 111020000\,1110_2⁠ give 0001 00102=180001\,0010_2 = 18⁠ instead of 4242⁠. Correct addition carries as in base ten.

    Feedback for a right answer

    Eight copies of the same full adder, one per bit. The carry “ripples” from right to left, hence the name ripple-carry adder. The loupe shows one of them, transistor by transistor.

    Worked solution

    1. Each column of binary addition adds three bits: two digits and a carry. That is a full adder.
    2. A byte has eight columns, so eight full adders.
    3. Each one’s carry out is the carry in of the one to its left.

    A table of every sum would need 65,536 rows; the gates work each sum out afresh.

  4. Step 4 of 5

    Open this step

    Overflow

    Practice · Calculate

    Question

    The first number is 200200⁠ and the second 100100⁠. The result has to fit in one byte, in cell 13. Which number will be stored there?

    Correct answer

    44 ± 0.01

    Setup, choices and feedback

    The Scene at this step

    Clock tick
    0
    First number
    200
    Second number
    100
    Zoom into the chip
    Blocks
    Accepted within
    ± 0.01
    A fixed value in the question

    Wrong answers it recognises

    • 300 ± 0.01

      Misconception: Expects an 8-bit adder to hold any sum, not knowing that a result over 255 wraps around.

      Feedback from the catalogue

      A byte has only eight places, so it holds at most 255. When a sum goes past 255, the carry out of the leftmost bit has nowhere to go: it lights as the carry flag, and the byte keeps only what is past 256. 200+100=300200 + 100 = 300⁠, and the byte keeps 300−256=44300 - 256 = 44⁠. Programs that compute with bigger numbers use several bytes.

    • 255 ± 0.01

      Misconception: Expects an 8-bit adder to hold any sum, not knowing that a result over 255 wraps around.

      Feedback from the catalogue

      A byte has only eight places, so it holds at most 255. When a sum goes past 255, the carry out of the leftmost bit has nowhere to go: it lights as the carry flag, and the byte keeps only what is past 256. 200+100=300200 + 100 = 300⁠, and the byte keeps 300−256=44300 - 256 = 44⁠. Programs that compute with bigger numbers use several bytes.

    Feedback for a right answer

    200+100=300=1 0010 11002200 + 100 = 300 = 1\,0010\,1100_2⁠: nine bits. The ninth leaves as the carry and lights the carry flag, and the byte keeps the eight on the right, 0010 11002=440010\,1100_2 = 44⁠. Try it: set the numbers and move Clock tick to the end.

    Hint

    A byte holds only 00⁠ to 255255⁠. What happens to the carry out of the leftmost bit?

    Worked solution

    1. 200+100=300200 + 100 = 300⁠.
    2. 300>255300 > 255⁠, so the sum does not fit in a byte: the carry from the leftmost bit goes to the carry flag.
    3. The byte keeps 300−256=44300 - 256 = 44⁠.

    300300⁠ cannot be stored in a byte, and 255255⁠ is not what happens: the hardware does not stop at the limit, it starts again from 00⁠.

  5. Step 5 of 5

    Open this step

    A byte in memory

    Practice · Reach the target

    Question

    Set the First number so that cell 14 holds the byte 0010 010120010\,0101_2⁠, and press Check.

    Goal

    • 37 ± 0.01

      At the start of the step: 28

    Setup, choices and feedback

    The Scene at this step

    Clock tick
    0fixed
    First number
    28
    Second number
    14fixed
    Zoom into the chip
    Blocks
    Read from the Scene at
    Cell14/nodes/cpu/props/cell14

    One setting that reaches it

    First number
    37

    Feedback for a right answer

    0010 01012=32+4+1=370010\,0101_2 = 32 + 4 + 1 = 37⁠. Cell 14 in memory now shows the same eight bits.

    Feedback for a wrong answer

    Not yet. Add the place values over the ones.

    Hint

    32+4+132 + 4 + 1⁠.

    Worked solution

    1. The place values: 128,64,32,16,8,4,2,1128, 64, 32, 16, 8, 4, 2, 1⁠.
    2. The ones in 0010 010120010\,0101_2⁠ stand under 3232⁠, 44⁠ and 11⁠.
    3. 32+4+1=3732 + 4 + 1 = 37⁠: set the First number to 37.

Across the unit · 11 misconceptions

Misconception catalogue

Each common mistake this unit recognises, in a few words. Open one for what the learner reads when an answer matches it, and where it is asked.

  • Thinks AND outputs 1 when either input is 1.

    The learner reads

    AND gives 11⁠ only when both inputs are 11⁠, like a door that opens only with a card and a code. A single 0 at an input is enough to make the output 0. The gate that gives 1 when at least one input is 1 is OR.

  • Takes OR to be 0 when both inputs are 1, as the everyday "or" (one or the other, not both).

    The learner reads

    In everyday speech “or” sometimes means “one of the two, not both”: tea or coffee. A logic gate’s OR includes both: it gives 1 when at least one input is 1, so 1 OR 1 is 1. The gate that gives 0 when both inputs are on is XOR, “exclusive or”.

  • Mixes up AND and OR.

    The learner reads

    AND is strict: it needs every input at 1. OR is lenient: one is enough. In a two-input truth table AND gives 1 on only one row, 11, and OR gives 0 on only one row, 00. The symbols help: the AND gate has a flat back, and OR a curved back and a pointed nose.

  • Thinks each extra input adds two rows to a truth table instead of doubling them.

    The learner reads

    Each extra input doubles the number of rows: every old row appears once with 0 in the new input and once with 1. So nn⁠ inputs have 2n2^n⁠ rows: two inputs 4, three 8, four 16. They are exactly all the binary numbers of nn⁠ bits.

  • Confuses the number of rows in a truth table with the number of different tables, that is of different gates.

    The learner reads

    A gate with two inputs has 4 rows, and a gate is decided by what it writes on each of them: 0 or 1. Four rows, with two choices on each, give 24=162^4 = 16⁠ different tables, that is 16 different two-input gates. AND, OR and XOR are three of them.

  • Takes the half adder's sum bit to be A OR B, so that 1 + 1 gives a sum of 1.

    The learner reads

    The sum bit is XOR, not OR. 1+1=21 + 1 = 2⁠, and in base 2 two is written 10: sum bit 0, and a carry of 1 into the next place, just as 5+5=105 + 5 = 10⁠ in base ten. So the sum is 1 only when exactly one input is 1, and in the half adder the NOT after the AND blocks it when both are on.

  • Adds only a and b in a full adder, ignoring the carry coming in from the bit to its right.

    The learner reads

    A full adder adds three bits: aa⁠, bb⁠, and the carry from the column to its right, just as in column addition at school. 1+1+1=3=1121 + 1 + 1 = 3 = 11_2⁠: sum bit 1 and carry 1. Without the carry in, each column would ignore what happened in the columns before it.

  • Adds binary numbers column by column without carrying.

    The learner reads

    When a column gives 1+11 + 1⁠, its sum is 0 and a 1 carries to the next column. Dropping the carry gives the XOR of the two numbers, not their sum: 0001 110020001\,1100_2⁠ and 0000 111020000\,1110_2⁠ give 0001 00102=180001\,0010_2 = 18⁠ instead of 4242⁠. Correct addition carries as in base ten.

  • Expects an 8-bit adder to hold any sum, not knowing that a result over 255 wraps around.

    The learner reads

    A byte has only eight places, so it holds at most 255. When a sum goes past 255, the carry out of the leftmost bit has nowhere to go: it lights as the carry flag, and the byte keeps only what is past 256. 200+100=300200 + 100 = 300⁠, and the byte keeps 300−256=44300 - 256 = 44⁠. Programs that compute with bigger numbers use several bytes.

  • Thinks the processor adds by looking up memorised answers rather than computing them with gates.

    The learner reads

    There is no table of every sum in the processor: two bytes have 256×256=65,536256 \times 256 = 65{,}536⁠ combinations, and such a table would be huge. The arithmetic unit computes the sum: eight full adders in a row, each made of a few gates, each passing its carry to the next. The same simple gates add any pair of numbers.

  • Expects NOT to pass its input through unchanged, or to output 0 whatever comes in.

    The learner reads

    NOT flips: 0 in, 1 out; 1 in, 0 out. It has just one input, here A. So the NOT light is on exactly when A is down, and goes dark when A goes up.

    Recognised in
    Not used by any question yet.
Index