Implementing Half and Full Adders in Minecraft - 115DAB/WS2024 GitHub Wiki

INTRODUCTION

At a young age, everyone’s first math lesson is the basics of addition. The incredibly simple lesson of “1 + 1 = 2” is the absolute foundation for all computation. Consequently, this same basic lesson must be revisited in the context of designing a digital computer to complete complex calculations. This paper describes the gate-level operation of half and full-adders, which digital computers implement as fundamental building blocks for binary addition. Minecraft is an open-world game that utilizes “redstone” as an imitation of electric circuits from the real world. All of the boolean algebra functions necessary to recreate any digital logic circuit can be implemented by utilizing redstone circuits. As a result, Minecraft is an effective tool for visualizing the gates used to build an adder.

HALF ADDERS

A half adder adds two one-bit numbers and displays their sum as the output. A one bit number is a binary number with a value of 0 or 1. Figure 1 displays a table of the half adder logic.

ha_truth-300x235 Figure 1[1]: Half Adder Logic Table

Adding in a one-bit binary format is almost the same as base-10 addition. Adding 0 and 0 together equals 0. Adding 1 and 0 together equals 1. However, once we add 1 and 1, we must have an additional digit to represent the output. This second digit is called the “carry” bit.

Looking at the “sum” bit and “carry” bit individually, we can see how to create the logic for a half adder. A karnaugh map for the “sum” bit is shown in Figure 2. It is identical to the XOR function. A karnaugh map for the “carry” bit is shown in Figure 3. It is the AND function. Putting them together, we can see the implementation of a half adder.

xorkmap Figure 2[1]

Inkedandkmap1-200x155 Figure 3[1]

image Figure 4[1]

FULL ADDERS

A full adder is similar to a half adder, but has an additional “carry-in” bit as an input. This “carry-in” bit can come from the “carry-out” of previous adders, and needs to be accounted for in the “sum” and “carry-out” outputs. Figure 5 shows the logic table for a full adder. By observation, we can see that the “sum” and “carry-out” functions in a full adder are similar to the functions in a half adder. Sum is still the XOR function but with 3 inputs now. “Carry-out” is slightly more complex but is the majority function (outputs 1 when at least 2 inputs are 1). This is equivalent to the function “(carry-in) (A’ B + A B’)”

Figure 6 shows the gate implementation for a full adder. We can also make a full adder with 2 half adders by feeding our “carry in” into the result of the first adder.

2-41 Figure 5[2]

3-57 Figure 6[2]

4-34 Figure 7[2]

MULTIPLE BIT ADDERS

So far, we have mentioned how to implement adders given 2 bits of input (plus a carry bit). In reality, modern computers run on 8-bit or higher systems which requires the addition of numbers that can have dozens of digits. Implementing larger adders can become more complex and have design considerations such as complexity, area, cost, and speed. The most basic multi-bit adder is the ripple-carry adder that is just a string of full adders where each ith adder takes the ith bit of input A and B and adds it with the ith carry in. This is a simple but slow adder because each successive adder needs to wait for the previous carry bit.

DIGITAL CIRCUITS

The most common method to implement logic gates in the real-world is Complementary Metal Oxide Semiconductor (CMOS) circuitry. CMOS circuitry is a combination of P-Channel and N-Channel MOSFETs, which can be simplified into switch-like models. We can represent binary numbers with voltage VDD for 1 and GND for 0. An NMOS’s output is identical to its input signal. A PMOS’s output is the NOT operation of its input. Then, we can use CMOS circuitry to build any arbitrary logic function. Shown below are the XNOR and NAND gates. These are the inverse of XOR and NAND, and are vital due to their universality. Any possible digital logic circuit can be recreated solely by the use of XNOR or NAND logic gates.

Screenshot-2023-04-14-at-4 02 16-PM-1536x942 Screenshot-2023-04-14-at-7 13 55-PM-833x1024 Figure 8[3]

Figure 9[3]

MINECRAFT ADDERS

In Minecraft, wires are represented with redstone dust, inputs can be represented with levers, and switches (transistors) can be represented by redstone torches. We will use these three elements to create our XOR and AND gates. 2016-08-26_15 17 06 Figure 10[5]

An XOR gate is shown in Figure 10. Here’s how it works. Each switch controls a pair of redstone torches on the left. On top, the wiring of the 2 torches creates an AND gate. It controls the middle redstone torch therefore creating a NAND gate. The output of that NAND gate is AND with the input from the lever. These 2 outputs are then inverted with the redstone torches on the right and then AND together to create the output. Figure 9 shows an example when both inputs on the left are 0. The redstone torches on the left are on which makes the central torch off. The AND creates 2 paths to the torches on the right that are on. The torches on the right invert the input and add to output 0. Now we add in the AND gate which can be seen below the XOR gate. The AND operation is performed by connecting the 2 inputs together through wires. There are some redstone torches to invert the input. Together, these 2 make our SUM and CARRY outputs and completes our half adder.

2016-08-26_16 02 52 Figure 11[5]

CONCLUSION

Adders are the foundation of all of digital and binary computing. We cover the most basic half and full adder topologies, and depict how they can be recreated in Minecraft using simple logic gates. For further work, there are more advanced topologies, such as carry-ripple adders, which are significantly more efficient for adding larger numbers of bits.

SOURCES

[1] Half Adder in Digital Logic - GeeksforGeeks [2]Full Adder in Digital Logic - GeeksforGeeks [3] Figure 5 CMOS - Wikipedia [4] CMOS Logic Gates Explained - ALL ABOUT ELECTRONICS Figure 6
[5] Figure 7,8: Minecraft redstone – Part 10: Half and Full Adders – Bermotech [6] Digital Design: A Systems Approach [7] Digital logic and computer design [8] Digital Vlsi Design