Video
Đăng bởi Ban biên tập OpenER ·
Tác giả giữ toàn bộ bản quyền (All Rights Reserved) — không phải giấy phép mở. Bạn vẫn xem và học miễn phí trên OpenER; muốn tái sử dụng cần xin phép tác giả.
[MUSIC PLAYING] PROFESSOR: Hello. Welcome back to our CPU design module.
We have designed the data path. So it's time to figure out how to design that control unit that we need to configure the data path.
So remember our picture of how the data processor look and work with the memory. We had the processor. And inside the processor, we had two main units, the data path and the control unit.
The control unit is, essentially, what we have already seen. We just haven't designed it yet. This is the data path, a different view of a data path, a detailed of a data path.
And the control unit is primarily the control logic that is at the bottom of this picture.
Inside the data path, we had a number of functional units, like the program counter, the fixed adder, instruction memory, immediate generation unit, register file, branch comparator, ALU, data memory, and the number of multiplexers that allowed us to configure this data
path to execute instructions.
Control unit was that that was setting up these multiplexers and other configuration options inside the data path to execute different instructions.
So in order to really understand how is this going to be done, let's take a look at the execution of a few instructions and see how does the control unit handle them and, simultaneously, try to understand how does the — how many of these different computations
inside or different actions inside the processor happen concurrently.
So we can do that by revisiting some of those instructions that we have introduced early on before we had the complete data path.
The idea now would be to see how they work with a complete data path where everything is in place to execute all the other instructions.
So let's visit one of the early instructions, which was the "store word."
That's the instruction that takes the value from the operand — or from the register rs2 and writes it into the memory into a location that is pointed by the base address, which is in register rs1, and the offset, which is the immediate.
Every instruction in our data path starts execution on clock tick. So on the rising edge of a clock, we are going to write a new value into the program counter.
It takes a little bit of a time for that to appear at the output of the program counter at this write here. And that time is what we characterize and clock to output delay.
So that clock to output delay — after the clock to output delay, we get a valid program counter address here pointing to instruction memory.
But it is also ready to be updated and, perhaps, used later on down the stream in a data path. Let's visit what is happening. So there are two things that are happening concurrently.
We are fetching an instruction from the instruction memory and we are updating the program counter.
So as we add this plus 4 to the program counter, we get a new value at the input of this multiplexer.
But it is not going to propagate through the multiplexer until we know what is the new value of the PC select control signal.
In order to let it go through, we need to know what is the actual instruction that is being executed and how does it affect PC select signal. Now, concurrently, we got our instruction.
While we are adding plus 4, we got our instruction from the instruction memory.
One thing that should be kept in mind — propagation delays through the instruction memory and this fixed adder are comparable to each other. Why is that? You may be puzzled with this.
We said early on that getting anything from memory is going to Sacramento. And addition is not — doesn't take us as long as going to Sacramento.
Keep in mind that this is a local copy of a subset of instructions that we brought from the memory such that we have them handy inside the room.
So we can just take a look at them. That's a concept of a cache. That is going to be introduced in the next module. But we don't need to know anything about the cache.
We just need to know that the instructions are handy, they're accessible to us, and the time that it takes us to get them is comparable to the time to add for to the program counter.
So as soon as we get an instruction, we can do multiple things concurrently with different data that we get from that instruction.
We know that addresses of different registers in the register files are always in the fixed locations. So we can go ahead and get data from those locations.
Even if we don't need it, if this instruction is not operating on the registers, it doesn't cost us anything, we can get that data and then toss it later if we don't need it.
But we don't have to wait for the control to proceed with that. Simultaneously, we can generate an immediate. We do need to know what kind of an immediate we want.
So this is going to be gated by the control logic.
But the third thing that we are going to do concurrently is determine which kind of instruction it is and what should be the values of control signals.
So the control logic is, essentially, a number of logic gates, Boolean logic gates, that we've already seen that takes bits from the instruction and determines the control signals based on them.
So in this case, since this is a "store word" instruction, it'll set the PC select value to plus 4.
As soon as it does that, it will let PC plus 4 propagate to the input program counter.
But it is not going to be written into a program counter until we get to the next clock tick. All the other control signals are set simultaneously. Immediate select is select to S type.
Register write enable is a 0 because we are not writing anything back into the register file at the end of a store. We don't care about the branches.
B select is select — set to be picking an immediate. A select is picking the rs1 value.
ALU select is going to do the addition of the offset with the base address. Memory read write signal is going to be set to write. And write back select is a "don't care."
So while we were doing that, we are also busy with getting the data out of the register file and generated the immediate.
It is likely that immediate generation may take a bit longer than getting data from the registers because it is gated by figuring out which kind of an immediate we want.
But it's still comparable. So we'll get approximately about the same time the values of rs1 and rs2 and the immediate, and we can proceed with executing the rest of the instruction.
They're going to propagate through the multiplexers. ALU is going to add the two values. And then we have everything we need to finish the instruction.
Rs1 plus the offset is pointing to the appropriate address in the data memory.
And the operand and the value that we would like to write into it is sitting at data write port of the data memory.
The only thing that we need to finish this instruction is to raise the clock again. So on this clock tick, both the program counter and the data memory get updated.
And we have finish this instruction. And we have actually simultaneously started an execution of the next instruction. Let's take a look at another instruction that we visited early on.
And we are going to do that a little bit faster this time. This is "branch if equal" instruction. So it also starts on the clock tick. Multiple things happen concurrently.
We increment the PC to a value PC plus 4.
But keep in mind that this is not going to be ready for writing into the program counter any time soon because that will be about the last thing that happens in the branch.
The branch does not get completed until we know whether we are taking it or not.
So we are fetching this instruction, but we are also lighting up this spot, showing that we have a program counter value sitting in front of the A multiplexer.
And this happens with every instruction. We just don't take it, don't proceed with this PC value, unless these are branches or jumps.
So concurrently with fetching the register values and generating the immediate, we decode what is this instruction and set the controlled bits.
We can't do anything with the PC select until we know the outcome of the branch. But we can set that immediate is of a branch type. Register write is 0.
We are not writing anything back to the registers. This is an "branch if equal." So sidedness does not matter. "Branch if less than" — we don't care about the outcome of that.
So we are not going to take into the consideration when calculating the control signals. B select is set to 1 to take the PC as the input.
A select is set — B select is taking the 1, which is the value of the immediate.
A select is taking value of 1 to take the program counter. ALU select is set to add the two inputs.
And memory is set to read because we are not writing anything to the memory. And write back select is "I don't care."
So we got everything now. By the time while we are setting that, we can take our operands that we were fetching from the memory. They're ready, and so is the immediate.
And we are ready to proceed. We can figure out what is now the result of a branch comparison. And we got our result whether the values are equal or not.
That allows us to set the PC select to "taken" or "not taken" value. But we cannot complete the instruction until we know where do we go if the branch is taken.
So that — we'll figure that out after the ALU completes its operation, its addition, and presents this new value at the input of the multiplexer.
At that point, we have both of those signals valid. One of them that is set by the PC select propagates into the program counter. And that completes the instruction.
Although the clock ticks everywhere, the only state that gets updated is the value of the program counter. So that is what wraps up the "branch if equal" instruction.
And that is it. We are going to take a look at more detailed timing in the next segment. See you then.
Đăng nhập để đánh giá học liệu này.
Đăng nhập để bình luận — chưa ai bình luận về học liệu này.
Không có khóa học liên quan.