Home ๐Ÿ–ฅ๏ธ [Computer Architecture] Instruction ๐Ÿ–ฅ๏ธ
Post
Cancel

๐Ÿ–ฅ๏ธ [Computer Architecture] Instruction ๐Ÿ–ฅ๏ธ

์ปดํ“จํ„ฐ๊ฐ€ ์ดํ•ดํ•˜๋Š” 0๊ณผ 1๋กœ๋œ ์ •๋ณด์—๋Š” ๋ฐ์ดํ„ฐ(Data)์™€ ๋ช…๋ น์–ด(Instruction)์ด ์žˆ์Šต๋‹ˆ๋‹ค. ํ•ด๋‹น ํฌ์ŠคํŠธ์—์„œ๋Š” ๋ช…๋ น์–ด์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

๐Ÿ–ฅ๏ธ Programming Language

  • Low-Level Programming Language
    • ๊ธฐ๊ณ„์–ด(Machine Code): 0๊ณผ 1๋กœ ์ด๋ฃจ์–ด์ง„ ๋ช…๋ น์–ด ์ง‘ํ•ฉ
    • ์–ด์…ˆ๋ธ”๋ฆฌ์–ด(Assembly Language): ๊ธฐ๊ณ„์–ด๋ฅผ ์ฝ๊ธฐ ํŽธํ•œ ์ƒํƒœ๋กœ ๋ฒˆ์—ญํ•œ ์–ธ์–ด
  • High-Level Programming Language
    • High-Level Programming Language โžœ Assembly Language โžœ Machine Code๋กœ ๋ณ€ํ™˜๋˜์–ด์•ผ ํ•จ
    • Compiled Language: Compiler๊ฐ€ Source Code ์ „์ฒด๋ฅผ ๋ณด๋ฉฐ ์˜ค๋ฅ˜๋ฅผ ํ™•์ธํ•˜๊ณ  ๊ธฐ๊ณ„์–ด๋กœ ๋ณ€ํ™˜๋œ ๊ฒฐ๊ณผ์ธ Object Code๋ฅผ ์–ป์Œ
    • Interpreter Language: Interpreter๊ฐ€ Source Code๋ฅผ ํ•œ ์ค„์”ฉ ๊ธฐ๊ณ„์–ด๋กœ ๋ณ€ํ™˜ํ•˜๊ณ  ์‹คํ–‰

๐Ÿ–ฅ๏ธ ๋ช…๋ น์–ด ๊ตฌ์กฐ

๋ช…๋ น์–ด๋Š” Opcode(Operation Code)์™€ Operand๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ–ฅ๏ธ Opcode

Opcode๋Š” ๋ช…๋ น์–ด์—์„œ ๋ช…๋ น ์ฆ‰, ์ˆ˜ํ–‰ํ•  ์—ฐ์‚ฐ์ด ๋ฌด์—‡์ธ์ง€๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋ถ€๋ถ„์ž…๋‹ˆ๋‹ค. Opcode์˜ ์ข…๋ฅ˜์™€ ์ƒ๊น€์ƒˆ๋Š” CPU(Central Processing Unit; ์ค‘์•™์ฒ˜๋ฆฌ์žฅ์น˜)๋งˆ๋‹ค ๋‹ค๋ฅด์ง€๋งŒ ํฌ๊ฒŒ ๋ถ„๋ฅ˜ํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

  • ๋ฐ์ดํ„ฐ ์ „์†ก
  • ์‚ฐ์ˆ  / ๋…ผ๋ฆฌ ์—ฐ์‚ฐ
  • ์ œ์–ด ํ๋ฆ„ ๋ณ€๊ฒฝ
  • ์ž…์ถœ๋ ฅ ์ œ์–ด

๐Ÿ–ฅ๏ธ Operand

Operand๋Š” ์—ฐ์‚ฐ์— ์‚ฌ์šฉํ•  ๋ฐ์ดํ„ฐ ๋˜๋Š” ์ฃผ์†Œ(Address)๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋ถ€๋ถ„์ž…๋‹ˆ๋‹ค. Opcode์— ๋”ฐ๋ผ ํ•„์š”ํ•œ Operand์˜ ์ˆ˜๊ฐ€ ๋‹ฌ๋ผ์งˆ ์ˆ˜ ์žˆ๋Š”๋ฐ ๋‹ฌ๋ผ์ง€๋Š” Operand์˜ ๊ฐœ์ˆ˜์— ๋”ฐ๋ผ ๋ช…๋ น์–ด๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋‚˜๋ˆ„์–ด ๋ถ€๋ฆ…๋‹ˆ๋‹ค.

InstructionOperand ๊ฐœ์ˆ˜
$0$-Address Instruction$0$๊ฐœ
$1$-Address Instruction$1$๊ฐœ
$2$-Address Instruction$2$๊ฐœ
$3$-Address Instruction$3$๊ฐœ

๐Ÿ–ฅ๏ธ ์ฃผ์†Œ ์ง€์ • ๋ฐฉ์‹

Operand์—๋Š” ์ฃผ๋กœ ์œ ํšจ ์ฃผ์†Œ(Effective Address)๋ฅผ ๋ช…์‹œํ•˜๋ฉฐ ์ฃผ์†Œ ์ง€์ • ๋ฐฉ์‹์ด๋ž€ ์œ ํšจ ์ฃผ์†Œ(Effective Address)๋ฅผ ์ฐพ๋Š” ๋ฐฉ๋ฒ•์„ ๋งํ•ฉ๋‹ˆ๋‹ค.

์œ ํšจ ์ฃผ์†Œ(Effective Address): ์—ฐ์‚ฐ์˜ ๋Œ€์ƒ์ด ๋˜๋Š” ๋ฐ์ดํ„ฐ๊ฐ€ ์ €์žฅ๋œ ์œ„์น˜(Ex. Memory Address, Register Address)

Operand์— ๋ฐ์ดํ„ฐ ๋Œ€์‹  ์ฃผ์†Œ๋ฅผ ํฌํ•จ์‹œํ‚ค๋Š” ์ด์œ ๊ฐ€ ๋ฌด์—‡์ธ๊ฐ€์š”?

  • ๋ช…๋ น์–ด์˜ ๊ณ ์ •๋œ ๊ธธ์ด ๋•Œ๋ฌธ์— ๋‹ค์–‘ํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ํ‘œํ˜„ํ•˜๊ธฐ ์ œํ•œ๋˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

์ฃผ์†Œ ์ง€์ • ๋ฐฉ์‹์˜ ์ข…๋ฅ˜๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

Addressing ModeOperand
์ฆ‰์‹œ ์ฃผ์†Œ ์ง€์ • ๋ฐฉ์‹(Immediate Addressing Mode)์—ฐ์‚ฐ์˜ ๋Œ€์ƒ์ด ๋˜๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ์ง์ ‘ ๋ช…์‹œ
์ง์ ‘ ์ฃผ์†Œ ์ง€์ • ๋ฐฉ์‹(Direct Addressing Mode)์œ ํšจ ์ฃผ์†Œ(Memory Address)๋ฅผ ์ง์ ‘ ๋ช…์‹œ
๊ฐ„์ ‘ ์ฃผ์†Œ ์ง€์ • ๋ฐฉ์‹(Indirect Addressing Mode)์œ ํšจ ์ฃผ์†Œ(Memory Address)๋ฅผ ์ €์žฅํ•œ ๋ฉ”๋ชจ๋ฆฌ ์ฃผ์†Œ๋ฅผ ๋ช…์‹œ
๋ ˆ์ง€์Šคํ„ฐ ์ฃผ์†Œ ์ง€์ • ๋ฐฉ์‹(Register Addressing Mode)์œ ํšจ ์ฃผ์†Œ(Register Address)๋ฅผ ์ง์ ‘ ๋ช…์‹œ
๋ ˆ์ง€์Šคํ„ฐ ๊ฐ„์ ‘ ์ฃผ์†Œ ์ง€์ • ๋ฐฉ์‹(Register Indirect Addressing Mode)์œ ํšจ ์ฃผ์†Œ(Memory Address)๋ฅผ ์ €์žฅํ•œ ๋ ˆ์ง€์Šคํ„ฐ ์ฃผ์†Œ๋ฅผ ๋ช…์‹œ
์Šคํƒ ์ฃผ์†Œ ์ง€์ • ๋ฐฉ์‹(Stack Addressing Mode)Operand ์—†์ด Opcode๋ฅผ ํ†ตํ•ด ์Šคํƒ ์ฃผ์†Œ ์ง€์ • ๋ฐฉ์‹์ž„์„ ์•Œ์•„๋‚ด๊ณ  Stack Pointer(Register)๋ฅผ ์‚ฌ์šฉํ•ด ์œ ํšจ ์ฃผ์†Œ(Memory Address)๋ฅผ ์•Œ์•„๋ƒ„
๋ณ€์œ„ ์ฃผ์†Œ ์ง€์ • ๋ฐฉ์‹(Displacement Addressing Mode)Operand์™€ ํŠน์ • ๋ ˆ์ง€์Šคํ„ฐ์˜ ๊ฐ’์„ ๋”ํ•˜์—ฌ ์œ ํšจ ์ฃผ์†Œ๋ฅผ ์–ป๋Š” ๋ฐฉ๋ฒ•(Ex. Relative, Base-Register Addressing Mode)
์ƒ๋Œ€ ์ฃผ์†Œ ์ง€์ • ๋ฐฉ์‹(Relative Addressing Mode)Operand์™€ PC(Program Counter)์˜ ๊ฐ’์„ ๋”ํ•˜์—ฌ ์œ ํšจ ์ฃผ์†Œ๋ฅผ ์–ป๋Š” ๋ฐฉ๋ฒ•(Ex. if๋ฌธ๊ณผ ๊ฐ™์ด ๋ถ„๊ธฐํ•˜๋Š” ๊ฒฝ์šฐ)
๋ฒ ์ด์Šค ๋ ˆ์ง€์Šคํ„ฐ ์ฃผ์†Œ ์ง€์ • ๋ฐฉ์‹(Base-Register Addressing Mode)Operand์™€ Base Register์˜ ๊ฐ’์„ ๋”ํ•˜์—ฌ ์œ ํšจ ์ฃผ์†Œ๋ฅผ ์–ป๋Š” ๋ฐฉ๋ฒ•

๐Ÿ–ฅ๏ธ Instruction Cycle

Instruction Cycle์ด๋ž€ ํ•˜๋‚˜์˜ ๋ช…๋ น์–ด๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ์ •ํ˜•ํ™”๋œ ํ๋ฆ„์„ ๋งํ•ฉ๋‹ˆ๋‹ค.

  • Fetch Cycle: ๋ฉ”๋ชจ๋ฆฌ์— ์žˆ๋Š” ๋ช…๋ น์–ด๋ฅผ CPU๋กœ ๊ฐ€์ง€๊ณ  ์˜ค๋Š” ๋‹จ๊ณ„
    1. PC(Program Counter)์— ๋‹ค์Œ ๋ช…๋ น์–ด์˜ ๋ฉ”๋ชจ๋ฆฌ ์ฃผ์†Œ๋ฅผ ์ €์žฅ
    2. PC์— ์ €์žฅ๋˜์—ˆ๋˜ ๋ฉ”๋ชจ๋ฆฌ ์ฃผ์†Œ๋ฅผ MAR(Memory Address Register)๋กœ ์ด๋™
    3. MAR์— ์ €์žฅ๋œ ๋ฉ”๋ชจ๋ฆฌ ์ฃผ์†Œ์™€ ์ œ์–ด ์‹ ํ˜ธ๋ฅผ ํ†ตํ•ด ํ•ด๋‹น ๋ฉ”๋ชจ๋ฆฌ ์ฃผ์†Œ์— ์ €์žฅ๋˜์–ด์žˆ๋˜ ๋ช…๋ น์–ด๋ฅผ ๊ฐ€์ ธ์™€ MBR(Memory Buffer Register)์— ์ €์žฅ
    4. PC๊ฐ€ ์ฆ๊ฐ€ํ•˜์—ฌ ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์ฝ์–ด๋“ค์ผ ์ค€๋น„
    5. MBR์— ์ €์žฅ๋œ ๋ช…๋ น์–ด๋ฅผ IR(Instruction Register)๋กœ ์ด๋™
  • Execution Cycle: ์ œ์–ด ์žฅ์น˜(Control Unit)๊ฐ€ IR์— ๋‹ด๊ธด ๊ฐ’์„ ํ•ด์„ํ•˜๊ณ , ์ œ์–ด ์‹ ํ˜ธ๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๋Š” ๋‹จ๊ณ„
  • Indirect Cycle: ์ถ”๊ฐ€์ ์œผ๋กœ ๋ฉ”๋ชจ๋ฆฌ์— ์ ‘๊ทผ์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ(Ex. ๊ฐ„์ ‘ ์ฃผ์†Œ ์ง€์ • ๋ฐฉ์‹(Indirect Addressing Mode))
  • Interrupt Cycle: CPU๋Š” Execution Cycle์ด ๋๋‚œ ํ›„ ๋ช…๋ น์–ด๋ฅผ Fetch ํ•˜๊ธฐ ์ „ ํ•ญ์ƒ Interrupt ์—ฌ๋ถ€๋ฅผ ํ™•์ธํ•˜๊ณ  Interrupt๊ฐ€ ๋ฐœ์ƒํ•œ ๊ฒฝ์šฐ ์‹คํ–‰ํ•˜๋Š” ๋‹จ๊ณ„

๐Ÿ–ฅ๏ธ Interrupt

Interrupt๋ž€ CPU์˜ ์ž‘์—…์„ ๋ฐฉํ•ดํ•˜๋Š” ์‹ ํ˜ธ๋ฅผ ๋งํ•˜๋ฉฐ Interrupt ์ข…๋ฅ˜๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

๐Ÿ–ฅ๏ธ Exception(Synchronous Interrupt)

Exception์€ CPU์— ์˜ํ•ด์„œ ๋ฐœ์ƒํ•˜๋Š” Interrupt๋กœ Exception์ด ๋ฐœ์ƒํ•˜๋ฉด CPU๋Š” ํ•˜๋˜ ์ผ์„ ์ค‘๋‹จํ•˜๊ณ  ํ•ด๋‹น Exception์„ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

ExceptionDefinitionExample
FaultException์„ ์ฒ˜๋ฆฌํ•œ ์งํ›„ Exception์ด ๋ฐœ์ƒํ•œ ๋ช…๋ น์–ด๋ถ€ํ„ฐ ์‹คํ–‰์„ ์žฌ๊ฐœํ•˜๋Š” Exception๋ฐ์ดํ„ฐ๊ฐ€ ๋ฉ”์ธ ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ์•„๋‹Œ ๋ณด์กฐ๊ธฐ์–ต์žฅ์น˜์— ์žˆ๋Š” ๊ฒฝ์šฐ Fault๋ฅผ ๋ฐœ์ƒ์‹œํ‚ด
TrapException์„ ์ฒ˜๋ฆฌํ•œ ์งํ›„ Exception์ด ๋ฐœ์ƒํ•œ ๋‹ค์Œ ๋ช…๋ น์–ด๋ถ€ํ„ฐ ์‹คํ–‰์„ ์žฌ๊ฐœํ•˜๋Š” ExceptionDebugging
AbortCPU๊ฐ€ ์‹คํ–‰์ค‘์ธ ํ”„๋กœ๊ทธ๋žจ์„ ๊ฐ•์ œ๋กœ ์ค‘๋‹จ์‹œํ‚ฌ ์ˆ˜ ๋ฐ–์— ์—†๋Š” ์‹ฌ๊ฐํ•œ ์˜ค๋ฅ˜๋ฅผ ๋ฐœ๊ฒฌํ–ˆ์„ ๋•Œ ๋ฐœ์ƒํ•˜๋Š” Exceptionย 
Software InterruptSystem call์ด ๋ฐœ์ƒํ–ˆ์„ ๋•Œ ๋ฐœ์ƒํ•˜๋Š” Exceptionย 

๐Ÿ–ฅ๏ธ Hardware Interrupt(Asynchronous Interrupt)

Hardware Interrupt๋Š” ์ฃผ๋กœ I/O Device์— ์˜ํ•ด์„œ ๋ฐœ์ƒํ•˜๋Š” Interrupt์ž…๋‹ˆ๋‹ค.

  • Non-Maskable Interrupt: Hardware ๊ณ ์žฅ์œผ๋กœ ์ธํ•œ Interrupt์™€ ๊ฐ™์ด ๋ฐ˜๋“œ์‹œ ๋จผ์ € ์ฒ˜๋ฆฌํ•ด์•ผ ํ•˜๋Š” Interrupt
  • Maskable Interrupt: Interrupt Flag๋กœ ๋ง‰์„ ์ˆ˜ ์žˆ๋Š” Interrupt
    1. I/O Device์—์„œ CPU๋กœ Interrupt ์š”์ฒญ ์‹ ํ˜ธ ์ „๋‹ฌ
    2. CPU๋Š” Interrupt ์š”์ฒญ ์‹ ํ˜ธ๋ฅผ ํ™•์ธํ•˜๊ณ  Interrupt Flag๋ฅผ ํ†ตํ•ด ํ˜„์žฌ Interrupt ์—ฌ๋ถ€๋ฅผ ํ™•์ธ
    3. Interrupt๋ฅผ ๋ฐ›์•„๋“ค์ผ ์ˆ˜ ์žˆ๋‹ค๋ฉด CPU๋Š” ์ง€๊ธˆ๊นŒ์ง€์˜ ์ž‘์—…์„ Stack Area์— ๋ฐฑ์—…
    4. CPU๋Š” Interrupt Vector๋ฅผ ์ฐธ์กฐํ•˜์—ฌ Interrupt Service Routine์„ ์‹คํ–‰
    5. Interrupt Service Routine์ด ๋๋‚˜๋ฉด ๋ฐฑ์—…ํ•ด ๋‘” ์ž‘์—…์„ ๋ณต๊ตฌํ•˜์—ฌ ์‹คํ–‰์„ ์žฌ๊ฐœ
  • Interrupt Service Routine(Interrupt Handler): Interrupt๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ ํ”„๋กœ๊ทธ๋žจ
  • Interrupt Service Routine(Interrupt Handler): Interrupt Service Routine๊ฐ€ ์ €์žฅ๋œ ๋ฉ”๋ชจ๋ฆฌ์˜ ์‹œ์ž‘ ์ฃผ์†Œ

๐Ÿ–ฅ๏ธ ๋ช…๋ น์–ด ๋ณ‘๋ ฌ ์ฒ˜๋ฆฌ ๊ธฐ๋ฒ•(ILP)

๋ช…๋ น์–ด ๋ณ‘๋ ฌ ์ฒ˜๋ฆฌ ๊ธฐ๋ฒ•(ILP; Instruction-Level Parallelism)์ด๋ž€ ๋ช…๋ น์–ด๋ฅผ ๋™์‹œ์— ํšจ์œจ์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•˜๋Š” ๊ธฐ๋ฒ•์„ ๋งํ•ฉ๋‹ˆ๋‹ค.

๋ช…๋ น์–ด ๋ณ‘๋ ฌ ์ฒ˜๋ฆฌ ๊ธฐ๋ฒ•์„ ์•Œ์•„๋ณด๊ธฐ์— ์•ž์„œ Instruction Cycle์„ Clock ๋‹จ์œ„๋กœ ๋‚˜๋ˆˆ Instruction Pipeline์„ ์‚ดํŽด๋ณด๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

  1. ๋ช…๋ น์–ด ์ธ์ถœ(Instruction Fetch)
  2. ๋ช…๋ น์–ด ํ•ด์„(Instruction Decode)
  3. ๋ช…๋ น์–ด ์‹คํ–‰(Execute Instruction)
  4. ๊ฒฐ๊ณผ ์ €์žฅ(Write Back)

์œ„์™€ ๊ฐ™์ด 4๋‹จ๊ณ„๊ฐ€ ์•„๋‹Œ 2๋‹จ๊ณ„ ํ˜น์€ 5๋‹จ๊ณ„๋กœ ๋‚˜๋ˆ„๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ–ฅ๏ธ Instruction Pipelining

Instruction Pipelining์ด๋ž€ ์œ„์˜ ๊ทธ๋ฆผ์ฒ˜๋Ÿผ ๋™์‹œ์— ์—ฌ๋Ÿฌ ๊ฐœ์˜ ๋ช…๋ น์–ด๋ฅผ ๊ฒน์ณ์„œ ์‹คํ–‰ํ•˜๋Š” ๊ธฐ๋ฒ•์ž…๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ Instruction Piepelining์€ ์„ฑ๋Šฅ ํ–ฅ์ƒ์„ ๊ฐ€์ ธ์˜ค์ง€๋งŒ Pipeline Hazzard๊ฐ€ ๋ฐœ์ƒํ•œ ๊ฒฝ์šฐ ์„ฑ๋Šฅ ํ–ฅ์ƒ์„ ํ•˜์ง€ ๋ชปํ•ฉ๋‹ˆ๋‹ค.

Pipeline Hazzard์—๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ฒƒ๋“ค์ด ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

  • Data Hazzard: ๋ช…๋ น์–ด๋“ค ์‚ฌ์ด์— Data Dependecy๊ฐ€ ๋ฐœ์ƒํ•œ ๊ฒฝ์šฐ(Ex. a = 1 โžœ b = a + 1)
  • Control Hazzard: PC๊ฐ€ ์ˆœ์ฐจ์ ์œผ๋กœ ์ฆ๊ฐ€ํ•˜์ง€ ์•Š๊ณ  ๊ฐ‘์ž๊ธฐ ๋ณ€ํ•˜๋Š” ๊ฒฝ์šฐ(Ex. if๋ฌธ๊ณผ ๊ฐ™์€ ๋ถ„๊ธฐ)
  • Structural Hazzard(Resource Hazzard): ์„œ๋กœ ๋‹ค๋ฅธ ๋ช…๋ น์–ด๋“ค์ด ๋™์‹œ์— ๊ฐ™์€ CPU Resource(Ex. ALU, Register)๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ

๐Ÿ–ฅ๏ธ Superscalar

Superscalar๋ž€ ์œ„์˜ ๊ทธ๋ฆผ์ฒ˜๋Ÿผ ์—ฌ๋Ÿฌ ๊ฐœ์˜ Instruction Pipeline์„ ๋‘๋Š” ๊ธฐ๋ฒ•์ด๋ฉฐ Superscalar ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•œ CPU๋ฅผ Superscalar Processor(Superscalar CPU)๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

Superscalar๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๊ฐ™์€ Clock์—์„œ ๋™์‹œ์— Fetch๊ฐ€ ๊ฐ€๋Šฅํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ด๋ก ์ ์œผ๋กœ๋Š” Instruction Pipeline์˜ ๊ฐœ์ˆ˜์— ๋น„๋ก€ํ•˜์—ฌ ์ฒ˜๋ฆฌ ์†๋„๊ฐ€ ์ฆ๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ Pipeline Hazzard๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์‹ค์ œ๋กœ๋Š” Instruction Pipeline์˜ ๊ฐœ์ˆ˜์— ๋น„๋ก€ํ•˜์—ฌ ์ฒ˜๋ฆฌ ์†๋„๊ฐ€ ์ฆ๊ฐ€ํ•˜์ง€๋Š” ์•Š์Šต๋‹ˆ๋‹ค.

๐Ÿ–ฅ๏ธ OoOE(Out-of-Order Execution)

OoOE(Out-of-Order Execution; ๋น„์ˆœ์ฐจ์  ๋ช…๋ น์–ด ์ฒ˜๋ฆฌ)๋ž€ Instruction Pipeline์˜ ์ค‘๋‹จ์„ ๋ฐฉ์ง€ํ•˜๊ณ ์ž ๋ช…๋ น์–ด๋ฅผ ์ˆœ์ฐจ์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•˜์ง€ ์•Š๋Š” ๊ธฐ๋ฒ•์ž…๋‹ˆ๋‹ค.

OoOE๋Š” ์˜ค๋Š˜๋‚  CPU ์„ฑ๋Šฅ ํ–ฅ์ƒ์— ํฌ๊ฒŒ ๊ธฐ์—ฌํ•œ ๊ธฐ๋ฒ•์ด์ž ๋Œ€๋ถ€๋ถ„์˜ CPU๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ๊ธฐ๋ฒ•์ž…๋‹ˆ๋‹ค.

๐Ÿ–ฅ๏ธ ๋ช…๋ น์–ด ์ง‘ํ•ฉ ๊ตฌ์กฐ(ISA)

ISA(Instruction Set Architecture; ๋ช…๋ น์–ด ์ง‘ํ•ฉ ๊ตฌ์กฐ)๋ž€ CPU๊ฐ€ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋Š” ๋ช…๋ น์–ด์˜ ๋ชจ์Œ์ž…๋‹ˆ๋‹ค.

๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— CPU๋งˆ๋‹ค ISA๊ฐ€ ๋‹ฌ๋ผ์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋Œ€ํ‘œ์ ์œผ๋กœ ISA๊ฐ€ ๋‹ฌ๋ผ์ง€๋ฉด ๋ช…๋ น์–ด์˜ ํ˜•ํƒœ, ์ œ์–ด์žฅ์น˜๊ฐ€ ๋ช…๋ น์–ด๋ฅผ ํ•ด์„ํ•˜๋Š” ๋ฐฉ์‹, ์‚ฌ์šฉ๋˜๋Š” ๋ ˆ์ง€์Šคํ„ฐ์˜ ์ข…๋ฅ˜์™€ ๊ฐœ์ˆ˜, ๋ฉ”๋ชจ๋ฆฌ ๊ด€๋ฆฌ ๋ฐฉ๋ฒ• ๋“ฑ์ด ๋‹ฌ๋ผ์ง‘๋‹ˆ๋‹ค.

์ฆ‰, ISA๋Š” CPU์˜ ์–ธ์–ด ๋ชจ์Œ์ด์ž H/W๊ฐ€ S/W๋ฅผ ์–ด๋–ป๊ฒŒ ์ดํ•ดํ• ์ง€์— ๋Œ€ํ•œ ์•ฝ์†์ด๋ผ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด๋Ÿฌํ•œ ISA๋Š” ์–ด๋–ป๊ฒŒ ์„ค๊ณ„ํ•˜๋Š”์ง€์— ๋”ฐ๋ผ ํฌ๊ฒŒ CISC(Complex Instruction Set Computer)์™€ RISC(Reduced Instruction Set Computer)๋กœ ๋‚˜๋ˆ•๋‹ˆ๋‹ค.

CISCRISC(load-store ๊ตฌ์กฐ)
๋ณต์žกํ•˜๊ณ  ๋‹ค์–‘ํ•œ ๋ช…๋ น์–ด๋‹จ์ˆœํ•˜๊ณ  ์ ์€ ๋ช…๋ น์–ด(load, store)
๊ฐ€๋ณ€ ๊ธธ์ด ๋ช…๋ น์–ด๊ณ ์ • ๊ธธ์ด ๋ช…๋ น์–ด
๋‹ค์–‘ํ•œ ์ฃผ์†Œ ์ง€์ • ๋ฐฉ์‹์ ์€ ์ฃผ์†Œ ์ง€์ • ๋ฐฉ์‹
ํ”„๋กœ๊ทธ๋žจ์„ ์ด๋ฃจ๋Š” ๋ช…๋ น์–ด์˜ ์ˆ˜๊ฐ€ ์ ์Œํ”„๋กœ๊ทธ๋žจ์„ ์ด๋ฃจ๋Š” ๋ช…๋ น์–ด์˜ ์ˆ˜๊ฐ€ ๋งŽ์Œ
์—ฌ๋Ÿฌ Clock์— ๊ฑธ์ณ ๋ช…๋ น์–ด ์ˆ˜ํ–‰1 Clock ๋‚ด์™ธ๋กœ ๋ช…๋ น์–ด ์ˆ˜ํ–‰
Instruction Pipelining์ด ์–ด๋ ค์›€Instruction Pipelining์ด ์‰ฌ์›€
Intel์˜ CPU(x86, x86-64)Apple์˜ CPU(ARM)
This post is licensed under CC BY 4.0 by the author.

๐Ÿ–ฅ๏ธ [Computer Architecture] Data ๐Ÿ–ฅ๏ธ

๐Ÿ–ฅ๏ธ [Computer Architecture] CPU ๐Ÿ–ฅ๏ธ