Alright guys, welcome back to the CS classroom. Today what we're going to do is topic 2, which is computer architecture. Now this topic is probably the most demanding topic out of the non-programming topics. So we've got topic 1 through 3, which are theory, and topic 4, which is programming on the SL side.
And yeah, I would say topic 2 is most challenging. So, without further ado, let's get started. Okay, so firstly, what is computer architecture?
So in talking about computer architecture, particularly in this topic, we're going to be focusing on what goes on physically in the computer itself. So how different components work together, how the CPU works, storage meaning RAM, hard drives, stuff like that, and the role of the OS. Now we're going to start with the CPU or the central processing unit.
We can consider the central processing unit to be the brain of the computer. It's responsible for processing all instructions that are sent from computer programs, from peripherals, etc. Any action is executed in the CPU, and any arithmetic or logical calculations that are done, I guess it wouldn't be a logical calculation, but any arithmetic or logical operations that are done, are done in the CPU. So this is basically where all the magic happens. Now, an example of how the CPU works would be a computer program.
You click on an X. That X triggers a certain piece of code. That code is executed by the CPU, and as a result, we exit the program. It's obviously a very high-level description, but in general, that is the role that the CPU plays.
Now, what we're going to do here is we're going to go through how a CPU works. This is sort of a long... and multi-step process that you need to know.
Now we're going to be following, well, like basically every CPU follows the Von Neumann model, and we're going to be describing how that works in kind of a high level. So get a coffee like I did and strap in. Now where we're going to start is the PC with program counter. Okay. Now, basically how this works is So basically anytime you open a computer program, the data for that program goes into the RAM.
The RAM is known as random access memory and basically all the instructions for that program, all the data for that particular program are loaded into RAM and in RAM they're organized into an address and the resultant data. So each address holds some data, some binary data, that corresponds to that program to the operations of the program. Basically the code that runs the program is going to be stored in RAM in the form of this data, this data right here, and in binary. So what the program counter does is a program counter repetitively goes through all the addresses in RAM and executes the instructions. So it's basically just going through and doing the work that has been assigned in the RAM.
Well, not doing the work, but I guess, okay, it's going through and it is identifying which addresses are next to be executed in the RAM. So how that works is the programs counter sends an address to the MAR known as the memory address register. Now, a register is just a small piece of memory. It holds data. It holds data in a very small amount, but it's also very fast.
So for example, let's say we want to go to address 0. Now in reality, in RAM addresses are stored in hexadecimal format. So it looks like x6ff, something like that. But for our purposes, let's say that the program counter is sending 0 to the memory address register.
So what's going to happen is through the address bus, which is just a wire, we're going to send 0 to the RAM, and then we're going to get this piece of data out of the RAM. this 1010 and we're going to send that back through the data bus to the MDR known as the memory data register. So that's being sent through the data bus and also through the data bus we're going to send that piece of data this 1010 to the control unit and it's going to be stored in the current instruction register because that is the instruction or the piece of data that's about to be executed. Now what happens as well is this this data right here So this 1010 gets translated. Now usually that data is not going to look exactly like this, but what it's going to do is get translated or decoded into another format that is readable by the AOU up here.
So we're going to decode our data and then we're going to send it up to the AOU, which is the arithmetic logic unit. Now the arithmetic logic unit is where any is where this data, the operation represented by this data right here, actually gets executed. So whatever that 1010 means, the action that that represents gets executed, gets done in the ALU.
As a result, from the ALU, we'll output either to the monitor, somewhere else in the computer, or we'll store something back in the RAM for further execution. And while the ALU is performing whatever logical or arithmetic operation is necessary, It will use the accumulator, the ACC, the accumulator, as sort of a place to keep data in between doing calculations. So it's like a little storage box that uses when it just needs to put something somewhere temporarily.
So in conclusion, we're going from the PC to the MAR. We're sending a memory address from the PC to the MAR, the MAR to the RAM, and then the RAM is sending data to the MDR, the Memory Data Register. which is sending it to the CIR, to the CU of the CIR, and there that data is being decoded and then sent to the ALU where the accumulator also exists. Now a few other things, so the CU, the control unit, also controls or orchestrates this entire process.
So if this whole process was an orchestra, the control unit would be responsible for making it all work in sync. There are other components inside the control unit you can't see in this diagram. In fact, a real sort of CPU is much more complex than this, but for the purposes of the IB and for the purposes of someone who is not an upper-level undergraduate or graduate student, this is as much as you need to know about the CPU. Now, these slides will be posted in the description below. But right here I can also show you a list of what's going on.
So if you find it difficult to follow my explanation on the other slide, you can go ahead and take a look at this list and match it up with the diagram. You do need to know this entire process along with what all of these components are for the IB exam. There will be questions where you are asked to describe what the role of, for example, a memory address register is, or a memory data register is, or other components in the CPU.
And just to review, the program counter was to tell basically the CPU what address and RAM to access next for data. The memory address register sends an address to the RAM to be accessed. The random access memory holds current program data in the form of an address and data.
The memory data register receives that data from the RAM and passes it on to the control unit where it is decoded and then sent to the arithmetic logic unit. So the control unit both does decoding and controls the overall process which is called the fetch-decode-execute cycle or FDE cycle. It's also called the machine instruction cycle.
I've seen both in the IB exam. Fetch is going to be this part right here fetching the address or actually probably this part fetching the data from the RAM. The decoding happens right here and the execution happens in the ALU or the arithmetic logic unit. Now a few notes. Again, as I said before, the FDE cycle or the machine instruction cycle is orchestrated by the control unit.
If there are two cores in a computer, maybe you've seen before that there are a multi-core or dual-core processor. That's talking about the number of ALUs in the processor. The processor speed is the number of FDE cycles per second. For example, If you see a computer with a 2 gigahertz processor speed, that means we're talking about 2 billion FDE cycles per second.
And again, the FDE cycle is also referred to as the machine instruction cycle. Now getting back to RAM. So RAM could be considered, so if the CPU is our brain, our RAM could be considered the short-term memory.
Again, it stands for random access memory. Now, some things to note about it are that it is volatile. That means when the computer is turned off. all the data on the RAM is lost. This also means that it's non-persistent storage, so the data is not going to remain on the RAM.
Now, primary memory is not only RAM but also ROM. ROM is known as read-only memory and it's used to store permanent instructions. So these are instructions that are the most basic instructions for a computer, including how to boot the computer. So that screen you see before like the Microsoft like the Microsoft Windows screen, that's basically coming from the RAM. Or if you've ever tried to access the BIOS, that's also sorry ROM.
Or if you've ever tried to access the BIOS, the BIOS screen to actually like overclock your computer or change very fundamental settings in your computer or maybe if you've ever installed an operating system you have to use the BIOS and the BIOS is stored in the RAM. So that's basic input output system. These instructions that are fundamental to start just even starting a computer which allow the computer to start and function at a very basic level are written in the factory and cannot ever be changed. And the ROM is also persistent, so even when the electricity turns off, that data on the ROM stays there. So collectively, the primary memory consists of ROM, read-only memory, and RAM, random access memory.
Now something else we have is cache. So a cache stores frequently used instructions from RAM. And the reason for this is because if we have the cache, so this is our CPU right here, right? And if we have instructions in the cache Or if we have a cache the CPU is going to check the cache first and see whether what it needs in the cache If not, then it'll go to the primary memory However, it's the cache can speed things up because the cache is always going to be closer to the CPU So it's much faster for the CPU to retrieve data from the cache rather than go all the way to the primary memory So remember the cache is going to sit between the CPU and the primary memory.
Going back to our diagram right here, the cache would be right here in between, right? That would sit between the CPU and the RAM. Now moving on, we've talked about primary memory, but secondary memory is our hard drive.
We can think of this as long-term memory. It is considered to be persistent storage because when you turn your computer off, the data is still there. It holds all data not currently in use.
So for example, if you start up Microsoft Word, as soon as you start that program, that program gets put into your RAM. However, prior to that, all the data for that program, including the code, was stored in your secondary storage on your hard drive. It is slower and cheaper than primary memory, and secondary storage is not directly connected to the CPU. Additionally, RAM will come in increments of like 2 gig, 4 gig, 8 gig, 16 gig.
but hard drives you're more likely to see in increments of, I don't know, like 512 gigabytes or a terabyte. So secondary memory will generally be slower but also present in much larger amounts than primary memory. Now virtual memory is something that we utilize when the primary memory is overloaded. A typical usage of this might be when running games which are very memory intensive or video editing programs like the one I'll use to edit this.
Now virtual memory is slower. Basically what happens is data from the RAM, generally less used data, is sent to the hard disk, to the secondary memory, and it's sent to a section of the secondary memory in units called pages. So we're sending the stuff to the secondary memory and then when it's needed it gets transferred back to the RAM. So the hard disk acts as kind of a backup for the RAM. Now virtual memory is slower and it's also temporary.
So whenever your computer is going to have to use virtual memory, the programs involved or the programs currently running will generally run slower. Hence why having more RAM in your computer is always better in terms of performance. Now, this is a great chart, particularly if you're ever asked to compare the different storage media.
So smaller, costlier, faster, larger, cheaper, slower. So the register. It's going to be the smallest, costliest, and fastest piece of memory.
Then you've got your L1 cache, your L2 and L3 cache, your system RAM, your permanent storage, which is going to be your hard drive, and then your network storage, which is something you might access over an Ethernet cord or over wireless. Now, the next section is about operating systems. Now, an operating system is defined as a set of software.
that controls computers hardware and resources and provides services for computer programs. Now broadly there are five roles that operating systems play. They are a user interface, a memory management, peripheral management, multitasking, and security.
And let's go over all five of these. Now the user interface is the link between user and hardware. So this right here is an example of a user interface. However, this is specifically a graphical user interface.
You can also have a command line interface, which is common. In fact, some operating systems, some Linux systems only have a command line. interface, like so. We could have a natural language interface, which is something like Siri. And we could have a menu-based interface, which actually looks like this, but you don't really have commands you type in.
You just have like a menu for stuff you want to do, which kind of sucks. That's something you might see in like a Game Boy, I suppose, or something like that. I'm not even, I can't even really think of a good example when you'd see that.
These are by far the most common. And for example, on either the Mac or Windows or any operating system, you usually have access to both. In a Mac computer, the CLI is the terminal app. In Windows, it's the command prompt.
Now, the next role of an operating system is in memory management. So this involves keeping track of storage devices, allocating the appropriate amount of RAM to programs for them to have the optimal performance, modifying memory locations, basically like reorganizing or moving data around in the RAM, just sorting data. Again, just having the optimal configuration of data on RAM or on disk drives for the most efficient performance, or for the highest efficiency, organizing data into folders and copying and deleting files.
Select the trash can, that's memory management. We also have peripheral management, peripherals being things like keyboards, mice, and monitors. So what the operating system does with peripheral management is it...
coordinates with the BIOS, which is that very fundamental part of the computer that's stored in ROM. It uses device drivers, which are just small programs, whose purpose are to interface with peripherals. So basically it manages that interaction between the computer and peripherals by utilizing these device drivers that either come with the operating system or are installed by the user.
Basically it allows us to use peripherals without thinking too much about it. We've also multitasking, and multitasking involves the allocation of CPU cycles, FD cycles, to programs that are running at the same time based on priority and time. Each program is given a slice of time where I turn to use the CPU for a certain number of cycles.
These slices can vary in length of time. So basically what it's doing is it's allowing multiple programs to run at the same time, and the operating system is basically coordinating their usage of the CPU. work optimally at the same time. It's basically like a gatekeeper for the CPU. So basically allows programs to access the CPU only when it says so that everything works smoothly.
Actually, if you do HO, I believe it's either in like topic six or topic seven, I can't remember which one it is, but we go more into detail about these slices and this sort of process in that topic in HO. Finally, we have security. It could be something as simple as username and password, user permissions. So certain users in the OS can access certain files and others can't. And then file permissions for reading and writing.
Again, certain users or even certain programs can read and write to certain folders while others can't. Now, this is kind of trivial and kind of ridiculous, actually. But one thing you do need to know, apparently, is just the names of three types of application software. So like really you just need to be able to mention like, like Noah mentioned two to three of these.
So you have a word processor, which is like Microsoft Word, spreadsheet software, which is like Microsoft Excel, a database management system, which is like Microsoft Access, an email client, which is like Outlook, I guess Mail on Mac, web browser, which is like Chrome, which you're probably watching this in, a, I guess you, I don't know if you like, you need to know that computer-aided design software is an application software. I don't think you need to know what it is, but in any case, this is an example of computer-aided design software. It allows you to design objects, design buildings, design things on the computer, and graphic processing software, which is basically, which an example is Photoshop.
So you seem to know that like three of these are applications that will run on a computer, as ridiculous as that might sound. Keep in mind, this was created in 2014. Like I guess people were already like pretty tech savvy in 2014, but I mean apparently not. Um Our next section is going to be data representation. And this is probably where we're going to have the most sort of math.
Now, data representation hinges on the fact that data and computers is represented in the form of bits, which constitute bytes. Now, bits, ones and zeros are binary code. And those are that's like the language that computers speak, every operation.
Like any code that you write in a computer is going to eventually get translated to ones and zeros to be interpreted by the CPU. What you do need to know is this right here. One byte is 8 bits, one kilobyte is 1024 bytes, one megabyte is 1024 kilobytes, one gigabyte is 1024 megabytes, one terabyte is 1024 gigabytes.
You need to know this, particularly this one right here, because you might get a question about how many bits is this, how many bytes is this, how many giga... how many... bytes is in a gigabyte, that sort of thing. So make sure that you pay attention to this. Now just to give you an idea of like what, like how stuff is stored in terms of bits and bytes, like one character, like an A in a text file is going to be one byte or eight bits, which essentially means like eight binary values.
All right. In email will be two kilobytes. A 3-minute audio file would be 3 megabytes. A movie is 4 gigabytes.
So at its core, you're still talking about ones and zeros, but depending on the kind of data you are storing, the number of ones and zeros gets massively bigger. Now, binary, as we said, is a language of the CPU in modern computing. There are two possible values in binary.
It's 1 and 0. And binary is what's called base 2. So it's basically you're representing values in a base two format. And honestly, I'm not a mathematician. So if that terminology is incorrect, don't write that in the comments. Well, I actually do write that in the comments, but just don't hold me accountable for that. Anyways, what I'm going to show you next is how to convert from binary to denary.
Now, denary is decimal values or the numbers we are used to seeing. So on the IB exam, you need to be able to convert between both of them. So here's a great example, actually. convert the 8-bit binary number 000110. Now this is an 8-bit binary number because there are 8 digits here.
1, 2, 3, 4, 5, 6, 7, 8. I'm not going to count all of them. So we want to take the 0011010 and convert that to a decimal value. And the decimal value is 26. And the way we know that is that basically this is base 2, right? So that means that starting from right here, This represents 2 to the power of 0. This represents 2 to the power of 1, 2 to the power of 2, 2 to the power of 3, 2 to the power of 4, 2 to the power of 5, 2 to the power of 6, and 2 to the power of 7. So what we're doing is we're basically adding up all the values where there's a 1. So we've got a 1 right here, so we're going to write down 2 to the power of 4 plus We've got a 1 right here, so we're going to write 2 to the power of 3, plus... We have a 0 right here, so we're not going to write that down.
And we have a 1 right here, so we're going to do 2 to the power of 1. And these numbers represent these right here. So really, we're going to have 16 plus 8 plus 2, which equals 26, which is our ultimate answer. So I'm going to do two exercises.
The first one is going to be this value right here. I'm just going to do some examples. So let's get started.
Okay, so the first value we have right here is 11101001. So I'm going to write that right here. 11101001. So that's going to be to the power of 0, to the power of 1, to the power of 2, to the power of 3. to the power of four, to the power of five, to the power of six, and to the power of seven. So right here, so we've got to the power of seven because there's a one there, plus to the power of six because there's a one there, plus to the power of five because there's a one there. We're not going to do two to the power of four because there's a zero there, to the power of three because there's a one there, we're not going to do two to the power of two or three to the power of one because there's zeros there, and to the power of zero because there is a one there. So this is going to be 1, 8, 16, 32, 64, and 128. And that should give us 233. Now, similarly, right here, we've got 10001101. So again, to the power of zero.
Actually, you could just write the numbers. So to the power of zero is going to be 1, 2, 4, 8, 16. 32, 64, 128. So for 128 we've got a 1, so we're going to do 128 plus 64 we got a 0, 32 we got a 0, 16 we got a 0, and then for 8 we've got a 1, 4 we've got a 1, and 2 to the power of 1 we've got a 0, and then to the power of 0 we've got a 1 which is going to be 1. That's going to be 136. plus four plus one equals 141. Now the next thing we're going to do is we're going to learn how to convert from denary to binary. So that means going from a number like 26 to how do we figure that out? So the way we figured that out is we want to look for the biggest number in this chart that fits into 26. So 32 is bigger than 26. So that's going to be 0, that's going to be 0, and that's going to be 0. But 16 is the biggest number that fits into 26, so that's where we're going to start with the 1. Now if we choose 16, we're going to do 26 minus 16, and now we have 10 left over.
Now what's the biggest number that fits into 10? That's 8, so you can put a 1 right here. We can subtract 8, and then we have 2 left over.
And what's the biggest number that fits into 2? Well that's just going to be 2, so we can have that right there. all the others will have zeros now let's go do some examples so right here we've got 168 all right so we need to think about our we need to take a look at our chart right back here so again we're basically going to like write down all the numbers that we have access to right so it's going to be 128 uh 64 uh 32 16 8 4 2 and 1. which corresponded to the power of 0, to the power of 1, etc. etc. etc.
So what's the biggest number that fits into 168? That's going to be 1. So if we do 168 minus 128, we get 40 left over. Now what's the biggest number that fits into 40? That's 32. So we're going to put a 1 right there. And 64 is too big, so we're just going to put a 0 right there.
So we do 40 minus 32 equals 8. And what's the number that fits into, what's the biggest number here that fits into 8? And that's 8 right here. So we're going to put a 1 right there.
And 8 minus 8 equals 0, so we're done. We can put 0s everywhere else. So we're going, we're trying to find the biggest number that fits into our denary number.
And then we're moving this direction. Okay, so we started with 128. Once we accounted for 128, we had 40 left over. And then we tried to find the next value, next biggest value.
that fits into 40. That was 32. And we subtracted 32 from 40 and we got 8. So then we tried to find the next biggest value that fit into 8 and that was just 8. And everything else was a 0. Now we still got 83 right here. We can still use the same chart. What's the biggest number that fits into 83?
That's going to be 1 right here. You can automatically put a 0 right there. 83 minus 64 equals...
What is that? That's going to be 19. So what's the biggest number that fits into 19? That's going to be 16. Put a 0 right there. What's the biggest number that fits into 3? That's going to be 2. Put a 0 right there and a 0 right there.
We have 1 left over, and we can put a 1 right there, and then we get our answer. So you're going to find the biggest number that fits into your denary, your decimal number. The biggest one of these numbers. and then work your way rightwards from there in a rightly direction, an easterly direction.
Okay, now the next type of value we're going to work with is hexadecimal. Now hexadecimal is used to efficiently represent large binary values. To represent colors, if you've done any HTML or CSS, you've probably used hex to hex for color codes to represent specific colors.
Memory addresses, as we said before, MAC addresses which you went over in topic 3, our networks topic, and hexadecimal is base 16. So for example with a binary value, right, you've got 1011 This is to the power of 0, to the power of 1, to the power of 2, to the power of 3. Well, in Bay 16, first of all, it's not just 1 and 0. It's 0 through f, because you have 15 different ways, or 16 different ways to represent values, right? And you're going to have 16 to the power of 0. So you're going to have 16 to the power of 0, 16 to the power of 1, 16 to the power of 2, 16 to the power of 3. Although this is pretty big. We normally never get to these. Normally we just have two digits.
We have two, we have six, we have two digit hexadecimal numbers, at least on the IB exam. And so, for example, if you have like F right here and two right here, that's going to be two times 16 to the power of one plus 15 times 16 to the power of zero. If you look at this chart right here, it makes a bit more sense. So hexadecimal has 15 possible digits. space 16 and this is what they correspond to and yeah they have letters it's weird you'll get over it so right here for example we have 2a5 okay now 2 is pretty simple so right here we're going to do 2 times 16 squared for this digit right here we're going to add that to well we have a in our next digit right here and a just corresponds to 10 so we're going to have 10 times 16 to the power of 1 squared.
And we're going to add those. And then our last digit, we have 5, which is pretty straightforward. And that's 16 to the power of 0. So we're going to have 5 times 16 to the power of 0. And if we add all those up, that gives us 677. So it's actually just like binary, except instead of having 2 to the power of 0, you have 16 to the power of 0, et cetera, et cetera, et cetera. So we're going to go over some examples right here.
So right here we have three and this these are some examples for converting from a hex value to a denary or a regular number as we know a decimal number. So we've got 3b right here and that's going to be 16 to the power of 0, 16 to the power of 1. So we're going to do 3 times 16 to the power of 1 plus b if we go back to our chart represents 11. So we're going to do 11 times 16 to the power of 0. And that's going to be like 48 plus 11 equals 59. Right here, we've got a slightly larger example. So we're going to have 18e.
So we're going to have 16 to the power of 0, 16 to the power of 1, and 16 to the power of 2. Now, 16 to the power of 2 is 256. So we're going to have 1 times, well, we'll just write 256, honestly. plus 8 times 16 plus, what is e? e is 14 right here. So we're going to have 14 times 1, and that's going to equal 398. I just know that because I did the work beforehand.
I'm not a human calculator. In fact, I'm not even really that good at math. And yeah, so the thing is, like, on the IB exam, you will most likely be asked to do such a conversion. And you're going to have to know what the letters correspond to. Okay, so make sure you memorize that and actually even rather than memorizing it, just do a bunch of problems and you'll have internalized it quite easily.
But make sure that you know that for the IB exam. Okay, now similar to binary, we're also going to learn how to convert between, convert from denary to hexadecimal, which essentially follows the same process. Okay, so now what we're going to do, similar to what we did with binary, is learn how to convert between denary and hexadecimal. So right here, we can represent, so we want to convert 480 to 1E0. So basically the way we want to think about this, this is a bit more complicated than with binary.
So our first digit is 16 to the power of 0. So the maximum, the highest number we can have here is F, which represents 15. So the highest amount we can represent with this is going to be 15. Okay, now we have 16 to the power of 1 for our next digit. Now if this is f, the highest number we can represent is going to be 15 times 16. Now that's going to be equal to 160 plus 80, which is going to be equal to 240. so we can represent at most 240 in this spot okay and now in a third digit 16 to the power of 2 if we have f here the most we can represent is 15 times 256 which i'm not going to try to calculate So we know 480 is bigger than 240 than our maximum possible value here, and obviously it's bigger than 15. So we're probably going to start right here. Now the biggest value we can put into 480 is going to be 1, really.
So we're going to have 1, because if we do 1 times 256, we just get 256. If we do 2 times 256... we get 512 which is already bigger than 480. So we're gonna have a 1 for our first digit. And then we're gonna have, we're basically gonna do 480 minus 256 and that is going to require a calculator for me. I would say, so it's gonna be 200. and then um it's gonna be 200 and then 224 right so it's gonna equal 224. so now we need to figure out how to get 224 well we're so basically in this in our next digit right here we're so 16 to the power of 2 for 16 to the power of 0 um we're going to see how we can fit 224 and it's probably going to be e because 240 minus 16. Well 240 was equivalent to f and minus 16 equals 224. So we're going to have e right here. 15 times 16 equals 224. And actually we took care of all that was left so we're just going to have 0 right here for 16 power 1. Now that's a bit complicated.
You're probably not going to have a number this big on the IB exam but it was just to kind of illustrate the concept. Now for 232. So if we remember right here, we actually had E. E was 224. And we can have a maximum value of 240 in the second for this digit.
So we're 16, we have 16 to the power of one, we're gonna have E, because if you have F, that's 240. And so if we do 232 minus 224, we get eight, so that's gonna be E8. Now this is just like a quick overview of how to convert between hex and hex and dennery and binary and dennery and vice versa I'm not like like there are a lot of tutorials out out there to cover this on The purpose of these slides is really more to cover very IB specific stuff that you can't really find everywhere and put it into One space so if you don't completely understand this want to see it explained in a different way I invite you to just YouTube it because there are a lot of videos on how to do this. It's a pretty common process Now one of the more important things is to convert between like hexadecimal and binary. And I'm just going to illustrate, I'm probably not going to do all of these, but like the way that this works is, let's say we have 3b, okay?
3b is a hexadecimal digit. Three just represents three in denary, and b represents, I want to say that's like 11 in hexadecimal. because 9 is 9 a is 10 and then b is 11. so um a really easy way to think about this is what is 3 and what is b 11 in binary is going to be 1 so it's going to be 1 1 0 1. so the biggest number that can fit into 11 is 8 so we're going to put 1 And then we have three left over.
So we're gonna have one and one. Okay, so that's B and Three in binary is just zero zero one one. Okay, so if you put these together we get zero zero one one one zero zero one zero one one Which is the same thing as this so if you want to convert from hexadecimal to binary You just split them up into individual digits you figure out what they're like denary value is and then you just find the binary value of that okay similarly right here we have one one zero one zero one one zero okay what is this in dennery that's gonna be one okay so one two four uh eight so that's gonna be thirteen in dennery right it's that first part that second part is going to be um two and four so six two plus four is six okay So basically what I'm trying to say is every four hexadecimal digits represents or every four binary digits represents a hexadecimal digit. Okay, these four represented this, these four represented this, and right here at 13 in hexadecimal is D, and 6 is a 6. So our answer is going to be D6. And this is an example of how hexadecimal can be a shorter way to represent binary.
So in order to convert between them, what you need to know is that every hexadecimal digit is equivalent to four binary digits. All you need to do is change each hexadecimal digit to denary and then convert that to binary. So here we converted 1 1 0 1 to... Look at here, we converted 3 to...
Well, we knew 3 was just 3, and b was 11, and we just converted those to binary, and we got this. Vice versa, we could have just taken our binary values, like this 4, we converted to 13, and then we converted that to 6, and then we just got d6. So it's actually a lot more simple than converting between denary and hexadecimal.
Now next we're talking about data representation in the larger sense. So basically strings are made up of characters. Each character has an 8-bit representation or a 1-byte representation. There are two formats, ASCII and Unicode.
Now ASCII was kind of the original data representation format and that actually uses about 7 bits and then one more bit i think that's for error um for detecting errors yeah it's a parity bit which is for detecting errors and um just kind of to go back so you've got seven bits to represent each character and one bit just to make sure there's no error and seven bits so two times seven means there are 128 possible combinations um that's going to include uh you know spaces punctuation etc now the other other format we have is unicode and there are a lot more bits because we can represent a lot more languages using Unicode. So for example, Chinese characters, Arabic, or just any other language really. Again, just a review of ASCII, seven bits for each character.
We also have punctuation included, 128 possible characters. These can also be represented by hex as we see right here in this column and the other columns. This is an example of the most recent version of Unicode where we can represent dinosaurs and stuff. But generally we have UTF-8 which is 8 bits, UTF-16 which is 16 bits, UTF-32 which is 32 bits.
Obviously the higher standard of UTF we're using, the more bits we can use to represent characters, and the more characters we have access to, the more languages we have access to. Now we talked about characters, we're going to talk about... Well, we just talked about characters. Now we're going to talk about how images are displayed. Now each display, each monitor or phone screen, is divided into pixels.
And pixels are little squares. So your screen is basically a grid of little squares called pixels. And each of these squares can be controlled in order to represent a specific color at a specific moment. So for example, if you're representing this photo right here, this is made up of a bunch of pixels and each pixel is showing a different color that collectively make up this image. Now if you have a video, those pixels are constantly changing in order to represent the particular still at any given moment.
Now each color represented in a pixel is a combination of red, blue, and green. And other colors besides these are a combination of all three as determined by Basically there's some variation or some mixture of all three in different shades. Now if we say that a monitor has a 1024x764 screen resolution, that means it is 1024 pixels high, 764 wide. You've probably seen other descriptions of screen resolution like 1080p, HD, and 4k, and these all refer to increasing number, to basically the number of pixels on the screen. We can represent the color of each pixel using a six-digit hexadecimal code.
The first two digits from the left represent red, the second two represent green, and the third two represent blue. And we can represent different colors using some mixture of these. So for example, orange is going to be whatever shade FF represents, whatever shade of red FF represents. whatever shade of green 8 represents or whatever shade of blue 0 represents, which is actually probably nothing.
Okay, so now we're going to move on to logic gates, but just kind of in conclusion, that is pretty much all you need to know about how data is represented both as characters and on the screen. There are other questions. The most common question is like how many possible color combinations can represent this, or just some question about what the role of pixels are.
And in order to see those questions, please take a look at the link in the description because I'm linked, I'm linking the slideshow and I'm not going to show you the IB questions just for copyright reasons, but if you check out the slideshow which is linked in the description, at the end of the slideshow there's a bunch of IB questions and you can see how these concepts are approached in the actual IB exam. They're all past IB questions. Now the last section is going to be logic gates.
This is probably like it's a, I mean, you need to, like there is something involved. I'm not going to say it's quantitative, but it's kind of in that direction, but a lot of students actually seem to enjoy this the most for some reason. So basically the concept behind logic gates is a logic gates takes one to two inputs of one or zero and outputs either a one or a zero. a 1 being represented by a high voltage electrical signal and a 0 being represented by a low voltage electrical signal.
Now a CPU is made up of thousands or millions of these logic gates and it's basically there are various patterns of logic gates that represent any of the operations that a CPU would want to conduct. It's basically made up of a bunch of logic gates and they can be configured into whatever pattern is necessary in order to accomplish a task. And these are all just taking ones and zeros and outputting either a one or zero.
So these are four, or actually six logic gates. So this is a not gate. This would take in a, for example, this would take in a, this will basically output the opposite of whatever's put in.
So oftentimes you can think of a zero as a false and a one as a true. That's kind of how I look at it. So if we put a zero here, we're going to return a one.
And if you put a one in here, we're going to return a zero. So if we put a false in here, we'll return a true. If we put a false, we put a true in here, then we'll return a false. Now this is an AND gate right here. Now with an AND, if both of the inputs...
are different. Wait, hold on. Okay.
If we put in a if you put in a false and a false, like a 0 and a 0, we're gonna end up with false. If we have any zeros, we have any falses, right? We're gonna end up with a 0. The only case in which you have an output of a 1 or a true is when we have two trues. So two trues equals a true, but if there's any false in the form of a 0, then our output is gonna be a false. Now an OR gate is an opposite.
So if we put in like a 1 and a 0, a true and a false, we're still going to get a true. We put in a 0 and a 1, we're still going to get a true. If you put in a 1 and a 1, we're obviously going to get a true. The only time we're going to get a false is if we put in a 0 and a 0, which represents a false and a false.
And that's this case right here. So this is going to be an XOR gate. And basically an XOR gate... outputs a false whenever both of the inputs are the same.
So if you have a 0 0 or a 1 1, so we can say false false or a true true, we're gonna have a false. Now if we have two different inputs like a 0 1 or a 1 0, our output's going to be a 1 or a true. So if you have 0 1 or 1 0, our output's going to be 1, which we can also represent as true.
Now these are just variations of these. This is a NAND. and this is a this is a nor and it's basically an and gate with the nor with a knot in front of it the not gate in front of it um and as we'll see later we can actually chain together these logic gates so that we take the input from this one put it through another gate and then we get the resultant output so as you can see here um so first of all these things right here are called uh truth tables so they basically show every possible um input and every possible output So for example, when we only have two inputs, we have A and B right here.
Our possible inputs are 0, 0, 0, 1, 1, 0, 1, 1, and we're writing down all of the outputs from those. Right here for a not gate, we only have one input, so our only options for input are 0 and 1. And our outputs are 1 and 0. Now, as you can see in the truth table, and and and or is basically not and and not or. So if you think about what that means in like lexical terms like as words Then everything here is the opposite of everything here So for example, with an AND gate, normally if we have any zeros, if we have any falses, then we're going to have a false.
But in NAND, if you have any falses, if you have any zeros, we're going to get a true. And similarly, if both are 1, if both are true, then we're going to get a false. So NAND and NOR are the mirror image of AND and OR.
So right here, the figure below shows a logic gate and its incomplete truth table. Complete the truth table below. So these are all our possible outputs of A and B. Okay, now these a and b go into a gate.
This is an or gate. Remember how or works. If there is one true in either of these, then we're going to get true.
One true or one one, right? A one is one equals true and zero equals false. So zero zero is going to be zero. This one has a one so it's going to be true. This one has a 1, so it's going to be true.
And this one has a 1, so it's going to be true. So remember, the C here represents the output when we input both A and B, which is why we're writing these numbers right here. So now that we've gotten right here, we have our output at C right here. Now, whatever output was here from the OR gate, that's going to go through this gate right here, which is a NOT gate. Remember, a NOT gate just reverses any input that we have.
So the zero is going to become a one, the one's going to become a zero, the one's going to become a zero, and the one's going to become zero. And that's our answer. Right here it says the figure below shows a logic gate and its incomplete truth table, complete its truth table. So again we have our a and b inputs right here right.
So c is going to be right here. Now c is taking in the, well so we have this gate here that's taking in a and b and outputting c. Now this gate is an OR gate.
So we just saw an OR gate. Remember if there's any, if there's a one at all then we're going to get a one. If there's a true at all we're going to get a true.
This is going to be false zero, true one, true one, true one. But also we have this wire right here that's going from B into another gate which is AND. It's sort of sneaky. So at this AND gate right here we're going to have the inputs of C which we saw right here and D which is this really B in disguise. So Q, which is the output from this gate, is going to be the output after C and D are put into an AND gate right here.
Now D is just B, right, because we're just going straight from here to D. So we already know D is going to be 0, 1, 0, 1, and both these are going into an AND, so we want to find C and D. Now remember with an end, if there is any, so the only time where we have a true or a one is if there are two trues. So this one's going to be one, this one's going to be one, and these are going to be zero and zero.
And that's going to be our answer. So here's another last example. This is XOR. Okay. Now this one's a bit more complex.
Okay. We have A and B. So we've got A right here and we've got B right here.
So in this truth table, A and B are just going to be... So we have A right here. For some reason, they didn't put B.
But A and B are just going to be all of our possible outputs, right? So we're going to have 0, 1, 0, 0, and then 1, 0, and 1, 1. Now, first, let's look at C. So this is a bit sneaky. but we have A and B going into an OR gate to get C. So what's going to happen is, remember, with OR, if we have a 1 at all, it's just going to be 1. So we have C right there, and D is just a result of B going through a NOT gate.
So remember, a NOT gate reverses whatever the input is. So this is our B right here, and D is just going to be... B after the NOT gate.
So it's going to be the reverse of B. So it's going to be 0, 1, 1, 0. Now Q is going to be the output when we put C or D through Q. So it's going to be C, X, or D.
So remember what an XOR was. If we go back to our chart. So right here, this is our XOR.
So if our a and b are the same, we have a zero or a false. If they're different, then we have a true. So we're comparing one and zero. So if they're the same, we have a false. If they are different, we have a true.
If they're the same, we have a false. If they're different, we have a true. So these are the same, so we're gonna have a false, which is zero.
All the other ones are different, so we're gonna have a true, which is one. So this is gonna be our output. Now this is a very common question, like these types of questions are very common. Let's look at how we can actually draw equations that are given to us, which is another type of question. We'll just look at it in a simple example or two.
So let's just say that we have A and B, okay? Basically the way we're showing that is going to be A and B, okay? and we're going to have 0 0 1 1 or 1 0 0 1 1 1 for a and b and a and b is going to be um so remember they have to both be true or both b1 to get a result of 1 or true so we're going to have 1 0 0 0 now what we can do is we can expand upon this to create different patterns of gates so let's say we want a and a and not b We're going to start outwards, so we're going to start with the a and the not b, and then draw those first, and then we'll work our way into the end. Now how this is going to work is we are going to say a and not b.
Do you remember what the not gate was? This was the not gate. Now if we put some value, let's say we put x here, and we have y. Okay? We have two possible values of x.
We do 0, 1. Our y is going to be 1, 0. So it's basically making the opposite of whatever input we put in there. And it's represented this way. So we're going to draw a. That's going to be our input.
And then b. But we're going to have a not gate for b. So whatever input, whatever 1 or 0 we put in here, the not gate is immediately going to reverse it. And both of those are going to be joined into an and gate, which is represented this way.
So that's kind of like what we're getting at here. We're chaining together logic gates. We're looking at the inputs You're going to have to both draw diagrams interpret draw diagrams and draw truth tables So let's draw some gates. Okay, we can chain gates together So we have x or not y so basically we have we have an x input and a y input we have two inputs And we're connecting a not y with an or So basically we want to start our way outwards and work our way in.
So we're going to do x and we're going to do y, but we're going to put a not gate because not y. And then both of those are going to go into an or gate. Now, if we want to make a truth table for this, what we're going to say is we have two inputs, right?
So we have x and y. So let's look at this, right? We have x and we have y. We can have 0, 0. So x are both 0. We can have x is 0 and 1. We can have x is 1 and 0. Or we can have x is 1 and y is 0. Or we can have x is 1 and y is 1. Now right here in this right here, we have not y.
So that's going to be the opposite of everything here. It's going to be 1, 0, 1, 0. And our final result is x, x or not y. So x or not y.
So if we have 0, 1, 0, 0, 1, 1, and 1, 0, which are x or not y, and we want to do an or between these. So we want to put both of these values into an or gate. Okay.
So you want 0, 1, and then 0, 0, and then 1, 1, and then 1, 0. That's going to be our result. So 0 is considered false and 1 is considered true. Remember for an OR gate, if we have a false and a true, we're still going to get a true.
If we have two falses, then we're going to get a false. It's probably the only situation. If you have two trues, we're going to get a true. Sorry, a false is represented by a 0. If you have two trues, we're going to get a true. Two ones, we're going to get a 1. If we have a 1 and 0, we're going to get a 1, which is a true.
So here our final output is going to be 1011. So basically what we're doing is we're getting our x's and y's and then looking at our equation we're figuring out what gates are going to be where and then we're going to create a truth table to show all the possible outputs and inputs. So initially like I was going to show you these examples but these represent three inputs which you will never see on the IB exam. If you're doing IGCSC then you may see it.
So this is just what we're worried about. Now that takes us to IB questions. Again Particularly with like logic gates and hexadecimal binary, those are just starting points.
I don't like, I kind of gave you something to work with, but I didn't want to go too much into detail with it. Like I didn't feel the need to go into detail with it too much. Again for both of those, there's a huge number of resources online.
So these are, this is a starting point. The point of these slides is just to give you all the information that you need in one place, and then if there's something you don't understand or just want to get further grasp on, at least you know what it is and then you can go pursue that further. Now again, you can find these IB questions in the slideshow that is linked in the description.
I'm just not going to put them up for copyright reasons, but yeah again just look at the slideshow. If you want to see more videos like this, then please remember to like this video and subscribe to this channel. Also feel free to comment if you have any questions or you have any videos you want me to make particularly related to the IB. Additionally, if you have questions, Besides writing in the comments, you can also check out the Discord where others can help you or I can help you. There is a channel for just IB questions.
Anyways, have a nice day.