IC Contest Practice(0) - Verilog Simulation Environment
這個系列主要記錄我練習 IC Contest 題目的心得。我認為 IC Contest 是在完成 HDL bits 後很好的 Verilog 練習,這也幫助我更深入地理解數位 IC 在 PPA(Performance、Power、Area)之間的 Trade-off。
此篇文章以搭建流暢練習 IC Contest 的環境為主軸,涵蓋 EDA Tool 的取得、文字編輯器的插件、基礎的 Linux command 還有方便的腳本。
EDA Environment
IC Contest 不僅考驗功能實現,某些年度還會根據設計的 PPA 進行評分,因此擁有一套能進行邏輯合成(Synthesis)的軟體是必要的。為了更深入地理解數位 IC,在某寶購買了 EDA 虛擬機練習,從 RTL to GDS 的軟體都能順利執行。但不乏有一些需要微調的地方,像是開啟 dc_shell
會一直 retry 回傳 ip 給 Synopsys 導致啟動過慢的問題,參考 eetop 的文章後順利解決。
虛擬機含以下安裝好的 EDA tool,使用 vmware 打開即可運行,能在本地完整模擬 Digital IC Design Flow,不受限於實驗室的資源或網路需求。
Design Stage | Key Activities | EDA Tools |
---|---|---|
Front-End |
|
|
Middle-End |
|
|
Back-End |
|
|
VS Code Extension Recommend
Editor Selection:
- Visual Studio Code
- Vim/Gvim/Neovim
- Emacs
- Notepad++
Based on my experience so far, VS Code fits my workflow best. The integration of VS Code with SFTP folders and the integrated terminal works very well.
Vim
Quick, flexible, and powerful text editing. Here are two use cases:
Increment Signal
To reset six registers named CNT1, CNT2, ..., CNT6 to 0, you can use the following Vim method. First, use yy
to copy the line CNT0
, then paste it five times with 5p
to create six identical lines. Next, enter visual block mode with <CTRL+V>
, select the column containing the 0
, and then press g<CTRL+a>
to increment each number, resulting in CNT1
through CNT6
being reset to 0.
Marks
In the signal declaration section, you can press ms
to mark a location, and in the FSM section, you can press mf
. You can then quickly jump between these two locations by pressing 's
and 'f
, which is useful for switching between different blocks of code.
To jump back to your current line after navigating away, you can set a mark before you move. For example, press ma
to mark your current line as 'a'. No matter where you jump to later, you can quickly return to the original spot by pressing 'a
.
Additionally, you can use Vim's built-in jump history. Pressing Ctrl-O
will take you back to your previous cursor position, which is particularly useful for multilevel jumps. If you want to jump forward again, you can press Ctrl-I
.
Definition
You can quickly view a signal's definition by pressing <CTRL+O>
with the Sigasi IDE plugin.
VHDL & SystemVerilog IDE by Sigasi
Both DVT IDE and Sigasi are commercial Verilog IDEs that offer more complete features compared to tools like Digital IDE and TerosHDL. However, Sigasi provides a community version that you can simply enable in the settings after installing the plugin, whereas DVT IDE requires you to apply for a separate license.
Peer-to-Peer Comparison:
- TerosHDL: Requires separate installation for linters and formatters. The FSM state diagram feature is often buggy and fails to open correctly.
- Digital IDE: Shares the same issues as TerosHDL regarding linters and formatters. Additionally, it suffers from performance problems, becoming slow and laggy when opening larger codebases.
- Sigasi: Its built-in formatter is considered superior to Verible's. Verible's formatter has a drawback where it indents macros to level 0, which is often not the desired behavior.
TCL
- Syntax highlighting
- Snippets
This VS Code extension provides advanced language support for Tcl and Tcl variants, particularly ones related to EDA (Electronic Design Automation) workflows.
Remote - SSH
Remote Development with Integrated Terminal and File Explorer
Utilites
Some useful utilites
Error Lens
- Highlight lines containing diagnostics
- Append diagnostic as text to the end of the line
- Show icons in gutter
- Show message in status
Hover Converter
A simple Visual Studio Code Extension which allows you to convert Hex and Decimal values to their corresponding Binary, Hex or Decimal values by just hovering over them.
Path Autocomplete
Provides path completion for visual studio code.
TabOut
Tab out of quotes, brackets, etc for Visual Studio Code.
Output Colorizer
Language extension for VSCode/Bluemix Code that adds syntax colorization for both the output/debug/extensions panel and *.log files.
It's more comfortable to read the vcs.log
and syn.log
files.
Comment Anchors
Place anchors within comments or strings to place bookmarks within the context of your code. Anchors can be used to track TODOs, write notes, create foldable sections, or to build a simple navigation making it easier to navigate your files.
Anchors can be viewed for the current file, or throughout the entire workspace, using an easy to use sidebar.
Basic Linux Command
pwd
- 簡介:Print Working Directory,顯示當前工作目錄的完整路徑。
- 用法:
pwd
。pwd -p
:印出此目錄所連結的實體目錄位置。
ls
- 簡介:list,列出指定目錄下的檔案和子目錄。
- 用法:
ls
:列出當前目錄下的非隱藏檔案。ls [path]
。
- 常用參數:
a
:顯示所有檔案,包含開頭為.
的隱藏檔案。A
:包含隱藏的全部檔案,但不包含.
(當前目錄) 和..
(上一層目錄)。l
:顯示詳細資訊,如檔案類型、權限、連結數、擁有者、群組、大小、最後修改時間等。S
:依照檔案大小排序 (預設降冪)。r
:以反向排序列出檔案。R
:遞迴列出目錄下所有檔案,包含子資料夾內的所有檔案。t
:依照檔案建立時間 (修改時間) 列出。c
:依照檔案狀態最後變更時間 (ctime) 列出。u
:依照檔案被讀取的最後時間 (atime) 列出。
- 檔案類型與權限 (Mode):第一個字元表示檔案類型 ( 一般檔案,
d
目錄,l
符號連結,b
區塊設備,c
字元設備)。隨後 9 個字元分為 3 組,分別表示檔案擁有者、群組、其他使用者的讀取 (r
)、寫入 (w
)、執行 (x
) 權限。 - 連結數量 (Links):顯示這個檔案或目錄的連結數量。
- 擁有者 (Owner):檔案的擁有者名稱。
- 群組 (Group):檔案所屬的群組名稱。
- 檔案大小 (Size):檔案的大小,以位元組 (bytes) 為單位。
- 最後修改時間 (Timestamp):檔案最後修改的日期和時間。
- 檔案名稱 (Name):檔案或目錄的名稱。
cd
- 簡介:Change Directory,用於切換當前工作目錄。
- 用法:
cd [相對路徑]
或cd [絕對路徑]
。cd /
:移至根目錄。cd ~
或cd
:移至當前使用者的家目錄。cd ..
:回到上一層目錄。cd .
:當前目錄。cd -
:回到前一個工作目錄。cd ~ <username>
:指定使用者的家目錄。
mkdir
- 簡介:建立新的目錄 (資料夾)。
- 用法:
mkdir <DIR_name>
。mkdir -p <DIRpath/DIR_name>
:如果後面的路徑不存在,會自動建立所需的路徑。
cat
- 簡介:concatenate,用於連接檔案內容並印出到標準輸出,常用於檢視檔案內容。
- 用法:
cat <filename>
。cat -b
:印出行號,空白行不標記。cat -n
:印出行號,空白行也標記。cat -T
:會把 TAB 按鍵用^I
顯示出來。
mv
- 簡介:move,用於移動檔案或目錄,也可用於更名。
- 用法:
mv <source> <destination>
:移動檔案或目錄到新的位置。mv <file_or_DIR> <new_name>
:更名檔案或目錄。
rm
- 簡介:remove,用於刪除檔案或目錄。
- 用法:
rm <filename_or_DIR>
。rm -r
:遞迴刪除目錄及其內容。rm -f
:強制刪除,不提示確認。rm -rf
:強制遞迴刪除檔案或目錄,請小心使用。sudo rm -rf --no-preserve-root /
:摧毀系統的危險指令,後果自負。rmdir
與rm -r
差異:rmdir
只能刪除空目錄。rm -r
可以刪除包含內容的目錄。
echo
- 簡介:在 terminal 上印出字串或變數的內容。
- 用法:
echo "hello world"
。echo -n "Hello"
:不換行。echo *.副檔名
:印出所有指定副檔名的檔案名稱。echo $PATH
:印出PATH
環境變數的內容。echo $$
:印出當前 shell 的 PID。echo <文字> > <檔名>
:將echo
顯示的內容覆蓋寫進另一個檔案內。echo <文字> >> <檔名>
:將echo
顯示的內容新增到原有內容後。
mktemp
- 簡介:自動建立檔名不重複的暫存檔案或目錄,方便程式或指令存放資料。
- 用法:
mktemp
:建立暫存檔案。mktemp -d
:建立暫存目錄。
更多指令的介紹:

Scripting Tools
To increase efficiency, here are a few scripts that can help streamline your workflow, adapted from implementations at the NYCU IC Lab. Here are some of the features. For more, check out Digital IC Scripts
use command prj
locates the root directory of the design.
Navigate between 00_TESTBED
, 01_RTL
, 02_SYN
, ...
Modify the synthesis cycle time
Generate RTL/GATE simulation file list
Summary of syn.log
Instead of changing directories and typing make rtl, you can run a quick RTL simulation more efficiently. This approach is the same for gate-level and post-layout simulations.