Lately I've been doing a series of threads, breaking down complex components piece by piece. Quite a few of my fellow users encouraged me to explain more advanced components, which I aim to do here in this topic. Today I will be going over various parts of an ALU, or arithmetic logic unit.
An ALU can have any number of functions, as long as there are at least two logical functions. For a decent CPU (from a programmer's standpoint) you at least need the basic 5, AND, NAND, OR, NOR, & NOT. But I'm not going to stop there, oh no. The ALU I built for this break down will have 9 functions, just like the ALU some of you may have seen that I recently designed.
This ALU is not actually functional. It's only a display model, so to speak, so I didn't add any control bits. But, I will be using a very similar design in my final ALU. I'm quite proud of this one, as it's only 3 meters wide. This makes it taller and longer, but who cares, the width is what will matter once I tile a bunch of these together.
Here's an overall view:
It's so skinty!
Okay, let's start at the beginning with the inputs:
This may look familiar to some of you, it's a vertical XOR gate. We won't be using it to XOR the data though, we will be using the control lines at the bottom to use it as a toggle-able inverter. Say the ALU input is input A in the XOR and the control line is input B. Well, if we leave B off and power A, then the output will reflect the input. If A is off, and we turn B on, once again it will output true, the exact opposite of the input.
The purpose of this, you ask? Well, let's say you want your ALU to be able to subtract. You could build a whole new level, ridiculously increasing the height of your design. Then modify an adder to become a subtracter, which can only subtract one input from the other, depending which input you invert. Or, we could do it like this, the easy way. Since this ALU already has an adder and a NOT gate built in, if we throw these doohickys on the inputs, we can use a combination of instructions to turn the existing adder into a subtracter.
Firstly, you would invert the data being subtracted from. (if A - B then invert A) Then we would instruct the ALU to output the result from the adder. But! we don't directly output this value, we instruct the ALU to send it through the NOT gate, inverting the data.
Now some of the simple functions, first let's take a look at AND:
This is an instant AND gate, using the reverse wire cutting technique. The pistons are placed directly under the inputs, so when the final piston moves the block from above the torch, the output goes low immediately. What you're seeing in this photo is technically a NAND gate, but what you don't see is an inverter behind me. (before I changed my mind about adding muxers) When building an ALU it is always good to use inverted outputs for your logic gates. You will need an inverted signal at some point so you can add a control bit, and invert the signal again. Yes, it adds delay, but you need control lines in an ALU, if you don't have them, it's pretty much broken.
The function directly above/in front of this one is addition. I have already went into great detail about adders in this thread:
I would also like to mention, for my new ALU I am using ohmgane3sha's EPIC insta-carry adder:
Theoretically, this will be able to pull of a full ripple carry in a 16-bit string of adders in 4 - 5 ticks. My old ALU took 16 ticks for a full ripple carry, and it was only an 8-bit. If my old design was expanded to 16 bits, a ripple carry would have taken 32 ticks. So, as you can see, ohmgane3sha's design is a drastic improvement.
Next function, above the adder, is the XOR gate:
Just like every function thus far, this branches from the main inputs. Nothing too fancy about this design, something basic I grabbed from the Wiki. I plan on using a better, piston based, design for my final ALU.
Moving on to the OR gate:
The inputs for this OR gate were created by double inverting the XOR gate's inputs, if you couldn't tell. The output comes directly from the middle, I just removed the line for a better screenshot. This is one logic gate you cannot get a directly inverted output for. It must be inverted, the muxer added, and inverted again.
Last, but not least, the NOT gate:
First I would like to say, if you ever build an ALU, do not build your NOT gate like this, lmao. Once again, this is just a display model. Only build a NOT gate like this if you plan on adding the control line from the bottom. Anyway, this function is what you will be using to turn your AND's into NAND's, OR's into NOR's, etc. Or you could just invert a single value using this, but you must ONLY have data in ONE REGISTER LOCATION. You cannot NOT two values together, you will just end up with corrupted data.
With one 16-bit value you have a few choices on how to invert it. You can send it through the adder, the XOR gate, or the OR gate, and then instruct the ALU to NOT the output. All of these functions will give you the same exact output when you only use one input, and that is, reflecting said input.
Well, I hope somebody out there learned something from this. If I missed anything, please let me know. I'm sure I did, as this is a pretty expansive topic. I know I missed some of the deeper elements of this subject, like IMPLIES, converse implication, bitwise shifting, multiplication, division, projection, negation, stuff like that. And that's because a lot of it isn't really needed... ever. And the stuff that is sometimes needed, I understand how it works, I would just like to know 100% for sure why it works before explaining it to you guys.
So, like always, if you have any questions, please ask. And if you have any requests for other advanced components, let me know.
And if you would like me to break this down even further, seperating everything, leave a post. I don't know why I didn't do that in the first place.
Nice design, but I bet within 10 posts people are gonna think this is PC because of flat world and video
Rollback Post to RevisionRollBack
Religion, has actually convinced people, that there's an invisible man, living in the sky, who watches everything you do every minute of the day, and the invisible man has a special list. Of 10 things he doesn't want you to do. And if you do ANY of these ten things he has a special place, full of fire, and smoke, and burning, and torture, and will send you there to suffer and choke and scream for all of eternity... But he still loves you.
Nice design, but I bet within 10 posts people are gonna think this is PC because of flat world and video
They usually do, with every thread I make. Hopefully the fact that this is on the edge and the land doesn't just end abruptly will give them a clue. And that video isn't mine, it's far too epic to be mine.
This design actually wouldn't work at all in the state it's in here. If you tried to use it, you would just end up with corrupted data. I left out all of the control lines to make the structure itself less confusing, and so it would be easier to take screenshots. If you add control bits, it would be just as powerful as my last design:
It would be about the same speed for most functions, maybe 1 tick faster. But, when adding or subtracting values, this thing makes up a lot of speed. In the old ALU it would take 2 ticks to carry between each bit, so it would become insanely slow in a 16 bit ALU. In theory, with this design of adder, a full ripple carry, through 16 bits, could be done in about 4 ticks, as opposed to 32 with the old design.
A full ripple carry is the worst case scenario for a group of adders. In 8 bit, this means 01111111 + 00000001. That 1 has to carry through all 7 bits and output a sum in the 8th one to make 10000000. This is the factor that usually limits the clock speed of an entire CPU. But, in my new design, it won't be.
I don't think I'm going to get into anything more complex than this. This one isn't being received quite as well as my other threads. I think I'll take a few steps back and go over memory storage components. Different memory latches, flip flops, how to store a large amount of data in a small space and send it over just a 1-bit bus. These things are useful, even in applications that have nothing to do with logic.
I don't think I'm going to get into anything more complex than this. This one isn't being received quite as well as my other threads. I think I'll take a few steps back and go over memory storage components. Different memory latches, flip flops, how to store a large amount of data in a small space and send it over just a 1-bit bus. These things are useful, even in applications that have nothing to do with logic.
It's not so much the complexity of the ALU that puts people off but how sophisticated and in-depth you go into it, schmucks like me aren't understanding it quite as well. I'm very bad with logic gates, I can only get them working horizontally, I don't understand all of those vertical tileable gates-- they're above my level of understanding as of now. If you could put it into simpler terms (not that you haven't already in some places) and have a brief overview of what the logic gates do towards the beginning of the post that helps this mechanism(?) function I feel I'd be able to understand it more, at least, and others too. I'm also confused as to what the potential use for the ALU itself is.
But feel free to ignore me, I've never been hardware-savvy.
This does look like an improvement though over the last design though.
It's not so much the complexity of the ALU that puts people off but how sophisticated and in-depth you go into it, schmucks like me aren't understanding it quite as well. I'm very bad with logic gates, I can only get them working horizontally, I don't understand all of those vertical tileable gates-- they're above my level of understanding as of now. If you could put it into simpler terms (not that you haven't already in some places) and have a brief overview of what the logic gates do towards the beginning of the post that helps this mechanism(?) function I feel I'd be able to understand it more, at least, and others too. I'm also confused as to what the potential use for the ALU itself is.
But feel free to ignore me, I've never been hardware-savvy.
This does look like an improvement though over the last design though.
Here's the deal, these threads are meant to be a segue for intermediate level redstone users, introducing them to more advanced applications, in terms of logic. These topics are aimed at people who already know how to build logic gates and already know how to use them individually. I really haven't gone in-depth at all in this thread, I've only scratched the surface of what an ALU can do and shown how it works.
Like I said in the OP, I could get deeper into the subject, things like IMPLIES, converse implication, bitwise shifting, multiplication, division, projection, negation, etc. but this would go over most peoples heads and it wouldn't be a gentle segue anymore. A couple of those operations I don't even understand completely how they work, and I definitely don't want to explain something until I know the subject inside out.
I realize I use some technical jargon here and there, and I try to avoid it as much as possible, but sometimes it's difficult to find a simpler way to explain certain things. If you could bring to my attention some of the things I say, which you don't understand, it would be very helpful to me and I'll try to avoid it in the future. Or I'll at least explain what I just said after I say it, I like to do this sometimes as it familiarizes people with technical terms they may see elsewhere. Sometimes I just forget people may not know what the hell I'm talking about and forget to explain.
If you look up any of the things I've explained in my threads, you'll see I've broken them down in a way that is much easier to understand. Even looking at explanations on the Wiki, very rarely will you see a redstone explanation in layman's terms. Still, thanks for bringing this to my attention, I like to know when I'm getting to far ahead of myself, as I would still like the every day redstoner be able to follow along. Even if they are never going to use something like this in their lives.
As for the potential of an ALU, it's basically a bunch of logic gates in one. This design can be any of the following gates: AND, NAND, OR, NOR, XOR, XNOR, and NOT, it can also add or subtract. So, you can use any of the logical functions with the same inputs, and the same output. This could be much more beneficial than tearing down a logic gate and building a different one to be used on the same machine. I'm sure there are many things you could use this for, at least a 1 bit version, I just can't think of any uses atm. It's main use is to actually be applied as an ALU, which is the part of the CPU that does all of the heavy lifting. It processes data based on the logical functions built in. Say you have a 16-bit word, 1011001101011101, but you only want the first 8 bits, you could AND this data with 1111111100000000 and the ALU would output 1011001100000000. I don't expect you to know the purpose of this, it's more of a programmer thing, I'm just explaining something it can do.
Whats cool is your useing binary code to basicly add and write sentences.
Not quite, when I say "word" I don't literally mean an alphabetical word that's made with numbers. A word is the unit of data a specific CPU is designed to handle. For example, the CPU in my first computer worked with 8-bit words, the new CPU, that I'm designing this ALU for, will be built to handle 16-bit words. That's one of many reasons why it will be literally thousands of times more powerful.
I guess I now see what Packeranatic meant about me using too much technical jargon.
I could build a word processor that converts binary into letters, which I've been thinking about doing. I'll probably build that by itself though, so it's not insanely slow. This computer will have a GPU though, but it won't be 16-bit since that would just be... insane. It will be somewhat of a hack to get it to work, but don't worry, I'll find a way to squeeze one in.
-
View User Profile
-
View Posts
-
Send Message
Retired StaffAn ALU can have any number of functions, as long as there are at least two logical functions. For a decent CPU (from a programmer's standpoint) you at least need the basic 5, AND, NAND, OR, NOR, & NOT. But I'm not going to stop there, oh no. The ALU I built for this break down will have 9 functions, just like the ALU some of you may have seen that I recently designed.
This ALU is not actually functional. It's only a display model, so to speak, so I didn't add any control bits. But, I will be using a very similar design in my final ALU. I'm quite proud of this one, as it's only 3 meters wide.
Here's an overall view:
It's so skinty!
Okay, let's start at the beginning with the inputs:
This may look familiar to some of you, it's a vertical XOR gate. We won't be using it to XOR the data though, we will be using the control lines at the bottom to use it as a toggle-able inverter. Say the ALU input is input A in the XOR and the control line is input B. Well, if we leave B off and power A, then the output will reflect the input. If A is off, and we turn B on, once again it will output true, the exact opposite of the input.
The purpose of this, you ask? Well, let's say you want your ALU to be able to subtract. You could build a whole new level, ridiculously increasing the height of your design. Then modify an adder to become a subtracter, which can only subtract one input from the other, depending which input you invert. Or, we could do it like this, the easy way. Since this ALU already has an adder and a NOT gate built in, if we throw these doohickys on the inputs, we can use a combination of instructions to turn the existing adder into a subtracter.
Firstly, you would invert the data being subtracted from. (if A - B then invert A) Then we would instruct the ALU to output the result from the adder. But! we don't directly output this value, we instruct the ALU to send it through the NOT gate, inverting the data.
Now some of the simple functions, first let's take a look at AND:
This is an instant AND gate, using the reverse wire cutting technique. The pistons are placed directly under the inputs, so when the final piston moves the block from above the torch, the output goes low immediately. What you're seeing in this photo is technically a NAND gate, but what you don't see is an inverter behind me. (before I changed my mind about adding muxers) When building an ALU it is always good to use inverted outputs for your logic gates. You will need an inverted signal at some point so you can add a control bit, and invert the signal again. Yes, it adds delay, but you need control lines in an ALU, if you don't have them, it's pretty much broken.
The function directly above/in front of this one is addition. I have already went into great detail about adders in this thread:
http://www.minecraft...-work-together/
I would also like to mention, for my new ALU I am using ohmgane3sha's EPIC insta-carry adder:
Theoretically, this will be able to pull of a full ripple carry in a 16-bit string of adders in 4 - 5 ticks. My old ALU took 16 ticks for a full ripple carry, and it was only an 8-bit. If my old design was expanded to 16 bits, a ripple carry would have taken 32 ticks. So, as you can see, ohmgane3sha's design is a drastic improvement.
Next function, above the adder, is the XOR gate:
Just like every function thus far, this branches from the main inputs. Nothing too fancy about this design, something basic I grabbed from the Wiki. I plan on using a better, piston based, design for my final ALU.
Moving on to the OR gate:
The inputs for this OR gate were created by double inverting the XOR gate's inputs, if you couldn't tell. The output comes directly from the middle, I just removed the line for a better screenshot. This is one logic gate you cannot get a directly inverted output for. It must be inverted, the muxer added, and inverted again.
Last, but not least, the NOT gate:
First I would like to say, if you ever build an ALU, do not build your NOT gate like this, lmao. Once again, this is just a display model. Only build a NOT gate like this if you plan on adding the control line from the bottom. Anyway, this function is what you will be using to turn your AND's into NAND's, OR's into NOR's, etc. Or you could just invert a single value using this, but you must ONLY have data in ONE REGISTER LOCATION. You cannot NOT two values together, you will just end up with corrupted data.
With one 16-bit value you have a few choices on how to invert it. You can send it through the adder, the XOR gate, or the OR gate, and then instruct the ALU to NOT the output. All of these functions will give you the same exact output when you only use one input, and that is, reflecting said input.
Well, I hope somebody out there learned something from this. If I missed anything, please let me know. I'm sure I did, as this is a pretty expansive topic. I know I missed some of the deeper elements of this subject, like IMPLIES, converse implication, bitwise shifting, multiplication, division, projection, negation, stuff like that. And that's because a lot of it isn't really needed... ever. And the stuff that is sometimes needed, I understand how it works, I would just like to know 100% for sure why it works before explaining it to you guys.
So, like always, if you have any questions, please ask. And if you have any requests for other advanced components, let me know.
And if you would like me to break this down even further, seperating everything, leave a post. I don't know why I didn't do that in the first place.
-
View User Profile
-
View Posts
-
Send Message
Curse Premium-
View User Profile
-
View Posts
-
Send Message
Retired StaffThey usually do, with every thread I make. Hopefully the fact that this is on the edge and the land doesn't just end abruptly will give them a clue. And that video isn't mine, it's far too epic to be mine.
This design actually wouldn't work at all in the state it's in here. If you tried to use it, you would just end up with corrupted data. I left out all of the control lines to make the structure itself less confusing, and so it would be easier to take screenshots. If you add control bits, it would be just as powerful as my last design:
Most Advanced Technology Ever Created in MCXBLA
It would be about the same speed for most functions, maybe 1 tick faster. But, when adding or subtracting values, this thing makes up a lot of speed. In the old ALU it would take 2 ticks to carry between each bit, so it would become insanely slow in a 16 bit ALU. In theory, with this design of adder, a full ripple carry, through 16 bits, could be done in about 4 ticks, as opposed to 32 with the old design.
A full ripple carry is the worst case scenario for a group of adders. In 8 bit, this means 01111111 + 00000001. That 1 has to carry through all 7 bits and output a sum in the 8th one to make 10000000. This is the factor that usually limits the clock speed of an entire CPU. But, in my new design, it won't be.
-
View User Profile
-
View Posts
-
Send Message
Retired StaffThanks!
I don't think I'm going to get into anything more complex than this. This one isn't being received quite as well as my other threads. I think I'll take a few steps back and go over memory storage components. Different memory latches, flip flops, how to store a large amount of data in a small space and send it over just a 1-bit bus. These things are useful, even in applications that have nothing to do with logic.
It's not so much the complexity of the ALU that puts people off but how sophisticated and in-depth you go into it, schmucks like me aren't understanding it quite as well. I'm very bad with logic gates, I can only get them working horizontally, I don't understand all of those vertical tileable gates-- they're above my level of understanding as of now. If you could put it into simpler terms (not that you haven't already in some places) and have a brief overview of what the logic gates do towards the beginning of the post that helps this mechanism(?) function I feel I'd be able to understand it more, at least, and others too. I'm also confused as to what the potential use for the ALU itself is.
But feel free to ignore me, I've never been hardware-savvy.
This does look like an improvement though over the last design though.
-
View User Profile
-
View Posts
-
Send Message
Retired StaffHere's the deal, these threads are meant to be a segue for intermediate level redstone users, introducing them to more advanced applications, in terms of logic. These topics are aimed at people who already know how to build logic gates and already know how to use them individually. I really haven't gone in-depth at all in this thread, I've only scratched the surface of what an ALU can do and shown how it works.
Like I said in the OP, I could get deeper into the subject, things like IMPLIES, converse implication, bitwise shifting, multiplication, division, projection, negation, etc. but this would go over most peoples heads and it wouldn't be a gentle segue anymore. A couple of those operations I don't even understand completely how they work, and I definitely don't want to explain something until I know the subject inside out.
I realize I use some technical jargon here and there, and I try to avoid it as much as possible, but sometimes it's difficult to find a simpler way to explain certain things. If you could bring to my attention some of the things I say, which you don't understand, it would be very helpful to me and I'll try to avoid it in the future. Or I'll at least explain what I just said after I say it, I like to do this sometimes as it familiarizes people with technical terms they may see elsewhere. Sometimes I just forget people may not know what the hell I'm talking about and forget to explain.
If you look up any of the things I've explained in my threads, you'll see I've broken them down in a way that is much easier to understand. Even looking at explanations on the Wiki, very rarely will you see a redstone explanation in layman's terms. Still, thanks for bringing this to my attention, I like to know when I'm getting to far ahead of myself, as I would still like the every day redstoner be able to follow along. Even if they are never going to use something like this in their lives.
As for the potential of an ALU, it's basically a bunch of logic gates in one. This design can be any of the following gates: AND, NAND, OR, NOR, XOR, XNOR, and NOT, it can also add or subtract. So, you can use any of the logical functions with the same inputs, and the same output. This could be much more beneficial than tearing down a logic gate and building a different one to be used on the same machine. I'm sure there are many things you could use this for, at least a 1 bit version, I just can't think of any uses atm. It's main use is to actually be applied as an ALU, which is the part of the CPU that does all of the heavy lifting. It processes data based on the logical functions built in. Say you have a 16-bit word, 1011001101011101, but you only want the first 8 bits, you could AND this data with 1111111100000000 and the ALU would output 1011001100000000. I don't expect you to know the purpose of this, it's more of a programmer thing, I'm just explaining something it can do.
-
View User Profile
-
View Posts
-
Send Message
Retired StaffNot quite, when I say "word" I don't literally mean an alphabetical word that's made with numbers. A word is the unit of data a specific CPU is designed to handle. For example, the CPU in my first computer worked with 8-bit words, the new CPU, that I'm designing this ALU for, will be built to handle 16-bit words. That's one of many reasons why it will be literally thousands of times more powerful.
I guess I now see what Packeranatic meant about me using too much technical jargon.
I could build a word processor that converts binary into letters, which I've been thinking about doing. I'll probably build that by itself though, so it's not insanely slow. This computer will have a GPU though, but it won't be 16-bit since that would just be... insane. It will be somewhat of a hack to get it to work, but don't worry, I'll find a way to squeeze one in.