It's been interesting learning how chips can perform basic logic and route signals, but now let's begin exploring one function to which the microchip is very well suited - performing fast mathematical operations.
Modern CPUs can perform billions of mathematical operations per second. We're going to start with something manageable - adding two bits together using a Half-Adder chip.
┌──────────┐
A ●─┤ │
│ HA ├─● S
B ●─┤ │
└────┬─────┘
●
COUT
The HA chip reads in two bits from its inputs named A and B, then outputs the single-bit sum on the pin S.
However if both the A and B pins are reading 1, then the binary result of 10 cannot be represented with the single-bit S pin.
In that case, the S pin is left unpowered and instead the COUT pin transmits a 1 signal to indicate a "carry bit" to be carried over to the next binary digit.
HA.A │ HA.B ║ HA.S │ HA.COUT
──────│──────║──────│─────────
0 │ 0 ║ 0 │ 0
0 │ 1 ║ 1 │ 0
1 │ 0 ║ 1 │ 0
1 │ 1 ║ 0 │ 1
The circuit board will come pre-installed with INPUT and OUTPUT chips as shown below:
───────┐ ┌────────
├─● A S ●─┤
INPUT │ │ OUTPUT
├─● B COUT ●─┤
───────┘ └────────
Digital Logic Circuit Interface
For these Digital Logic Circuits tasks, you will not be providing an answer string you would for other tasks.
Instead, your Solution Code will be interpreted directly to place chips onto the circuitboard and connect them with wires.
Click here to learn the Digital Logic Circuit Syntax used on this site.
After the chips have been placed and connected, the server will run a series of tests, randomly assigning values to the input pin(s) and checking to see if the output pins read the corresponding expected values. If all tests produce the expected outputs, then the circuitboard is considered a success.
Even though we won't be using the "Your answer" box, you'll still need to put something in that box to submit your solution. Just put anything - it will not be passed to the interpreter.
Truth Table
Design a circuit board which satisfies the following Truth Table:
INPUT.A │ INPUT.B ║ OUTPUT.S │ OUTPUT.COUT
─────────│─────────║──────────│─────────────
0 │ 0 ║ 0 │ 0
0 │ 1 ║ 1 │ 0
1 │ 0 ║ 1 │ 0
1 │ 1 ║ 0 │ 1