Who loads the data of a process into the register bank which is in the data path?

Viewed 49

When a process is in the running state and for example lets say we want to add two numbers therefore the instruction register will have the instruction to add two numbers (Add two registers in the register bank).

My question is who loads the data into the register bank to be added by the ALU?

1 Answers

The hardware is an instruction set interpreter.

You can think of an interpreter written in C as a loop something like this:

unsigned int *PC = START_ADDRESS;
while ( 1 ) {
    unsigned ir = *PC++;
    switch ( ir >> 24 ) {
    ...
    case 0 :
         unsigned regA = (ir & 0x1F0) >> 5;
         unsigned regB = (ir & 0x7E) >> 10;
         unsigned answer = registerFile[regA] + registerFile[regB];
         unsigned regC = (ir & 0x1F00) >> 15;
         registerFile[regC] = answer;
         break;
    ...
    }
}

The hardware is similar except that it can do many things in parallel.

So, the operation of ir = *PC++ is typically considered part of "Instruction Fetch".  The complexity of this varies dramatically, from simple in early MIPS where the instruction size is fixed at 32 bits and pipeline only 5 stages, to very complex on x64 with variable length instructions, long pipelines, intermediate caches of instruction decode (micro ops), and other parallelisms and complexities.

The + operation in answer = registerFile[regA] + registerFile[regB] is part of the ALU operations, and the fetch of operands, as in registerFile[regA] is sometimes referred to as part of "Instruction Decode".

There will be wires that do the register file indexing to fetch the value held in the register and feed them to the ALU.

Because the ALU can source from registers or immediates, there are control signals that allow only the proper source through to the ALU.

Related