Using the Full-Adder chip, we can add take two 1-bit inputs and output their 1-bit sum and possible carry bit.
But using only four FA chips we can construct a "4-Bit Ripple Carry Adder" which is able to add together two 4-bit inputs and likewise output their 4-bit sum and possible carry bit.
CIN
●
┌────┴─────┐
A[0] ●─┤ ├─● S[0]
A[1] ●─┤ ├─● S[1]
A[2] ●─┤ ├─● S[2]
A[3] ●─┤ ├─● S[3]
│ RCA_4B │
B[0] ●─┤ │
B[1] ●─┤ │
B[2] ●─┤ │
B[3] ●─┤ │
└────┬─────┘
●
COUT
The addends are read into the A and B pins as 4-digit Binary Numbers.
We won't reproduce the entire truth table for the RCA_8B chip here, but below are some testcases to make clear how it works:
RCA_8B.A │ RCA_8B.B ║ RCA_8B.S │ RCA_8B.COUT
──────────│──────────║──────────│─────────────
00000000 │ 00000000 ║ 00000000 │ 0 (0 + 0 => 0)
00000001 │ 00000000 ║ 00000001 │ 0 (1 + 0 => 1)
00000001 │ 00000001 ║ 00000010 │ 0 (1 + 1 => 2)
00000101 │ 00000101 ║ 00001010 │ 0 (5 + 5 => 10)
00000101 │ 00000111 ║ 00001100 │ 0 (5 + 7 => 12)
00000101 │ 00001010 ║ 00001111 │ 0 (5 + 10 => 15)
01010100 │ 10101010 ║ 11111110 │ 0 (84 + 170 => 254)
01010101 │ 10101011 ║ 00000000 │ 1 (85 + 171 => 0 +carry)
11111111 │ 11111111 ║ 11111110 │ 1 (255 + 255 => 254 +carry)
Notice that if the sum of the two input numbers is greater than 256 (the largest value able to be expressed by n 8-bit binary number), then the COUT pin will be active to indicate that there has been an overflow. The result of the sum will be the excess value (equivalent to the total sum modulo 256).
The circuit board will come pre-installed with INPUT and OUTPUT chips as shown below:
───────┐ ┌────────
├─● CIN S[0] ●─┤
│ S[1] ●─┤
├─● A[0] S[2] ●─┤
├─● A[1] S[3] ●─┤
├─● A[2] │
INPUT ├─● A[3] │ OUTPUT
│ │
├─● B[0] │
├─● B[1] │
├─● B[2] │
├─● B[3] COUT ●─┤
───────┘ └────────
For this problem, you will only be allowed to place Full-Adder chips. You should only need 4 of them, one per bit being processed.
After solving this problem you will also be allowed to place the 8-bit and 16-bit variants of this chip.
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.