112 年 國立中正大學電機工程學系碩士班晶片系統組《計算機組織》

📄 試題原卷 免費註冊後即可對照原始考卷 PDF免費註冊

第 1 題20 分

  1. (20%) An engineer designs a watching dog timer for MIPS platform using D type flip-flops as follows. With the initial condition (Ω,Ω˙)=(1,1)(\Omega, \dot{\Omega}) = (1,1), what are the outputs from A0 to A2 at 5th positive clock edge? Why?

🖼️【此處有附圖,請對照原卷】

🖼️ 本題含圖表,以下為原卷對應頁面:
原卷第 2 頁

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

圖中的 D 型正反器時脈端有「三角形+反相泡泡」符號,表示它是負緣觸發:只有時脈由高電位降至低電位時,正反器才會取樣 D 輸入並更新輸出。時脈由低電位升至高電位的正緣不會觸發更新。

解題方法

題目問的是第 5 個正時脈緣。逐一檢查每個正緣,因為它們都不是此正反器的觸發邊緣,所以輸出維持初始值。圖中的 Clear 接至 Logic 1,未啟動清除功能。

🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 2 題20 分

  1. (20%) A timing sequence for writing data to the memory is as shown below. Please re-draw a timing sequence with the conditions of (a) memory is triggered by clock's positive edge, (b) write enable is high level triggered, (c) data's hold time is 3/4 T, (d) data's setup time is 1/2 T.

🖼️【此處有附圖,請對照原卷】

🖼️ 本題含圖表,以下為原卷對應頁面:
原卷第 2 頁

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

本題考查記憶體寫入時序中的三個基本條件:

  1. 正緣觸發(positive-edge triggered):記憶體在時脈由低電位轉為高電位的瞬間取樣資料。

  2. 高電位有效的寫入致能(active-high write enable):WE=1WE=1 時允許寫入,WE=0WE=0 時禁止寫入。

  3. 資料設定時間與保持時間:

    • 設定時間 tsut_{su}:資料必須在取樣時脈正緣前穩定的時間。
    • 保持時間 tht_h:資料在取樣正緣後仍須維持穩定的時間。

題目給定:

tsu=12Tt_{su}=\frac{1}{2}T th=34Tt_h=\frac{3}{4}T

因此,若記憶體於 t=0t=0 的時脈正緣寫入資料,資料必須於 t=−12Tt=-\frac{1}{2}T 前穩定,並持續穩定至 t=34Tt=\frac{3}{4}T。

解題方法

以記憶體取樣正緣為時間基準:

  • 寫入時脈正緣設定在 t=0t=0。
  • 資料由 t=−12Tt=-\frac{1}{2}T 開始穩定。
  • 資料持續到 t=34Tt=\frac{3}{4}T 才能改變。
  • 因為 WEWE 為高電位有效,所以在整個寫入有效期間令 WE=1WE=1。
  • 位址訊號也必須在正緣前穩定,並至少維持至記憶體完成取樣。

所需時序如下:

🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 3 題20 分

  1. (20%) Assume two different CPUs designs running with the same instruction set architecture as shown below. The CPU1 is with a clock rate of 2.5 GHz, and the CPU2 is with a clock rate of 3 GHz. Given a program with a dynamic instruction count of 1.0E6 instructions divided into classes as follows: 10% class A, 20% class B, 50% class C, and 20% class D.

CPI for each instruction class

ABCD
CPU1 CPI1233
CPU2 CPI2222

(a). (10%) Please provide the global CPI for each case?
(b). (10%) What is the clock cycles required for each CPU design?

🖼️ 本題含圖表,以下為原卷對應頁面:
原卷第 2 頁原卷第 3 頁

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

整體 CPI 是各指令類別 CPI 的加權平均,權重為該類指令占總指令數的比例:

Global CPI=∑i(指令比例i×該類 CPIi)\text{Global CPI}=\sum_i \left(\text{指令比例}_i \times \text{該類 CPI}_i\right)

總時脈週期數則為:

Clock cycles=Dynamic instruction count×Global CPI\text{Clock cycles}=\text{Dynamic instruction count}\times\text{Global CPI}

解題方法

CPU1 的整體 CPI:

0.10×1+0.20×2+0.50×3+0.20×3=0.10+0.40+1.50+0.60=2.60.10\times1+0.20\times2+0.50\times3+0.20\times3 =0.10+0.40+1.50+0.60 =2.6

CPU2 的每類指令 CPI 都是 2,因此:

🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 4 題20 分

  1. (20%) Assume the instructions are as follows, and the bne is determined at the output of the register file.
    (a). (10%) Please plot the MIPS five-stage pipeline sequence diagram without forwarding. (10%)
    (b). (10%) Please re-plot the diagram of question (a) with forwarding. (10%)

Instructions:
add 10,10, 21, 9lw9 lw 9, 20(10)bne10) bne 10, $9, 1000

登入後即可作答並保存紀錄。

這一題的完整詳解

參考書等級:大學教材(例:《Computer Organization and Design, MIPS Edition》)

(a) 五階段不轉發流水線時序表

Cycle →1234567891011
add 10,10,21,$9IFIDEXMEMWB
lw 9,20(9,20(10)IFIDEXMEMWB
bne 10,10,9,1000IFIDEXMEM

說明

  • bne 的比較在 ID 階段,必須等到 add 完成 WB($10 已寫回)以及 lw 完成 WB(
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 5 題20 分

  1. (20%) Translate the following loop into C. Assume that the C-level integer i is held in register t1,t1, s2 holds the C-level integer called result, and $s0 holds the base address of the integer MemArray.

Instructions:
addi t1,t1, 0, 0
LOOP:
lw s1,0(s1, 0 (s0)
add s2,s2, s2, s1addis1 addi s0, s0,4addis0, 4 addi t1, t1,1sltit1, 1 slti t2, t1,100bnet1, 100 bne t2, $s0, LOOP

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

本題考查 MIPS 組合語言與 C 語言迴圈、陣列存取及指標位址運算的對應關係:

  • $0 永遠為 00。
  • lw $s1, 0($s0):從 $s0 指向的記憶體位置載入一個整數。
  • 一個整數占 44 bytes,因此 $s0 += 4 等同於陣列指標前進一格。
  • slti $t2, $t1, 100 會設定:
t2={1,i<1000,i≥100t2 = \begin{cases} 1, & i<100\\ 0, & i\ge 100 \end{cases}
  • bne 的意思是兩個暫存器內容不相等時跳躍。

題面指令的關鍵問題

題目最後一行寫成:

bne $t2, $s0, LOOP

這會比較條件值 $t2 與記憶體位址 $s0,無法形成「i<100i<100 時繼續迴圈」的正常控制流程。依題意,該行應為:

bne $t2, $0, LOOP

也就是 $t2\ne0$ 時回到 LOOP`。以下依此合理假設說明命題意旨。

逐行解讀

MIPS 指令C 語言意義
addi $t1, $0, 0i = 0
lw $s1, 0($s0)讀取目前的 MemArray[i]
add $s2, $s2, $s1result += MemArray[i]
addi $s0, $s0, 4陣列位址前進一格
addi $t1, $t1, 1i++
slti $t2, $t1, 100計算 i < 100
bne $t2, $0, LOOP若 i < 100,回到迴圈開頭

初始時:

i=0,s0=&MemArray[0]i=0,\qquad s0=\&\text{MemArray}[0]

第 kk 次進入迴圈時:

s0=&MemArray[k]s0=\&\text{MemArray}[k]

因此 lw 會讀取:

MemArray[0],MemArray[1],…,MemArray[99]\text{MemArray}[0],\text{MemArray}[1],\ldots,\text{MemArray}[99]

第 100100 次執行完畢後:

i=100i=100

此時 slti 產生 $t2=0$,不再跳回 LOOP。

C 語言翻譯

🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

其他考古題