Showcase [Showcase] A calculator using only logic gates!

ekinator

Empress of Light
I've been spending this past month making an 8 bit calculator without any knowledge about logic gates.
I didn't want to use any hoiking (because that would be another game mechanic to learn) so I ended up making everything out of logic gates. I hope that nobody else has done that so I can say that I am the first one to build an instant/spam-proof calculator in the game( ͡° ͜ʖ ͡°)
So this is the build:
7TorJ2w.png

It's quite HUGE, but I am not done with it since it doesn't even have the divider circuit yet. (All the gates I've colored purple are buffers fyi)
Here's a closer look at the inputs:
AjEpzv9.png

The inputs are in binary and displayed in decimal above them for convenience. The lever in the middle is for cycling between +, -, * and /
Pluses of the design:
+It does all the logic in a single game tick.
That means it can't get any faster than this ;)
+It's spam proof
Minuses:
-difficult to make (uses thousands of buffer gates)

I will provide a world download after I make and add a divider circuit to it.

-----------------------------------------------------------------------------------------------------------------------------------------------------------
PROGRESS UPDATE!
The divider circuit is done! I would have liked it to be a little bit more compact though.

With wiring:
yplkgTY.png


Without wiring:
Da5LkHK.png

I'd like to see how others have made their divider circuits (are there even other dividers made in terraria? I can't find any.)
Also thanks for the suggestion @Programmatic to use my adder circuit to subtract! I'll make sure to try that.
 

Attachments

  • 8b_calculator_new.wld
    472.3 KB · Views: 252
Last edited:
Ripple carry I guess. I just used a design that I found on google :D
mult4x4.gif
yup that looks like ripple carry to me :p I was going to work on something like this eventually, but you beat me to it XD I've spent too much time building minigames instead of computational stuff. But hey, this is really cool! Also, if you want to make the torches more invisible, use shadow paint for the torches and background instead of black.
 
I'm also making a calculator. However, mine will not be instantaneous (so you can keep the bragging rights). I understand how your multiplication algorithm works, but your binary->BCD converter doesn't look familiar. Is there a name for the conversion algorithm you're using? Also, to make your calculator smaller, you can actually get rid of the entire subtractor circuit by using your adder to subtract. You can do this by adding the first argument and the 2's complement (negative) of the second argument. To get the 2's complement, take the second argument, invert it (turn every 0 into a 1 and vice versa), and then add 1 to it using the carry input to the 1s digit in the adder.
 
I'm also making a calculator. However, mine will not be instantaneous (so you can keep the bragging rights). I understand how your multiplication algorithm works, but your binary->BCD converter doesn't look familiar. Is there a name for the conversion algorithm you're using? Also, to make your calculator smaller, you can actually get rid of the entire subtractor circuit by using your adder to subtract. You can do this by adding the first argument and the 2's complement (negative) of the second argument. To get the 2's complement, take the second argument, invert it (turn every 0 into a 1 and vice versa), and then add 1 to it using the carry input to the 1s digit in the adder.
I'm curious, what do you personally use as binary to bcd? I use double dabble algorithm
 
I also use Double-Dabble, though that algorithm might not be enough for my floating point calculator.
Well, I don't think double dabble would work with that. I honestly don't understand floating point that much. Maybe you could release a tutorial? :p This is the best thing I could find for floating point binary to decimal http://sandbox.mc.edu/~bennet/cs110/flt/ftod.html

Also, I don't know if you're interested, but here's what I was able to put together/design for binary to bcd.
7812138a71.png

2a71ce4d0d.png
fc303b2c35.png

88bbd4668c.png
 
I understand how your multiplication algorithm works, but your binary->BCD converter doesn't look familiar. Is there a name for the conversion algorithm you're using? .
It uses double dabble.
I forgot to add in the post that I used a design made by crawlr here. All I did was just ''flip'' the module upside down an rearange their position to make it look a bit cleaner.
 
Last edited:
It uses double dabble.
I forgot to add in the post that I used a design made by crawlr here. All I did was just ''flip'' the module upside down an rearange their position to make it look a bit cleaner.
do you think you should show your shift-add-3 module? :) I'm curious how other people are doing it
 
It uses double dabble.
I forgot to add in the post that I used a design made by crawlr here. All I did was just ''flip'' the module upside down an rearange their position to make it look a bit cleaner.

So that is Double-Dabble. It just didn't look familiar to me since the logic gate only design that you used differs from the step-by-step technique that I know (like the one showed here (https://en.wikipedia.org/wiki/Double_dabble). I suppose the modules that you highlighted in blue are what add 3 if a BCD digit is 5 or greater.
 
do you think you should show your shift-add-3 module? :) I'm curious how other people are doing it
here are both of the designs side by side:
5bhlubF.png

The one on the right is the original by @crawlr and the other one is what I used in the calculator.
Now, that both of the designs are next to each other, I noticed that I could have done a better work compacting my version of the circuit XD
 
here are both of the designs side by side:
5bhlubF.png

The one on the right is the original by @crawlr and the other one is what I used in the calculator.
Now, that both of the designs are next to each other, I noticed that I could have done a better work compacting my version of the circuit XD
ahh nice! You're doing yours left to right, i did mine top to bottom :p
2a71ce4d0d.png
 
I'm pasting a copy in the replies section because I don't know if a notification popped up in anybody's alert section when I edited the thread.

-----------------------------------------------------------------------------------------------------------------------------------------------------------
PROGRESS UPDATE!
The divider circuit is done! I would have liked it to be a little bit more compact though.

With wiring:
yplkgTY.png


Without wiring:
Da5LkHK.png

I'd like to see how others have made their divider circuits (are there even other dividers made in terraria? I can't find any.)
Also thanks for the suggestion @Programmatic to use my adder circuit to subtract! I'll make sure to try that.
 
I'd like to see how others have made their divider circuits (are there even other dividers made in terraria? I can't find any.)
Also thanks for the suggestion @Programmatic to use my adder circuit to subtract! I'll make sure to try that.

I have an 8-bit integer divider:

k3n3tt.png


n4hx0o.png


It uses faulty lamp gates and a hoik line, so it's not instantaneous (takes about 16 ticks to operate). However, it's pretty compact and can detect a divide by 0 error. I also made a 16-bit floating point divider (no screenshot yet, but I will make a post on it soon).
Also, about subtracting using the adder, make sure you also discard the extra 9th bit when doing so, or else you'll end up with a number larger than your input.
 
I have an 8-bit integer divider:

k3n3tt.png


n4hx0o.png


It uses faulty lamp gates and a hoik line, so it's not instantaneous (takes about 16 ticks to operate). However, it's pretty compact and can detect a divide by 0 error. I also made a 16-bit floating point divider (no screenshot yet, but I will make a post on it soon).
Well that looks like a MILLION times easier to make :D
the divide by 0 error shouldn't be a problem to me since I can just add an AND gate with 8 inputs and connect the divider circuits output to it. Then I can use that signal to display an error message or cut off the outputs from reaching the binary to BCD converter, or maybe do both :)
[doublepost=1470261219,1470255721][/doublepost]
Well that looks like a MILLION times easier to make :D
the divide by 0 error shouldn't be a problem to me since I can just add an AND gate with 8 inputs and connect the divider circuits output to it. Then I can use that signal to display an error message or cut off the outputs from reaching the binary to BCD converter, or maybe do both :)
I just noticed that wouldn't work. the error of dividing by 0 has the same output values as when dividing 255 by 1:(
 
Well that looks like a MILLION times easier to make :D
the divide by 0 error shouldn't be a problem to me since I can just add an AND gate with 8 inputs and connect the divider circuits output to it. Then I can use that signal to display an error message or cut off the outputs from reaching the binary to BCD converter, or maybe do both :)
[doublepost=1470261219,1470255721][/doublepost]
I just noticed that wouldn't work. the error of dividing by 0 has the same output values as when dividing 255 by 1:(

Or you could just wire each bit of the denominator to a NOR gate. Then, if the NOR gate returns true, block off the signal to every segment in each display digit and configure the rightmost digit to show the letter E (basically a backwards 3).
 
Or you could just wire each bit of the denominator to a NOR gate. Then, if the NOR gate returns true, block off the signal to every segment in each display digit and configure the rightmost digit to show the letter E (basically a backwards 3).
Thanks for the help!
[doublepost=1470431272,1470311070][/doublepost]
ANOTHER PROGRESS UPDATE
I have connected the divider to the system! I also modified the adder circuit so it can be used to subtract too!
This is how it looks now:
cMxPMhc.png

I used TEdit to make the image because it was too big for the in-game capture system causing the logic gates not to display.
Things to do:
*displaying the remainder when dividing,
*displaying negative values when subtracting.
Other than that the calculator is working perfectly and I will be releasing a world download shortly.
 
Things to do:
*displaying the remainder when dividing,
*displaying negative values when subtracting.

For the negative values part, what you can do is check the value of the 9th bit before discarding it. If the 9th bit is one, then discard it and return the output value as is. If it's zero, then replace the output value with its 2's complement and then discard the 9th bit, while also returning a negative sign.
 
Back
Top Bottom