Verilog代碼
以VCS 2017為例,可以使用-autoprotect128/-auto2protect128/-auto3protect128選項(xiàng),實(shí)現(xiàn)不同級(jí)別的自動(dòng)代碼加密。以auto2protect128為例,可以對(duì)module內(nèi)除端口列表以外的內(nèi)容加密。
vcs -auto2protect128 -f dut_file_list.f
還有一個(gè)-protect128選項(xiàng),需要先在待加密代碼前后添加“`protect128”和“`endprotect128”。
SystemVerilog代碼
我個(gè)人實(shí)際測(cè)試下來,上面的-autoprotect128/-auto2protect128/-auto3protect128選項(xiàng)不能對(duì)SystemVerilog代碼自動(dòng)加密,只能借助于-protect128選項(xiàng)。如果平時(shí)寫代碼過程中就已經(jīng)添加“`protect128”和“`endprotect128”,可以直接使用vcs命令加密:
vcs-protect128-ftb_file_list.f
而如果平時(shí)寫代碼時(shí)沒有加,下面提供一個(gè)Python腳本,在給定文件列表中每個(gè)文件的首行添加“`protect128”,末尾添加“`endprotect128”,具體使用sed和echo命令實(shí)現(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ù)接受一個(gè)字符串參數(shù),其中包含要執(zhí)行的命令。在21-22行中,line為字符串變量,和前面雙引號(hào)中的linux命令拼接在一起,組成system()函數(shù)的字符串參數(shù)。
pythonadd_protect.pytb_file_list.f
審核編輯:黃飛
-
Verilog
+關(guān)注
關(guān)注
30文章
1374瀏覽量
114534 -
字符串
+關(guān)注
關(guān)注
1文章
596瀏覽量
23170 -
VCS
+關(guān)注
關(guān)注
0文章
80瀏覽量
10303 -
python
+關(guān)注
關(guān)注
57文章
4877瀏覽量
90071
原文標(biāo)題:使用VCS進(jìn)行代碼加密的方法
文章出處:【微信號(hào):處芯積律,微信公眾號(hào):處芯積律】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。
發(fā)布評(píng)論請(qǐng)先 登錄
round robin 的 systemverilog 代碼
請(qǐng)問GLCM verilog代碼不能正常工作該怎么辦?
保護(hù)您的 IP 內(nèi)核——第一部分軟 IP,第一節(jié):HDL 代碼的加密
SystemC 和SystemVerilog的比較
使用Verilog/SystemVerilog硬件描述語言練習(xí)數(shù)字硬件設(shè)計(jì)
從Verilog PLI到SystemVerilog DPI的演變過程
verilog/systemverilog中隱藏的初始化說明
verilog-2005和systemverilog-2017標(biāo)準(zhǔn)規(guī)范
SystemVerilog相比于Verilog的優(yōu)勢(shì)
如何對(duì)Verilog/SystemVerilog代碼加密
評(píng)論