User:HaydenBobMutthew/Mathematical analog circuit

A mathematical analog circuit is a circuit which operates on signal strength, such as arithmetic and comparison.

Introduction
Since there is no redstone adder in Minecraft, we need to convert addition into subtraction.

a + b = a + b - 15 + 15 = - 15 + a + b + 15 = - (15 - a - b) + 15 = 15 - (15 - a - b)

However, as signal strength cannot be higher than 15, we need to have sum and carry out outputs on the adder. Then we have:

sum = / a + b if a + b < 16 \ a + b - 16 if a + b ≥ 16 = / 15 - (15 - a - b) if a + b < 16 (hereinafter omitted) \ a + b - 15 - 1 if a + b ≥ 16 = a - 15 + b - 1 = - (15 - a) + (b - 1) = (b - 1) - (15 - a) carry out = / 0 if a + b < 16 \ 1 if a + b ≥ 16

In an adder, there is also a carry in input (denoted by c below) on the adder, called a full adder, so we have the following equations:

sum = a + b + c    = / 15 - (15 - a - b - c) if a + b + c < 16 (hereinafter omitted) \ (b + c - 1) - (15 - a) if a + b + c ≥ 16 = (b - 1 + c) - (15 - a)    = b - (1 - c) - (15 - a) carry out = / 0 if a + b + c < 16 \ 1 if a + b + c ≥ 16

If a + b + c > 15, 15 - (15 - a - b - c) will be 15 in terms of comparators. If a + b + c < 16, b - (1 - c) - (15 - a) will be 0 in terms of comparators. This runs a problem: if a + b + c = 15 or 16, then 15 - (15 - a - b - c) will be 15 and b - (1 - c) - (15 - a) will be 0, making impossible to distinguish whether the first expression or second expression should be the final output. So this method didn't work. We can spilt the full adder into two half adders, that is using the following equations:

p = / 15 - (15 - a - b) if a + b < 16 \ (b - 1) - (15 - a) if a + b ≥ 16 q = / 0 if a + b < 16 \ 1 if a + b ≥ 16 r = q + c sum = p + r    = / 15 - (15 - p - r) if a + b + c < 16 \ (r - 1) - (15 - p) if a + b + c ≥ 16 carry out = / 0 if p + r < 16 \ 1 if p + r ≥ 16

Designs

 * ?×?×? (? block volume)
 * flat, silent
 * circuit delay: TBD


 * Earliest Known Publication: February 5, 2013

Introduction
Although we have a redstone subtractor that can be achieved by a comparator in subtract mode, there are no negative signal strength in Minecraft. Our first approach is use the fact that a - b - c = a + NOT b + NOT c = a + (15 - b) + (1 - c), where c is the borrow in. Then we can apply an analog inverter before the "b" input.

Analog inverter
An signal strength inverter is a circuit that inverts the signal strength, for example a signal with the strength of 6 will be changed to 9, and a full strength signal will be 0. This can be achieved by placing a redstone block or redstone torch at the back of a redstone comparator and the input signal will be at the side of the comparator, and the output signal will be at front of the comparator, or by making a signal strength repeater wire, but instead of the wire in front of the repeater, place a block with a redstone torch attached to the front. place a wire in front of every torch, and the bottom-left redstone dust is the output. Note that the signal strength inverter works as a 4-bit bitwise NOT operation.