免費詳解 / 中山 / 硬體 / 103

103 中山資工所考古題解答|硬體逐題詳解

103 中山資工所硬體考古題的逐題詳解,共 9 題,免費公開。

逐題詳解

112%

Consider two different implementations of the same instruction set architecture. There are four classes of instructions, A, B, C, and D. The clock rate and CPI of each implementation are given in the following table.

Clock RateCPI Class ACPI Class BCPI Class CCPI Class D
(a)P12.5 GHz1233
P23 GHz2222
(b)P12.5 GHz21.521
P23 GHz1211

(a) Given a program with 106 instructions divided into classes as follows: 10% class A, 20% class B, 50% class C, and 20% class D, which implementation is faster? (7%)

(b) What is the global CPI for each implementation? (5%)

題目的表有 (a)、(b) 兩組 CPI,兩組都算

global CPI \(=\sum f_i\,\text{CPI}_i\),時間 \(=\dfrac{IC\times\text{CPI}}{\text{clock}}\),\(IC=10^6\)

表 (a) P1:\(0.1\cdot1+0.2\cdot2+0.5\cdot3+0.2\cdot3=2.6\)  P2:\(2\)

\(T_{P1}=\dfrac{10^6\cdot2.6}{2.5\times10^9}=1.04\) ms,\(T_{P2}=\dfrac{10^6\cdot2}{3\times10^9}\approx0.667\) ms

表 (b) P1:\(0.1\cdot2+0.2\cdot1.5+0.5\cdot2+0.2\cdot1=1.7\)  P2:\(0.1\cdot1+0.2\cdot2+0.5\cdot1+0.2\cdot1=1.2\)

\(T_{P1}=\dfrac{1.7\times10^6}{2.5\times10^9}=0.68\) ms,\(T_{P2}=\dfrac{1.2\times10^6}{3\times10^9}=0.4\) ms

CPI 表P1 global CPIP2 global CPIP1 時間P2 時間較快
(a)2.62.01.04 ms0.667 msP2(快 1.56 倍)
(b)1.71.20.68 ms0.4 msP2(快 1.7 倍)
214%

(a) \((520)_{10}=(\ \ \ )_8=(\ \ \ )_{16}\). (4%)

(b) Convert the decimal number −320 into signed 10-bit binary number in the 2's complement representation. (2%)

(c) Assume that signed numbers are stored in 10-bit words in 2's complement representation. What is the result of \((256)_{10}+(257)_{10}\)? (4%)

(d) Show the IEEE 754 binary representation of the number \((-0.75)_{10}\) in single precision. (4%)

(a) \(520=512+8=1\cdot8^3+0\cdot8^2+1\cdot8+0\);\(520=2\cdot256+0\cdot16+8\)

\((1010)_8=(208)_{16}\)

(b) \(320=256+64=0101000000_2\);取反 \(1010111111\),加 1

1011000000

\(-512+128+64=-320\)

(c) 10-bit 範圍 \(-512\sim511\),\(256+257=513\) 超出

\(0100000000+0100000001=1000000001\),兩正數相加得到 sign bit 1 → overflow

overflow(位元為 1000000001,讀成 \(-511\),結果錯誤)

(d) \(-0.75=-1.1_2\times2^{-1}\);sign \(=1\),exponent \(=-1+127=126=01111110_2\),fraction \(=1000\ldots0\)

1 01111110 10000000000000000000000 (0xBF400000)

312%

True or False Questions: (each 2%)

(a) A multi-core processor consists of multiple chips, each containing a processor.

(b) A server is a computer composed of hundreds to thousands of processors and terabytes of memory.

(c) Access time to random access memory (RAM) is longer than access time to hard disk.

(d) Assembly language consists of commands that processors understand.

(e) The application software is software/programs developed by the users.

(f) NaN in IEEE 754 can be the result of dividing 0 by 0 (0/0).

(a) multi-core 是一顆晶片上有多個 core → F

(b) 數百到數千 processor、TB 級記憶體是 supercomputer 的描述 → F

(c) RAM 為 ns 級,disk 為 ms 級,RAM 較短 → F

(d) processor 懂的是 machine language,assembly 要經 assembler 翻譯 → F

(e) application software 是開發者寫給使用者用的程式,不是使用者自己開發 → F

(f) \(0/0\) 為 invalid operation,結果 NaN → T

(a)F (b)F (c)F (d)F (e)F (f)T

410%

Consider the segment of MIPS assembler code below.

lw   $v1, 0($a0)
add  $v2, $v2, $v1
sw   $v2, 0($a1)
addi $a0, $a0, 1

(a) How many times is instruction memory accessed? How many times is data memory accessed? (Count only accesses to memory, not registers.) (6%, 3% each)

(b) What are the addressing modes used in the four instructions? (4%)

(a) 每條指令 fetch 一次,instruction memory:4 次

只有 lw(讀)與 sw(寫)碰 data memory:2 次

(b)

指令addressing mode
lw $v1, 0($a0)base (displacement)
add $v2, $v2, $v1register
sw $v2, 0($a1)base (displacement)
addi $a0, $a0, 1immediate
514%

The latency of a block of digital logic is the time needed to do the work in the block. Assume that logic blocks needed to implement a processor's datapath have the following latencies:

I-MemAddMuxALUReg'sD-MemSign-ExtendShift-Left-2
200ps70ps20ps90ps90ps250ps15ps10ps

Consider the following single-cycle datapath using the above logic blocks (PC, Add, Shift-left-2, Registers, Sign-extend, ALU, Data memory, muxes).

(a) What is the clock cycle time if the only types of instructions we need to support are ALU instructions (ADD, AND, etc.)? (5%)

(b) What is the clock cycle time if we only have to support LW (load word) instructions? (5%)

(c) What is the clock cycle time if we must support ALU, branch, load/store instructions? (4%)

(Hint: find the overall latencies of the blocks in the longest path required to execute an instruction.)

clock 取最長路徑;mux 只算被選中的那條;sign-extend(15)、shift-left-2(10)與 Reg 讀(90)平行,被蓋掉

(a) ALU 指令:I-Mem → Reg 讀 → ALUSrc mux → ALU → MemtoReg mux → Reg 寫

\(200+90+20+90+20+90=510\)

510 ps

(b) LW:I-Mem → Reg 讀 → ALU → D-Mem → MemtoReg mux → Reg 寫

ALUSrc 選 sign-extend:它在 \(200+15=215\) 就好,經 mux 235,早於 Reg 讀完的 \(290\),mux 的 20 不用另算

\(200+90+90+250+20+90=740\)

740 ps

(c) 各類指令的最長路徑

指令路徑延遲
ALUI-Mem + Reg + Mux + ALU + Mux + Reg510
LWI-Mem + Reg + ALU + D-Mem + Mux + Reg740
SWI-Mem + Reg + ALU + D-Mem630
BranchI-Mem + Reg + Mux + ALU + Mux420

740 ps

若寫入暫存器的 90 ps 不計,(a) 為 420 ps、(b) 與 (c) 為 650 ps。

610%

Let the above datapath be implemented with pipelining. Assume that individual stages of the datapath (Instruction Fetch, Instruction Decode, Execution, Memory access, Write Back) have the following latencies:

IFIDEXEMEMWB
250ps350ps150ps300ps200ps

(a) What is the clock cycle time in a pipelined and non-pipelined processor? (5%)

(b) What is the total latency of an LW instruction in a pipelined and non-pipelined processor? (5%)

(a) pipelined:取最慢的 stage(ID)

non-pipelined:一個 cycle 走完全部 \(250+350+150+300+200=1250\)

pipelined 350 ps,non-pipelined 1250 ps

(b) pipelined:LW 走 5 個 stage,每個 stage 一個 350 ps 的 cycle,\(5\times350=1750\)

non-pipelined:1250

pipelined 1750 ps,non-pipelined 1250 ps

pipeline 增加的是 throughput,單一指令的 latency 反而變長。

78%

Assume that you are using a standard 5-stage pipelined processor (as shown in Problem 6) to execute the following MIPS instructions:

lw  $1, 40($6)
add $6, $2, $2
sw  $6, 50($1)

(a) Indicate dependences and their type. (4%)

(b) Assume there is no forwarding in this pipelined processor. Indicate hazards and add NOP instructions to eliminate them. (4%)

(a)

register指令對型態
$1lw → sw(lw 寫、sw 當 base 讀)RAW
$6add → sw(add 寫、sw 讀來存)RAW
$6lw → add(lw 先讀 $6 當 base、add 後寫)WAR

(b) 寫入在 WB、讀取在 ID,同一 cycle 前半寫、後半讀

lw:IF1 ID2 EX3 MEM4 WB5  add:IF2 ID3 EX4 MEM5 WB6  sw 在 cycle 4 ID

sw 要讀 $1:lw 在 cycle 5 寫回,sw 的 ID 要 \(\ge5\);sw 要讀 $6:add 在 cycle 6 寫回,sw 的 ID 要 \(\ge6\) → sw 要延後 2 個 cycle

hazard 是 (lw, sw)、(add, sw) 兩個 RAW;WAR 在 in-order pipeline 不會有 hazard

lw  $1, 40($6)
add $6, $2, $2
nop
nop
sw  $6, 50($1)

插 2 個 NOP 後 sw 的 ID 在 cycle 6,$1、$6 都已寫回。若寫與讀不能在同一 cycle,要 3 個 NOP。

812%

Cache system

(a) Consider a direct-mapped cache with 16KB of data and 16-byte blocks, assuming a 32-bit address. What is the length of the tag field? How many total bits are required, assuming a valid bit is used? (6%)

(b) Assume an instruction cache miss rate for gcc of 2% and a data cache miss rate of 4%. If a machine has a CPI of 2 without any memory stalls and the miss penalty is 40 cycles for all misses, determine how much faster a machine would run with a perfect cache that never missed. Assume 36% of instructions are loads/stores. (6%)

(a) block 數 \(=16\text{KB}/16\text{B}=1024=2^{10}\)

offset 4 bits,index 10 bits,tag \(=32-10-4=18\) bits

每個 block:data \(16\times8=128\) + tag 18 + valid 1 \(=147\) bits

tag 18 bits;總共 \(1024\times147=150{,}528\) bits(147 Kbits)

(b) I-cache stall:\(1\times0.02\times40=0.8\)

D-cache stall:\(0.36\times0.04\times40=0.576\)

CPI \(=2+0.8+0.576=3.376\);perfect cache 的 CPI \(=2\)

\(\dfrac{3.376}{2}=1.688\) → perfect cache 約快 1.69 倍

98%

Briefly explain the following terms: (a) Page fault (4%) (b) Direct memory access (DMA) (4%)

(a) page fault:程式存取的 page 不在 main memory(page table 的 valid bit 為 0)時引發的 exception;OS 從 disk 把該 page 讀進一個 frame、更新 page table,再重新執行原指令

(b) DMA:I/O 裝置的 controller 不經 CPU、直接與 main memory 搬資料的機制;CPU 只設定來源、目的位址與長度,搬完由 controller 發 interrupt 通知,省下逐字搬運的 CPU 負擔

109–115 的詳解也是這樣寫的。

國立中山大學 109–115 的詳解收錄在付費版;106–115 全年度完整詳解共 236 頁,逐題推導。

購買 · NT$ 850 看中山其他免費詳解

其他年度與考科

同一年的其他科

同一科的其他年度

聯絡我們

題目有錯、詳解看不懂,都歡迎來信

想許願補哪一份、對購買有疑問也可以,收到後會盡快回覆。

william.chou.123123@gmail.com