1. Trang chủ
  2. » Giáo án - Bài giảng

kiến trúc máy tính trương văn cường lecture 02 chương ter 02 language of the computer 01 sv sinhvienzone com

50 102 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 50
Dung lượng 885,18 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

• Bốn nguyên tắc thiết kế cơ bản• Ba toán hạng trong máy tính • Biểu diễn lệnh trong máy tính • Phân loại được lệnh theo 3 định dạng: R-type, I-Type, J-Type • Phân loại được lệnh theo c

Trang 1

COMPUTER ARCHITECTURE

Lecture 1

Instruction: Language of the Computer

Chapter 2

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 2

• Bốn nguyên tắc thiết kế cơ bản

• Ba toán hạng trong máy tính

• Biểu diễn lệnh trong máy tính

• Phân loại được lệnh theo 3 định dạng:

R-type, I-Type, J-Type

• Phân loại được lệnh theo chức năng

• Chuyển đổi lệnh giữa các ngôn ngữ: cấp cao, hợp ngữ, và ngôn ngữ máy.

Sep-16

The goals

2

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 4

• Slide:

Patterson & Hennessy, © 2008, MK

Trang 5

• Giới thiệu về lệnh, tập lệnh

• Kiến trúc tập lệnh MIPS

• Phép toán/toán hạng trong máy tính

• Xem lại số có dấu, số không dấu

• Biểu diễn lệnh, phân loại lệnh

Sep-16

Lecture goals

5

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 6

• Introduction

• Operations of the Computer Hardware

• Operands of the Computer hardware

• Representing Instruction in Computer

Trang 10

• Tập lệnh của một máy tính

• Máy tính khác nhau thì có tập lệnh khác nhau

• Máy tính sơ khai thì có tập lệnh đơn giản

• Nhiều máy tính hiện đại cũng có tập lệnh đơn giản

Sep-16

Instruction Set

10

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 11

• Được sử dụng trong môn học

• Cung cấp bởi MIPS Technologies

Trang 12

Operations of the Computer Hardware

Arithmetic Operations

• Add và subtract, có 3 toán hạng

Trang 13

Operations of the Computer Hardware

Arithmetic Operations

There must certainly be instructions for

performing the fundamental arithmetic

Trang 14

Operations of the Computer Hardware

MIPS operands

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 15

Operations of the Computer Hardware

MIPS assembly language

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 16

Operations of the Computer Hardware

Trang 17

Operations of the Computer Hardware

Trang 18

Operations of the Computer Hardware

Design Principle 1

Simplicity favours regularity

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 19

Operands of the Computer Hardware

Có ba loại toán hạng:

1 Toán hạng thanh ghi (Register Operand)

2 Toán hạng bộ nhớ (Memory Operand)

3 Toán hạng trực tiếp (Immediate Operand)

Sep-16

Operands

19

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 20

Operands of the Computer Hardware

• Các lệnh toán học sử dụng các toán hạng thanh ghi

• MIPS có một tập thanh ghi 32 × 32-bit

• Gọi tên theo chức năng các thanh ghi

Design Principle 2: Smaller is faster

Trang 21

Representing Instructions in the Computer

• Holds thirty-two 32-bit registers

MIPS Register File

Register File

src1 addr src2 addr dst addr write data

32 bits

src1 data

src2 data

32 locations

32 5

32

5 5 32

 Faster than main memory

- But register files with more locations are slower (e.g., a 64 word file could be as much

as 50% slower than a 32 word file)

- Read/write port increase impacts speed quadratically

 Easier for a compiler to use

- e.g., (A*B) – (C*D) – (E*F) can do multiplies in any order vs stack

 Can hold variables so that

- code density improves (since register are named with fewer bits than a memory location)

write control

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 22

Operands of the Computer Hardware

$zero 0 constant 0 ( hardware ) n.a.

$at 1 reserved for assembler n.a.

$ra 31 return addr ( hardware ) yes

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 23

Operands of the Computer Hardware

Trang 24

Operands of the Computer Hardware

Trang 25

Operands of the Computer Hardware

• Bộ nhớ chính được sử dụng cho dữ liệu hỗn hợp

• Ứng dụng cho các phép toán số học

• Bộ nhớ được đánh địa chỉ theo byte

• Các word được sắp xếp trong bộ nhớ

• MIPS is Big Endian

c.f Little Endian: Bit thấp là bit địa chỉ thấp của 1 từ

Memory Operands

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 26

Operands of the Computer Hardware

Memory Operands

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 27

Operands of the Computer Hardware

Trang 28

Operands of the Computer Hardware

add $s1, $s2, $t0

Memory Operand Example 1

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 29

Operands of the Computer Hardware

• C code:

A[12] = h + A[8];

• Compiled MIPS code:

Trang 30

Operands of the Computer Hardware

• Các thanh ghi thì truy xuất nhanh hơn bộ nhớ

• Hoạt động trên dữ liệu bộ nhớ yều cầu nạp và lưu

dữ liệu

• Trình biên dịch phải sử dụng các thanh ghi cho các biến nhiều nhất có thể

Registers vs Memory

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 31

Operands of the Computer Hardware

Trang 32

Operands of the Computer Hardware

• Thanh ghi MIPS 0 ($zero) là hằng số zero

• Hữu dụng cho các phép toán phổ biến

add $t2, $s1, $zero

The Constant Zero

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 33

Review: Signed and Unsigned Numbers

• Given an n-bit number

Unsigned Binary Integers

0 0

1 1

2 n 2 n

1 n 1

Trang 34

Review: Signed and Unsigned Numbers

Review: Unsigned Binary

Trang 35

Review: Signed and Unsigned Numbers

• Given an n-bit number

2s-Complement Signed Integers

0 0

1 1

2 n 2 n

1 n 1

Trang 36

Review: Signed and Unsigned Numbers

• Bit 31 is sign bit

• Non-negative numbers have the same unsigned

and 2s-complement representation

• Some specific numbers

Trang 37

Review: Signed and Unsigned Numbers

Signed Binary

Representation

2 3 - 1 =

-(2 3 - 1) = -2 3 =

1010 complement all the bits

1011 and add a 1

complement all the bits

Trang 38

Review: Signed and Unsigned Numbers

• Biểu diễn một số khi sử dụng nhiều bit hơn

• Trong tập lệnh MIPS

• addi: extend immediate value

• lb, lh: extend loaded byte/halfword

• beq, bne: extend the displacement

• Nhân rộng các bit dấu bên trái

• Examples: 8-bit to 16-bit

Trang 39

Representing Instructions in the Computer

• Design-time metrics:

• Can it be implemented? With what performance, at what costs (design,

fabrication, test, packaging), with what power, with what reliability?

• Can it be programmed? Ease of compilation?

• Static Metrics:

• How many bytes does the program occupy in memory?

• Dynamic Metrics:

• How many instructions are executed? How many bytes does the processor

fetch to execute the program?

• How many clocks are required per instruction?

• How "lean" a clock is practical?

Best Metric: Time to execute the program!

Review : Evaluating ISAs

CPI

Inst Count Cycle Time

depends on the instructions set, the processor

organization, and compilation techniques.

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 40

Representing Instructions in the Computer

1 Instructions are represented as numbers and, as such, are

indistinguishable from data

2 Programs are stored in alterable memory (that can be

read or written to)

just like data

Two Key Principles of Machine

Design

Stored-program concept

 Programs can be shipped as files of

binary numbers – binary compatibility

 Computers can inherit ready-made

software provided they are

compatible with an existing ISA – leads

industry to align around a small

number of ISAs

Accounting prg (machine code)

C compiler (machine code) Payroll data

Source code in C for Acct prg

Memory

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 41

Representing Instructions in the Computer

• Simplicity favors regularity

• fixed size instructions

• small number of instruction formats

• opcode always the first 6 bits

• Smaller is faster

• limited instruction set

• limited number of registers in register file

• limited number of addressing modes

• Make the common case fast

• arithmetic operands from the register file (load-store

machine)

• allow instructions to contain immediate operands

• Good design demands good compromises

• three instruction formats

MIPS (RISC) Design Principles

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 42

Representing Instructions in the Computer

• Phân loại theo chức năng

Trang 43

Lecture review

• Các trường của MIPS

MIPS Instruction Fields

6 bits 5 bits 5 bits 5 bits 5 bits 6 bits

 Op: phép toán cơ bản của lệnh, thương được gọi là opcode(mã lệnh)

 Rt: toán hạngRs : toán hạng thanh ghi thứ nhất

 Rd: toán hạng thanh ghi đích Nơi lưu kết quả của phéptoán

 Shamt: shit amount

 Funct: trường này thường được gọi là mã hàm (functioncode), chọn biến cụ thể của phép toán trong trường mã lệnh

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 44

Lecture review

• Có tất cả bao nhiêu lệnh MIPS được biểu diễn?

• Tầm địa chỉ của lệnh I-TYPE?

• Tầm địa chỉ của lệnh J-Type?

Question

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 45

Lecture review

Có 4 nguyên tắc thiết kế cơ bản:

1 Simplicity favors regularity

2 Smaller is faster

3 Make the common case fast

4 Good design demands good compromises

MIPS (RISC) Design Principles

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 46

Lecture review

Có ba loại toán hạng:

1 Toán hạng thanh ghi (Register Operand)

2 Toán hạng bộ nhớ (Memory Operand)

3 Toán hạng trực tiếp (Immediate Operand)

Sep-16

Operands of the computer hardware

46

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 47

Lecture review

• Các trường của MIPS

MIPS Instruction Fields

6 bits 5 bits 5 bits 5 bits 5 bits 6 bits

 Op: phép toán cơ bản của lệnh, thương được gọi là opcode(mã lệnh)

 Rs : toán hạng thanh ghi thứ nhất

 Rt: toán hạng nguồn thanh ghi thứ hai

 Rd: toán hạng thanh ghi đích Nơi lưu kết quả của phéptoán

 Shamt: shit amount

 Funct: trường này thường được gọi là mã hàm (functioncode), chọn biến cụ thể của phép toán trong trường mã lệnh

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 48

Lecture review

Sep-16

Instruction format

op op op

R format: Các lệnh có các toán hạng là toán hạng thanh ghi

I format: Các lệnh có các toán hạng là toán hạng bộ nhớ

J format: Các lệnh nhảy (Jump)

48

CuuDuongThanCong.com https://fb.com/tailieudientucntt

Trang 49

Lecture review

Sep-16

MIPS instruction class

Instruction class MIPS example

Ngày đăng: 28/01/2020, 23:15

TỪ KHÓA LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm