###### tags: `co` `thu`
# 計算機組織109
## 1.(10%)請說明您對於Apple M1 CPU的影片中所提到的架構與本課程的相關性有哪些?

## 2.(10%) How about the different between cache memory (SRAM) and RAM? (HINT: from organization, cost, speed, size, and applications)
| | organization | cost |speed|size|application|
| -------- | -------- | -------- |-------- |-------- |-------- |
| SRAM | 一個flip-flop和兩個transistors,不須更新電路(6個transistors和2個NOT gate | 貴 |快 |小 |Cache |
| DRAM | 1bit有一個電容和一個transistors,須更新電路| 便宜 |慢 |大 |Main memory(RAM) |
## 3.(30%) Please draw these two cache diagrams for MIPS, this cache specification of processor is listed as bellows:
- The size of maximum memory (RAM) space is 4G Bytes
- The size of cache memory is 4M Bytes
- Cache line size is 4 Bytes (32bits)
- You can refer the following cache diagram of MIPS (4-way) for drawing MIPS processor cache diagram
(a) Please draw the diagram for Direct Mapping (1-way set-associated) cache (tag ?bit : line ?bit : word ?bit), please calculate the total SRAM space needed for this 4MB cache memory.
$4G=2^{32}$,需要$32bits$
$4=2^2$,word有$2bits$
$\frac{4M}{4}=2^{10}$,line有$10bits$
$32-2-10=20$,tag有$20bits$
$\frac{32+20+1}{32}\times 4KB=6.625KB$
(b) Please draw the diagram for 2-way set-associated cache (tag ?bit : set ?bit : word ?bit), please calculate the total SRAM space needed for this 4MB cache memory.
$4G=2^{32}$,需要$32bits$
$4=2^2$,word有$2bits$
$\frac{4M}{4}=2^{10}$,$2=2^1$,$10-1=9$,set有9$bits$
$32-9-2=21$,tag有$21bits$
$\frac{32+21+1}{32}\times 4KB=6.75KB$
(c) Please draw the diagram for 16-way set-associated cache (tag ?bit : set ?bit : word ?bit), please calculate the total SRAM space needed for this 4MB cache memory.
$4G=2^{32}$,需要$32bits$
$4=2^2$,word有$2bits$
$\frac{4M}{4}=2^{10}$,$16=2^4$,$10-4=6$,set有6$bits$
$32-6-2=24$,tag有$24bits$
$\frac{32+24+1}{32}\times 4KB=7.125KB$
## 4.(16%) Please calculate the average access time of this hard disk for transferring an 4GB video data file. As we known, the seek time of this HD is 0.5ms, spindle speed is 72000rpm, sectors per track is 512, and byes per sector is 4096 bytes (advanced format).
公式為
$$T_a=T_s+\frac{1}{2r}+\frac{b}{rN}$$
so:
$$T_a=0.5+\frac{1}{2\cdot \frac{72000}{60}}+\frac{4\cdot 2^{30}}{\frac{72000}{60}\cdot 4096\cdot 512}$$
## 5.(20%) Please draw diagrams and describe the functions in detail for RAID 0, RAID 1, and RAID 10, and RAID 5.
RAID 0:
1、沒有多餘的磁碟
2、Data striped across all disks
3、循環striping
4、提高速度
5、多個資料需求可能出現在不同磁碟上
6、disk平行查找
7、一組資料可能跨多個磁碟
| DISK1 | DISK2 |
| -------- | -------- |
| $A1$ | $A2$ |
| $A3$ | $A4$ |
RAID 1:
1、兩組以上硬碟相互做鏡像
2、Data is striped across disks
3、兩份複製的資料分別放在不同的disk
4、Read from either
5、Write to both
6、回復容易(更換disk後重新做鏡像)
7、昂貴
| DISK1 | DISK2 |
| -------- | -------- |
| $A1$ | $A1'$ |
| $A2$ | $A2'$ |
| $A3$ | $A3'$ |
| $A4$ | $A4'$ |
RAID 10:
1、先分割資料再鏡像,以RAID 1作為最低組合
2、當有一個磁碟受損,其餘硬碟仍可運作
| DISK 1 | DISK 2 | DISK 3 |DISK 3 |
| -------- | -------- | -------- |-------- |
| $A1$ | $A1'$ | $A2$ |$A2'$ |
RAID 5:
1、同位元錯誤檢測循環分配在每個磁碟
2、N個disk用戶需要N+1個disk
3、常用於網路服務器
| DISK1 | DISK2 |DISK3 |
| -------- | -------- |-------- |
| $A1$ | $A2$ |$P_{A1、A2}$ |
| $A3$ | $P_{A3、A4}$ | $A4$ |
| $P_{A5、A6}$ | $A6$ |$A5$ |
## 6.(15%) Please describe the functions of DMA in detail.
1、DNA controller 從CPU接管I/O
2、會偷取CPU閒置時間
3、允許一個設備直接讀寫系統記憶體而不需CPU參與
## 7.(8%)請問下列各種RAID ,至少需要幾顆硬碟才可達到其功能?
RAID 0:2
RAID 1:2
RAID 10:4
RAID 2:3
RAID 3:3
RAID 4:3
RAID 5:3
RAID 6:4
## 8.(6%) Please describe the functions of Data Buffering.
1、資料以快速突發的方式從主記憶體傳輸到I/O設備
2、資料在I/O設備中緩衝再以它本身的速度傳送至電腦周邊的設備