 In this video, we're going to explain how the memory module works as part of this overall computer system. As we can see, it is connected to the rest of the system through three connections here. Data, address and control, which we're going to be studying in a little bit more detail. So let's see exactly how memory works. A memory chip is a very simple circuit. This comprises of a very large, typically very large number of certain units, which we're going to call addressable units. These addressable units have a certain number of bits inside, and is where the information is stored. So a memory chip is basically a collection of these addressable units. Now, why do we call these units addressable is because each of them has an address, which starts from zero all the way down to size minus one. Now, what are the typical values of these addressable units? And we can find in the market memories that can address these units of 8 bits, 16 bits, 32 bits, so on and so forth. So in other words, the basic manipulation of data of this circuit is always the same. It stores data, but the way it is organized internally depends on the size of this addressable unit. The total size of the memory can be obtained multiplying the number of addressable units. Let's call it AUs for addressable units times the number of bytes per addressable unit. Now, this circuit can perform two operations, very intuitive. The first one is a read operation. A read operation consists on reading the content of one of these addressable units and return it as the output of this circuit. So what it needs is an address and returns an addressable unit. The second operation that this circuit is able to perform is a write operation. And this write operation, given an address and data, it guarantees that this data is stored in this addressable unit with the address given in the operation. Now, as we have seen before, all these units and all these information needs to be encoded with zeros and ones. Now, in case of data, this is trivial, we're going to use some binary representation. But in the case of the address, as we can see, it's a natural number going from zero to size minus one. And what we are going to do is encode it as a natural number. So, once we know that a memory address is encoded bits, if a chip has the memory addresses encoded as n bits, then what we can conclude is that we have two to the n maximum addressable units. And therefore, the memory size in terms of the information that is allowed to store is two to the n number of bits encoding the address times the size of the addressable units. Let's see an example. Suppose we have a two gigabyte memory, and suppose the addressable unit is one byte. So, in this case, what we have is two to the 31 bytes possible and two to the 31 addressable units. And therefore, what we have is a 31-bit address. So, given the size of the memory and the size of the addressable unit, we can deduce the number of bits that are being used to encode the address. Now, let's see what type of signals then do we need to manipulate or to control the circuit. Well, the first obvious one is that the data has to come in for a writing operation, and we're going to put this number n bits of the data that needs to be written. The data needs to come out when we are performing a read operation. This is going to be m as well. Now, the read and write operations, of course, both of them need an address, which we're going to denote like this, and it will have n bits. And finally, we have one additional control signal, which is the one telling the chip or telling this circuit if we're doing a reading or a writing operation, typically represented like this, meaning that the read operation is represented by a 1 and the write operation is represented by a 0. So, a very simple example. Suppose that we have a chip and the operation we want to do is to write byte with value that's represented in hexadecimal for convenience 3f in position or in address 0x358a. So, what happens here? If I have a memory that assumes that the addressable unit is 1 byte, then at some point we have this position here or this addressable unit, which is the one that has the address 358a, and this value over here is then written or stored inside the cell. Analogously, if we perform the read operation, read the content 0x358a, what the circuit will return is the value 0x3f, the value 3f of this byte, which was previously written. Another interesting property of these memory chips is that they can be combined to obtain a bigger chip having more capacity. Let's see this with an example. Suppose that I am given 4 chips of memory. Let's suppose that the addressable unit is 1 byte in each one and the size is 1 kilobyte each. Now, these 4 chips can be combined with a little bit of logic to obtain a 4 kilobyte chip or a 4 kilobyte memory bank. Now, the way we do that is outside of this circuit, we're going to need exactly the same signals as we said before. We're going to have data in, we're going to have some data coming out, same size, in this case m will be 8, because we said that the addressable unit is 1 byte. We will also have an address. Now, in this case, since we have a 4 kilobyte memory, what we'll have is 12 bits memory, sorry, 12 bits encoding the address, and then finally we have the read-write signal. So, how do we connect these 4 chips here so that we can obtain a 4 kilobyte memory chip? So, the trick is the following. The data that comes in can be connected to all 4 of these circuits. All 4 of them receive the same data that is coming in. We know that each one of them will only write this data if they are given the proper read-write signal, therefore there is no problem on providing all this data to them. The problem comes with the data out, because the data out of each of them has to be selected because when we are reading one single data from this memory bank it could be storing any of these 4 banks. So, the idea would be to connect the data out of each of these systems to a multiplexer, and out of this multiplexer we are going to select the right data that needs to be produced to the outside of the circuit. So, this is basically our new circuit that we are. Now, how do we select which one of them is storing the data that is being asked? And we have to deduce that based on the address. So, address has 12 bits, but what we are going to do is we are going to separate 2 of these bits to select which one of these 4 entries is the one being selected. And the remaining 10 bits are going to be connected to all the circuits. We have here is 10 bits. So, as we can see, this is consistent because the size of the chip is 1 kilobyte and we are providing a 10-bit address signal to all of them. Now, what remains to be distributed is the right encoding for the read-write signal. And this can also be done with an additional circuitry. What we take is again these 2 bits over here, feed them through a circuit, which is going to decode it into 4 different signals. So, depending on the value of these 2 bits, 0, 1, 2 or 3, each one of these signals will become 1. And then what we do is we add a little tiny OR gate with one of the inputs negated each of these modules like this. And then this signal over here will be combined with the read-write signal to generate the read-write signal for each one of the systems. This one will be connected here together with the read-write signal to produce this one. The third one will be connected with this one through this OR gate and the fourth one will be connected as well to produce the final signal. So, this new circuit over here will implement a 4 kilobyte memory chip combining 4 units of a 1 kilobyte memory chip. And this is typically the approach that is following most computer systems to combine several chips of the same size and obtain a 1 single circuit that behaves a long list of these addressable units.