Instructions are stored in memory encoded in binary representation. How they are encoded? This is decided by ISA(Instruction Set Architecture) designers. There are five stages which take place when implementing any instruction.
1) Fetch
As we know instructions are stored in memory as the binary number. During Fetch stage, CPU send address using address bus to the memory and get the instruction. Then this instruction is stored in a register. This register is earmarked for storing the instruction and is not accessed by the programmer.
There is another register- Program counter which stores the address of next address of the instruction to be fetched. After fetching the instruction, it is incremented to point to next address.
2) Decode
In this stage, CPU determines the type of instruction to be implemented. It is done by checking some bits of the binary representation of instruction. The instruction can be load/store, arithmetic or branch instruction.
3) Register read
After determining the type of instructions in Decode stage, operands are loaded to dedicated registers. Operands are present in a memory called register file. The size of the register file is determined by ISA of the processor.
4) Execute
The operands in the registers are operated upon at Execute stage. The operation can be the addition, comparison, subtraction, multiplication, division.
5) Write back
The result computed in Executed stage is to be stored in the respective register as dictated by the binary representation of the instruction. If the instruction is of store type then the result computed is stored in data memory.
1) Fetch
As we know instructions are stored in memory as the binary number. During Fetch stage, CPU send address using address bus to the memory and get the instruction. Then this instruction is stored in a register. This register is earmarked for storing the instruction and is not accessed by the programmer.
There is another register- Program counter which stores the address of next address of the instruction to be fetched. After fetching the instruction, it is incremented to point to next address.
2) Decode
In this stage, CPU determines the type of instruction to be implemented. It is done by checking some bits of the binary representation of instruction. The instruction can be load/store, arithmetic or branch instruction.
3) Register read
After determining the type of instructions in Decode stage, operands are loaded to dedicated registers. Operands are present in a memory called register file. The size of the register file is determined by ISA of the processor.
4) Execute
The operands in the registers are operated upon at Execute stage. The operation can be the addition, comparison, subtraction, multiplication, division.
5) Write back
The result computed in Executed stage is to be stored in the respective register as dictated by the binary representation of the instruction. If the instruction is of store type then the result computed is stored in data memory.
No comments:
Post a Comment