2

enter image description here

This is an abstract view of the implementation of the MIPS subset showing the major functional units and the major connections between them

Why we need to add the result of (PC+4) with instruction address?

I know that the PC (Program Counter) is a register in a computer processor that contains the address (location) of the instruction being executed at the current time, but i didn't understand why we add the second adder in this picture?

Reem Aljunaid
  • 109
  • 1
  • 9

2 Answers2

4

Some of the operations that can be performed by the CPU are 'jumps'. If your operation is a Jump, from the second block you get the address of the new instructions OR the lenght of the jump you have to do.

a.ndrea
  • 536
  • 2
  • 5
  • 19
  • a.ndrea ok you gave me a clear explanation, but i have another question if the instruction is not jump, why need to add the address of the new instructions or what will be the address of the new instructions? – Reem Aljunaid Nov 20 '15 at 16:34
  • If the instructions is not a jump, the address of the new instruction will simply be `actual_instruction_address + 4`, and the second adder would get a 0 as the second input – a.ndrea Nov 20 '15 at 17:12
  • a.ndrea last question ^_^" , in branch addressing target = PC+ offset *4 and the PC here already incremented by 4 .. so the instruction that comes from instruction memory should be offset *4 .. but they didn't show this details .. am i right? – Reem Aljunaid Nov 20 '15 at 18:39
0

It's not the instruction address, the output of the instruction memory is an instruction itself.

They've obviously hidden most of the components (there's NO control circuitry). What they probably meant is the data path for branches, though they really should have put at least the link with the ALU output in there. Even so it would be better to explicitly decode the instruction, sign extend and shift left. So it's really inaccurate, but I don't see what else they could mean.

harold
  • 61,398
  • 6
  • 86
  • 164
  • harold, yes they must add 3 multiplexers and control circuitry to make it accurate, i understand from you that the second adder adds the instruction itself and (PC+4), but why we need to do that? – Reem Aljunaid Nov 20 '15 at 16:24
  • @ReemAljunaid well hopefully only part of the instruction, but they pretty much left the instruction decoding implicit.. but this is necessary to implement branches, which have the offset as the last 16 bits – harold Nov 20 '15 at 16:28