3.3.19.1 Read-After-Write Dependency Rules

If the W register is used as a write operation destination in the current instruction, and the W register being read in the prefetched instruction is the same, the following rules apply.

  • If the destination write (current instruction) does not modify the contents of Wn, no stalls will occur.
  • If the source read (prefetched instruction) does not calculate an EA using Wn, no stalls will occur.

During each instruction cycle, the dsPIC33A hardware automatically checks to see if a RAW data dependency is about to occur. If the conditions specified above are not satisfied, the CPU automatically adds a one-instruction cycle delay before executing the prefetched instruction. The instruction stall provides enough time for the destination W register write to occur before the next (prefetched) instruction that uses the written data. Table 3-9 provides a summary of read-after-write dependency.

Table 3-9. Read-After-Write Dependency Summary
Destination Addressing Mode Using WnSource Addressing Mode Using WnStatusExamples (Wn = W2)

Direct

Direct

Allowed

ADD.w W0, W1, W2 MOV.w W2, W3

Direct

Indirect

Stall

ADD.w W0, W1, W2 MOV.w [W2], W3

Direct

Indirect with Modification

Stall

ADD.w W0, W1, W2 MOV.w [W2++], W3

Indirect

Direct

Allowed

ADD.w W0, W1, [W2] MOV.w W2, W3

Indirect

Indirect

Allowed

ADD.w W0, W1, [W2]

MOV.w [W2], W3

Indirect

Indirect with Modification

Allowed

ADD.w W0, W1, [W2] MOV.w [W2++], W3

Indirect with Modification

Direct

Allowed

ADD.w W0, W1, [W2++] MOV.w W2, W3

Indirect

Indirect

Stall

ADD.w W0, W1, [W2]

MOV.w [W2], W3

; W2=0x0004 (mapped W2)

Indirect

Indirect with Modification

Stall

ADD.w W0, W1, [W2] MOV.w [W2++], W3

; W2=0x0004 (mapped W2)

Indirect with Modification

Indirect

Stall

ADD.w W0, W1, [W2++] MOV.w [W2], W3

Indirect with Modification

Indirect with Modification

Stall

ADD.w W0, W1, [W2++] MOV.w [W2++], W3