Atledbet_11
Official Terrarian
Before I get started, I would like to thank NiraExecuto for their thread on how terraria's code treats wires, logic gates, etc.
I Created a youtube video demonstrating the 4 bit full adder I created, but it was put together kind-of abruptly and is a little lower quality than i would like it to be because my computer randomly started blue screening all of a sudden while I was recording.
So, now I will go over the Diagrams etc.
To begin I will Show you the old, Broken, Full adder.
Whenever C-in + A + B are on, you get output O + C-out. Which is correct for a full adder.
But if C-in + A + B are on and you deactivate either A or B, The or-gate gets the "smoke/steam error"
This steam error causes the C-out to be powered when it is not supposed to be powered. If the output
is on and runs into the C-in for the next bit then the addition will not be correct.
Now to look at how the "steam error" in this adder occurs.
If you read NiraExecuto's thread, you will understand why it occurs.
So here we have a picture of the wiring in the original 1bit Full Adder.
As you can see, the Or-gate has two inputs, both being the and-gates.
So the error here occurs at the timing of the outputs for the and-gates.
The one at the bottom gets both of its inputs from the A/B switches, however the and-gate at the top gets one of its inputs directly from the C-in Switch and the other from the output of an xor-gate. Since one of the top and-gate's inputs come from a logic gate, the and gate is technically-according to the game code for wiring-slower than the other and gate by one "tick".
And therefore when the output for the bottom and gate toggles, it gets to the or gate earlier. So when the top and gate is outputting, and the bottom and-gate is not, it takes longer for the top and-gate to turn on than the bottom and-gate takes to turn off. So when you deactivate A/B the or-gate is on, then it turns off, and turns back on all in one iteration of the circuit. And according to the game code when it detects a gate turning on multiple times in one iteration it will switch off and emit steam from the gate.
So... now how to fix that :>
The way you fix it is to get the and gate outputs to reach the or gate a the same time without considering the wire color based timing, so all you have to do is delay the bottom and-gate by one extra logic gate worth of delay. The way you do this without changing the value of the wire is by adding an or-gate with only one input. Then you run the output of the and-gate to the single input of the or-gate, and the output of the or-gate to the original or-gate.
So here is an example of the fix.
This new or-gate Delays the output of the bottom and-gate so that it reaches the original or-gate at the same time as the top and-gate. And as I demonstrated in the youtube video, this solution works. :>
Yet again Thanks NiraExecuto.
Also thanks to ZeroGravitas, it was your video that led me to the [T-MEC] forums. I then decided to like the page and signed up for alerts on it. The first [T-MEC] alert I received was Nira's, so technically I would not have completed it without ZeroGravitas, the [T-MEC] community, and NiraExecuto.
I will Try to keep check on this Thread in case any of you leave replies or questions, but I graduate tomorrow so I may not see them if you post tomorrow (May 27, 2016).
And by the way, if anyone was wondering, this is my first forum post. :>
I Created a youtube video demonstrating the 4 bit full adder I created, but it was put together kind-of abruptly and is a little lower quality than i would like it to be because my computer randomly started blue screening all of a sudden while I was recording.
So, now I will go over the Diagrams etc.
To begin I will Show you the old, Broken, Full adder.
Whenever C-in + A + B are on, you get output O + C-out. Which is correct for a full adder.
But if C-in + A + B are on and you deactivate either A or B, The or-gate gets the "smoke/steam error"
This steam error causes the C-out to be powered when it is not supposed to be powered. If the output
is on and runs into the C-in for the next bit then the addition will not be correct.

Now to look at how the "steam error" in this adder occurs.
If you read NiraExecuto's thread, you will understand why it occurs.

So here we have a picture of the wiring in the original 1bit Full Adder.
As you can see, the Or-gate has two inputs, both being the and-gates.
So the error here occurs at the timing of the outputs for the and-gates.
The one at the bottom gets both of its inputs from the A/B switches, however the and-gate at the top gets one of its inputs directly from the C-in Switch and the other from the output of an xor-gate. Since one of the top and-gate's inputs come from a logic gate, the and gate is technically-according to the game code for wiring-slower than the other and gate by one "tick".
And therefore when the output for the bottom and gate toggles, it gets to the or gate earlier. So when the top and gate is outputting, and the bottom and-gate is not, it takes longer for the top and-gate to turn on than the bottom and-gate takes to turn off. So when you deactivate A/B the or-gate is on, then it turns off, and turns back on all in one iteration of the circuit. And according to the game code when it detects a gate turning on multiple times in one iteration it will switch off and emit steam from the gate.
So... now how to fix that :>
The way you fix it is to get the and gate outputs to reach the or gate a the same time without considering the wire color based timing, so all you have to do is delay the bottom and-gate by one extra logic gate worth of delay. The way you do this without changing the value of the wire is by adding an or-gate with only one input. Then you run the output of the and-gate to the single input of the or-gate, and the output of the or-gate to the original or-gate.
So here is an example of the fix.

This new or-gate Delays the output of the bottom and-gate so that it reaches the original or-gate at the same time as the top and-gate. And as I demonstrated in the youtube video, this solution works. :>
Yet again Thanks NiraExecuto.
Also thanks to ZeroGravitas, it was your video that led me to the [T-MEC] forums. I then decided to like the page and signed up for alerts on it. The first [T-MEC] alert I received was Nira's, so technically I would not have completed it without ZeroGravitas, the [T-MEC] community, and NiraExecuto.
I will Try to keep check on this Thread in case any of you leave replies or questions, but I graduate tomorrow so I may not see them if you post tomorrow (May 27, 2016).
And by the way, if anyone was wondering, this is my first forum post. :>
Last edited: