# 2025年4月30日 一對一討論 cache > contributed by < `JeffBla` > ## Q1: 為什麼 cache 越慢的範圍越大 ![image](https://liujunming.top/images/2019/4/1.jpg) 1. 擁有較大的搜索範圍,當資料範圍離存取位置較近,則能夠馬上的存取,但若較遠,就需要搜索,如硬碟的 Seek time (移動驅動臂到正確的磁軌)、Rotational delay (等待磁盤轉到正確的磁區)。 2. 各元件的運行速度不同,如: (1). cache:bitlines 與 wordline 的充電,電晶體的運作和放大器讀取。 (2). 硬碟則是需要驅動臂移動讀寫頭到正確的磁軌,磁盤旋轉到正確磁區,讀取頭偵測並將資料轉換成電子訊號。 ## Q2: cache 讀取是快的但寫入是慢的。但為什麼? ### cache 的組成 ![image](https://computationstructures.org/lectures/caches/slides/Slide04.png) cache 由 SRAM cell 組成,這裡我們看到了 8 位置 SRAM 陣列的元件佈局,其中每個位置都保存 6 位元資料。透過 wordlines 選擇要操作的資料。 bitlines 與 drivers 則負責寫入與讀取的電位操作。 ![image](https://computationstructures.org/lectures/caches/slides/Slide05.png) SRAM cell 由兩個 CMOS inverter 組成,形成 1 與 0 的兩種狀態,本單元提供穩定的存儲,只要有電源,逆變器的抗噪能力就能確保邏輯值得以維持,即使任一逆變器輸入端存在雜訊。 ### SRAM 讀取 ![image](https://computationstructures.org/lectures/caches/slides/Slide06.png) 其順序如上圖,值得注意的是,不須真的等到電位下降到有效邏輯電平,利用 Sense amplifiers 快速檢測兩條位線之間產生的微小電壓差並產生適當的數位輸出。 ![image](https://hackmd.io/_uploads/Hy_n0E1ble.png) 讀取的主要延遲為 bitlines 的電容 $C$ 與 sense amplifiers 的靈敏度 $\Delta V$。 ![image](https://hackmd.io/_uploads/Byzi1wxbxx.png) ### SRAM 寫入 ![image](https://hackmd.io/_uploads/SkbR4XxZgl.png) 其順序如上圖,bitlines drivers 設計的比單元內的弱反相電晶體(尤其是 PMOS 電晶體)更強,這樣一來 BL/BL̅ 的輸入將能夠覆寫先前資料。 寫入時需要將先前資料覆寫,以翻轉其內部狀態,然而,不同於讀取,此電位變化過程無法被大幅縮減,若減少太多,則會導致覆寫失敗,也就是必須保證最小寫脈衝寬度、資料有效時間和寫入恢復;內部「高節點」達到 VDD 的 90%。 ![image](https://hackmd.io/_uploads/r1yqkDlbex.png) 其對應的比較如下: | Operation | Bitline Swing Typical | Reason | | -------- | -------- | -------- | | Read | Very small (~100–250 mV) | Small swing to detect data without disturbing it | | Write | Moderate to full (e.g., ~0.5–1 V for VDD = 1 V) | Full swing needed to overwrite existing data | ## ref [Computation structures - L14: The Memory hierarchy by The staff of M.I.T. 6.004](https://computationstructures.org/lectures/caches/caches.html#5) [DIGITAL ELECTRONICS SYSTEM DESIGN by PROF. IRIS BAHAR in BROWN School of Engineering](https://www.brown.edu/Departments/Engineering/Courses/En163/Lectures/ENGN1630-23-sram.pdf) [Lecture 14: Memory Elements by Mark McDermott in The University of Texas at Austin](https://users.ece.utexas.edu/~mcdermot/vlsi1/main/lectures/lecture_14.pdf)