Download Embedded Systems Design, Analysis and Optimization using the

Transcript
62
EMBEDDED SYSTEM OPTIMIZATION USING RENESAS RL78 MICROCONTROLLERS
Elapsed time (state)
Internal system clock
Concurrent processing by CPU
Instruction 1
Instruction 2
Instruction 3
Instruction 4
Instruction 5
<1>
<2>
<3>
<4>
<5>
<6>
IF
ID
MEM
IF
ID
MEM
IF
ID
MEM
IF
ID
MEM
IF
ID
<7>
MEM
End of End of End of End of End of
instruc- instruc- instruc- instruc- instruction 1
tion 2
tion 3 tion 4 tion 5
Figure 3.3 RL78 Instruction processing pipeline sequence.
䡲
The MEM (Memory access) stage executes the instruction and accesses the specified memory location.
Many, but not all, RL78 instructions take one cycle to execute once the pipeline is full. The
RL78 Family Users Manual: Software (Renesas Electronics, 2011) presents execution
times for each instruction.
There are various situations in which instructions cannot flow smoothly through the
pipeline due to hazards. The following situations lead to hazards which stall the pipeline:
䡲
䡲
䡲
䡲
Accessing data from flash or external memory (if present) rather than internal
RAM.
Fetching instructions from RAM rather than from internal flash ROM.
Current instruction using memory addressed by register written in previous instruction (e.g., indirect access).
Changing the control flow of the program with instructions such as calls, branches,
and returns. Conditional branches are not resolved until the MEM stage, so the target address is not known until two cycles later. Because instruction fetching proceeds sequentially, branches are essentially predicted to be not taken. As a result,
taken conditional branches take two more cycles than not-taken conditional
branches.