본문 바로가기
Computer Science/Computer Architecture

4. Single Cycle, Multi Cycle, Pipeline

by Gofo 2021. 5. 23.

Performance

Delay는 무시하고, 각 access time이 다음과 같다고 해보자.

  • Memory access : 200ps
    • Instruction fetch, lw, sw
    • 실제 memory access에 걸리는 시간은 훨씬 더 오래걸리지만, 속도를 높이기 위해서 cache memory를 사용한다.
  • ALU and Adders : 200ps
  • Register file access : 100ps
    • register는 32개 밖에 없기 때문에 memory access 보다 속도가 훨씬 빠르다.
    • 절반의 속도를 가지는 것은 의도된 현상이다.

 

각 instruction 실행에 걸리는 시간은 다음과 같이 된다.

이 중 가장 긴 것(critical path)을 기준으로 하나의 clock(cct)를 결정한다.

 

CPU Performance

Critical path는 load instruction(lw)이다.

실제로는 mult나 FP operation 들이 더 길지만 이들은 너무 길기 때문에 single cycle에 작동하지 않는다.

만약 이들을 single cycle에 돌리면 다른 instruction들의 실행시간이 전부 길어지게 된다.

더군다나 이런 instruction들은 자주 나오지도 않기 때문에 전체적인 성능이 저하되는 결과를 낳는다.

그렇기에 multi-cycle instruction으로 한다.

 

따라서 Single cycle instruction이기 때문에 CPI는 1이 되고, cct는 800ps가 된다.

 


MIPS Pipeline

Single cycle vs. Multi-cycle

하나의 cycle에 돌리지 않고 cct를 작게 지정해서 multi cycle에 instruction을 돌린다면

  • CPI는 증가하지만,
  • clock cycle은 감소한다.
  • 따라서 전체적인 성능은 향상된다.

 

좌 : single cycle / 우 : multi-cycle

 

MIPS Multicycle

MIPS는 5개의 stage로 나눠서 한 stage가 하나의 clock에 수행되도록 한다.

  1. IF : instruction fetch
  2. ID : instruction decode, register read
  3. EX : execute operation or calculate address
  4. MEM : memory access
  5. WB : write result back to register

 

Pipeline

단순히 multicycle로 구성하면 각 단계 사이에 노는 시간이 발생한다.

따라서 이를 없애고 여러 instruction들의 실행을 overlap한다.

즉, 매 cycle마다 instruction 하나가 실행완료되도록 해서 CPI를 줄이고, 성능을 향상시킬 수 있다.

 

여러 instruction들을 동시에 실행시킨다는 의미에서 instruction-level parallelism이라고도 한다.

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

4. Pipeline Hazards  (0) 2021.05.30
4. Pipelining  (0) 2021.05.23
4. Single Cycle Design  (0) 2021.05.16
4. Single Cycle Datapath and Control Design  (0) 2021.05.16
3. MIPS ISA  (0) 2021.05.16

댓글