How in the WORLD do filt adders work??

  • Rons
    7th December Member 1 Permalink

    i have played tpt for 3 years but i still have no clue how they work and nothing ever helped me understand

  • Jerehmia
    8th December Member 2 Permalink

    First you need to understand how wavelengths work, IOW that light in TPT consists of a mix of 30 predefined colors represented as a 30-bit number where every bit indicates whether the predefined color is present in the mix or not.

     

    FILT can do logic operations on the 30 bits of TPT light simultaniously, so 1 particle of FILT can be 30 logic gates (like AND, OR, NOT and XOR) at once. The TPT wiki explains how to set up FILT as a logic component.

     

    Once you understand FILT logic you design a binary half adder circuit that adds two input bits together and produces the sum in a "sum bit" and indcates if there was an overflow (IOW if both input bits were 1) in a "carry bit".

     

    Now all you have to do is feed the output of one half adder into the next half adder while bitshifting the carry bit to the left and repeat that either 28 times or until there are no more carry bits to create an adder.

     

    You can either use a single half adder in a loop like this:

     

    Or you can physically couple 29 half adders together to create a fast adder:

    Edited 3 times by Jerehmia. Last: 8th December
  • Rons
    8th December Member 1 Permalink

    i understand the light wavelenght stuff but i cant understand the part abt filt doing stuff the only adder i made was made of ptct and ntct gates

  • Jerehmia
    8th December Member 2 Permalink

    @Rons (View Post)

     A FILT particle can store a light wavelength as its ctype. All FILT operations apply the wavelength stored in their ctype to light shining through it. You can set a FILT ctype by hand (with the PROP tool) or you can use a sensor (generally a LDTC or a DTEC) to set a FILT's ctype dynamically. The most convenient light source to use is a BRAY emitted by an ARAY because BRAYs have infinite speed and are easy to aim (unlike PHOT).

     

    To set up FILT logic you set up an ARAY that shines a BRAY through a first FILT particle in SET-mode that sets the BRAY wavelength to its ctype, followed by one or more FILT particles in a logic operation mode that change the wavelength of the BRAY shining through it and finally you set up a DTEC or LDTC to read the BRAYs wavelength into a result FILT.

     

    Note that light (including BRAY) has to have at least one wavelength to exist, if light has no wavelength left it will be annihilated by the game. This means FILT logic won't work if the BRAY that holds the calculated value has no wavelength set because there will be no BRAY to read the result from. The easiest way to avoid this problem is to always set one wavelength bit to 1 (usually the 30th bit with value 536870912) so the BRAY will never be annihilated and ignore the always-on bit in the end.

    Edited 2 times by Jerehmia. Last: 8th December
  • Rons
    8th December Member 1 Permalink

    The OR FILT is the one responsible for adding the 2 values?

  • Jerehmia
    8th December Member 2 Permalink

    Yes, the OR FILT logically ors ("adds") the wavelengths of its ctype to the wavelengths of the BRAY that passes through it and changes the BRAY accordingly.

  • Rons
    9th December Member 1 Permalink

    so is the half adders in that save basically filts with value firing through or-filts with value but they have extra steps so these values can be passed to the other half adders

  • Jerehmia
    9th December Member 2 Permalink

    A half adder is basically an XOR gate to calculate the bit sum and an AND gate to calculate the bit overflow/carry. Because FILT works with 30 wavelengths in parallel, a single FILT particle works like 30 logic gates working on 30 signals simultaneously. As explained above we need to have the 30th bit set to 1 always to avoid BRAY annihilation so that leaves 29 logic gates working on 29 signals.

     

    This means that a FILT half adder produces all 29 bit sums and carry bits in a single step. All following steps will take the carry bits from the previous step, shift them one bit to the left and add them to the existing 29 bit sums.

     

    Step 1) Let's do 11 + 9 = 20 as an example:

    Input A: 11 = 01011 binary

    Input B: 9 = 01001 binary

    Sum bits: A XOR B => 01011 XOR 01001 = 00010

    Carry bits: A AND B => 01011 AND 01001 = 01001

     

    Step 2) Because we have carry bits set to 1 the calculation hasn't ended so we take the carry bits and shift them to the left so we can add them to the next larger sum bits:

    Input A: 00010 sum bits from last step

    Input B: 10010 carry bits from last step shifted left

    Sum bits: A XOR B => 00010 XOR 10010 = 10000

    Carry bits: A AND B => 00010 AND 10010 = 00010

     

    Step 3) We still have carry bits set to 1, so:

    Input A: 10000 sum bits from last step

    Input B: 00100 carry bits from last step shifted left

    Sum bits: A XOR B => 10000 XOR 00100 = 10100

    Carry bits: A AND B => 10000 AND 00100 = 00000

     

    Step 4) We have no carry bits set to 1 so:

    Result: 10100 = 20 decimal, sum bits from last step

     

    This is exactly how the sequential adder above works, the fast adder always does 29 steps even if the carry bits are all 0 but because adding a 0 to a result doesn't change the result it doesn't affect the outcome of the addition.

    Edited 4 times by Jerehmia. Last: 9th December
  • Rons
    10th December Member 1 Permalink

    i think i finally understood it. how does one shift their carries left

     

  • Jerehmia
    10th December Member 2 Permalink

    You use a FILT in variable red shift mode (tmp 10) and a 1 bit shift (ctype 2). Because you shift out the 30th bit you could end up annihilating the BRAY, so you have to OR a 29th bit (IOW use a FILT with tmp 2 and ctype 268435456) to the BRAY before you shift left.

    Edited once by Jerehmia. Last: 10th December