Try   HackMD

Some interesting script for ICLAB

功能介紹

  1. 登入時顯示目前 quota 百分比
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →
  2. 快速切換資料夾
    展開功能說明

    輸入 0 快速切換到 00_TESTBED
    輸入 1 快速切換到 01_RTL
    輸入 2 快速切換到 02_SYN
    輸入 3 快速切換到 03_GATE
    輸入 4 快速切換到 04_MEM
    輸入 9 快速切換到 09_SUBMIT
    輸入 m 快速切換到 Memory

    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →
  3. 一鍵修改 clk peroid
    輸入 c 查看目前 clk 設定
    輸入 c peroid修改並顯示 clk
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →
  4. 一鍵開啟/關閉 fsdb
    輸入 f 查看目前 fsdb 設定
    輸入 f rtl on/off修改並顯示 rtl fsdb 設定
    輸入 f gate on/off修改並顯示 gate fsdb 設定
    輸入 f post on/off修改並顯示 post fsdb 設定
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →
  5. 一鍵開啟 DesignWare IP User Guide
    輸入 dwip 開啟 DesignWare IP Pdf
    輸入 io 開啟 IO Pdf
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

腳本內容與設定方式(新版)

  1. 切換回家目錄
    ​​​​cd $HOME
  2. Github repo 下載整包code,將 src 內的 .cshrcscript 資料夾直接丟到家目錄
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →
  3. Terminal 輸入指令: source $HOME/.cshrc
  4. 之後如果要修改Lab路徑
    • 編輯~script/setting.csh中的set FOLDER="Lab??/Exercise"
    • 或直接輸入setting,將跳出 VSCode 視窗後進行編輯
      Image Not Showing Possible Reasons
      • The image was uploaded to a note which you don't have access to
      • The note which the image was originally uploaded to has been deleted
      Learn More →

腳本內容與設定方式(舊版)

  1. 以下步驟中的指令直接複製,在MobaXterm中可以按滑鼠右鍵貼上執行
  2. 執行以下指令新增腳本資料夾script
    ​​​​cd $HOME ​​​​mkdir script ​​​​
  3. 執行以下指令新增 setting.csh 腳本並設定執行權限
    ​​​​cat > $HOME/script/setting.csh << EOF ​​​​#!/bin/tcsh ​​​​# Brief : This is a script to set variable for cd.csh, clk.csh, fsdb.csh ​​​​# Author: Jyun-Wei, Su ​​​​# Update: 2023.10.23 ​​​​set FOLDER="Lab05/Exercise" ​​​​#set FOLDER="Bonus_formal_verification/Exercise" ​​​​#set FOLDER="Final_Project" ​​​​set TESTBED_FILE=\$HOME/\$FOLDER/00_TESTBED/TESTBED.v ​​​​set PATTERN_FILE=\$HOME/\$FOLDER/00_TESTBED/PATTERN.v ​​​​set SYN_FILE=\$HOME/\$FOLDER/02_SYN/syn.tcl ​​​​# Define colors ​​​​set GREEN='\033[0;32m' ​​​​set BLUE='\033[0;34m' ​​​​set RED='\033[0;31m' ​​​​set NC='\033[0m' # No Color ​​​​EOF ​​​​chmod +x $HOME/script/setting.csh
  4. 執行以下指令新增 cd.csh 腳本並設定執行權限
    ​​​​cat > $HOME/script/cd.csh << EOF ​​​​#!/bin/tcsh ​​​​# Brief : This is a script to change directory ​​​​# Author: Jyun-Wei, Su ​​​​# Update: 2023.12.23 ​​​​# get the variable from setting.csh ​​​​source \$HOME/script/setting.csh ​​​​# check parameter ​​​​if (\$# == 0) then ​​​​ echo "\${RED}Please input 0, 1, 2, 3, 4, 5, or 9\${NC}" ​​​​ exit 1 ​​​​else ​​​​ # cd to folder ​​​​ switch (\$1) ​​​​ case [0-9]: ​​​​ cd \$HOME/\$FOLDER/0\$1_* || (echo "\${RED}Change directory fail\${NC}"; exit 1) ​​​​ breaksw ​​​​ case m: ​​​​ cd \$HOME/\$FOLDER/Memory || (echo "\${RED}Change directory fail\${NC}"; exit 1) ​​​​ breaksw ​​​​ default: ​​​​ echo "\${RED}Please input 0, 1, 2, 3, 4, 5, or 9\${NC}" ​​​​ exit 1 ​​​​ breaksw ​​​​ endsw ​​​​ # Check if cd was successful ​​​​ if (\$? == 0) then ​​​​ echo "\${GREEN}Current directory: \`pwd\`\${NC}" ​​​​ endif ​​​​endif ​​​​EOF ​​​​chmod +x $HOME/script/cd.csh ​​​​
  5. 執行以下指令新增 clk.csh 腳本並設定執行權限
    ​​​​cat > $HOME/script/clk.csh << EOF ​​​​#!/bin/tcsh ​​​​# Brief : This is a script to change the clock peroid define ​​​​# Author: Jyun-Wei, Su ​​​​# Update: 2023.12.23 ​​​​# get the variable from setting.csh ​​​​source \$HOME/script/setting.csh ​​​​# check parameter ​​​​if (\$# == 0) then ​​​​ # testbed file ​​​​ echo \${BLUE}File: \$TESTBED_FILE\${NC} ​​​​ setenv GREP_COLOR '01;32' ; cat --number \$TESTBED_FILE | grep --color "define\s\+CYCLE_TIME\s\+[0-9]\+\.\?[0-9]\?" ​​​​ # pattern file ​​​​ echo \${BLUE}File: \$PATTERN_FILE\${NC} ​​​​ setenv GREP_COLOR '01;32' ; cat --number \$PATTERN_FILE | grep --color "define\s\+CYCLE_TIME\s\+[0-9]\+\.\?[0-9]\?" ​​​​ # syn file ​​​​ echo \${BLUE}File: \$SYN_FILE\${NC} ​​​​ setenv GREP_COLOR '01;32' ; cat --number \$SYN_FILE | grep --color "set CYCLE [0-9]\+\.\?[0-9]\?" ​​​​ exit 1 ​​​​else ​​​​ #if([string tofloat \$1] < 5.0) then ​​​​ # echo "\${RED}Cycle time must >= 5. \${NC}" ​​​​ #else ​​​​ # testbed file ​​​​ echo \${BLUE}File: \$TESTBED_FILE\${NC} ​​​​ setenv GREP_COLOR '01;31' ; cat --number \$TESTBED_FILE | grep --color "define\s\+CYCLE_TIME\s\+[0-9]\+\.\?[0-9]\?" ​​​​ sed -i "s/define\s\+CYCLE_TIME\s\+[0-9]\+\.\?[0-9]\?/define CYCLE_TIME \$1/" \$TESTBED_FILE ​​​​ setenv GREP_COLOR '01;32' ; cat --number \$TESTBED_FILE | grep --color "define\s\+CYCLE_TIME\s\+[0-9]\+\.\?[0-9]\?" ​​​​ # pattern file ​​​​ echo \${BLUE}File: \$PATTERN_FILE\${NC} ​​​​ setenv GREP_COLOR '01;31' ; cat --number \$PATTERN_FILE | grep --color "define\s\+CYCLE_TIME\s\+[0-9]\+\.\?[0-9]\?" ​​​​ sed -i "s/define\s\+CYCLE_TIME\s\+[0-9]\+\.\?[0-9]\?/define CYCLE_TIME \$1/" \$PATTERN_FILE ​​​​ setenv GREP_COLOR '01;32' ; cat --number \$PATTERN_FILE | grep --color "define\s\+CYCLE_TIME\s\+[0-9]\+\.\?[0-9]\?" ​​​​ # syn file ​​​​ echo \${BLUE}File: \$SYN_FILE\${NC} ​​​​ setenv GREP_COLOR '01;31' ; cat --number \$SYN_FILE | grep --color "set CYCLE [0-9]\+\.\?[0-9]\?" ​​​​ sed -i "s/set CYCLE [0-9]\+\.\?[0-9]\?/set CYCLE \$1/" \$SYN_FILE ​​​​ setenv GREP_COLOR '01;32' ; cat --number \$SYN_FILE | grep --color "set CYCLE [0-9]\+\.\?[0-9]\?" ​​​​ # Check if cd was successful ​​​​ if (\$? == 0) then ​​​​ echo "\${GREEN}Change cycle time to \$1 dnoe. \${NC}" ​​​​ endif ​​​​ #endif ​​​​endif ​​​​EOF ​​​​chmod +x $HOME/script/clk.csh
  6. 執行以下指令新增 fsdb.csh 腳本並設定執行權限
    ​​​​cat > $HOME/script/fsdb.csh << EOF ​​​​#!/bin/tcsh ​​​​# Brief : This is a script to open/close the FSDB ​​​​# Author: Jyun-Wei, Su ​​​​# Update: 2023.12.23 ​​​​# get the variable from setting.csh ​​​​source \$HOME/script/setting.csh ​​​​# check parameter ​​​​if (\$# == 0) then ​​​​ set show = 1 ​​​​ set help = 1 ​​​​ goto conclusion ​​​​else ​​​​ # check if file exit ​​​​ if (-e \$TESTBED_FILE) then ​​​​ #--------------------------------------------------------- section ​​​​ switch (\$1) ​​​​ case 'rtl': ​​​​ set section = 'RTL' ​​​​ breaksw ​​​​ case 'gate': ​​​​ set section = 'GATE' ​​​​ breaksw ​​​​ case 'post': ​​​​ set section = 'POST' ​​​​ breaksw ​​​​ default: ​​​​ set show = 0 ​​​​ set help = 1 ​​​​ goto conclusion ​​​​ breaksw ​​​​ endsw ​​​​ else ​​​​ echo "\$TESTBED_FILE not exist" ​​​​ endif ​​​​ #--------------------------------------------------------- FSDB ON/OFF ​​​​ if (\$2 == 'on') then ​​​​ # find and remove comment in ifdef RTL to endif ​​​​ sed -i "/ifdef \$section/,/endif/s/\/\/\(.sdf_annotate(.*);\)/\1/g" \$TESTBED_FILE ​​​​ sed -i "/ifdef \$section/,/endif/s/\/\/\(.fsdbDumpfile(.*);\)/\1/g" \$TESTBED_FILE ​​​​ sed -i "/ifdef \$section/,/endif/s/\/\/\(.fsdbDumpvars(.*);\)/\1/g" \$TESTBED_FILE ​​​​ echo "\${GREEN}Uncomment \${section} fsdbDumpfile, fsdbDumpvars done.\${NC}" ​​​​ set show = 1 ​​​​ set help = 0 ​​​​ goto conclusion ​​​​ else if (\$2 == 'off') then ​​​​ # check if file is commented ​​​​ if (\`awk 'BEGIN { s=0 } /.ifdef '\$section'/,/.endif/ { if (\$0 ~ /\/\/.*/) { s=1; exit } } END { print s}' \$TESTBED_FILE\` == "0") then ​​​​ #sed -i "/ifdef \$section/,/endif/s/\(.sdf_annotate(.*);\)/\/\/\1/g" \$TESTBED_FILE ​​​​ sed -i "/ifdef \$section/,/endif/s/\(.fsdbDumpfile(.*);\)/\/\/\1/g" \$TESTBED_FILE ​​​​ sed -i "/ifdef \$section/,/endif/s/\(.fsdbDumpvars(.*);\)/\/\/\1/g" \$TESTBED_FILE ​​​​ endif ​​​​ echo "\${GREEN}Comment \${section} sdf_annotate, fsdbDumpfile, fsdbDumpvars done.\${NC}" ​​​​ set show = 1 ​​​​ set help = 0 ​​​​ goto conclusion ​​​​ else ​​​​ set show = 0 ​​​​ set help = 1 ​​​​ goto conclusion ​​​​ endif ​​​​endif ​​​​conclusion: ​​​​# show the state of fsdb file ​​​​if (\$show == 1) then ​​​​ echo \${BLUE}File: \$TESTBED_FILE\${NC} ​​​​ echo \${GREEN}In RTL\${NC} ​​​​ awk '/.ifdef RTL/,/.endif/ {if (\$0 ~ /sdf_/) print}' \$TESTBED_FILE ​​​​ awk '/.ifdef RTL/,/.endif/ {if (\$0 ~ /fsdb/) print}' \$TESTBED_FILE ​​​​ echo \${GREEN}In GATE\${NC} ​​​​ awk '/.ifdef GATE/,/.endif/ {if (\$0 ~ /sdf_/) print}' \$TESTBED_FILE ​​​​ awk '/.ifdef GATE/,/.endif/ {if (\$0 ~ /fsdb/) print}' \$TESTBED_FILE ​​​​ echo \${GREEN}In POST\${NC} ​​​​ awk '/.ifdef POST/,/.endif/ {if (\$0 ~ /sdf_/) print}' \$TESTBED_FILE ​​​​ awk '/.ifdef POST/,/.endif/ {if (\$0 ~ /fsdb/) print}' \$TESTBED_FILE ​​​​endif ​​​​# show the usage of this script ​​​​if(\$help == 1) then ​​​​ echo "\${RED}Please input {rtl, gate, post} {on, off} to turn on/off fsdb file.\${NC}" ​​​​endif ​​​​# exit ​​​​exit 1 ​​​​EOF ​​​​chmod +x $HOME/script/fsdb.csh ​​​​
  7. 新增quotq.csh在登入時自動show quota
    ​​​​cat > $HOME/script/quota.csh << EOF ​​​​#!/bin/tcsh ​​​​# Brief : ​​​​# Author: Jyun-Wei, Su ​​​​# Update: 2023.11.06 ​​​​if (\$?prompt) then ​​​​ # set filesize limit ​​​​ limit filesize 10G ​​​​ if (\`limit | grep filesize | grep unlimited\` != "") then ​​​​ echo ">>> Current limit: \033[1;41m\`limit | grep filesize\`\033[m" ​​​​ else ​​​​ echo ">>> Current limit: \033[1;42m\`limit | grep filesize\`\033[m" ​​​​ endif ​​​​ echo '======================================================' ​​​​ # show quota ​​​​ quota | awk 'NR==4 {printf ">>> Current space usage: "; \ ​​​​ if (\$1/\$2 < 0.5) printf "\033[1;42m%.2f%%\033[m\n", \$1/\$2*100; \ ​​​​ else if(\$1/\$2 < 0.8) printf "\033[1;43m%.2f%%\033[m\n", \$1/\$2*100; \ ​​​​ else printf "\033[1;41m%.2f%%\033[m\n", \$1/\$2*100}' ​​​​ echo '======================================================' ​​​​ echo '\033[1;31mFiles >500M:\033[m' ​​​​ find ~/ -type f -size +500M -exec ls -l {} \; | awk '{print \$NF}' ​​​​ echo '======================================================' ​​​​endif ​​​​EOF ​​​​chmod +x $HOME/script/quota.csh
  8. 新增.cshrc設定檔
    ​​​​cd $HOME ​​​​cat > $HOME/.cshrc << EOF ​​​​# .cshrc configuration file for iclab workstation ​​​​# Author: Jyun-Wei, Su ​​​​# Update: 2023.12.23 ​​​​# Show space usage ​​​​source ~/script/quota.csh ​​​​# set terminal preference ​​​​set autolist = ambiguous ​​​​set complete = enhance ​​​​set recexact ​​​​set autoexpand ​​​​# Hotkey ​​​​alias 0 'source ~/script/cd.csh 0' ​​​​alias 1 'source ~/script/cd.csh 1' ​​​​alias 2 'source ~/script/cd.csh 2' ​​​​alias 3 'source ~/script/cd.csh 3' ​​​​alias 4 'source ~/script/cd.csh 4' ​​​​alias 5 'source ~/script/cd.csh 5' ​​​​alias 6 'source ~/script/cd.csh 6' ​​​​alias 7 'source ~/script/cd.csh 7' ​​​​alias 8 'source ~/script/cd.csh 8' ​​​​alias 9 'source ~/script/cd.csh 9' ​​​​alias m 'source ~/script/cd.csh m' ​​​​alias c 'source ~/script/clk.csh' ​​​​alias f 'source ~/script/fsdb.csh' ​​​​alias rs 'source ~/.cshrc' ​​​​alias setting 'code ~/script/setting.csh' ​​​​alias dwip 'evince /usr/cad/synopsys/synthesis/cur/dw/doc/manuals/dwbb_userguide.pdf >& /dev/null &' ​​​​alias io 'evince ~iclabTA01/umc018/Doc/umc18io3v5v.pdf >& /dev/null &' ​​​​alias myps 'ps -aux | grep \$user' ​​​​EOF ​​​​source $HOME/.cshrc
  9. 之後如果要修改Lab路徑
  • 編輯~script/setting.csh中的set FOLDER="Lab??/Exercise"
  • 或直接輸入setting,將跳出
    VSCode 視窗後編輯
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →