如何使用Modelsim進行數位電路模擬
撰寫時間 : 2021/08/24
前言
僅為測試小電路區塊方便用,Windows環境makefile、shell script、unix-like指令、macro展開都沒辦法用或是比較麻煩。實際還是要用學校工作站linux環境下NC Verilog、Verdi、design vision等一系列EDA tools進行模擬、合成。
步驟
-
用文字編輯器(vim, vscode)寫好整個電路架構與要用測試的testbench*.v(與golden data*.dat),放在同一目錄。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
打開Windows 10下的Modelsim v10.1c
-
file->change Directory->選擇工作目錄,等同於指令cd到工作目錄,於下方Transcript視窗也可觀察到是一樣的,差別只是一個用GUI,一個用CLI而已。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
創建work目錄,此目錄將存放Modelsim模擬時產生的部分檔案。
- 編譯所有
*.v檔
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
選擇work目錄下的testbench並按右鍵,選擇Simulate Without Optimatization
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
將想要觀察的波型drag and drop到wave面板
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- 如果沒有
wave面板或不小心關閉,到上方工具列view->New Window->Wave開啟。
- 跑一個比
testbench中開始到$finish更久時間的秒數
-
在執行到$finish後,Modelsim會跳出視窗詢問是否結束,選擇結束會如同$finish一樣關閉程式,因此選擇No,以便後續觀察波形。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
按快捷鍵F可全畫面的波型顯示,而對任意波型按右鍵->Radix可以改變進位制。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
剛才的Transcript視窗產生的所有文字可於目錄C:\modeltech64_10.1c\examples找到,程式每執行一次就會自動覆蓋掉前一個Transcript檔案。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
-
最終產生預期的灰階圖、work資料夾與*.wlf,*.wlf為波型檔,下次可以直接打開Modelsim->file->open->選擇該檔案,就可看到之前產生的波型圖。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
僅列舉一小部分自己常用的,更多指令與功能,請見Mentor Graphics官方PDF文檔。