제 2 장. CPU. ALU. 2.1 CPU (Central Processing Unit) Organization. Consists of Registers, ALU (Arithmetic and Logical Unit), Control Unit. Register. Register. Control Unit. ALU. Microprocessors = CPU on Chip. Register. Control Unit. Register. Microprocessor.
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation
Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement.Téléchargez la présentation en cliquant sur ce lien.Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.
ALU 2.1 CPU (Central Processing Unit) Organization Consists of Registers, ALU (Arithmetic and Logical Unit), Control Unit Register Register Control Unit
ALU Microprocessors = CPU on Chip Register Control Unit Register Microprocessor Microcomputer = Microprocessor를 CPU로 이용하는 computer
ALU 2.1.1 ALU (Arithmetic and Logic Unit) Performs arithmetic and logic operations on operands operand operand operation output
Program : set of instructions, Data Instruction : Opcode field + Operand field ex) ADD R1, $2000 -> R1 = R1 + 2000번지의 값 Data = Operand Opcode field : operation의 종류를 결정 -> ADD Operand field : operand의 위치를 결정 -> R1, $2000 Operand : operation시 필요한 정보 -> R1 및 2000번지에 있는 내용
ALU ALU (Arithmetic and Logic Unit) Performs arithmetic and logic operations on operands ADD R1, $2000 R1 = R1 + $2000 Register R1 메모리 2000번지 내용 제어신호 (+) Control Unit
2.1.2 Registers High speed memory location used to store important information during CPU operation (1). General Purpose Register -> used to hold temporary data during CPU operation R1, R2, R3, R4, R5 ex) MOVE R1, $1000 ADD R1, $2000
ALU MOVE R1, $1000 Register R1 메모리 1000번지 내용 ADD R1, $2000 Register R1 메모리 2000번지 내용 제어신호 (+) Control Unit
(2). Special Purpose Register Execution Step (CPU가 명령어를 수행하는 과정 Fetch Instruction - Memory로 부터 명령어를 가지고 온다 Decode Instruction - 가지고 온 명령어를 해독한다 Execute Instruction - 해독한 결과에 따라 명령어를 수행한다
(a). PC (Program Counter) = IP (Instruction Pointer) -> Points to the location of the next instruction (다음 번에 수행해야 할 명령어의 주소를 저장) 일반적으로, 현재 수행중인 명령어에 의하여 다음 번에 수행해야 할 명령어의 주소를 알 수 있다. ex) 2000번지 : ADD R1 #50 (2Byte 명령어라 가정) 2002번지 : MOVE $2000 R1 ... 3000번지 : JUMP $5000 현재 CPU에 의하여 수행중인 명령어가 ADD R1 #50 이라면 PC = 2002 현재 CPU에 의하여 수행중인 명령어가 JUMP $5000 이라면 PC = 5000
일반적으로, 현재 수행중인 명령어에 의하여 다음 번에 수행해야 할 명령어의 주소를 알 수 있다. 제일 처음 수행해야 할 명령어의 주소 -> 처음 컴퓨터 작동 시 CPU에 의하여 결정 ex) Intel CPU : 0xFFFF00
ALU Flag Bits - automatically set by certain events during arithmetic and logic operations 명령어의 수행결과에 따라 자동적으로 set ADD R1, $2000 Register R1 메모리 2000번지 내용 제어신호 (+) Flag Bits Control Unit
Flag Bit의 종류 carry flag (C) : 연산결과 carry가 발생하였을 때 set zero flag (Z) : 연산결과가 0일 때 set sign flag (N) : 일반적으로 연산 결과가 음수일 때 set overflow flag (V) : 연산의 결과가 넘침이 발생했을 때 set 연산의 결과가 잘못된 결과 N Z V I C
2의 보수에 의한 수의 표현 (8bit의 경우 표현 범위 : -128 ~ +127) 0 1111111 +127 ….. 0 0000000 0 1 1111111 -1 ….. 1 0000000 -128
Overflow는 부호가 다른 두 수를 더하는 경우는 절대로 발생하지 않음 carry bit EXOR sign bit = 1이면 overflow 0 1000000 +64 1 0111111 -65 0 1000000 +64 1 0111111 -65 1 0000000 (-128 ? overflow) 1 0 1111110 (+126 ? overflow) 0 1000000 +64 1 1000000 -64 0 0111111 +63 1 1000000 -64 0 1111111 +127 1 1 0000000 -128
Control Bits - set by program in order to enable certain modes of CPU operation 명령어에 의하여 인위적으로 set ex) interrupt disable/enable -> DISINT : I = 0 ENINT : I = 1 N Z V I C
(d). SP (Stack Pointer) -> Stack is a set of contiguous memory location where information items are added or removed in a stack operation. Stack operation -> Push, Pop by LIFO (Last-In-First-Out) 마지막에 입력된 정보가 먼저 출력 된다. ex) 출구와 입구가 같은 경우 E D C B A Queue operation -> Push, Pop by FIFO (First-In-First-Out) 먼저 입력된 정보가 먼저 출력 된다. ex) 출구와 입구가 다르고 반대편에 있는 경우 E D C B A
SP (Stack Pointer) points to the top of the stack Push : 정보를 SP다음에 저장하고 SP를 증가한다 Stack의 저장단위 : 1 Byte -> SP의 변화 단위 1 Stack의 저장단위 : 2 Byte -> SP의 변화 단위 2 Push E E 1003 1004 번지 1004 1004 번지 SP SP D D 1003 번지 1003 번지 C C 1002 번지 1002 번지 B B 1001 번지 1001 번지 A A 1000 번지 1000 번지
Pop : SP가 가리키는 곳의 정보를 출력하고 SP를 감소한다 Pop 1003 1004 번지 E SP 1004 1004 번지 SP D 1003 번지 D 1003 번지 C 1002 번지 C 1002 번지 B 1001 번지 B 1001 번지 A 1000 번지 A 1000 번지
Stack이 이용되는 예 : 프로그램에서 함수의 호출 시 ex) main(){ ... function1(); ... <-- 1000번지 } function1(){ ... function2(); ... <-- 2000번지 } function2(){ ... } 1. main()에서 function1()을 호출하기 전 다음 주소 1000번지를 스택에 push한다. 2. function1()에서 function2()를 호출하기 전 다음 주소 2000번지를 스택에 push한다. 4. function1()이 끝난 후 1000번지부터 실행되어야 하며 이를 위하여 스택으로부터 그 정보를 pop한다. 3. function2()가 끝난 후 2000번지부터 실행되어야 하며 이를 위하여 스택으로부터 그 정보를 pop한다.
Push E E 1003 1004 번지 1004 1004 번지 SP SP D D 1003 번지 1003 번지 C C 1002 번지 1002 번지 B B 1001 번지 1001 번지 A A 1000 번지 1000 번지 Push E 1000 번지 A 1000 번지 A 996 999 번지 B SP 997 999 번지 B SP 998 번지 C 998 번지 C 997 번지 D 997 번지 D E 996 번지
Pop 1003 1004 번지 E SP 1004 1004 번지 SP D 1003 번지 D 1003 번지 C 1002 번지 C 1002 번지 B 1001 번지 B 1001 번지 A 1000 번지 A 1000 번지 Pop 1000 번지 A 1000 번지 A 997 999 번지 B 996 SP 999 번지 B SP 998 번지 C 998 번지 C 997 번지 D 997 번지 D E 996 번지
Memory에서 Program의 구성 프로그램의 수행 시 Heap과 Stack은 가변적으로 변한다. 최대한의 Heap영역과 Stack영역을 보장하기 위해서는 증가방향이 반대이어야 한다. int a[10]; function( int s1, int s2 ) { int b[10]; static int p; int *c; c = new int[10]; … a[5] = b[5] + *(c+5); … } Stack Heap Data Code
int a[10]; int k=3; function( int s1, int s2 ) { int b[10]; static int p; int *c; c = new int[10]; … a[5] = b[5] + *(c+5); … } Stack Heap U Data I Data Code U Data : Uninitialized Data I Data : Initialized Data
Process in memory Program in disc Stack Head Info I Data Heap Code U Data I Data Code Process : CPU (processor) 에 의하여 수행중인 program
2.1.3 Control Unit -> Generates predefined signal sequences timed by pluses derived from a clock 제공되는 clock에 동기화 된 제어신호가 발생한다. -> The type of a signal sequence depends on the opcode and external inputs Opcode에 의하여 제어신호가 만들어진다. ex) ADD R1, $2000 외부 입력에 의하여 제어신호가 만들어진다. ex) Interrupt Request, Bus Request
-> Consists of internal and external control signal Information flow within CPU CPU 내부의 요소(ALU, Registers, ..) 들을 제어하기 위한 신호 Data Transfer between CPU and Memory Data Transfer between CPU and I/O CPU 외부의 요소(Memory, I/O, ..) 들을 제어하기 위한 신호
ALU CPU Register Register Control Unit Memory Input/Output
2.2.1 소개 CPU가 프로그램을 수행하는 과정에서 CPU <-> Memory, CPU <-> I/O, Memory <-> I/O 사이에 정보 교환이 일어남을 알 수 있다. CPU I/O Memory 따라서, CPU의 핀들은 CPU, Memory, I/O사이의 정보교환을 원활히 할 수 있도록 정의되어야 한다.
CPU와 Memory사이의 정보 교환을 위하여 필요한 핀들 (Direct) - Address Bus - Data Bus - Data Transfer Control CPU와 I/O사이의 정보 교환을 위하여 필요한 핀들 (Direct I/O, Polled I/O) - Address Bus - Data Bus - Data Transfer Control
CPU와 I/O사이에 Interrupt 방식에 의하여 정보를 교환하기 위하여 추가적으로 필요한 핀들 (Interrupt Driven I/O) - Interrupt Memory와 I/O 사이에 직접 정보를 교환하기 위하여 추가적으로 필요한 핀들 (DMA) - Bus Control
2.2.2 핀의 구성 8 bit CPU INTREG INTACK A15-A0 NMINT D7-D0 BR BG M/IO# AS# RD# RESET# WR# Clock READY Vcc Gnd
2.2.3 Power and Clock (1). Power --> Voltage Pin, Ground Pin --> 8bit one set, 16, 32bit two or more set - for current distribution (2). Clock --> Synchronous machine which depend on clock pulse to synchronize their operation (대부분의 CPU : 제공되는 clock에 동기화 하여 동작)
(3). Address Bus --> Identify the location accessed by the CPU during a read or write operation with memory devices or I/O devices --> Location - Memory location, I/O Location --> The set of different addresses specified over the address bus - Address Space ex) N address lines => address space -> 2N => lowest address -> 0 highest address ->2N-1
I/O를 위한 Address Space -> 공유 Address Space 와 독립 Address Space (a). Memory Mapped I/O (공유 Address Space) -> 하나의 Address Space를 Memory와 I/O가 공유한다. (b). I/O Mapped I/O (독립 Address Space) -> Memory Address Space와 I/O Address Space가 독립적으로 존재한다. -> Address bus의 주소가 메모리 주소인가 I/O 주소인가를 구분해주어야 한다.