Yo what’s up guys welcome back to logical redstone i want to say a few things before i start though the first thing is about ticks um i’ve been saying the term ticks pretty much exclusively and i probably should have been saying redstone ticks because the game actually Runs on two separate tick systems one is for game ticks and there’s 20 of them per second and one is redstone ticks where there’s 10 of them per second so when i say ticks i’m always referring to redstone ticks aka a 10th of a second but anyways today’s topic is about Binary edition which is really really cool i mentioned logic gates in the very first episode of this series but i didn’t really like do anything with them and now we’re finally going to use them a lot but before we talk about addition i want to talk about displays a little Bit more because there’s one thing i forgot to mention which is really really cool and i can’t believe i didn’t mention it in the last video so this light blue part you’ve seen before it’s just an array of two by two pixels but this orange part is basically a way for Us to allow only a certain column through at a time so all these towers here are connected to a bunch of comparators on each column and depending on which tower we depower that entire column’s information is going to be sent through to the screen so for example if we type in a Bunch of stuff in random spots well nothing’s going to go through yet but let’s say we pick this column to be allowed through then it’s going to show these two pixels and so you can see that that’s true on the screen because right now if you only allow a certain column Through that’s the equivalent of saying hey only allow pixels through that have that specific x value and so now all you have to do is or together all of the pixels with the same y value and you have successfully made an x y plotter because when we select a certain y value It’s going to attempt to send signal through everybody on that row but nothing is being allowed through then we select a specific x value to allow through and it will only allow through the intersection of the row and the column so let me show you one more Example in case it didn’t make sense this bottom row well if we activate it it’s going to send signal on everything on that bottom row but none of the x’s are letting it through so we don’t get anything on the screen yet because we haven’t declared an x as soon as we Declare an x it’s going to allow all the pixels through that are on that specific column the only one that’s on that column is the y that i specified so it’s essentially taking the intersection and we are getting the intersection which is that specific pixel on the Screen so now let’s just make it a little bit fancier we can add in the memory which is this green and purple that i showed in my previous video and it has the right button and the clear button so now we can select a specific point let’s do this y and this x Nothing is being sent through yet because you didn’t write it yet and when we hit the right button we see that specific pixel on the screen you can even select a different pixel and write it as well so if we want to change the y to this for example and then hit Right again it’s going to also plot that pixel so now let’s just clean it up with some decoders i have a three bit decoder for y which takes in a y coordinate and decodes into a specific y layer same thing with x it takes in a three bit Binary number which resembles the x coordinate and decodes into a specific x layer the way that we use this is by specifying the x and y out here so let’s just do 2 for x and 4 for y we hit that right button and we get the pixel 2 4. let’s write Another real quick let’s do four seven right and we got four seven we can hit clear to clear out the board and yeah that is a completely finished xy plotter all right now for the good stuff let’s talk about binary edition in case you don’t know how binary edition works on paper I’m just going to do a few examples here here we have 1 1 0 1 plus 0 1 1 0 which equates to 13 plus 6. just like with decimal edition we go column by column starting on the right so we start with the rightmost column and we do one plus Zero which is just one then we do zero plus one which is also one then we do one plus one which is two but remember we’re in binary so we have to do a zero here and then carry over to the next guy and now this column is 1 plus 1 after You include the carry and we can just directly write 2 right here and so we got 13 plus 6 is 19. let’s do one more example one zero one zero plus zero one one zero this equates to ten plus six zero plus zero is zero One plus one is two so we have to do a zero plus a carry one plus one is also two so we do the same thing we put down a zero and then we carry one plus one is two again so we do a zero and carry but we can Just directly write down the two right there so 10 plus 6 is 16. so if we want a circuit that can add two binary numbers together at any size we need to dissect what is happening exactly at every single column so let’s start to think about this more generally at any Column how many inputs do you have and how many outputs do you have well you have the top bit which is an input you have the bottom bit which is another input do we have more inputs yes we do we have one more input because we could Have had a carry from last time and i’m going to call this the carry in so at every column we have three inputs which are all either zero or one okay that makes sense how many outputs do we have well we have the sum which is down here Which can either be a zero or a one but we also might have a carry which goes on to the next guy like this and so i’m going to call that carry the carry out okay so we’ve taken the procedure at every single column and made more of a Generalized function we have three inputs again we have the carry in at the top which we could have had from the previous column we have a which is the top bit b which is the bottom bit and then we have two outputs the first one Is the sum which is part of our answer down here and the second one is the carry out which carries on to the next column and this function might seem a little bit weird or complicated but if you know how to do binary edition on paper like we were doing over here then Actually you know exactly how this function works for any combination of inputs for example let’s say that i told you that we have a top bit but we have no bottom bit and we also have no carry in at the top what does this give well it’s just one Plus zero so we get a sum of one and we have no carry out because we’re finished and so what you can do is construct a truth table with all the combinations of carry in a and b since you know what’s supposed to happen at all of those different combinations for the top Section here this is when we have nothing and of course we want nothing out this is if we have one of them so either we have just the carry in or maybe just a or just b it’s all the same we just want a one we want a sum and no carry out If we have any combination of two of them then we want a two we want nothing in the sum and we want to carry out if we have all three of them then we want both we want a sum and a carry out and remember this all just derives from What you’re doing at each column i guarantee you if you take any rows of this truth table and plop it onto these letters here it will make sense so all we need to do to make a binary adder is take this truth table and bring it to Life with a circuit and that’s what i’ve done right here this circuit is called a full adder it takes in the three inputs that i was talking about the carry in a and b and it gives you two outputs a carryout and a sum these bottom two Circuits are just xor gates they’re the comparative version of an xor gate that i showed you in the logic gate video as a refresher xor is only given output if only one of their inputs are on and on the top two gates we just have a couple Of and gates these guys only give a signal if both of the inputs are on and this will do exactly what we want it will follow this exact truth table pretty cool right i mean we have all these rows on the truth table and yet we can represent it with literally just Four gates so let’s do some examples well we know that if we have nothing in we want nothing out so that’s working so far it’s a good start if we have any combination of one we just want a sum in other words when you look at it this way It looks like zero one and so we’re getting a one if we have any combination of two we wanted to give one zero aka we wanted to give a carryout and no sum so that it looks like a two and if we want any combination of three well actually there’s only one Combination of three we get one one which is a carryout and a sub so i really encourage you to download this world and trace through exactly what’s happening there is reasoning for how all of these circuits and gates were derived and the more you play with it the more it will make sense About how it all gets traced through and why it works out in the end but now that we have our full adder completely finished and working i’m just gonna move around some of the inputs and outputs and you’ll see why so we’re gonna put a And b on the bottom we’re going to put the carry in over here we’re going to put the carryout over here and the sum up here i did not change the circuit at all literally all i did was i just rearranged the inputs and outputs it Still behaves the exact same way so just as a quick example if you have any combination of two we get a carry out and no sum now what i’m going to do is i’m just going to take this circuit and compact it down so we Have a and b on the bottom here we have carry in on the right carryout is right here and sum is on the top and it’s a ton smaller but it still follows the exact same truth table let’s give another quick example if you just give one we get a sum If you give two we get just to carry out if you do all three it gives both so for the sake of time i’m not going to go over exactly how all the parts of this tiny full adder actually work but it follows the exact same logic as this laid out diagram here Just in a tiny amount of space and i’ll also link a video in the description going over this full adder in detail if you’re interested and of course i recommend watching that video completely before trying to use this full adder in your builds because otherwise if you don’t understand how something works Something breaks you won’t be able to fix it so i put a and b on the bottom because those are actually the two binary numbers that we want to add together i put the sum on the top because well that’s the answer and the carry in and carry out are laid out like This because they can connect to each other and they’re used inside the machine if you remember back here from the column representation the carry out of any individual column is automatically the carry in of the next guy because let’s say that like okay if you have a here Oh my god that’s among us and a b here then the carry out of this guy aka this green c becomes the carry in of this next column and when we stack full adders together what’s gonna happen is the carryout of the previous guy goes into the carry-in of the next guy which Is exactly what we want and that happens at every single stage along this stack then you take all of the a’s and line them up on the top row you take all of the b’s and line them up on the bottom row and now we can add a plus b so check This out if we do 5 for a and we do 3 for b we get eight if we do seven plus five we get twelve and if we turn on all of the lamps that are part of a and b we get fifteen plus fifteen which is thirty Which also makes use of the final guys carryout that makes perfect sense because over here when we were doing addition remember how if we got a carryout on the last guy it like it didn’t have to go to another column and it just goes straight into the answer that’s what’s happening We gotta carry out on the last column and it goes straight into the answer but matt what about the carrion what the hell is that guy doing well think about it in terms of columns again what value did the carrion have compared to a and b It had the exact same value right we’re treating it as basically the same thing as a or b so the carry in is going to act the exact same as the first full adders inputs so in other words the carry in is gonna act like another one so one plus one is two One plus one plus one is three awesome we made a circuit that can add two binary numbers together this is exactly what we wanted there is one slight problem though this type of addition is called ripple carry addition and the reason it’s called that is because well let’s just show you if you Type in a huge number on a and then you add one more the carry has to ripple across all the full adders before finally updating and giving us that final carryout and so this is fine if you’re only doing a small amount of adders like i have here But imagine you had like a 32-bit adder or a 64-bit adder it’s literally gonna take so long for that ripple to go all the way across sometimes so wouldn’t it be cool if we had an adder where we didn’t have this like ripple effect what If we just had an adder where no matter what combination we put into it it always took like four ticks i’ll explain that next time peace out Video Information
This video, titled ‘Addition | Logical Redstone #8’, was uploaded by mattbatwings on 2021-11-20 03:25:54. It has garnered 75534 views and 3273 likes. The duration of the video is 00:13:37 or 817 seconds.
!!! Check out the NEW AND IMPROVED logical redstone series here! https://youtube.com/playlist?list=PL5LiOvrbVo8keeEWRZVaHfprU4zQTCsV4 !!!
In this episode, I go over how binary addition works in Minecraft.
Patreon: https://www.patreon.com/mattbatwings Discord: https://discord.gg/V5KFaF63mV My socials: https://linktr.ee/mattbatwings My texture pack: https://github.com/Xyverle/MattPack World Download: (JAVA 1.16.5) https://www.planetminecraft.com/project/addition-from-tutorial-video/
Small full adder tutorial – https://youtu.be/o51SmP-0YvE
————————-
Want to get more involved in the logical redstone community? Learn Logical Redstone! https://youtube.com/playlist?list=PL5LiOvrbVo8keeEWRZVaHfprU4zQTCsV4 Open Redstone Engineers (ORE): https://openredstone.org/
0:00 Welcome to Episode 8! 0:35 Extra display thingy 3:29 Addition basics 4:46 Addition Circuit theory 7:32 Full adder 10:58 4-bit binary adder 13:28 Subscribe!
Music: https://youtu.be/mWebB6zby6Y