CPU (Central Processing Unit) feladatai a végrehajtandó utasítás betöltése,
C P U(Central Processing Unit)
description
Transcript of C P U(Central Processing Unit)
![Page 1: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/1.jpg)
LOGO
“ Add your company slogan ”
C P U(Central Processing Unit)2006081008 장필구2006081025 나대로
![Page 2: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/2.jpg)
Contents
1. CPU(Central Processing Unit) 의 개요
2. 명령어 집합
3. 레지스터 (Register)
4. 마 무 리
- 명령어 형식- 명령어 종류- 명령어 지정 방식
![Page 3: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/3.jpg)
CPU 는 왜 필요하지 ?
폰 노이만형 컴퓨터방식을 따라 프로그램이 필요
작성된 프로그램을 해석( 컴파일러 )
2 진수의 기계어로 이루어진 목적파일 생성
2 진수의 명령어들 실행
2 진수 명령어들 고속처리→ 실행
아하 !이래서 필요하구나 !
![Page 4: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/4.jpg)
CPU 의 구성 요소
버스 통로
Main Memory
Control Unit(PC, IR)
Registers(MAR, MBR)
BUS Interface Unit
ALU
병목현상 (Bottle Neck) 전통적인 컴퓨터 설계기법에서 , CPU 와 기억장치 사이의 통로에 정보가 집중됨으로써 야기되는 작업 지연 현상 .
![Page 5: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/5.jpg)
CPU 의 구성 요소*PC(Program Counter)프로그램카운터로 CPU 내의 제어장치 레지스터에 속합니다 .이 PC 는 CPU 에서 다음에 실행할 명령어의 번지를 기억합니다 .
*IR(Instruction Resister)명령레지스터로 CPU 가 현재 수행하고 있는 명령어를 기억합니다 .
*Decoder해독기로 제어장치에 속해 있으며 , CPU 내로 들어오는 명령어를실제로 판독가능한 신호로 해석하는 레지스터입니다 .
*Encoder부호기로써 디코더로 부터 해독된 신호를 각 장치에 지시하기 위해각 장치로 신호를 보내주는 장치입니다 .
*MAR(Memory Address Resister)기억장치로 부터 입 / 출력되는 데이터의 주소를 기억하고 있는 레지스터입니다 .
*MBR(Memory Buffer Resiter)기억장치로 부터 입 / 출력되는 데이터 자체를 기억하고 있는 레지스터입니다
•PC(Program Counter)•IR(Instruction Registers)Control
Unit•MAR(Memory Address Registers)•MBR(Memory Buffer Registers)Registers
•Internal bus•External busBus Inter-
face Unit
•AU(Arithmetic Unit) – 가산기(adder), 레지스터(register), 보수기(complementary)
•LU(Logic Unit)
ALU
![Page 6: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/6.jpg)
캐시
- 이번에 나온 i7 CPU 의 캐시 구성도 이다 .
- 캐시 메모리를 CPU 안에 내장 하고 있으며- 가장 빠르고 가장 빈도 높은 데이터를 가진 L1 캐시메모리가 제일 가까이 있다 .
![Page 7: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/7.jpg)
CPU 의 내부 구조
MAR
MBR
IR
IR0
IRn
PC
ALU
Control Unit
IRZ
Rx
MemoryDevice
-------------c0 cn
![Page 8: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/8.jpg)
Contents
1. CPU(Central Processing Unit) 의 개요
2. 명령어 집합
3. 레지스터 (Register)
4. 마 무 리
- 명령어 형식- 명령어 종류- 명령어 지정 방식
![Page 9: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/9.jpg)
명령어 집합 인출 주기 (Fetch Cycle)
주기억 장치 ( 프로그램 )
명령 레지스터명령코드부 주소부
명령해독기 번지 해독기
부호기
제어 계수기➀➁
➂
➃
➄
➅➆
- 주기억장치에 있는 명령을 꺼내는 작업을 패치 (fetch cycle)
- 명령어가 CPU 내에서 실행 될 수 있도록 명령을 명령 레지스터까지 가져와 준비하는 단계CPU
![Page 10: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/10.jpg)
명령어 집합 실행 주기 (Execution Cycle)
(데이터 )주기억장치
제어장치연산장치
➀
➁
번지해독기
명령어 레지스터명령 코드 주소부
기억레지스터가산기누산기
➂
➃➄
- 꺼내어진 명령을 해석하여 실행(execution cycle)
- 명령어가 CPU 내에서 실행 될 수 있도록 명령을 명령 레지스터까지 가져와 준비하는 단계
CPU
전부 CPU 안에서 일어나는 일들이다 .
![Page 11: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/11.jpg)
Operation code• 어떤 연산을 할 것인가 ? • 연산에 필요한 자료가 어떤 레지스터 , 기억장치 중 어느 곳에서 오는가 ?• Data 의 종류가 문자 , 고정소수점 , 부동소수점인가 ?
Operand• 주기억장치에서 자료나 명령어의 주소를 기억하는 부분• 몇 번지부터 기억된 자료를 연산할 것인가 ?
명령부 (Operation code)
번지부 (Operand)
명령어 형식
[EX]
ADD A, B
MOV X, R1명령부 주소부
레지스터(Register)
![Page 12: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/12.jpg)
명령어 형식
동작 코드 기능ADD 덧셈 (Add)
SUB 뺄셈 (Subtract)
MUL 곱셈 (Multiply)
DIV 나눗셈 (Divide)
LD 기억장치로부터 레지스터로 데이터 적재 (load)
STO 기억장치에 데이터 저장 (Store)
명령어의 동작 코드
![Page 13: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/13.jpg)
명령어 형식 0 주소 명령어 (0 Address Instruction)
-1 개의 명령부를 갖는 명령형식- 모든 연산은 stack 에 있는 자료를 이용하여 수행하고그 결과 또한 stack 에 보존
OP code(Operation Code)[EX]
PUSH A SP(TOP) ← APUSH B SP(TOP) ← BADD SP(TOP) ← (A+B)POP X M[X] ← SP(TOP)
![Page 14: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/14.jpg)
명령어 형식 1 주소 명령어 (1 Address Instruction)
OP code
-1 개의 명령부와 1 개의 번지부를 갖는 명령형식- 연산 결과가 항상 누산기 (accumulator) 에 기억- 연산 결과의 주소를 지정해 줄 필요가 없다- 연산 결과를 효율적으로 사용하기 위해서는 명령의 load 와 store 가 반드시 필요하다 (temporary register)
주소 1[EX] X = (6 + 7) * 5
LOAD 6 ACADD 7 ACSTORE X ACMUL 5 ACSTORE T AC
![Page 15: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/15.jpg)
명령어 형식 2 주소 명령어 (2 Address Instruction)
OP code
-1 개의 명령부와 2 개의 번지부를 갖는 명령형식- 주소 1 에 위치한 자료와 주소 2 에 위치한 자료를 명령어 내용대로 처리하여 주소 1 에 저장- 장점 : 1 개의 연산자에 입력자료 보관 주소와 연산결과 주소가 포함된 명령어 형식으로 수행시간이 짧다
주소 1 주소 2[EX] X = (6 + 7) * 5
MOV R1, 6 ADD R1, 7MUL R1, 5MOV X, R1
![Page 16: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/16.jpg)
명령어 형식 3 주소 명령어 (3 Address Instruction)
OP code
-1 개의 명령부와 3 개의 번지부를 갖는 명령형식- 명령코드가 단항 (unary) 연산인 경우에는 주소 2 를 생략함- 장점 : 연산 후 입력자료가 변하지 않고 보존되고 레지스터 주소를 사용하면 프로그램 길이가 짧아짐-2 진 코드로 명령을 나타날때 너무 많은 비트가 필요함- 하나의 명령어가 수행하려면 최소한 4 번 access 하여야 하므로 수행시간
주소 1 주소 2 주소 3
[EX] X = (6 + 7) * 5
ADD R1, 6, 7MUL X, R1, 5
![Page 17: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/17.jpg)
명령어 주소 지정 방식 정의
- 주소 지정 방식 (addressing mode) 란 주기억장치의 유효 주소 (effective address), 즉 자료를 찾을 수 있는 주소를 계산 하는 방법을 말한다 .
절대 주소 (absolute Address)
- 주소부분의 값이 고유의 번지로 지정된 형식 - 기억공간의 효율 저하 상대 주소 (relative Address)
- 직접 자료에 접근 할 수 없음- 모든 주소는 어느 기본주소 (base address) 에 상대적으로 표시되어 유효 주소를 구하는 방법
- 명령어 주소 비트를 절약 할 수 있어 절대 주소보다 기억공간의 효율 좋은반면 사용시 절대주소로 번역해야 하는 단점이 있다 .
![Page 18: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/18.jpg)
명령어 주소 지정 방식 즉시 주소 지정 방식 (Immediate Addressing Mode)
동작 코드 실제 데이터- 오퍼랜드 (Operand) 는 실질적 명령어 내에 포함 즉 , “Operand = A”- 상수로 취급- 장점 : 기억장치에 접근 할 필요 없어 기억 사이클 하나를 줄 일 수 있다 .- 사용되는 경우 : 일정한 값으로 레지스터를 초기화 할때 유용
OP code
![Page 19: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/19.jpg)
명령어 주소 지정 방식 직접 주소 지정 방식 (Direct Addressing Mode)
OP code Address(100 번지 )
실제데이터(500)
operandMemory
1st
- 기억장치 상의 주소와 프로그램 상의 주소가 일치- 주소를 표현하는데 많은 비트를 필요로 하므로 합리적이지 못하다 .
100 번지
![Page 20: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/20.jpg)
명령어 주소 지정 방식 간접 주소 지정 방식 (Indirect Addressing Mode)
OP code Address(100 번지 )I
주소번지 500
실제데이터(700)
operand
I = 0 : 직접주소 방식I = 1 : 간접주소 방식 1st
2nd
Memory
- 직접 주소 방식의 주소 지정 공간이 제한되는 문제를 보완하기 위해 등장- 참조 방식을 취함- 단점 : 두 번 기억 장치를 참조 해야 하는 단점이 있다 .
500 번지100 번지
![Page 21: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/21.jpg)
명령어 주소 지정 방식 레지스터 주소 지정 방식 (Register Addressing Mode)
OP code Address R 실제 데이터Register
- 직접 주소 지정 방식과 유사 즉 , 해당 레지스터 안에 실제 데이터가 기억 되어있다 .- 장점 : 매우 빠른 속도를 가지고 있기에 실행 시간을 단축 시킬 수 있다 .
![Page 22: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/22.jpg)
명령어 주소 지정 방식 레지스터 간접 주소 지정 방식 (Register Indirect Addressing Mode)
OP code RR(100)
주소 번지 700
실제데이터(1500)
500 번지100 번지 Register 700
Memory
- 간접 주소 지정 방식과 유사 즉 , 피연산자를 통해 실제 데이터가 들어있는 레지스터를 찾아간다 .
![Page 23: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/23.jpg)
명령어 주소 지정 방식 상대 주소 지정 방식 (Relative Addressing Mode)
OP code d
실제데이터+
nn
nn = 500
Program counter
유효주소nn + d(515)
Memory
- 피연산자의 주소는 PC 에 따라서 지정- PC 를 베이스 레지스터로 간주하며 현재 명령어의 주소가 주소 필드의 값과 합해져서 유효 주소 (Effective Address) 를 얻는다 .- 주소 필드의 값은 2 의 보수로 다루어진다 .
![Page 24: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/24.jpg)
명령어 주소 지정 방식 베이스 레지스터 주소 지정 방식 (Base Register Addressing Mode)
OP codeBase register 변위
+ 실제데이터 (500)
Memory
시작 주소 mm(300) 변위값 nn(15)
mm + nn(315 번지 )
- 베이스 레지스터 ( 시작점 ) 라는 레지스터를 이용하여 그 내용을 기준 주소로 사용 하는 방식 - 인덱스 주소 방식과 유사하다 .- 명령어 주소 부분은 베이스 주소로 부터 상대적인 변위가 된다 .
![Page 25: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/25.jpg)
명령어 주소 지정 방식 인덱스 레지스터 주소 지정 방식 (Indexed Register Addressing Mode)
OP code d
실제데이터 (500)+nn
Index register nn=300
유효주소nn + d
(350 번지 )
MemoryIx
operand
변위값 d=50
- 베이스 레지스터 주소 지정 방식의 반대- 인덱싱은 인덱스 레지스터가 있어서 해당 내용과 메모리 주소 레지스터 (MAR) 의 값을 필요할 때마다 더하여 피연산자를 참조한다 .- 오퍼랜드 부분이 지정하는 인덱스 레지스터의 번호와 상수값 , 즉 변위로 나뉘어 있다 .
![Page 26: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/26.jpg)
명령어 주소 지정 방식 데이터 주소의 표현 방식
◇ 완전 주소- 정보가 데이터 또는 주소이거나 구별하지 않고 그 기억된 장소에 직접 매핑 시킬 수 있는 완전한 주소- 단점 : 가장 많은 비트 수를 필요 2n 워드일 때 n 개의 비트 필요◇ 약식 주소- 주소의 일부분 생략- 계산에 의한 주소는 대부분 약식 주소에 속함◇ 생략 주소- 주소를 구체적으로 나타내지 않아도 원하는 정보가 기억된 곳을 알 수 있을 때 사용- 스택 , 큐가 있다 . - 장점 : 명령어의 길이 축소◇ 데이터 자신
- 주소를 위해 별도의 비트가 필요 없음 - 스스로 표현 위해 상당한 수의 비트 필요
![Page 27: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/27.jpg)
명령어 주소 지정 방식 스택 (Stack) 주소 지정 방식
- 스택 포인터는 푸시나 팝이 일어 날 때마다 자동으로 증가 또는 감소- 위의 이유로 프로세서는 주소를 명시 할 필요 없이 스택 사용 가능
100
100223010
주소1000
1001100210031004
Stack pointer
a) MUL(*) 연산
100
10022
300
주소1000
1001100210031004
Stack pointer
b) ADD(+) 연산
100
100322
주소1000
1001100210031004
Stack pointer
[EX]
2 * 3 + 4 / 2 중위표기 방법을 후위표기방식으로 변경2 3 * 4 2 / +
2 23
6 64
642
62
82 3 * 4 2 / +
![Page 28: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/28.jpg)
Contents
1. CPU(Central Processing Unit) 의 개요
2. 명령어 집합
3. 레지스터 (Register)
4. 마 무 리
- 명령어 형식- 명령어 종류- 명령어 지정 방식
![Page 29: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/29.jpg)
레지스터 (Register)
범용레지스터(GPR)
레지스터
전용레지스터(SPR)
CPU 에 필요한 작은 Data 의 임시저장 공간연산 처리 및 번지지정을 도와줌CPU 내부에는 각 용도에 맞는 다양한 레지스터가 존재
![Page 30: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/30.jpg)
범용 레지스터 (General Purpose Register)
범용레지스터(GPR)
Scratch Pad RegisterWorking Register
CPU 내에서 생성하는 data 를 보관
여러가지 연산을 할 수 있음
Accumulator 의 역할
특정 주소 지정 방식에서주소를 지정
![Page 31: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/31.jpg)
전용 레지스터 (Special Purpose Register)
4) 상태 레지스터
2) 메모리 지정 레지스터
1) 명령어 레지스터
3) 스택 레지스터
GPR 은 성능 향상을 고려하는데 비해 대부분 SPR 은 반드시 필요로 하는 용도로 사용 .
![Page 32: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/32.jpg)
명령어 레지스터 (IR : Instruction Register)
OP-code 피연산자(X)
피연산자(Y)
동작코드에는 덧셈 , 뺄셈 , 분기 등의 동작코드를 가지고 있다 .피연산자 (X) 는 주소지정모드로 동작하며 ,피연산자 (Y) 는 해당모드에 필요한 주소값을 가지고 있다 .
Instruction Register 는 명령어을 수행하기 위해 잠시 정보를 보관하고 있는 레지스터
![Page 33: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/33.jpg)
메모리 지정 레지스터
MAR - CPU 가 기억장치의 주소를 참조하는 데 반드시 필요한 레지스터MBR - 실질적으로 CPU 가 주기억장치주소를 참조하는 레지스터Index Register - 데이터를 비교하거나 전송하는 명령에서 사용됨SI(Source Index): Data 의 시작지DI(Destination Index): Data 의 목적지Segment Register - 프로그램의 크기가 주기억장치보다 클 때 프로그램을 한 묶음으로 쪼갠 영역
메모리 지정 레지스터에는 메모리 주소 레지스터 , 인덱스 레지스터 , 세그먼트 레지스터 , 메모리 버퍼 레지스터 , 프로그램 카운터 등이 있다 .
![Page 34: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/34.jpg)
스택 레지스터 (Stack Register)
Stack Register 는 스택 및 데이터 메모리를 관리
이전에 하던 작업의 내용과 그 상태를 보존을 위한 유지영역의 기능을 가진다 .
(Stack Pointer)가장 최근에 Stack 에 들어온 데이터를 가리킴 (Top)(Base Pointer, Frame Pointer)현재 사용 중인 Stack 의 바닥을 가리킴 (Bottom)
![Page 35: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/35.jpg)
상태 레지스터 (Status Register)
Status Register 는 CPU 의 다음 동작의 기준을 정하기 위해 연산의 상태를 저장하고 있다 .
Status Register 에는 Carry Flag , Zero Flag , Sign Flag ,Overflow Flag 등이 있다 .
(Carry Flag) - 8 + 7 = 15 여기서 ‘ 1’ 이 세트(Zero Flag) - 8 – 8 = 0 여기서 값이 ‘ 0’ 이면 ‘ 1’ 이세트 (Sign Flag) - 5 – 8 = -3 이처럼 부호값 (Sign) 있을때 ‘ 1’ 이 세트(Overflow Flag) - 2 – 5 = -3 결과 값이 범위를 벗어날때 ‘ 1’ 이 세트
![Page 36: C P U(Central Processing Unit)](https://reader035.fdocument.pub/reader035/viewer/2022081503/56816731550346895ddbdd76/html5/thumbnails/36.jpg)
LOGO
“ Add your company slogan ”