สถาปัตยกรรมคอมพิวเตอร์ (computer architecture)

37
สสสสสสสสสสสสสสสสส (Computer Architecture) 1 สสสสสสสสสสส สสสสสสสสสสส (Computer Architecture)

Upload: bryar-kidd

Post on 02-Jan-2016

52 views

Category:

Documents


9 download

DESCRIPTION

สถาปัตยกรรมคอมพิวเตอร์ (Computer Architecture). บทที่ 3 การคำนวณทางคณิตศาสตร์ หน่วยประมวลผลทางคณิตศาสตร์และตรรกะ (ALU). หน่วยประมวลผลทางคณิตศาสตร์และตรรกะ. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 1

สถาปั�ตยกรรม คอมพิ�วเตอร�

(Computer Architecture)

Page 2: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 2

บทท��3การค�านวณทาง

คณ�ตศาสตร�หน�วยปัระมวลผล

ทางคณ�ตศาสตร�และ ตรรกะ (ALU)

Page 3: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 3

หน�วยปัระมวลผลทางคณ�ตศาสตร�และตรรกะ

หน�วยปัระมวลผลทางคณ�ตศาสตร�และตรรกะ

ALU เปั�นส�วนปัระกอบที่��เปั�นอ�เล็�กที่รอน�กส�ที่��ใช้�พิ !นฐานที่างดิ�จิ�ตอล็ล็อจิ�ก ที่&าหน�าที่��ปัระมวล็ผล็ในคอมพิ�วเตอร�ที่) !งที่างดิ�านคณิ�ตศาสตร�แล็ะตรรกะ โดิยซี�พิ�ย/จิะม� ALU ปัระกอบอย/�ภายในซี�พิ�ย/ โดิยซี�พิ�ย/จิะใช้�งาน ALU ร�วมก)บหน�วยควบค1ม (Control Unit) ร�จิ�สเตอร� หน�วยความจิ&า แล็ะอ1ปักรณิ�อ�นพิ1ต/เอาต�พิ1ต ร/ปั 31. จิะเห�นว�า ALU อย/�ภายในซี�พิ�ย/โดิยม�ซี�พิ�ย/ควบค1มการที่&างาน แล็ะม�ร�จิ�สเตอร�ส&าหร)บส�งข้�อม/ล็เข้�าส/� ALU หล็)งจิากน)!นผล็ล็)พิธ์�ที่��เก�ดิจิากการปัระมาล็ผล็ข้อง ALU จิะเก�บไว�ที่��ร �จิ�สเตอร�เช้�นก)น ร�จิ�สเตอร�น�!ที่&าหน�าที่��เปั�นหน�วยเก�บข้�อม/ล็ช้)�วคราว หล็)งจิากน)!นจิะน&ามาเก�บไว�ในหน�วยความจิ&าโดิยการควบค1มข้องซี�พิ�ย/

Page 4: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 4

ALUALU

Page 5: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 5

การเปัล��ยนเปั"นค�าตรงข้$ามการเปัล��ยนเปั"นค�าตรงข้$าม ใช้$ - -sign and magnitude

21 00010101+ =- 21 10010101= -sign and-magnitude

ใช้$ 2’s complement21 = 000101012

s complement= 11101010กล็)บค�า

แต�ล็ะบ�ต+ 1

-21 = 11101011

Page 6: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 6

การบวกและการลบการบวกและการลบ ใช้$ 2’s complement :

- ใช้$หล(ก a-b = a+(-b)- ไม�ค�ดต(วทด และค�าส+งส,ดไม�เก�นข้องจำ�านวนบ�ต

Page 7: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 7

การบวกและการลบการบวกและการลบ ใช้$ 1’s complement :

- ถ$าม�ต(วทดเก�ดข้./น จำะน�าไปับวกเข้$าก(บค�าผลล(พิธ์�ท��ได$

Page 8: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 8

การค+ณการค+ณ จำ�านวนเต1มไม�ม�เคร2�องหมาย :

- ต(/งต(วค+ณให$ต�าแหน�งข้วาส,ดตรงก(บต(วต(/ง- ผลค+ณย�อยท��เก�ดข้./นต�าแหน�งข้วาส,ดให$ตรงต(วค+ณ- น�าผลค+ณย�อยมารวมก(น

Page 9: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 9

การค+ณการค+ณ จำ�านวนเต1มม�เคร2�องหมาย (บวก)

Page 10: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 10

การค+ณการค+ณ จำ�านวนเต1มม�เคร2�องหมาย (ลบ)

ผ�ดิ ถ/ก (ข้ยายผล็ค/ณิย�อย)

Page 11: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 11

การค+ณการค+ณ อ(ลกอร�ท.�มข้องบ+ธ์

Page 12: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 12

การค+ณการค+ณ

Page 13: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 13

การหารการหาร

Page 14: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 14

Page 15: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 15

Page 16: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 16

การบวกและลบเลข้ทศน�ยมการบวกและลบเลข้ทศน�ยม การตรวจำสอบค�า 0 การปัร(บเลข้ช้�/ก�าล(งให$เท�าก(น ท�าการบวกหร2อลบค�าข้องจำ�านวนน(/น (Mantissa) ปัร(บให$อย+�ในร+ปัแบบท(�วไปั

Page 17: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 17โฟล็ว�ช้าร�ตแสดิงการบวกแล็ะล็บเล็ข้ที่ศน�ยม

(Z <--X+-Y)

Page 18: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 18

การค+ณเลข้ทศน�ยมการค+ณเลข้ทศน�ยม

โฟล็ว�ช้าร�ตแสดิงการค/ณิเล็ข้ที่ศน�ยม (Z <-- X x Y)

Page 19: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 19

การหารเลข้ทศน�ยมการหารเลข้ทศน�ยม

โฟล็ว�ช้าร�ตแสดิงการค/ณิเล็ข้ที่ศน�ยม (Z <-- X / Y)

Page 20: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 20

Haft Adder และ Full Adder

Haft Adder และ Full Adder

ตารางค�าความจิร�งข้องการบวกเล็ข้ 2 บ�ต แล็ะวงจิรส&าหร)บการบวกเล็ข้ 2 บ�ต

Page 21: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 21

Haft Adder และ Full Adder

Haft Adder และ Full Adder

ตารางค�าความจิร�งการบวกเล็ข้ 3 บ�ต (2 บ�ตแล็ะม�ต)วที่ดิ )แล็ะส)ญล็)กษณิ� Full Adder

Page 22: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 22

Haft Adder และ Full Adder

Haft Adder และ Full Adder

วงจิร Full Adder ที่��เก�ดิจิาก 2HaftAdder ต)ว

Page 23: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 23

Ripple-Carry AdderRipple-Carry Adder

- Ripple Carry Adder (ข้นาดิ 4 บ�ต)

Page 24: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 24

Ripple-Carry AdderRipple-Carry Adder

ต)วบวกข้นาดิ 16 บ�ตที่��เก�ดิจิากการเร�ยงต�อก)นข้อง - Ripple Carry Adder 4 ต)ว

Page 25: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 25

Full Subtractor Full Subtractor

ตารางค�าความจิร�งแล็ะส)ญล็)กษณิ�ข้อง Full Subtractor

Page 26: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 26

Ripple-Borrow Subtractor

Ripple-Borrow Subtractor

- Ripple Borrow Subtractor

Page 27: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 27

Ripple-Borrow Subtractor

Ripple-Borrow Subtractor

ต)วล็บข้นาดิ 16 บ�ตที่��เก�ดิจิากการเร�ยงต�อก)นข้อง - Ripple Borrow Subtractor 4 ต)ว

Page 28: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 28

วงจำรบวกและลบวงจำรบวกและลบ

วงจิรบวกแล็ะล็บ

Page 29: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 29

Carry-LookaheadCarry-Lookahead

Full Adder ที่��สร�างเอาต�พิ1ตต)วที่ดิก�อก&าเน�ดิ (G) แล็ะต)วที่ดิแพิร� (P) ส&าหร)บใช้�ใน - Carry Lookahead

Page 30: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 30

Carry-LookaheadCarry-Lookahead

Full Adder ที่��รวม - Carry Lookahead โดิย Full Adder

Page 31: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 31

Serial MultiplierSerial Multiplier

SSSSSS S SSSSSSSSS

Page 32: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 32

ต(วอย�างการค+ณท��ใช้$ Serial Multiplier

ต(วอย�างการค+ณท��ใช้$ Serial Multiplier

Page 33: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 33 Array Multiplier

Page 34: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 34

Serial DividerSerial Divider

Serial Divider

Page 35: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 35ต)วอย�างการหารโดิยใช้� Serial Divider

Page 36: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 36

Combination ALUCombination ALU

Combination ALU

Page 37: สถาปัตยกรรมคอมพิวเตอร์  (Computer Architecture)

สถาปั�ตยกรรมคอมพิ�วเตอร� (Computer Architecture) 37

Sequential ALUSequential ALU

Sequential ALU

Addi ti on AC := AC + DR

Subtracti on AC := AC – DR

Mul ti pl i cati on AC.MQ :=

DR x MQDivision

AC.MQ := MQ/DRAND AC := AC

AND DROR AC := AC

OR DR-EX OR AC := AC

XOR DRNOT AC :=NOT(AC)