엔지니어가 되고 싶은 공돌이

12. Pipelining 본문

Computer Science/Computer Architecture

12. Pipelining

Geca 2025. 5. 5. 17:03

 

12. 1. Pipelining

 

- Pipelining: 여러 명령어를 중첩시켜 실행시켜서, 총 명령어 수행시간을 줄이는 방법.

 

- Pipelining의 속도 향상은 Pipelining의 단계 수 와 같습니다.

 

  Execution Time of Instructions 을 줄이는게 아닌, Instructions Throughput 을 높이는 방법.

 


 

12. 2. MIPS Instructions 5단계

 

1) IF(Instruction Fetch): Instruction Memory에서 Instruction을 읽습니다.

 

2) ID(Instruction Decode): Instruction을 해석하는 동시에, Register를 Register File에서 읽습니다.

 

3) EX(Execution): Operations을 수행하거나 Address를 계산합니다.

 

4) MEM(Memory): Data Memory에 접근합니다.

 

5) WB(Write Back): Result를 Register File에 씁니다.

 

 

[Pipelining을 위한 설계]

 

1) MIPS Instruction은 같은 길이를 갖습니다.

 

2) Instruction은 몇 가지 안되는 Instruction Type을 가지고 있고,

 

    Data Memory에 접근할 때는 lw, sw만 사용합니다.

 


 

12. 3. Pipelining Hazard

 

Next Instruction이 Next Clock Cycle에 실행될 수 없는 상황.

 

1) Structural Hazard: 하나의 Memory에 2개 이상의 명령어가 동시에 접근하는 등 Hardware가 지원할 수 없는 상황.

 

- MIPS Instruction Set은 Pipelining을 목적으로 설계되서, Structural Hazard를 피하는 것이 비교적 용이합니다.

 

- Stall 시키거나, Hardware를 추가해서 해결합니다.

 

 

2) Data Hazard: 어떤 단계가 다른 단계가 끝나기를 기다려야 하는 상황.

 

- 별도의 Hardware를 추가하여 미리 값을 받는 Forwarding(전방전달)으로 해결할 수 있습니다.

 

 

 

- Forwarding을 한다고 해서 Data Hazard를 피할 수 있는 것은 아닙니다.

 

- 만약 연속해서 명령어 수행이 불가능하다면 Pipeline Stall(파이프라인 지연)을 발생시킵니다.

 

    Pipeline Stall을 Bubble이라고도 부릅니다.

 

 

3) Control Hazard: beq or J Instruction 등 Branch Instruction을 통해 명령어를 건너뛰어버려,

 

    PC값이 변해버리고, 중간에 있는 명령어를 실행하지 않는 상황.

 

  - 해결을 위해 Stall 시키거나, Branch Prediction을 수행합니다.


'Computer Science > Computer Architecture' 카테고리의 다른 글

14. Data Hazard  (0) 2025.05.05
13. Pipelining Datapath  (0) 2025.05.05
11. Datapath Including Controls  (0) 2025.05.05
10. Datapath  (0) 2025.04.29
09. Floating Point Number  (0) 2025.04.29
Comments