# VLSI final 姓名:劉祐瑋 學校:國立清華大學 學號:110020015 # 目錄 - [完成度](#完成度) - [環境設定](#環境設定) - [基本操作參考資料](#基本操作參考資料) - [Coin_bank設計流程](#Coin_bank設計流程) - [The hardness in this assignment](#The_hardness_in_this_assignment) - [Conclusion_and_Feedback](#Conclusion_and_Feedback) - [Reference](#Reference) # 完成度 100% 完成 # 環境設定 首先利用Mobaxterm連接至學校工作站。 ![](https://hackmd.io/_uploads/Bkx9YdpW6.png =40%x) 緊接著連線到機台(X記得要大寫,不然無法使用wv) ``` ssh -X ic53 ``` 再來初始化source,等等才能使用hspice、waveview以及Virtuoso ``` source /users/cad/synopsys/CIC/hspice.cshrc source /users/cad/synopsys/CIC_new/customexplorer.cshrc source /users/cad/cadence/CIC/ic.cshrc source /users/cad/mentor/CIC/calibre.cshrc ``` 設定 Rule.rce 裡的 Rule_20KA.rc 和 Rule_08KA.rc 這兩個檔要改成絕對路徑(約在 300 多行左右)。 # 基本操作參考資料 sp檔指令說明: https://hackmd.io/Y92TbIvNTYCb0o3FEj1ftg#sp%E6%AA%94%E6%8C%87%E4%BB%A4%E8%AA%AA%E6%98%8E virtuoso 操作說明:如eeclass上課ppt說明(https://eeclass.nthu.edu.tw/course/homework/28815) # Coin_bank設計流程 ## Specifiaction 設計一個基於全客製化設計風格的硬幣銀行,其電路框圖如下圖所示。輸入側包含4位元儲存貨幣(M3至M0,其中M3為最高有效位,M0為最低有效位元)、觸發訊號Clk、控制儲存訊號 Store、電源開關訊號 Power。 輸出端由4位元顯示器輸出(Mo3至Mo0,其中Mo3為最高有效位,Mo0為最低有效位元)和兩個電路組成狀態表示方法:狀態表使用二進位編碼表示State1、State0,S3到S0使用one-hot編碼(S3作為最高有效位,S0作為最低有效位)。 此外,還需要輸出觸發器儲存的值硬幣銀行中的總金額以確認初始金額因為架構中沒有重設訊號來初始化 DFF(Init3到Init0是儲存在DFF Total_store_money中的值,其中 Init3 為最高有效位,Init0 為最低有效位)。 VDD為1.8V,VSS為0V。 ![image](https://hackmd.io/_uploads/SJ78SlEua.png =80%x) 這個設計中會有一個FSM,其中有四個State,下面為四個state的簡介一即相對應的動作。(本段引用講義pdf) - Sleep Sleep is the initial state of the coin bank. In this state, the monitor will output zero and the state will change to Idle State when the coin bank detects that Power signal = 1. - Idle In this state, state will change from Idle State to Store money State when the coin bank detects that Store signal is 1 (Power signal is also 1), and the signal M3~M0 will be a valid input money only when the state is Idle State and the Store signal = 1. Besides, the monitor will output zero in this state. - Store money In this state, input store money (M3 to M0) will be updated into the 4-bit DFF Money_in. Besides, the monitor will output the current deposited amount, that is, the new value stores in Money_in. Note that the accumulated value in DFF Money_in and the value in DFF Total_store_money will not be updated into DFF Total_store_money in this state but the monitor will still output the current deposited amount (M3 to M0). That is, state will change to Show money state next cycle if Power signal is 1, and the DFF Total_store_money will be updated. Otherwise, DFF Total_store_money will not be updated. - Show money In this state, the coin bank will update the accumulated total amount into the 4-bit DFF Total_store_money and output the new total amount to the monitor, and the state will change to Idle state if Power signal is 1. ## 設計構思 - State table 我們可以根據上述的描述來繪製出state table如下圖: ![image](https://hackmd.io/_uploads/SJFQeGVOT.png) 此外,FSM狀態也會影顯示器輸出(Mo3至Mo0),如下表所示。 ![image](https://hackmd.io/_uploads/ryaKefV_a.png) - Data path 根據上述的FSM,以及spec的描述,我們可以畫出整個block的data path如下圖: ![image](https://hackmd.io/_uploads/HJEdTUV_T.png) 這樣我們就很明顯清楚知道我們需要哪些電路來實現。 ## Pre-sim 我們所需要的電路有 - FSM - 4 to 1 MUX - one bit flip flop - 4 bits adder - 2 to 4 decoder 這當中會用到基本電路nand、nor、transmission(以下簡稱transm)、buffer 、 inv 等等基本的gate,這些就不再另外說明設計圖,可以由HW1 ~ HW3 [參考](https://hackmd.io/@you8132) ### 基本電路subckt描述 ![image](https://hackmd.io/_uploads/BJTJa7NO6.png =40%x) ![image](https://hackmd.io/_uploads/Hy3-aX4uT.png =40%x) ![image](https://hackmd.io/_uploads/rkNX67Nup.png =40%x) ![image](https://hackmd.io/_uploads/ByMH6X4_p.png =40%x) ### FSM 設計圖如下: ![image](https://hackmd.io/_uploads/HyIqa8NOa.png) sp檔如下: ![image](https://hackmd.io/_uploads/Sy3vEME_a.png =40%x) ### 4 to 1 MUX 設計圖如下: ![image](https://hackmd.io/_uploads/ByQrSGEOT.png =40%x) sp檔如下: ![image](https://hackmd.io/_uploads/B1NFBf4O6.png =40%x) ### one bit flip flop 設計圖如下: ![image](https://hackmd.io/_uploads/Hy4GUGNOT.png) sp檔如下: ![image](https://hackmd.io/_uploads/HJNNLME_p.png =40%x) ### 4 bits adder ![image](https://hackmd.io/_uploads/B1CPwMV_p.png) 由上圖可以知道4 bits adder 是由4個full adder 所組成,所以我們先做出full adder。 full adder 設計圖如下: ![image](https://hackmd.io/_uploads/HJlTGXNup.png =60%x) full adder sp檔如下: ![image](https://hackmd.io/_uploads/B1u2XmEua.png =40%x) 所以我們可以利用full adder來設計出4 bits adder,4 bits adder sp檔如下: ![image](https://hackmd.io/_uploads/SJaZNQNda.png =40%x) ### 2 to 4 decoder 設計圖如下: ![image](https://hackmd.io/_uploads/rJ7fHX4d6.png) sp檔如下: ![image](https://hackmd.io/_uploads/r1-YEQEu6.png =40%x) ### Integrate and testing 根據data path 來整合上述所有的電路就可以完成pre-sim的設計了。sp檔如下: ![image](https://hackmd.io/_uploads/r19BLQVuT.png =80%x) 接者我們需要設計testbench來給定輸入訊號來驗正我們的設計。 tb 如下: ``` .protect .lib "/users/course/2023F/cs312000110001/u110020015/HW1/cic018.l" TT .unprotect .option post +accurate=1 +ingold=2 +runlvl=6 **Clock Parameter** .param CLK_Period = 2.5n .param CLK_Period_2 = 'CLK_Period/2' .param r_time = 1p .param f_time = 1p .param Sim_time = '20*CLK_Period' .param Rst_time = '2*CLK_Period' **Other Parameter (if needed)** .param SupplyV = 1.8v **Call subcircuit need to be tested** .include 'Coin_bank.sp' *********************************************************** *** Declaration of subcircuit *********************************************************** XCoin_bank State1 State0 S3 S2 S1 S0 Mo3 Mo2 Mo1 Mo0 Init3 + Init2 Init1 Init0 M3 M2 M1 M0 Store Power Clk VDD VSS Coin_bank *********************************************************** *** Voltage source setting *********************************************************** .global VDD VSS vdd VDD 0 SupplyV vss VSS 0 0 *********************************************************** *** Simulation setting *********************************************************** V_Clk Clk 0 PULSE(0v SupplyV Rst_time r_time f_time CLK_Period_2 CLK_Period) V_Power Power 0 PWL (0n 0v Rst_time 0v + 'CLK_Period*3.5' 0v 'CLK_Period*3.5+r_time' SupplyV + 'CLK_Period*4.5' SupplyV 'CLK_Period*15.5' SupplyV 'CLK_Period*15.5+f_time' 0v) V_Store Store 0 PWL (0n 0v Rst_time 0v + 'CLK_Period*4.5' 0v 'CLK_Period*4.5+r_time' SupplyV + 'CLK_Period*5.5' SupplyV 'CLK_Period*5.5+f_time' 0v + 'CLK_Period*7.5' 0v 'CLK_Period*7.5+r_time' SupplyV + 'CLK_Period*15.5' SupplyV 'CLK_Period*15.5+f_time' 0v ) V_M0 M0 0 PWL (0n 0v Rst_time 0v + 'CLK_Period*4.5' 0v 'CLK_Period*4.5+r_time' SupplyV + 'CLK_Period*5.5' SupplyV 'CLK_Period*5.5+f_time' 0v + 'CLK_Period*7.5' 0v 'CLK_Period*7.5+r_time' SupplyV + 'CLK_Period*8.5' SupplyV 'CLK_Period*8.5+f_time' 0v ) V_M1 M1 0 0 V_M2 M2 0 0 V_M3 M3 0 0 *********************************************************** *** Measuement setting *********************************************************** .Op .tran 0.1n Sim_time .temp 30 .meas TRAN S0_1 FIND V(XCoin_bank.S0) AT = 'CLK_Period*3.5' .meas TRAN S1_1 FIND V(XCoin_bank.S1) AT = 'CLK_Period*3.5' .meas TRAN S2_1 FIND V(XCoin_bank.S2) AT = 'CLK_Period*3.5' .meas TRAN S3_1 FIND V(XCoin_bank.S3) AT = 'CLK_Period*3.5' .meas TRAN ST0_1 FIND V(XCoin_bank.State0) AT = 'CLK_Period*3.5' .meas TRAN ST1_1 FIND V(XCoin_bank.State1) AT = 'CLK_Period*3.5' .meas TRAN M0_1 FIND V(XCoin_bank.Mo0) AT = 'CLK_Period*3.5' .meas TRAN M1_1 FIND V(XCoin_bank.Mo1) AT = 'CLK_Period*3.5' .meas TRAN M2_1 FIND V(XCoin_bank.Mo2) AT = 'CLK_Period*3.5' .meas TRAN M3_1 FIND V(XCoin_bank.Mo3) AT = 'CLK_Period*3.5' .meas TRAN Init0_1 FIND V(XCoin_bank.Init0) AT = 'CLK_Period*3.5' .meas TRAN Init1_1 FIND V(XCoin_bank.Init1) AT = 'CLK_Period*3.5' .meas TRAN Init2_1 FIND V(XCoin_bank.Init2) AT = 'CLK_Period*3.5' .meas TRAN Init3_1 FIND V(XCoin_bank.Init3) AT = 'CLK_Period*3.5' .meas TRAN S0_2 FIND V(XCoin_bank.S0) AT = 'CLK_Period*5.5' .meas TRAN S1_2 FIND V(XCoin_bank.S1) AT = 'CLK_Period*5.5' .meas TRAN S2_2 FIND V(XCoin_bank.S2) AT = 'CLK_Period*5.5' .meas TRAN S3_2 FIND V(XCoin_bank.S3) AT = 'CLK_Period*5.5' .meas TRAN ST0_2 FIND V(XCoin_bank.State0) AT = 'CLK_Period*5.5' .meas TRAN ST1_2 FIND V(XCoin_bank.State1) AT = 'CLK_Period*5.5' .meas TRAN M0_2 FIND V(XCoin_bank.Mo0) AT = 'CLK_Period*5.5' .meas TRAN M1_2 FIND V(XCoin_bank.Mo1) AT = 'CLK_Period*5.5' .meas TRAN M2_2 FIND V(XCoin_bank.Mo2) AT = 'CLK_Period*5.5' .meas TRAN M3_2 FIND V(XCoin_bank.Mo3) AT = 'CLK_Period*5.5' .meas TRAN Init0_2 FIND V(XCoin_bank.Init0) AT = 'CLK_Period*5.5' .meas TRAN Init1_2 FIND V(XCoin_bank.Init1) AT = 'CLK_Period*5.5' .meas TRAN Init2_2 FIND V(XCoin_bank.Init2) AT = 'CLK_Period*5.5' .meas TRAN Init3_2 FIND V(XCoin_bank.Init3) AT = 'CLK_Period*5.5' .meas TRAN S0_3 FIND V(XCoin_bank.S0) AT = 'CLK_Period*7.5' .meas TRAN S1_3 FIND V(XCoin_bank.S1) AT = 'CLK_Period*7.5' .meas TRAN S2_3 FIND V(XCoin_bank.S2) AT = 'CLK_Period*7.5' .meas TRAN S3_3 FIND V(XCoin_bank.S3) AT = 'CLK_Period*7.5' .meas TRAN ST0_3 FIND V(XCoin_bank.State0) AT = 'CLK_Period*7.5' .meas TRAN ST1_3 FIND V(XCoin_bank.State1) AT = 'CLK_Period*7.5' .meas TRAN M0_3 FIND V(XCoin_bank.Mo0) AT = 'CLK_Period*7.5' .meas TRAN M1_3 FIND V(XCoin_bank.Mo1) AT = 'CLK_Period*7.5' .meas TRAN M2_3 FIND V(XCoin_bank.Mo2) AT = 'CLK_Period*7.5' .meas TRAN M3_3 FIND V(XCoin_bank.Mo3) AT = 'CLK_Period*7.5' .meas TRAN Init0_3 FIND V(XCoin_bank.Init0) AT = 'CLK_Period*7.5' .meas TRAN Init1_3 FIND V(XCoin_bank.Init1) AT = 'CLK_Period*7.5' .meas TRAN Init2_3 FIND V(XCoin_bank.Init2) AT = 'CLK_Period*7.5' .meas TRAN Init3_3 FIND V(XCoin_bank.Init3) AT = 'CLK_Period*7.5' .end ``` 這裡面可以更改clock period來測試整個系統的latency,接者在Simulation setting 的部分,我們可以用pwl指令來給我們想要測試的input 訊號,最後利用meas指令來測量negative edge 時的值來判斷是否正確。(我們所有輸入訊號即測量都是在negative edge 給定和測量) 接著利用 HSPICE程式產生出相對應的檔案 ``` hspice –i <inputFile.sp> –o <outputFile.lis> ``` 會產生以下五種檔案: - .tr0檔:這是Transient Analysis(瞬態分析)的輸出文件,用於記錄電路在不同時間點上的響應數據,通常是電流和電壓隨時間的變化。 - .st0檔:這是Steady-State Analysis(穩態分析)的輸出文件,用於記錄電路在穩態條件下的狀態,包括節點電壓、電流值等。 - .pa0檔:這是AC Analysis(交流分析)的輸出文件,記錄了電路對不同頻率的交流訊號的反應,通常以振幅和相位的形式表示。 - .lis檔案:這是HSPICE的模擬日誌文件,用於記錄模擬過程中的詳細信息,包括警告、錯誤和其他模擬參數的設定。 - .ic0檔:這是Initial Conditions(初始條件)的輸出文件,用於記錄模擬的初始狀態,包括電路元件的初始電壓和電流值。 其中的.tr0檔可利用waveview觀察波型 ``` wv pre.tr0 & ``` 其中的.lis檔可以查看meas測量的值 ``` vim pre.lis ``` 結果為: - waveform ![image](https://hackmd.io/_uploads/S1TXPLNua.png) 白色為各OUTPUT訊號在negative edge時,所對應的輸出。而框框起來是為了驗證當今天沒有到State 3時,Total money 並不會更新。 紅色指標為meas測試點,數值如下: ![image](https://hackmd.io/_uploads/Hye52SE_T.png =20%x) - latency 2ns(periods) * 20(cycles)=40ns 由波型我們可以確認這設計符合我們的spec。 ## Post-sim ### virtuoso part 我們藉由pre.sim 模擬後可以知道cell中mos對應的W和L,以及cell連接方式。我們設計應該是由曉得cell設計,把每個cell設計好,且分別跑過drc跟lvs後,再來最後的接線,這樣過程中比較容易debug。完整layout(面積大小約為 W:135um、L:145um )如下: ![image](https://hackmd.io/_uploads/HyGNi4Edp.png =80%x) ![image](https://hackmd.io/_uploads/Bkf_oEE_T.png =80%x) 接者我們要跑最終的DRC測驗(操作過程如講義所述),確定我們設計的形式有符合規範。 結果為: ![image](https://hackmd.io/_uploads/SkJ-2VVuT.png =40%x) 通過。 接者再跑LVS(操作過程如講義所述),驗證這個layout產出的積體電路與其原始電路設計 pre.sp 之間的差異有無異常。 結果為: ![image](https://hackmd.io/_uploads/S1lP3EEu6.png =40%x) cd 通過 最後跑PEX(操作過程如講義所述),產出: - Coin_bank.pex.sp.pex - Coin_bank.pex.sp - Coin_bank.pex.sp.COIN_BANK.pxi 這三個檔案來描述電路。 ### testing 一樣利用上述的tb來做測量 結果為: - waveform ![image](https://hackmd.io/_uploads/S1AED84O6.png) 白色為各OUTPUT訊號在negative edge時,所對應的輸出。 紅色線為meas測試點,數值如下: ![image](https://hackmd.io/_uploads/SyMrqBEd6.png =20%x) - latency 2.5ns(periods) *16(cycles)=40ns 由波型比對pre-sim,我們可以確認這結果符合我們的預期。 # The_hardness_in_this_assignment 雖然完成了本次final,但在這次的設計中也遇到幾個困難如下: - 設計很多種,如一開始的datapath的抉擇,如我們在input mux的部分可以只用2 to 1設計就好,但考慮到整體設計時間,我最後還是選擇較統一的4 to 1 mux,不過這也相對會造成面積變大、電阻便大,等等trade off ,是個值得好好思考的設計選擇。 - layout 面積問題,如何排出最小的面積,這攸關到我們的latency。排出最小的面積要考慮cell cell間擺放的位置同時也要考慮到metal連接的問題,像是我最後用到了metal4來做連接。但不過還是有空白的區域,如果真的要佈滿可能要從一開使就構思好。 # Conclusion_and_Feedback 這是這學期最後一個作業了,雖然過程很坐牢,layout畫到死,不過真正做完時,也有一股莫名的成就感。感謝這門課帶給我如此精彩的體驗以及豐富的知識。 # Reference workbook- https://eeclass.nthu.edu.tw/course/homework/30686 HackMD- https://hackmd.io/@you8132