Minecraft Wiki
Advertisement

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

Analog addition

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, but it increases the circuit delay. See the next section for the workaround.

Designs

Seiterarch's analog full adder
Newomaster's analog full adder

Disadvantages

These adders are called ripple-carry adders. However, the ripple-carry adder is relatively slow, since each full adder must wait for the carry out to be calculated from the previous full adder. We may use the carry cancel adder, which have less circuit delay than the ripple-carry adder. See the next section for more details.

Carry cancel adder

The carry cancel adder (CCA) is based on comparator XOR gates. A 4 hexadecimal digits carry cancel adder have a lower circuit delay than ripple-carry adders by a factor of 4, since the carry is computed in parallel. Currently, the only analog carry cancel adder is designed by YellowBunny.

Analog subtraction

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

Signal strength 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.

Design

Analog comparison

A is equal to B (A=B)

A is greater or equal to B (A≥B)

References

Advertisement