1 / 174

제 2 장

제 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.

shaw
Download Presentation

제 2 장

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 제 2 장 CPU

  2. ALU 2.1 CPU (Central Processing Unit) Organization Consists of Registers, ALU (Arithmetic and Logical Unit), Control Unit Register Register Control Unit

  3. ALU Microprocessors = CPU on Chip Register Control Unit Register Microprocessor Microcomputer = Microprocessor를 CPU로 이용하는 computer

  4. ALU 2.1.1 ALU (Arithmetic and Logic Unit) Performs arithmetic and logic operations on operands operand operand operation output

  5. 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번지에 있는 내용

  6. ALU ALU (Arithmetic and Logic Unit) Performs arithmetic and logic operations on operands ADD R1, $2000 R1 = R1 + $2000 Register R1 메모리 2000번지 내용 제어신호 (+) Control Unit

  7. 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

  8. ALU MOVE R1, $1000 Register R1 메모리 1000번지 내용 ADD R1, $2000 Register R1 메모리 2000번지 내용 제어신호 (+) Control Unit

  9. (2). Special Purpose Register Execution Step (CPU가 명령어를 수행하는 과정 Fetch Instruction - Memory로 부터 명령어를 가지고 온다 Decode Instruction - 가지고 온 명령어를 해독한다 Execute Instruction - 해독한 결과에 따라 명령어를 수행한다

  10. (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

  11. 일반적으로, 현재 수행중인 명령어에 의하여 다음 번에 수행해야 할 명령어의 주소를 알 수 있다. 제일 처음 수행해야 할 명령어의 주소 -> 처음 컴퓨터 작동 시 CPU에 의하여 결정 ex) Intel CPU : 0xFFFF00

  12. (b). IR (Instruction Register) -> 수행할 명령어를 해독하기 전에 저장하는 장소 Control Unit PC IR Memory

  13. (c). SR (Status Register) -> Consists of Control bits and Flag bits N Z V I C

  14. ALU Flag Bits - automatically set by certain events during arithmetic and logic operations 명령어의 수행결과에 따라 자동적으로 set ADD R1, $2000 Register R1 메모리 2000번지 내용 제어신호 (+) Flag Bits Control Unit

  15. 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

  16. 2의 보수에 의한 수의 표현 (8bit의 경우 표현 범위 : -128 ~ +127) 0 1111111 +127 ….. 0 0000000 0 1 1111111 -1 ….. 1 0000000 -128

  17. 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

  18. 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

  19. (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

  20. 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 번지

  21. 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 번지

  22. 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한다.

  23. main function1 function2 stack

  24. Push시 Stack Pointer의 주소는 감소한다. Pop시 Stack Pointer의 주소는 증가한다.

  25. 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 번지

  26. 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 번지

  27. 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

  28. 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

  29. Process in memory Program in disc Stack Head Info I Data Heap Code U Data I Data Code Process : CPU (processor) 에 의하여 수행중인 program

  30. 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

  31. -> 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, ..) 들을 제어하기 위한 신호

  32. ALU CPU Register Register Control Unit Memory Input/Output

  33. 2.2 CPU 외부 pin들의 구성 Microprocessor

  34. 2.2.1 소개 CPU가 프로그램을 수행하는 과정에서 CPU <-> Memory, CPU <-> I/O, Memory <-> I/O 사이에 정보 교환이 일어남을 알 수 있다. CPU I/O Memory 따라서, CPU의 핀들은 CPU, Memory, I/O사이의 정보교환을 원활히 할 수 있도록 정의되어야 한다.

  35. 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

  36. CPU와 I/O사이에 Interrupt 방식에 의하여 정보를 교환하기 위하여 추가적으로 필요한 핀들 (Interrupt Driven I/O) - Interrupt Memory와 I/O 사이에 직접 정보를 교환하기 위하여 추가적으로 필요한 핀들 (DMA) - Bus Control

  37. 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

  38. 16 bit CPU INTREG A23-A1 INTACK NMINT D15-D0 BR BG BE1# BE0# M/IO# AS# RESET# Clock RD# Vcc WR# Gnd READY

  39. 32 bit CPU A31-A2 INTREG INTACK D31-D0 NMINT BE3# BR BE2# BG BE1# BE0# M/IO# RESET# AS# Clock RD# Vcc WR# Gnd READY

  40. 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에 동기화 하여 동작)

  41. (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

  42. 210 = 1024 = 1K 220 = 1024K = 1M 230 = 1024M = 1G ex1) 216 = 26 X 210 = 64K ex2) 224 = 24 X 220 = 16M ex3) 232 = 22 X 230 = 4G

  43. ex) CPU의 address bus가 8 bit이면 -> Address Space = 256개의 주소로 구성 -> 최하위 주소 = 0, 최상위 주소 = 255 Address Space 255번지 : 0b 11111111 location A7 ….. A6 Address Bus A5 A4 CPU A3 A2 A1 3번지 : 0b 00000011 A0 2번지 : 0b 00000010 1번지 : 0b 00000001 location 0번지 : 0b 00000000

  44. 10진수 10 16진수 0x10 (10)16 8진수 010 (10)8 2진수 10 0b10 (10)2

  45. Memory Map Address Space location 255번지 : 11111111 ….. 2Byte ROM 3번지 : 00000011 2Byte RAM 2번지 : 00000010 1번지 : 00000001 location 0번지 : 00000000

  46. CPU는 Memory Map을 통하여 Memory 소자들과 통신한다. Memory Map - (Memory) Address Space상에 Memory 소자들의 사상관계 회로해석 : Memory Interface회로로부터 Memory Map을 해석 회로설계 : Memory Map으로부터 Memory Interface회로의 설계

  47. 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 주소인가를 구분해주어야 한다.

  48. Memory Mapped I/O (공유 Address Space) Address Space 255번지 : 11111111 location A7 ….. A6 Address Bus A5 A4 CPU A3 A2 A1 3번지 : 00000011 A0 2번지 : 00000010 1번지 : 00000001 location 0번지 : 00000000

  49. Address Space location 255번지 : 11111111 Keyboard ….. 2Byte ROM 7번지 : 00000011 3번지 : 00000011 2Byte RAM 2번지 : 00000010 1번지 : 00000001 location 0번지 : 00000000

  50. I/O Mapped I/O (독립 Address Space) Memory Address Space I/O Address Space location location A7 ….. ….. A6 A5 A4 CPU A3 A2 A1 3번지 3번지 A0 2번지 2번지 1번지 1번지 M/IO* location location 0번지 0번지

More Related