# Static Timing Analysis(STA) ###### tags: `Digital IC Design` [回到主頁面](https://hackmd.io/@derek8955/BkK2Nb5Jo/https%3A%2F%2Fhackmd.io%2FdpcBlBL8TlShpQ-wSi9Quw) ### <font color="blue"> What is STA </font> - STA 是一個驗證 timing 是否有 violation 的方法,透過檢查電路中所有 path 的 Timing arc(pin 與 pin之間的 timing 關係)是否符合 constraint 的要求 - DTA( Dynamic Timing Analysis ) 是另外一種驗證方法,利用測試資料對整個電路跑 simulation > DTA 因為要對所有電路跑過一次邏輯模擬,相對速度不會比 STA 快。而且 STA 可以確保所有的 Timining path 有被 detect ### <font color="blue"> Goal of STA</font> - 檢查 synthesis 之後 timing 是否有 violation ( Logic synthesis ) - 檢查 scan chain insertion 之後 timing 是否有 violation ( DFT ) - 檢查 Place & Route 之後 timing 是否有 violation ( APR ) |![1000010153](https://hackmd.io/_uploads/HkebGy_Eel.jpg)| |:---:| |Ref:[6] STA確認的各種Timing(斜體字為user指定;直體字為vendor提供)| ### <font color="blue"> Start Points and End Points </font> - Timing path start points include: - Clock pins of registers - Input ports - Timing path end points include: - All input pin of registers except clock pins - Output ports ### <font color="blue"> Timing Path </font> 在數位電路中有四條 Timing path: - in2reg (Path1) : input(port) to register(except clock pins) - reg2reg (Path2) : register(Clock pins) to register(except clock pins) - reg2out (Path3) : register(Clock pins) to output(port) - in2out (Path4) : input to output ( 盡量避免這條路徑 ) |![](https://i.imgur.com/z0dItdu.png)| |:---:| |Ref : [1]| ### <font color="blue"> Term definition </font> - setup time : 輸入訊號必須在 clock edge 之前 tsu 即穩定 - hold time : 輸入訊號必須在 clock edge 之後 thd 都保持穩定 :::success tsu 與 thd 是製程提供的 ::: - recovery time : reset de-assert後,恢復到正常狀態時必須在clock edge 前的一段時間到來,才能保證clock能有效恢復到正常狀態(類似setup time) - removal time: reset de-assert必須在clock edge 後一段時間才能改變(類似 hold time) |![](https://i.imgur.com/w10YuoN.png)|![](https://hackmd.io/_uploads/BJ_nO7YNxl.jpg)| |:---:|:---:| | setup time & hold time | removal time & recovery time| |Ref : [2]| Ref : [7]| - nochange: 某些訊號需要進行 no-change 時序檢查,以確保它們不會在週期性訊號(例如時鐘)的作用期間內切換(變化) - max_skew: 檢查同一個時鐘在不同 flip-flop 間的到達時間差(skew)是否超出允許範圍。太大的 skew 會讓 setup 或 hold time margin 被吃掉 - min_period: 檢查兩個相鄰時鐘邊緣之間的最小時間間隔是否小於某個限制。如果週期太短,flip-flop/logic 沒時間完成運算 → 設計會錯亂 - min_pulse_width: 檢查 clock 的高電位或低電位維持的時間是否太短。如果 clock 高或低的時間太短(glitch),FF 可能無法辨識為一個合法的 edge 導致 FF 沒有正確觸發,產生 meta-stability、資料錯誤 - clock gating check - setup: 檢查 gating cell 的 enable訊號(L1/A),是否在時鐘 edge 來臨前有足夠的 setup 時間穩定下來 - hold: Clock gating hold check 是檢查 enable 訊號(L1/A)在 clock gating cell觸發時,是否維持一段時間不變,避免 clock glitch 或錯誤 gating。 |![1000010181](https://hackmd.io/_uploads/ryclXBtNee.png)|![1000010182](https://hackmd.io/_uploads/HJybmrFExx.png)| |:---:|:---:| |clock gating |waveform of clock gating check| - data to data check: 檢查「兩個 data 訊號彼此之間的時序關係」。例如數據訊號要比ready訊號早穩定一段時間,並且ready訊號assert後一段時間才可以toggle數據訊號 - contamination delay(tcd) : 輸入訊號改變之後 Y 開始改變的時間 - propagation delay(tpd) : 輸入訊號改變之後 Y 改變至穩定的時間 - Clock-to-Q contamination delay : clock edge 到 Y 開始改變的時間 - Clock-to-Q propagation delay : clock edge 到 Y 改變至穩定的時間 |![](https://i.imgur.com/rlEeTyo.png)|![](https://i.imgur.com/UOVGKtp.png)| |:---:|:---:| |contamination delay & propagation delay|Clock-to-Q contamination/propogation delay| |Ref : [3]|Ref : [4]| ### <font color="blue"> Setup Time Criterion & Hold Time Criterion </font> - Setup Time Criterion : (Tcycle + tskew) >= (tpcq + tpd + tsetup) data required time( data 到達所需時間 ) : Tcycle + tskew data arrival time( data 實際到達的時間 ) : tpcq + tpd + tsetup > 1. Tcycle : clock period > 2. 線路中難免都會有電阻,所以兩個 cell 收到 clock 的時間點會有所不同,我們稱彼此之間的差值為 clock skew > 3. tpcq : DFF_1 clock to q 所需的時間 |![](https://i.imgur.com/HnPqzxH.png)|![](https://i.imgur.com/ZqHMMvG.png)| |:---:|:---:| |Ref : [5] |Setup Time Criterion | - Hold Time Criterion : (tccq + tcd) >= (thold + tskew) data required time : tccq + tcd data arrival time : thold + tskew > 1. tccq : DFF_2 clock to q 所需的時間 |![](https://i.imgur.com/HnPqzxH.png)|![](https://i.imgur.com/bMtgMct.png)| |:---:|:---:| |Ref : [5] | Hold Time Criterion | ### <font color="blue"> Timing Violation </font> designer 必須權衡 Performance & Power & Area,但在這之前必須先解決 Timing 問題,確保所有的 Timing path 都不可有 Timing violation,否則會導致 metastable 的問題產生 - Setup Time Violation : 一個 cycle 內太多件事要做,可以設計 [pipeline](https://hackmd.io/lmsj4cLzTS-_IUq3GkHo8A) 或是調高 clock period > Input delay( 見 [synthesis flow](https://hackmd.io/on4SdHtHSc2pa9BD8k2u4g) ) 不適當也會造成 setup time violation - Hold Timiming Violation : 代表 delay 不足,可以在 violated path 加上 buffer > hold time 若有 violation,在 clock tree synthesis 之後才能改善 ### <font color="blue"> Reference Image </font> [1] https://www.synopsys.com/glossary/what-is-static-timing-analysis.html [2] http://www.vlsi-expert.com/2011/04/static-timing-analysis-sta-basic-part3a.html [3] https://www.sciencedirect.com/topics/computer-science/contamination-delay [4] https://slideplayer.com/slide/17358331/ [5] https://medium.com/mirkat-x-blog/iclab-lab04-note-6a19d03b8d42 [6] https://zhuanlan.zhihu.com/p/392478843 [7] https://www.intel.com/content/www/us/en/docs/programmable/683539/20-4/recovery-and-removal-checks.html ### <font color="blue"> Apendix --- 為何 flip-flop 需在 clock edge 的前後保留一段準備時間 </font> https://www.edn.com/understanding-the-basics-of-setup-and-hold-time/ ### <font color="blue"> Apendix --- setup/hold youtube介紹影片 </font> https://www.youtube.com/watch?v=xCA54Qu4WtQ&list=PLpCkjM331Aa8JNoZ1s1o1txve2wlf9pCP