Warning this video is nerdy like really nerdy check out the links in the description if you want to learn more about any of the topics in this video computers arguably the most insane invention of all time and since I started YouTube they’re my most requested build so let’s build a Computer in Minecraft I hope you enjoy First let’s talk about what we want our computer to do our computer is going to run programs but these programs are not what you might be used to like C plus or python we need to go a little bit lower instead a program is going to be a list Of instructions for the computer to execute one by one this is called an assembly language which is the lowest level language a computer can understand but what is an instruction actually look like two main sections the op code which tells the computer which instruction it is and the operands or the arguments of The instruction you can think of this kind of like a function call the op code is the name of the function and the operands are the parameters in summary when we code a program we’re really just making a list of instructions and when our computer runs a program it executes Those instructions one by one now let’s talk about how our computer will actually work there are infinitely many ways to design a computer and there’s a lot of research and planning that goes into making one luckily though I’ve already done that so let me show you how the computer is going to work The first component we need is a register file of eight registers each register has an address like a house address and some data that lives there I can write to any register and I can read from any register actually let’s make this so that we can read two registers at once you’ll see Why in a minute next we’ll have an ALU or an arithmetic logic unit an ALU performs common operations like addition subtraction or even bitwise logic once you tell it which operation to do it performs that operation to the two inputs and outputs the results specific Ally our ALU is going to have nine Different operations so if I want to add two plus two it looks like this or to subtract 7 minus four it looks like this next I’m going to plug the output of the ALU back into the register file and now this is the heart of the computer we’re Not done yet but we can already start executing certain types of instructions for example consider an ad instruction that takes three operands a destination register and two Source registers its goal is to add the two sources together and put the result in the destination so let’s execute add three one two to do This we can read registers one and two tell the ALU to add them together and write the result back to register 3. and just like that we executed an add instruction pretty cool right in fact let’s make a similar instruction for every ALU operation and this gives Us our first nine instructions okay but how do we get numbers into the registers in the first place for that let’s add an instruction called load immediate which loads a register with a number that’s all it does executing load immediate 210 puts a 10 into register 2. notice how The number we want to load is literally stored on the instruction itself this is called an immediate and now with just these 10 instructions you can already write a program here’s a program which calculates two plus two and it puts the result into register three so again this Isn’t the full computer but I think it’s enough to start building let’s start with the registers these are just memory which makes me think of locked repeaters if you didn’t know you can save the state of a repeater by powering the side of it which locks the repeater and Stores one bit of information let’s go ahead and stack this up perfect now we have a tower of 8 Bits which I’ll just say is one register writing to this register is actually pretty easy all you have to do is put data behind it and then quickly unlatch and re-latch the Locks and then for reading what we can do is block the output of the register until someone wants to read it easiest way to do that is with a comparator on subtract mode cancel it from the side by default and then when you want to read the register stop canceling it and the Data comes out okay now we have a fully working 8-bit register let’s make some more copies and we’ll have a register file alright register file done I changed the design a little bit to make it smaller but it still uses repeater locks so let’s try this out I’ll start By writing a 5 to register three we can do that by putting a 5 here a Destination 3 here and pressing this button let’s also write a six to register four and now reading register 3 shows us a five and reading register 4 shows us 6. beautiful Next let’s make the ALU I actually don’t really know how to make this but uh you know what I’ve got an idea Thank you Okay after some learning from Sammy I finally have an ALU uh here’s the two inputs and the result comes out over here and these levers let you choose which operation you want to do to show you how it works let’s go ahead and put in a five and a three turning on Addition gives us eight subtraction gives us two and bitwise uh and gives us a one those are just some of the operations obviously we have a lot more at our disposal alright let’s connect these together awesome and with that the heart of the computer is done Okay so far we’ve got a register file an ALU and 10 instructions to work with but there are still a lot of problems first of all where are we gonna store the instructions I mean we can’t fit them in the registers so let’s make a memory bank for them I’ll call it the Instruction memory address 0 will store the first instruction address one will store the next one Etc and it’s gonna be read only because once a program is in there we don’t want anything to modify it great but we also need a way to keep track of which instruction we’re on for That let’s add a program counter the program counter stores a single number which points to the instruction that we’re currently executing so logically when we run a program it’ll start at zero and after every instruction we’ll increment the program counter by one telling the computer to move to the next instruction For example let’s actually run this program this is the two plus two program from earlier the program counter starts at zero which tells the computer to execute instruction number zero so it does which loads register one with a 2. then we increment the program counter because we’re done with that instruction And now the computer executes instruction number one increment the program counter again and execute the last instruction and that concludes the program we have a 4 in register 3 which is exactly what we were expecting but wait how does the program counter know when to stop it doesn’t so let’s add a new Instruction called halt to the end of the program halt freezes the program counter and therefore stops the computer from running fantastic guys I just realized we need a name for this computer what are we doing that’s like the most important part so if you’ve got a good name put it in the Comments and I’ll pin my favorite one anyways back to explaining stuff the last big problem with this computer is that currently there’s no way to Loop looping is incredibly important for programs it allows you to repeat something without actually repeating the code for it enter the jump instruction Which takes one operand and a dress when it gets executed it puts that address in the program counter by doing that it essentially forces the computer to jump to the instruction at that address for example consider this countdown program it starts by loading a 1 into register One and a 10 into register 2. then it subtracts that one from register two and jumps to instruction number two again which subtracts one from register two and then we jump again over and over and over and yeah you get the idea this program keeps decrementing register 2 Forever and we never reach the halt so clearly we have loops but they’re infinite it would be really nice to have some kind of conditional jump a jump that only happens if a certain condition is met enter the jump if zero instruction wait is that really the acronym uh how about We call it Branch if zero instead just like jump it takes an address but it only jumps if the last ALU operation resulted in a zero now let’s see what happens when we insert a branch of zero instruction into that countdown program it starts out the same way that it did Before counting down in register two but now when this subtraction results in a zero the branch instruction that comes after it says hey take my Branch to number five which is Halt and now register 2 counts down to zero and stops beautiful let’s keep building for the program counter I think I Actually made one before by accident I I know how that sounds but like when I was making a line drawer for uh this video there was a component that did the exact same thing yeah oh my God look at what I found I can increment it to the next Instruction with this button and I can jump to a new one by putting it here and pressing this button well that is extremely lucky program counter taken care of next let’s make the instruction memory so far I’ve been showing you instructions as strings of words and that’s totally fine that’s how An Assembly Language works but at the lowest level everything is just a binary number to the computer even the instructions and that’s what truly gets stored in the instruction memory a bunch of binary numbers each representing a unique instruction so what I’m thinking is we can store that binary as a tower Of barrels behind comparators if an instruction is for example one zero one I would Place barrels like this and as you can see when we uncancel the comparators it reads one zero one so let’s just copy this a bunch of times alright instruction memory looking good I wasn’t sure how many instructions we Actually want to be able to store but uh currently it can store up to 64 instructions if we need more we can always expand this later now let’s connect everything together oh man this is looking pretty cool already if I did everything right everything should be hooked up so at This point I think it’s time to code our first program in Minecraft Let’s code that countdown program from earlier this is going to be kind of painful because right now the only way to code a program is to do it by hand placing barrels manually but uh we gotta do what we got To do I’ll be back in a bit Foreign Horrible but the countdown program has been coded when I press this button we should see a 10 countdown to zero okay we got a 10 nice yes cool feeling I’ve never made a redstone build where I can actually code things I definitely should have done this earlier that’s so freaking cool We’ve made some amazing progress but there’s one more thing we have to talk about as of now this is our computer and this is our list of instructions but here’s the problem right now the only data that programs can use is the data in the registers that is not very much To work with only what eight bytes so let’s give it some more we have two options here on the one hand we could just expand the instruction memory and make some room in there for data that would work and this would be called a Von Neumann architecture on the other Hand we could keep data separate from the instructions in its own brand new memory bank and this is called a Harvard architecture where the instructions and data are separated I personally feel like Harvard is just the cleaner way to do it and it’s a little bit less Confusing so let’s do it but how are programs going to use this new data memory well let’s add two more instructions load and store load and store act as a transfer method between the registers and the data memory load will load the data from an address into A register and store does the opposite storing data from a register into an address perfect now if a program needs more memory there’s a lot more to work with all right you know what’s next let’s build a data memory and hook it up to the computer Oh my God that took a while but I think it’s done dude can I just say I love how Square this thing is it makes it look more like a like a real life CPU also now that I think about it we should probably make a screen and maybe some Inputs right because right now it’s kind of just a box it’s pretty hard to tell what’s going on well back to it Thank you dude this looks so good we have a little like Xbox style controller nice little screen and a number display too I’m super happy with that and with that we’re done I’ll see you in the Showcase Thank you Thank you [Applause] Video Information
This video, titled ‘I Made a Working Computer with just Redstone!’, was uploaded by mattbatwings on 2023-03-25 19:30:07. It has garnered 373397 views and 19925 likes. The duration of the video is 00:15:37 or 937 seconds.
Over the last 2 months, I created a programmable 8-bit computer with just redstone.
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.18.2) Comes preloaded with fibonacci, but not recommended to use with custom programs. See the github repo for more information. https://www.planetminecraft.com/project/8-bit-redstone-computer-5892975/
Github Repo (assembler and programs): https://github.com/mattbatwings/BatPU Instruction Set: https://docs.google.com/spreadsheets/d/1Em4ugw7qa9VX12AoGqpYfUq0a0jHWwtgRfksVHQf2S4 Computer Specs: – Harvard Architecture – Custom instruction set w/ 16 instructions – 24 redstone tick clock speed (0.41 hz) – 64 bytes RAM – 128 bytes program memory – 8 general purpose registers – 1 central ALU
Getting into computers can be intimidating. These are some of my favorite videos on them! Crash Course Playlist – https://www.youtube.com/playlist?list=PL8dPuuaLjXtNlUrzyH5r6jN9ulIgZBpdo Ben Eater’s Building a Breadboard Computer Playlist – https://youtube.com/playlist?list=PLowKtXNTBypGqImE405J2565dvjafglHU Computer Architecture Course Playlist – https://youtube.com/playlist?list=PLEAYkSg4uSQ33dr4EWxBZwm6t_3_C745S Memory Mapping – https://youtu.be/hLYGTpvoMgE
————————-
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 Intro 0:27 Computer Overview 1:28 Introduction to Registers and the ALU 3:37 Building the Registers 5:00 Building the ALU 5:58 Introduction to Instruction Memory and the Program Counter 7:44 What about loops? 9:28 Building the Program Counter 9:57 Building the Instruction Memory 10:55 Countdown Program in Minecraft 11:50 One last problem 13:01 Building the Data Memory 14:18 Showcase
Music (in order): Mellowind – Reality https://youtu.be/5XBngLBHm-c Harris Heller – Streamline https://youtu.be/GB7SYPFs7QQ Harris Heller – Plethora https://youtu.be/4U3iFdSyNuI Harris Heller – Guilty Spark https://youtu.be/w9M1_ZoxP54 Infraction – Serotonin https://youtu.be/saNSLwgRkrw Deltarune Chapter 2 OST: 42 – sans https://youtu.be/9RtnFtqTWbQ MokkaMusic – Only You and Me https://youtu.be/a08OsBSt4cM Harris Heller – Path Less Traveled https://youtu.be/l_o56ny2aao Phillip Schlosser – Super Mario World Remix https://youtu.be/e0T0rI-GiR4 LitKidBeats – Happy Type Beat https://youtu.be/WRBRA3ZZ1cM Gareth Coker – Firefly in a Fairytale https://youtu.be/UtwES8o9HM4 Infraction – Vlog lo-fi Anime Fashion https://youtu.be/lqbDvmXg1cE Sascha Ende – finger in ear https://youtu.be/8jFDyrzU1Ag Fibbage 3 Lobby Music – https://youtu.be/-ag1NNTZJ3I Patricia Taxxon – Wavetable https://youtu.be/p9zuIoJ-y3M Harris Heller – Manhattan Project https://youtu.be/s02K_ofVPJc Dj Quads – Cruise around https://youtu.be/1H9dpRcUB1c Infraction – Montevideo https://youtu.be/8RzYK4aOaJY I believe – Lightmare https://youtu.be/U0hibvFfRdg I believe – Epilogue https://youtu.be/tOZNh8veU_Y