In this video we are going to explain what is the role of the control unit. Let's first say that this control unit is one part of the CPU and is sitting next to the data path. Now the main purpose of the control unit, as the name suggests, is to make sure that the rest of the chip or the rest of the CPU is performing the right applications or the right operations. So let's first consider what was the purpose of the data path. Now this circuit over here was in charge of processing data and performing certain operations but it also had certain control signals that needed to be provided. Like for example the address of the register to be read, sometimes if the bank of registers allows, we will provide two of these addresses. Another one was the operation in the ALU that needs to be executed. Another control signal would be how to select operand1 of the ALU or select operand2. And we can have many more signals that change the behavior of the rest of the CPU, namely the data path. So this is precisely the responsibility of the control unit. It needs to create all these units, all these signals, that modify the behavior of this data path to perform the right set of operations. Now how does the control unit know what kind of operation needs to be executed? Well it has one very important register, typically known as IR or IR, typically stands for instruction register. Now this instruction register, where it contains is the instruction that is being executed by the CPU. It is very important because this instruction will have certain encoding and binary of course, 1.0, 1.0, and now from the content of these 1s and 0s over here, what this control unit needs to do is one of the most important steps, which is the coding, this instruction, this instruction need to be the code, and from this the coding, it uses the steps to carry the operation. So this control unit can be seen as a little bit like the conductor of an orchestra. There are a lot of circuits over here that can carry multiple operations, but they need to be control or they need to be told what to do. The control unit is in charge of looking at this instruction over here, and the coding, the message that is containing the 0s and 1s, and as a consequence, providing the right signals over time, this is not a one single time instant, but across several time units, to provide all the control signals so that this circuit over here executes the operation encoding in this register. Now another detail that needs to be explained is that where is this instruction actually coming from? This instruction is actually part of a program, and this program is stored in memory or in RAM. Which means that this control unit, prior to starting the coding instruction over here, what it needs to do is get the content from outside the CPU, go to memory, and read certain position and store its content here. So even before providing all these control units for the data path to perform the right operation first, before that the control unit needs to provide control signals so that the memory content is obtained from the right location and place on the instruction register. Now the next question is how does this unit know what location needs to be loaded with the following instruction, and this brings us to the other very important circuit or register within the control unit, which is typically called as the PC. Now the PC stands for Pro Encounter. It is very important, it has a set of C-Los and 1s over here as well, and the value of this register is precisely the memory location into which the control unit needs to perform a read operation such that the following instruction to be executed gets loaded. So as we can see, for operations such as for example adding these two registers on the data path, the steps that the control unit would follow would be these ones. So let's first read the instruction from memory in location given by the Pro Encounter, the PC. Once this instruction has been obtained from the position stated by the PC, it is a story in the IR, next step is to decode this instruction. In other words, we need to know exactly what kind of C-Los and 1s are here and they are meaning in order to interpret the next operation to execute. Now let's assume for this example that these combination of C-Los and 1s are encoding an operation such that two values in two registers in the data path need to be added. Now the following steps that the control unit would do is provide all the control signals at the right time synchronized with the clock such that we read the operands from the register bank. Then we need to also select the right operation in the ALU, store the result. Once the result has been stored at the output of the ALU it needs to be written in another register. And finally the control unit needs to prepare the execution of the following instruction and the following instruction is in allocation which is next to the one that occupied instruction just executed. So in order to do that it needs to increase or update the value of the program counter. So as we can see out of all these steps over here these ones are specific for an instruction that is performing an addition. Now once the instruction has been finished we increase the value of the program counter and these instructions are repeated or these steps are repeated by the control unit. So the control unit is constantly performing this loop with the difference that depending on the instruction that is the code here, instead of these steps over here we could be executing some other set of steps for another instruction I2 or another set of steps which could be shorter. The important conclusion to understand exactly what is the role of the control unit is that it constantly executes these steps in a loop in an iterative matter and it needs always to rely on the program counter to go to memory, get the next instruction, put it in the instruction register, decode and find out what it means and then provide the right signal so that the data performs. Let's give an example, let's suppose this instruction I2 here, it's an instruction to store the value of register R1 in memory but in position 0x358A for example. So in this case the control unit would go to memory, we'll obtain the instruction, bring it to the instruction register, this instruction is being obtained from the location pointed to by the program counter with the code instruction as we did here and now instead of following these steps which were part of the addition instruction then we following these other steps which needs to read the data from register 1 or 1 as we say in the operation. Then we also need to read the address from the instruction and by others we mean this value 0x358A and finally write data in memory. Now these three steps over here would be exactly the analogous of these four steps we described previously for these operations but they would be executed by the control unit when the instruction to store R1 in memory is received. Once this instruction is executed this loop continues we increase and update the PC and the control unit goes again to read instruction from memory in the location pointed to by the PC and this loop repeats itself forever.