IC Contest Practice(0) - Verilog Simulation Environment

IC Contest Practice(0) - Verilog Simulation Environment
Photo by Hen Kaznelson / Unsplash

這個系列主要記錄我練習 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
  • RTL design
  • Functional verification
  • Synthesis
  • VCS, Verdi, SpyGlass
  • Design Compiler
Middle-End
  • Logical equivalence check (LEC)
  • Test insertion (DFT)
  • Static timing analysis (STA)
  • Formality, Conformal, VC Static
  • TetraMAX
  • DFT Shell/TestMAX, Tessent
  • PrimeTime
Back-End
  • Floorplanning
  • Placement & Routing
  • Physical verification
  • ICC, ICC2, INNOVUS
  • Calibre
  • RedHawk
  • Virtuoso
本虛擬機中的軟體僅供個人學習使用,嚴禁任何形式的商業用途。擅自買賣或散布本虛擬機者,若因此涉及侵權,須自行承擔相關法律責任。若對數位 IC 設計有興趣,但缺乏相關資源練習,歡迎私訊。

VS Code Extension Recommend

Editor Selection:

  1. Visual Studio Code
  2. Vim/Gvim/Neovim
  3. Emacs
  4. 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

Vim - Visual Studio Marketplace
Extension for Visual Studio Code - Vim emulation for Visual Studio Code

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.

0805-ezgif.com-video-to-gif-converter

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.

image-20250805010600083

VHDL & SystemVerilog IDE by Sigasi

VHDL & SystemVerilog IDE by Sigasi - Visual Studio Marketplace
Extension for Visual Studio Code - SystemVerilog, Verilog, VHDL, UVM, UVVM, highlighting, autocomplete, formatting, and so much more

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

Tcl - Visual Studio Marketplace
Extension for Visual Studio Code - Tcl language support
  • Syntax highlighting
  • Snippets
tclint Language Server - Visual Studio Marketplace
Extension for Visual Studio Code - Linting and formatting for Tcl and EDA scripts.

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 - SSH - Visual Studio Marketplace
Extension for Visual Studio Code - Open any folder on a remote machine using SSH and take advantage of VS Code’s full feature set.

Remote Development with Integrated Terminal and File Explorer

If your server's GLIBC version is older than 2.28, you will need to use a version of VS Code from before 1.99.0 (released in March 2025) to establish a successful SSH connection. Alternatively, you can update the user-level GLIBC on your server.

image-20250805012354089

Utilites

Some useful utilites

Error Lens

Error Lens - Visual Studio Marketplace
Extension for Visual Studio Code - Improve highlighting of errors, warnings and other language diagnostics.
  • Highlight lines containing diagnostics
  • Append diagnostic as text to the end of the line
  • Show icons in gutter
  • Show message in status

Hover Converter

Hover Converter - Visual Studio Marketplace
Extension for Visual Studio Code - Hover over Hex or Decimal values to quickly get their corresponding values in Binary, Hex or Decimal.

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

Path Autocomplete - Visual Studio Marketplace
Extension for Visual Studio Code - Provides path completion for visual studio code and VS Code for Web.

Provides path completion for visual studio code.

TabOut

TabOut - Visual Studio Marketplace
Extension for Visual Studio Code - Tab out of quotes, brackets, etc

Tab out of quotes, brackets, etc for Visual Studio Code.

Output Colorizer

Output Colorizer - Visual Studio Marketplace
Extension for Visual Studio Code - Syntax highlighting for log files

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.

image-20250805012940255

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) 列出。
    1. 檔案類型與權限 (Mode):第一個字元表示檔案類型 ( 一般檔案, d 目錄, l 符號連結, b 區塊設備, c 字元設備)。隨後 9 個字元分為 3 組,分別表示檔案擁有者、群組、其他使用者的讀取 (r)、寫入 (w)、執行 (x) 權限。
    2. 連結數量 (Links):顯示這個檔案或目錄的連結數量。
    3. 擁有者 (Owner):檔案的擁有者名稱。
    4. 群組 (Group):檔案所屬的群組名稱。
    5. 檔案大小 (Size):檔案的大小,以位元組 (bytes) 為單位。
    6. 最後修改時間 (Timestamp):檔案最後修改的日期和時間。
    7. 檔案名稱 (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 /摧毀系統的危險指令,後果自負
    • rmdirrm -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:建立暫存目錄。

更多指令的介紹:

NCNU OpenSource - LSA 課程共筆 - HackMD
課程介紹

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.

image-20250805014826020

Navigate between 00_TESTBED, 01_RTL, 02_SYN, ...

image-20250805015040108

Modify the synthesis cycle time

image-20250805015134723

Generate RTL/GATE simulation file list

image-20250805015238086

image-20250805015246975

Summary of syn.log

image-20250805015333215

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.

image-20250805015424674

image-20250805015431809

Reference