kiến trúc máy tính trương văn cường ôn thi cuối kỳ sinhvienzone com

31 102 0
kiến trúc máy tính trương văn cường ôn thi cuối kỳ sinhvienzone com

Đ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

COMPUTER ARCHITECTURE CuuDuongThanCong.com https://fb.com/tailieudientucntt Nội dung • Số floating point • Bộ xử lý (The Processor) • Đường liệu • Đường điều khiển • Pipelined Datapath and Control • Hazards • Structural Hazards • Data Hazards • Control Hazards CuuDuongThanCong.com https://fb.com/tailieudientucntt IEEE Floating-Point Format S x single: bits double: 11 bits single: 23 bits double: 52 bits Exponent Fraction ( 1) S (1 Fraction) (Exponent Bias) • S: bit dấu (0 số khôn âm, số âm) • Chuẩn hóa phần lẻ (F): 1.0 ≤ |significand| < 2.0 • Phần mũ: phần mũ thực + Bias • Chắc chắn số mũ không dấu ( ex: 2-1 = 2126-127 , F = 126 thay F= -1) • Chính xác đơn: Bias = 127; Chính xác kép: Bias = 1023 PIPELINED PROCESSOR CuuDuongThanCong.com https://fb.com/tailieudientucntt Single-Precision Range • Giá trị nhỏ • Phần mũ: 00000001 phần mũ thực = – 127 = –126 • Phần lẻ: 00000 significand = 1.0 1.0 ì 2126 1.2 × 10–38 • Giá trị lớn • Phần mũ: 11111110 phần mũ thực= 254 – 127 = +127 • Phn l: 11111 significand 2.0 2.0 ì 2+127 ≈ ±3.4 × 10+38 PIPELINED PROCESSOR CuuDuongThanCong.com https://fb.com/tailieudientucntt Floating-Point Example • Biểu diễn số thực –0.75 • • • • –0.75 = (–1)1 × 1.12 × 2–1 S=1 Fraction = 1000…002 Exponent = –1 + Bias • Single: –1 + 127 = 126 = 011111102 • Double: –1 + 1023 = 1022 = 011111111102 • Single: 1011111101000…00 • Double: 1011111111101000…00 PIPELINED PROCESSOR CuuDuongThanCong.com https://fb.com/tailieudientucntt Floating-Point Example • Giá trị số thực biểu diễn số sau bao nhiêu? 11000000101000…00 • S=1 • Fraction = 01000…002 • Fxponent = 100000012 = 129 x = (1)1 ì (1 + 012) × 2(129 – 127) = (–1) × 1.25 × 22 = –5.0 PIPELINED PROCESSOR CuuDuongThanCong.com https://fb.com/tailieudientucntt MIPS Pipeline • Chia làm tầng, bước tầng IF: Instruction fetch from memory (Nạp lệnh) ID: Instruction decode & register read (Giải mã lệnh & đọc ghi) EX: Execute operation or calculate address (Thực thi phép toán tính địa chỉ) MEM: Access memory operand (truy xuất toán hạng nhớ) WB: Write result back to register (ghi kết vào ghi) PIPELINED PROCESSOR CuuDuongThanCong.com https://fb.com/tailieudientucntt The Five Stages of Load Instruction Cycle Cycle lw IF ID Cycle EX Cycle Mem Cycle WB • IF: Nạp lệnh cập nhật PC • Dec: Nạp ghi giải mã lệnh • Exec: Tính tốn địa nhớ • Mem: đọc liệu từ nhớ • WB: ghi liệu đọc vào ghi PIPELINED PROCESSOR CuuDuongThanCong.com https://fb.com/tailieudientucntt Single Cycle Processor • Datapath • Control 31:26 5:0 Controller ALU Decoder Main Decoder ALUOp[1:0] MemWrite MemWrite RegWrite RegDst ALUSrc Branch PCSrc Zero ALUControl [2:0] MemRead CLK CLK ALUOut Reset ADDR 32 Instr Datapath WriteData 32 Data Memory RD 32 WD ReadData PC ADDR 32 Lecture review CuuDuongThanCong.com Instr RD Instruction Memory MIPS Processor https://fb.com/tailieudientucntt ReadData 32 R-type Instruction Data/Control Flow Add ALUOp Instr[31-26] Add Shift left PCSrc Branch Control Unit MemtoReg MemWrite MemRead ALUSrc RegWrite RegDst Instr[25-21] Read Addr Instruction Memory PC Read Address ovf Instr[31-0] Register Read Instr[20-16] Read Addr Data File Write Addr Read Data Instr[15 Write Data -11] Instr[15-0] 16 Sign Extend zero ALU Address Data Memory Read Data Write Data 32 ALU control Instr[5-0] CuuDuongThanCong.com https://fb.com/tailieudientucntt Data Hazards • Một lệnh phụ thuộc vào việc hoàn thành truy xuất liệu lệnh trước • add sub $s0, $t0, $t1 $t2, $s0, $t3 PIPELINED PROCESSOR CuuDuongThanCong.com https://fb.com/tailieudientucntt One Way to “Fix” a Data Hazard IM Reg DM Reg IM Reg ALU O r d e r add $1, ALU I n s t r Can fix data hazard by waiting – stall – but impacts CPI IM Reg stall stall sub $4,$1,$5 ALU and $6,$1,$7 DM CSE431 Chapter 4B.18 Reg DM Reg Irwin, PSU, 2008 CuuDuongThanCong.com https://fb.com/tailieudientucntt Another Way to “Fix” a Data Hazard and $6,$1,$7 or $8,$1,$9 Reg IM Reg IM Reg IM Reg DM Reg DM Reg DM Reg DM ALU xor $4,$1,$5 IM ALU sub $4,$1,$5 Reg ALU IM ALU O r d e r add $1, ALU I n s t r Fix data hazards by forwarding results as soon as they are available to where they are needed CSE431 Chapter 4B.20 Reg DM Reg Irwin, PSU, 2008 CuuDuongThanCong.com https://fb.com/tailieudientucntt Xung đột liệu Tóm lại, với kỹ thuật forwarding có:   ALU-ALU forwarding hay EX-EX forwarding (hình 1) MEM-ALU forwarding hay MEM-EX forwarding (hình 2) Hình Hình CSE431 Chapter 4B.21 Irwin, PSU, 2008 CuuDuongThanCong.com https://fb.com/tailieudientucntt Cho chuỗi lệnh sau : lw $1, 40($6) add $6, $2, $2 sw $6, 50($1) Trong trường hợp pipeline tầng khơng dùng kỹ thuật nhìn trước (no forwarding), sử dụng lệnh ‘nop’ để giải xung đột xảy (nếu có) chuỗi lệnh Trong trường hợp pipeline tầng có kỹ thuật nhìn trước (forwarding), sử dụng lệnh ‘nop’ để giải xung đột xảy (nếu có) chuỗi lệnh CuuDuongThanCong.com https://fb.com/tailieudientucntt Control Hazards Xung đột điều khiển Một số lệnh nhảy có điều kiện không điều kiện MIPS (branches, jump) tạo xung đột điều kiển Ví dụ xét đoạn chương trình sau: add $1, $5, $6 beq $1, $2, label lw $3, 300($s0) Nếu áp dụng pipeline thông thường, chu kỳ thứ ba pipeline, beq thực thi cơng đoạn ID lệnh lw nạp vào Nhưng điều kiện lệnh beq xảy lệnh thực hiệp tiếp sau khơng phải lw mà lệnh gán nhãn ‘label’, lúc xảy xung đột điều khiên PIPELINED PROCESSOR CuuDuongThanCong.com https://fb.com/tailieudientucntt Control Hazards Time (cycles) 20 beq $t1, $t2, 40 24 and $t0, $s0, $s1 28 or 2C sub $t2, $s0, $s5 30 IM lw $t1, $s4, $s0 $t1 RF $t2 IM and DM - $s0 RF $s1 IM or RF DM & RF $s0 IM sub DM | $s0 RF $s5 CuuDuongThanCong.com IM slt RF DM - $s2 RF $s3 slt slt $t3, $s2, $s3 Flush these instructions $s4 64 RF https://fb.com/tailieudientucntt RF DM $t3 RF CuuDuongThanCong.com https://fb.com/tailieudientucntt Datapath Branch and Jump Hardware Jump PCSrc ID/EX Shift left IF/ID EX/MEM Control Add PC+4[31-28] PC Instruction Memory Read Address Shift left Add Read Addr Data Memory Register Read Read Addr 2Data File Write Addr Write Data 16 Sign Extend Read Data 32 MEM/WB Branch ALU Address Read Data Write Data ALU cntrl Forward Unit CSE431 Chapter 4B.26 Irwin, PSU, 2008 CuuDuongThanCong.com https://fb.com/tailieudientucntt Summary • All modern day processors use pipelining • Pipelining doesn’t help latency of single task, it helps throughput of entire workload • Potential speedup: a CPI of and fast a CC • Pipeline rate limited by slowest pipeline stage • Unbalanced pipe stages makes for inefficiencies • The time to “fill” pipeline and time to “drain” it can impact speedup for deep pipelines and short code runs • Must detect and resolve hazards • Stalling negatively affects CPI (makes CPI less than the ideal of 1) PIPELINED PROCESSOR CuuDuongThanCong.com https://fb.com/tailieudientucntt Assignments • Trong tập này, khảo sát pipeline ảnh hưởng tới chu kỳ xung clock (clock cycle time) processor Giả sử cơng đoạn (stage) pipeline có thời gian thực IF ID EX MEM WB a 300ps 400ps 350ps 500ps 100ps b 200ps 150ps 120ps 190ps 140ps Chu kỳ xung clock cần cho processor processor thiết kế có pipeline khơng pipeline Thời gian cần thiết để thực lệnh lw, sw, add, beq cho trường hợp processor có pipeline khơng pipeline PIPELINED PROCESSOR CuuDuongThanCong.com https://fb.com/tailieudientucntt Assignments • Giả sử lệnh thực thi processor phân rã sau (áp dụng cho câu 4) ALU beq lw sw a 50% 25% 15% 10% b 30% 25% 30% 15% Giả sử khơng có khoảng thời gian rỗi (stalls) xung đột (hazards), phần truy xuất nhớ (MEM) phần truy xuất ghi tập ghi (WB) sử dụng % chu kỳ tồn chương trình lw sw ALU (add, sub, AND, OR, slt) Branch (beq) IF x x x ID x x x EX x x x x x x MEM x x x PIPELINED PROCESSOR CuuDuongThanCong.com WB x https://fb.com/tailieudientucntt Assignments • Giả sử lệnh thực thi processor phân rã sau (áp dụng cho câu ALU beq lw sw 4) a 50% 25% 15% 10% b 30% 25% 30% 15% Giả sử có thiết kế sau: lệnh sử dụng giai đoạn cần có nó, lấy nhiều chu kỳ để hoàn thành, lệnh phải hoàn thành xong lệnh khác nạp vào Thiết kế tạm gọi thiết kế đa chu kỳ Theo kiểu này, lệnh qua cơng đoạn mà thực cần (ví dụ, sw sử dụng cơng đoạn, khơng có cơng đoạn WB) Tính chu kỳ xung clock, so sánh thời gian thực thi thiết kế đa chu kỳ với thiết kế đơn chu kỳ (single cycle design) pipeline (Chú ý: lw: sử dụng stage; sw: stage (không WB); ALU: stage (không MEM), beq stage (khơng WB)) PIPELINED PROCESSOR CuuDuongThanCong.com https://fb.com/tailieudientucntt Assignments • The pipelined MIPS processor is running the following program Which registers are being written, and which are being read on the fifth cycle? add $s0, $t0, $t1 sub $s1, $t2, $t3 and $s2, $s0, $s1 or $s3, $t4, $t5 slt $s4, $s2, $s3 PIPELINED PROCESSOR CuuDuongThanCong.com https://fb.com/tailieudientucntt Using a diagram similar to above Figure show the forwarding and stalls needed to execute the following instructions on the pipelined MIPS processor add $t0, $s0, $s1 sub $t0, $t0, $s2 lw $t1, 60($t0) and $t2, $t1, $t0 CuuDuongThanCong.com https://fb.com/tailieudientucntt ... vào Thi t kế tạm gọi thi t kế đa chu kỳ Theo kiểu này, lệnh qua cơng đoạn mà thực cần (ví dụ, sw sử dụng cơng đoạn, khơng có cơng đoạn WB) Tính chu kỳ xung clock, so sánh thời gian thực thi thiết... kỳ với thi t kế đơn chu kỳ (single cycle design) pipeline (Chú ý: lw: sử dụng stage; sw: stage (không WB); ALU: stage (không MEM), beq stage (khơng WB)) PIPELINED PROCESSOR CuuDuongThanCong .com. .. (Thực thi phép tốn tính địa chỉ) MEM: Access memory operand (truy xuất toán hạng nhớ) WB: Write result back to register (ghi kết vào ghi) PIPELINED PROCESSOR CuuDuongThanCong .com https://fb .com/ tailieudientucntt

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

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan