Tutorials/Calculator

This is my first big Minecraft project, and also it is the first time I will be explaining this to others. If I will not explain clearly, you should check the tutorials I am based on.

Resume
This is the plan of the current calculator I've built :

Of course, all compilations are made with binary code. This is why we have many different decoders.

Current Parts
I will try to go in a somewhat logic order to describe the parts.

Control Panel (room)
The control panel is the room from which you set the inputs and decide of the operation

Numbers Input Panel
Here, the user will decide what numbers he wants to use. Right now, I am using a lever-based binary input system, so the user has to decompose the numbers he wants to use into powers of two.

Operation Panel
From this panel, the user chooses between the operations he is going to use : add (+), subtract (-), multiply (*) and divide (/). Again, right now, I am using the lever system.

Input Wires (white and orange)
These wires link the input panel and the operation panel to the different logic units. Try to rearrange them in a manner where the same values go together. So, your wires should look like, from left to right: A1; B1; A2; B2; A4; B4; ...

Logic Units
These are the machines that perform the operations.

Adder/Subtractor (yellow and red)
'''NOTE: On the plan, the subtractor and the adder are separated. I will try to fix it as soon as I can.'''

I've built my own version of a adder/subtractor. Its construction is simple because it is modulated (made of many same parts). That means that if you use more bits, you can just add more parts on the side, but you'll have to change some links.



In this machine, your inputs (in binary code) goes into the bottom (yellow) full adders. Each adder needs the two inputs (A and B) with the same values. Also, the least significant bit has to be on the left, so they should all be connected by their carries. Basically, your inputs look like the wires in the section. Use basic bridges to pass wires over the others without connecting them. Your A inputs (left) are the minuend (X in X-Y=Z), and go straight in the adders. The B inputs, your subtrahend (Y in X-Y=Z), have to pass through a multiplexer, made out of a modified version of a XOR gate which gives to the adder an inverted signal in case of a subtraction. The multiplexer is controlled by a switch (on the picture, that switch is on the left). The sums go into another multiplexer, which, again, gives an inverted input in case of a subtraction. This is controlled by an IMPLIES gate (in the top right) which gives a true output if the switch is on "Subtraction" AND if the last carry is true. This is required because on a subtraction, that last carry actually means the "-" (minus) sign.

The white machines are half-adders, that use, as inputs, the carry of the last adder and the sum of their respective full adder. We need this because, if the answer is negative, it uses the equation " -A = !A (inverted A)+ 1 ", as explained here. The final outputs are all of the top-most wires you can observe, plus the wire on the right (the carry from the last full adder) and the carry that goes in the first (left) half-adder, as the negation sign.

Multiplier
Let's start with the basics here, because this is the most complicated part. As you should know, if you went to school, multiplication is a repeated addition. That means that, once again, we will use adders here.