輸入 0 快速切換到 00_TESTBED
輸入 1 快速切換到 01_RTL
輸入 2 快速切換到 02_SYN
輸入 3 快速切換到 03_GATE
輸入 4 快速切換到 04_MEM
輸入 9 快速切換到 09_SUBMIT
輸入 m 快速切換到 Memory
clk
設定clk
fsdb
設定rtl fsdb
設定gate fsdb
設定post fsdb
設定cd $HOME
src
內的 .cshrc
和 script
資料夾直接丟到家目錄source $HOME/.cshrc
~script/setting.csh
中的set FOLDER="Lab??/Exercise"
setting
,將跳出 VSCode
視窗後進行編輯script
cd $HOME
mkdir script
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
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
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
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
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
.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
~script/setting.csh
中的set FOLDER="Lab??/Exercise"
setting
,將跳出
Learn More →
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up