8-bit addition calculator

  • Synergy
    25th Mar 2011 Member 0 Permalink
    v. 1.4 (beta)

    Version History

    1.0 Public beta release
    1.1 Small bugfix (solution 174) 24/3/11
    1.2 Asthetic overhaul
    1.3 Adder redesign
    1.4 Binary > BCD encoder upgrade (to 10-bit)

    UNFINISHED.



    Shows how to use it (if textual instructions just arent enough):

    (V.1.1)



    First of all, notice that this is unfinished, but still about 95% functional. By unfinished I mean that solutions under 65 will not display properly. Every other solution will.

    Features:

    Binary input
    8-bit binary adder with 9 bit output, checks overflow
    9-bit binary > BCD encoder
    BCD > 7-segement display decoder

    What I intend to add in the future:

    1. Obviously finish the Binary > BCD encoder, to allow values under 65 to be converted. This issue seems to result from a triggering issue, where bits are not shifted from the 6 rightmost positions if there is no value in the 3 highest value positions (which would be 64, 128 and 256) hence why at the moment values below 65 will not display properly.

    2. Add subtraction. It is an easy process to convert to an addition-subtraction calculator. Sadly I have no WIFI left meaning I need to place wires all over the place, so there isn't much room.

    3. Add a button for reseting the calculator. I already have allocated spots for reseting all of the switches. Sadly there are some stuborn ones which require a little more attention otherwise everything goes to shit

    4. Make a decimal input. Once again, hard since I have no wifi left. I have never actually done a decimal to binary input (except those simple 1-9 ones) I mean the type where you press 9, then 0 and it equates to 90, then pressing + changes the target to the second binary value. I will figure it out eventually, it would be easy if I have some space and WIFI left.


    Notes:

    Input: Well as you can see the input is riddled with wires, yep, dam that WIFI limit. It is a simple 8-bit input, and the two numbers are inputted at two seperate places. I guess a bit of lazyness on my behalf.

    8-bit adder: This was actually a bitch to make. Mainly because sparks are generated constantly and I needed to send sparks into it at the exact same time and also output the result to the Binary > BCD encoder at the exact same time. This meant complex switches and using the remaining 2-3 WIFI I had ;_;. Otherwise the adder is pretty generic, uses something like 3 XOR gates, 1 OR gates and 1 AND gate for each bit. Something like that. It generates carry and does check for overflow, hence its 9 -bit output.

    Binary > BCD encoder:

    First ever Binary > BCD encoder for TPP if i'm correct.

    Well shit, this was amazingly difficult. 90% of the time I spent on this calculator was spent on this little devil. And just to annoy me, it uses litterally all but 5-6 of the WIFI. Gee thanks encoder, just leave me to do the rest of the calculator with raw wiring... I love you too. It was pretty lucky to actually have enough WIFI, I rejoiced after designing the thing, when I realised that I would have just enough WIFI to create it.

    It works like this. It has 9 inputs for binary, and outputs BCD. It ouputs three BCD decades, so 1's, 10's and 100's. The premise is that each binary bit must be shifted left 9 times. For every shift, values in the BCD decades (values begin outside of the decades, and are shifted into them, however I started the encoder just before the third shift, because doing the first two wasn't nessasary.) must be checked. If the check returns a value 4 or lower, the bits are simply shifted left again for the next check. If the check returns a value of 5 or higher, +3 is added to the value and then it is shifted. I think I finished up with about 15 or so different value checking operations. Values are brought through a system in which they are sent to 9 different contraptions with 4 inputs. Those devices each output 1 for only one input. Eg. The device might ouput 1 only when the inputs are 0101 (5). There are 9 for decimal values 1-9. So for any value, only one of these devices will return 1. If 1 is returned, then the corresponding value depending on the device will be created. Eg, the earlier gate that outputs 1 for 0101 (5) would send back the value 8 to be shifted. This is because it is 5 or over. If a device that outputs 1 for 0100 (4) is activated, then this will trigger the encoder to shift the value left again, without altering its value. This is because it is under 5.

    BCD is an encoded form of binary. However, numbers are represented in 4-bit nibbles. These range from 0000 - 1001 (0-9). Values of 10-15 are not used in BCD. Each nibble corresponds to a place value. Eg. 10011011 (155)

    = 0001 0101 0101 in BCD.

    0001 = hundreds value
    0101 = tens value
    0101 = ones value

    These three values are then sent through a BCD > 7-segement decoder to three corresponding 7-segement place values. This is far easier to do than convert binary to 7-segement and hence the reason for the conversion to BCD in the first place.

    BCD > 7-segement decoder: This takes up alot of space. Why you ask?

    1. I wanted to make one without using WIFI, as a challenge.
    2. I had no WIFI...

    With WIFI this would have taken up about as much space as an internet tab... Anywho, it works in the same way the value checker for the Binary > BCD encoder works. Each 4-bit nibble is sent to 9 different contraptions where the appropriate device will be activated depending on the 9 different possible inputs. That device will then trigger certain parts for the seven-segement place value to light up and display the proper number. Simple really.
    __________________________________________________________________________________________________


    As this is a beta test, I would appreciate any bug reports you may have. As I found tens for bugs just by trying out different combinations, all have been fixed, but I could have missed some.

    Special thanks to Alexthesax. I really appreciate you helping me get started with TPP. You gave me a place to start, thanks mate.

    Cheers in advance for feedback.
    __________________________________________________________________________________________________

    @jalfor

    You messaged me asking for some more detail on what the WIFI is doing. The browser crashed when I tried to post this in pm so:

    Yeah your adder-subtractor is abit smaller, I remember noticing that (if I am thinking of the right one) I remember thinking DAM YOU, HOW DID YOU GET IT SO SMALL!! haha.

    Ok, so the Binary to BCD encoder is the main user of the WIFI and that is what is probably the most confusing. It has 9 inputs. Those inputs are at the top encoder (which is the thing that is shaped like a diagonal rectangle or something.) There is also 1 more thing that looks like an input (very top left of the encoder) which is not actually an input. So the solution (after addition is finished) is wired to these 9 inputs (it is a 9 bit sollution)

    First I recommened looking up the method for changing binary to BCD. (the left shift method)

    Once you get that, the concept is simple. So the 9 inputs are all in what I call decades (or sections) of 4. Keep in mind my encoder starts before the third left shift, because the first two werent nessasary. Because of this my values dont start in the binary section. The 3 leftmost values actually start in the first (lowest) BCD decade. So say if the binary number was 110000000, the value in the lowest BCD decade starts like this 0110. The leftmost thing that looks like, but isn’t an input, represents the last value for that decade. This is hear so that if the value in the decade returns 5 or higher, then 3 can be added, and the new value can take advantage of that. So 0110 (6) would be changed to 9 and then that leftmost one would send a spark down. So the decade would now look like 1001.

    So now that you understand the inputs (I probably lost you but yeah) now is the system for achieving the method. Values are sent downward and shifted 1 space left (9 times because it is 9 bits. If it were 8 bits it would be 8 times) however I only have 7 shifts because I skipped the first two because they aren’t needed, this is because shifting the number twice, will never create a value in the first BCD decade high enough to warrant a value change. The max value in the BCD decade after two shifts would be 0011 (3) so a check is not nessasary.) The decades are aligned so that there are 4 bit positions for the 1’s, then the next 4 bit positions to the left are for the 10’s ect.

    So here we go. Values move down. They activate a switch and at the same time they trigger a WIFI which sends them to the value checker (the chip on the right) Each decade has its own chip, and each shift has its own chip. So there needs to be a value checker for each decade on each shift level. They all need to be separate (you will notice that my value checker has several of the same looking thing. These correspond to the different decades on different shifts. Some of them are small, those are for shift levels where values first enter a certain decade. Say the 10’s decade. For the first shift into the tens decade the highest value is 0001. So I only need to check if the value of 0001 is true or not. This is compared to say the 1’s decade on the second shift, which has a highest value of 1001 and therefore I need to check if it is 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001.

    To explain the sections that check values. Each little part has 4 inputs. So if it is the 1;s decade for the second shift and there are 9 different possibilities (excluding 0) then I need 9 different checkers (which are practically gates that only output a spark if a certain value is true. They all output a spark for a corresponding value 0001-1001. So there are 4 inputs for each of these. So if 1001 is sent into the 1’s second shift, then at the same time as turing on the switch, sparks are sent through WIFI on the sparked rods. These values will Be sent to the four inputs. So 1001 would be sent to all 9. Since these 9 value checkers are grouped together, they all have the same inputs, so the WIFI will be the same for all 9 (for the inputs) So say the inputs all have temperatures of 100,200,300 and 400. Each different group of 9 value checkers must have different WIFI inputs.

    So if there is a value of 5 or higher, say 6, the checker for 6 will send a spark through. This spark will send a value back to the encoder which is 3 higher that the beginning value. So for example, input 110000000 into the beginning of the encoder. The 1’s decade for the first shift will have 0110 (6) this will activate the switch and send WIFI to the checkers. The checker for 6 will activate and send the value 9 back. It does this be sending to a certain amount of WIFI. For nine, it will send to two different places. (NOTICE THE LEFTMOST THING THAT LOOKED LIKE AN INPUT, AND NOTICE THE WIFI AT THE TIP) the first part of 9 will be send here (the 8 value) and the second part will be send back to the first value in the BCD decade which is also the same bit position that 11(0)000000 was. Notice that the leftmost thing has that WIFI at the tip of a rod pointing down. All positions have this, and this is where the value is sent back to (if the checkers find a value of 5 or higher) If you entered 011000000 at the start, the 1’s decade for the first shift would = 3. Therefore it is under 5. Any return for a value under 5 will trigger the switch next to the battery (there is a battery/switch combination on most bit positions on all the shifts) to turn on and therefore release a spark, it will be shortly triggered to turn off so that only one spark is sent through. Once again, all different decades have different WIFI to trigger the turning on/off of the switch, but this time it doesn’t matter what shift it is. So if there is a value in that decade before the value check, the large verticle switch would be on. This means that the spark sent be the battery would pass through and would be shifted left once to ready for the next shift. When the spark moves past the large switch, regardless of a value of less than or more than 5, some INST is triggered, which turns off the large vertical switches from the previous shifts which is no longer desired to be on.

    Values that are not in the BCD decades do NOT need to be checked. So these still need a method of shifting left regardless or 1-4 or 5-9. So I set up some WIFI (in those rectangular things encased in NSCN) if a value is under 5 the wifi that triggers the battery/switch combo to turn on, also triggers a spark to move through all the binary decade bits. If a value is present in the bit, the vertical switch would be on and therefore the spark would send through. All four WIFI from the WIFI return value (all for of them) is also placed in the rectangle. This is incase a value 5-9 is returned.

    So this means the binary section always triggers, wether the values in the BCD are 1-4 or 5-9. However, the one problem I have at the moment is that it wont trigger for a value of 0 in the BCD decades, and hence 64 and below wont work. I will fix this soon.

    I also placed some timing devices in some of the shifts. This helps to prevent timing problems, because sparks need to be really close together to trigger the value checkers properly.

    This whole process happens until all the bits are shifted out of the binary into the BCD decades. Sorry, it is extremely hard to explain, I did a bad job J
  • HeyJD
    25th Mar 2011 Member 0 Permalink
    @Synergy
    Ooh... That's very nice. And it's very easy to use too. I vote up.

    But you shouldn't have put Beta in the title, Because then when you've got the full version you'll have to upload it as a different name and loose all your votes.
  • jalfor
    25th Mar 2011 Member 0 Permalink
    @Synergy
    WOW. You have certainly earned a place in static.
  • Synergy
    25th Mar 2011 Member 0 Permalink
    Thanks mate.Though votes mean nothing :)

    Haha thanks Jalfor

    Finished version aswell as the Binary > BCD converter (when its finished) will be uploaded on the static account.
  • The-Con
    25th Mar 2011 Member 0 Permalink
    The WIFI problem can be solved with portal.
    Spark travels through portal, and portal has frequencies like WIFI.
    I'm jealous... I still can't work out binary to decimal
  • Synergy
    25th Mar 2011 Member 0 Permalink
    Mother of jesus are you serious... I really wish I knew this...

    Seriously I can now make the whole BCD to 7-segment decoder section the size of a tic-tac. And eliminate all of the crazy wiring. Cheers.

    Although I think I will keep the wiring, unless I need quicker conversion or more room. I like the wiring :)

    @jalfor

    I answered part of your question in the topic post. If you can understand that (I doubt it, I suck at explaining) then I doubt you will have a problem finding out the rest of the calculators function.
  • The-Con
    25th Mar 2011 Member 0 Permalink
    (I voted up)
    Do you have any advice on binary to decimal (Normal decimal/binary)... I could just use someone elses and give credit, but i want to understand. (sorry for being off topic)
  • Synergy
    25th Mar 2011 Member 0 Permalink
    Firstly you will have the oppurtunity to use mine once I fix the final bug in it (which is the reason this is beta and the reason it doesn't display solutions less than 65 atm) I really can't explain it any better than what I did (look at the first post in this thread, I added a rough explanation at the bottom)

    However, I might create a full on tutorial complete with pictures and the whole process of making it if everyone really wants to know. I pretty much constructed this by learning the left-shift binary > BCD method (google it) once you learn the mathmatical process, it is atleast feasable to begin making something like this. It wasn't thaat hard I guess. I only just really started TPP and I seem to have made it. But yeah when it is finished I will post the encoder seperately, open source.

    I will think about a full on tutorial, because the explaination I gave Jalfor was pretty shift and unorganised.
  • shroom207
    25th Mar 2011 Member 0 Permalink
    @Synergy
    Lol thats bigger than the wall of words on my ash topic lol.
  • dnerd
    25th Mar 2011 Member 0 Permalink
    @Synergy
    Wow, very nice job!
    i love the simplicity of your work, its quite nice.