Verilog代碼
以VCS 2017為例,可以使用-autoprotect128/-auto2protect128/-auto3protect128選項,實現(xiàn)不同級別的自動代碼加密。以auto2protect128為例,可以對module內(nèi)除端口列表以外的內(nèi)容加密。
vcs -auto2protect128 -f dut_file_list.f
還有一個-protect128選項,需要先在待加密代碼前后添加“`protect128”和“`endprotect128”。
SystemVerilog代碼
我個人實際測試下來,上面的-autoprotect128/-auto2protect128/-auto3protect128選項不能對SystemVerilog代碼自動加密,只能借助于-protect128選項。如果平時寫代碼過程中就已經(jīng)添加“`protect128”和“`endprotect128”,可以直接使用vcs命令加密:
vcs-protect128-ftb_file_list.f
而如果平時寫代碼時沒有加,下面提供一個Python腳本,在給定文件列表中每個文件的首行添加“`protect128”,末尾添加“`endprotect128”,具體使用sed和echo命令實現(xiàn)文件首尾添加內(nèi)容。?
#add_protect.py
import sys
import os
def main():
if(len(sys.argv) != 2):
print("Optionsilleagal.")
sys.exit()
else:
o_file = sys.argv[1]
add_protect(o_file)
def add_protect(o_file):
try:
f_obj = open(o_file)
except FileNOtFoundError:
print(o_file+" :no such file.")
else:
for line in f_obj:
os.system("sed -i '1i `protect128' " + line)
os.system("echo'`endprotect128'>>"+line)
f_obj.close()
main()
os模塊中的system()函數(shù)接受一個字符串參數(shù),其中包含要執(zhí)行的命令。在21-22行中,line為字符串變量,和前面雙引號中的linux命令拼接在一起,組成system()函數(shù)的字符串參數(shù)。
pythonadd_protect.pytb_file_list.f
審核編輯:黃飛
-
Verilog
+關(guān)注
關(guān)注
30文章
1369瀏覽量
113929 -
字符串
+關(guān)注
關(guān)注
1文章
594瀏覽量
22992 -
VCS
+關(guān)注
關(guān)注
0文章
80瀏覽量
10213 -
python
+關(guān)注
關(guān)注
57文章
4851瀏覽量
89346
原文標題:使用VCS進行代碼加密的方法
文章出處:【微信號:處芯積律,微信公眾號:處芯積律】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。
發(fā)布評論請先 登錄
round robin 的 systemverilog 代碼
請問GLCM verilog代碼不能正常工作該怎么辦?
保護您的 IP 內(nèi)核——第一部分軟 IP,第一節(jié):HDL 代碼的加密
SystemC 和SystemVerilog的比較
使用Verilog/SystemVerilog硬件描述語言練習數(shù)字硬件設(shè)計
從Verilog PLI到SystemVerilog DPI的演變過程
verilog/systemverilog中隱藏的初始化說明
verilog-2005和systemverilog-2017標準規(guī)范
SystemVerilog相比于Verilog的優(yōu)勢

如何對Verilog/SystemVerilog代碼加密
評論