Understanding Instruction Cycle?

In summary: For instruction (III) MA stage will fetch data from memory at specified address and will write back into register ##R_3## at WB stage.In summary,A basic instruction cycle consists of these 5 stages. 1. IF - Instruction Fetch2. RD - Instruction Decode and Register Read3. EX - Execute4. MA - Memory Access5. WB - Write Back
  • #1
22990atinesh
143
1
A basic instruction cycle consists of these 5 stages.

1. IF - Instruction Fetch
2. RD - Instruction Decode and Register Read
3. EX - Execute
4. MA - Memory Access
5. WB - Write Back

I understood the meaning of all the stages accept 4th MA (Memory access), what's the significance of this stage.
 
  • Like
Likes Medicol
Technology news on Phys.org
  • #2
Step 4 Memory access - implies memory reads, since step 5 includes write back, which I assume means write back to memory.

Step 2 - register read - this doesn't always happen, at least not at step 2. Take the case of an add immediate to memory / subtract immediate from memory / compare immediate with memory. The memory read needs to occur before the add / subtract / compare can occur.
 
  • Like
Likes Medicol
  • #3
steps 4 and 5 also do not always happen. If, for example, you perform an operation that just changes a register or moves one register's value to another register or stuff like that, there is no need for any memory access beyond the instruction fetch.

SO ... your statement really should say "A basic instruction cycle consists of these 5 POSSIBLE stages."
 
Last edited:
  • Like
Likes Medicol and jim mcnamara
  • #4
Everything starts in memory, even the program instructions. Your example is getting data that the program needs. As @phinds says, the memory access you are referring to may not be necessary for some instructions. Many instructions need to use some data that is stored in memory. When data from memory is needed, it can be quite involved. It may require moving data from the slowest level of memory, to an intermediate speed memory, to the fastest access memory. The processor may have looked ahead and began pulling the data in several cycles early so it would be immediately available in the fastest memory when this instruction is executed.
 
  • Like
Likes Medicol
  • #5
Yeah Surely MA stage wouldn't do anything, if we have to operate operands from registers itself.
Over Internet what I've found is this

MA(Memory Access) does following operation

• If load or store instruction, then access memory
• If branch instruction, replace PC with destination address

##2^{nd}## point is clear, I'm confused with ##1^{st}## point.

Suppose we have load and store instruction like this
##R_1 \leftarrow m[A_1##]
##m[A_2] \rightarrow R_2##
##R_3 \leftarrow m[A_3] + m[A_4]##
what MA stage will do for the above instructions
 
  • #6
I think you have the MA out of order. It should be before EX if it refers to getting the data that EX needs for its operation. Maybe the instruction set you are using does not exactly match up with the conceptual partitioning of your original post, but data must be brought from memory somewhere in your notation.
 
  • #7
22990atinesh said:
what MA stage will do for the above instructions
I think I must be missing something in your question. You seem to be asking "when the instruction requires a memory fetch, what does the memory fetch do?" It fetches from memory.
 
  • #8
phinds said:
I think I must be missing something in your question. You seem to be asking "when the instruction requires a memory fetch, what does the memory fetch do?" It fetches from memory.

Actually The exam I'm preparing for, asks questions on pipe-lining on load and store architecture. So it is irrelevant to mention

##R_3 \leftarrow m[A_3] + m[A_4]##

because a load/store architecture only allows memory to be accessed by load and store operations, and all values for an operation need to be loaded from memory and be present in registers. So a load/store architecture only allows operations like

##(I) R_1 \leftarrow m[A_1]##
##(II) m[A_2] \leftarrow R_2##
##(III) R_3 \leftarrow R_4 + R_5##

Now, I've this following concept in my mind. Please suggest whether I'm right or wrong.

1. For instruction (I) MA stage will fetch data from memory from a particular address and will write back into register ##R_1## at WB stage.
2. For instruction (II) MA stage will store data of register ##R_2## into memory at specified address.
 

Related to Understanding Instruction Cycle?

1. What is the instruction cycle?

The instruction cycle, also known as the fetch-decode-execute cycle, is the basic process by which a computer executes instructions. It involves retrieving instructions from memory, decoding them, and then carrying out the specified operation.

2. How does the instruction cycle work?

The instruction cycle begins with the computer fetching the next instruction from memory. The instruction is then decoded to determine what operation needs to be performed. Finally, the instruction is executed, which may involve accessing or manipulating data in memory or performing a calculation.

3. What is the purpose of the instruction cycle?

The instruction cycle is essential for a computer to execute instructions and perform tasks. It ensures that instructions are retrieved, understood, and carried out in the correct order, allowing the computer to complete tasks and execute programs.

4. What are the different stages of the instruction cycle?

The instruction cycle consists of three stages: fetch, decode, and execute. During the fetch stage, the computer retrieves the next instruction from memory. In the decode stage, the instruction is translated into a form that the computer can understand. And in the execute stage, the specified operation is carried out.

5. How does the instruction cycle impact computer performance?

The instruction cycle plays a crucial role in determining overall computer performance. The faster the computer can retrieve, decode, and execute instructions, the more efficiently it can perform tasks and execute programs. Improvements in the instruction cycle have greatly contributed to the speed and efficiency of modern computers.

Similar threads

  • Programming and Computer Science
Replies
1
Views
3K
  • Sticky
  • Programming and Computer Science
Replies
13
Views
4K
  • Programming and Computer Science
Replies
29
Views
3K
Replies
14
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
  • Programming and Computer Science
Replies
10
Views
3K
  • Science and Math Textbooks
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
25
Views
8K
  • Computing and Technology
Replies
10
Views
2K
Back
Top