D:
There is an adder (above the letter "D" in your schematic) adding the constant 4 to the PC.
This means that the line "D" will always hold the value PC+4
- even if the current instruction is a jump or branch instruction.
And if an instruction is not a jump or branch instruction, the "D" line is fed back to through the two multiplexers at the top left of your schematic to the input of the PC register.
This means that the next value of PC
will be the old value of PC+4
unless a jump or branch instruction is executed.
By the way:
The CPU in your schematic does not work like a real MIPS CPU (as they were found in WLAN routers 10 years ago).
If I understand the schematic correctly, there are only two instructions that can do a jump/branch: A variant of j
and one of beq
(or beqz
) (both variants not using delay slots).
Using such a CPU you are not able to do subroutine calls (function calls) because there is no instruction "jumping back" to the calling function.
E:
"E" is the output of some multiplexer. If you are not performing a "MemToReg" instruction (I suppose lw
is meant), the "B" signal is fed through the multiplexer.
In other words: If the current instruction is not lw
, "E" and "B" are equal.
If the instruction is lw
, "E" is the value stored in the RAM at address "B".
EDIT
For E, still not sure how to get that outcome though
This would really be a programming and not an electronics question. Let's look at your program:
addi $t0,$zero,0x3ff0
Now t0
contains 0x3FF0
addi $t0,$t0,16
Now t0
contains 0x4000
sw $t0,-8($t0)
The value 0x4000 is written to RAM address 0x3FF8 (Note: 0x4000-8=0x3FF8)
addi $t0,$t0,12
Now t0
contains 0x400C
lw $s2,-20($t0)
A word is read from address 0x3FF8 (Note: 0x400C-20=0x3FF8).
Two instructions above, the value 0x4000 has been written to address 0x3FF8.
For this reason, the value 0x4000 is read from RAM. And therefore the value 0x4000 is fed though the multiplexer to line "E".