Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
97
Добавлен:
01.03.2016
Размер:
921.07 Кб
Скачать

PM0044

Pipelined execution

 

 

5.4.3Pipeline with Call/Jump

In the example shown in Table 10, a branch is taken after the JP/CALL instruction, and the fetched instruction(s) are lost (flush). New instructions must be fetched. 3 fetch sequences are required to refill the pre-fetch buffer. The fetch start depends on the instruction being executed.

For a JP instruction, the fetch can start during the first cycle of the "dummy" execution.

 

 

For the CALL instruction, it starts after the last cycle of the CALL execution.

 

 

 

 

Table 10.

 

Example of pipeline with Call/Jump

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Add.

 

Instruction

Decode

Execute

 

lgth

 

 

 

 

 

 

Cycle

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

cycles

cycles

 

1

2

3

4

5

 

6

 

7

8

9

10

11

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0xC000

 

INC A

1

1

 

1

F1

D

E

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0xC001

 

JP label

1

1

 

3

 

D

E

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0xC004

 

LDW X,[$5432.w]

X

X

 

4

 

F2

Flush

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0xD010

 

label: NEG A

1

1

 

1

 

 

 

F1

D

 

E

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0xD011

 

CALL label2

1

2

 

3

 

 

 

 

 

D

 

E

E

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0xD014

 

LDW X,[$5432.w]

X

X

 

4

 

 

 

 

F2

 

 

 

Flush

 

 

 

 

0xD018

 

LDW X,[$7895.w]

X

X

 

4

 

 

 

 

 

 

F3

 

FS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0xE030

 

label2: INCW X

1

1

 

1

 

 

 

 

 

 

 

 

 

 

F1

D

E

 

 

Table 11. Legend

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Symbol/Color

 

 

 

 

 

 

 

 

Definition

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

F

 

 

 

 

 

 

 

 

 

Fetch

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

FS

 

 

 

 

 

 

 

 

Fetch stalled

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

D

 

 

 

 

 

 

 

 

Decode

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

E

 

 

 

 

 

 

 

 

Execute

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

5.4.4Pipeline stalled

The decode stage can be stalled when the execution lasts more than one cycle.

The flush is due to the branch. Fetching the branch address is performed during the second execution cycle of the BTJF instruction.

The Decode operation can also be stalled when the memory target is modified during the previous instruction. In the example given in Table 12, the INCW Y instruction writes the X

Doc ID 13590 Rev 3

27/162

Pipelined execution

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

PM0044

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

register during the first execution cycle. As a result, in this cycle, the next instruction

 

 

 

(LD A,(X)) cannot be decoded since it reads the X register.

 

 

 

 

 

 

 

 

Table 12.

 

Example of stalled pipeline

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Address

 

Instruction

Decode

 

Execute

lgth

 

 

 

 

 

Time (cycles)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

cycles

 

cycles

1

2

3

4

7

 

8

9

10

11

12

13

14

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0xC000

 

SUB SP, #20

1

 

1

2

 

F1

D

E

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0xC002

 

LD A, #20

1

 

1

2

 

 

D

E

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0xC004

BTJT 0x10, #5, to

1

 

2

5

 

 

F2

 

D

E

 

E

 

 

 

 

 

 

0xC009

 

INC A

1

 

1

1

 

 

 

F3

 

D

 

D

E

 

 

 

 

 

0xC00A

BTJF 0x20, #3, to

1

 

2

5

 

 

 

 

F1

 

 

 

D

E

E

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0xC00F

 

NOP

X

 

X

1

 

 

 

 

 

 

 

 

Flush

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0xC010

LDW X,[$5432.w]

X

 

X

4

 

 

 

 

 

F2

 

 

 

 

 

 

0xC014

LDW X,[$1234.w]

X

 

X

4

 

 

 

 

 

 

 

F3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0xD020

 

to: INCW Y

1

 

1

2

 

 

 

 

 

 

 

 

 

 

F1

D

E

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0xD023

 

LD A,(X)

1

 

1

2

 

 

 

 

 

 

 

 

 

 

D

D

E

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Table 13. Legend

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Symbol/Color

 

 

 

 

 

 

 

 

Definition

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

F

 

 

 

 

 

 

 

 

 

Fetch

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

D

 

 

 

 

 

 

 

Decode stalled

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

D

 

 

 

 

 

 

 

 

 

Decode

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

E

 

 

 

 

 

 

 

 

 

Execute

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

28/162

Doc ID 13590 Rev 3

Соседние файлы в папке Минимум документации STM8