Hello everyone,
I am currently working on a cortex-M0 microprocessor(LPC1114). I have looked through all the possible instruction descriptions but I did not find anyone of them explaining why some instructions takes two cycle to execute.
For example, ANDS, MOVS takes only one cycle to execute. but why do we need two cycles to execute LDR? and STR?
Because those need the external bus. All other instructions use just registers (== internal "bus").
Thanks so much for your answer.
So there will be a pipeline stall for LDR and STR to allow the bus to fetch the data?
For example, assume I have a LDR PC-relative instruction as LDR R4, =(#0xFEDCBA98);
Assume at cycle 0, this instruction is fetched with another instruction (assume it as NOP),
At cycle 1, the LDR pc-relative instruction is decoded
at cycle 2, the ldr pc-relative instruction is executed and also the final address of the data is calculated as PC+ offset here
at cycle 3, the processor has a pipeline stall stage to let the bus write back the value to R4 register.
The above picture is a timing diagram,
Assume FEDCBA98 is stored at address 0x074. cycle 2 is the execution cycle of LDR R4 =(0xFEDCBA98) instruction. Thus, PC+offset is ready at time t2 (some delay after clock edge 1). Then, data will be available on the bus at time t2, and write back to the register at clock edge 3.
Cycle 3 is the pipeline stall stage.
Please correct me if I am wrong.
Thanks so much!
Sorry, I have no idea about pipeline etc.
View all questions in Cortex-M / M-Profile forum