在systemverilog協議中,logic定義四態值,即向量(vector)的每個位(bit)可以是邏輯0, 1, Z或X,與verilog協議中的reg很接近。但是logic有個很明顯的優勢,不允許多驅動。
多驅動對關鍵字logic而言是語法錯誤,在VCS編譯階段就能夠發現,能夠更早得發現錯誤。
而在Verilog協議中,并沒有強調reg是不允許多驅的,因此VCS等編譯工具不會主動報錯。
需要在spyglass lint才能檢查出來,或者通過VCS 仿真發現。
在芯片設計中,更早的暴露問題一直是設計和驗證人員追求的目標,因此在RTL編碼時,如果正常設計是不允許多驅動的場景中,建議使用logic替代reg。
如下案例中:cfg_mode 被多驅動,在實際項目設計中,多驅動的問題往往更加隱蔽,更不容易發現。
module try_top ( input clk , // input rst_n , // input [1:0] cfg_mode_in // ); logic [1:0] cfg_mode ; always_ff@(posedge clk, negedge rst_n) if(~rst_n) cfg_mode <= 1'b0; else cfg_mode <= cfg_mode_in; always_ff@(posedge clk, negedge rst_n) if(~rst_n) cfg_mode <= 1'b0; else cfg_mode <= cfg_mode_in; endmodule
VCS報錯:
如下案例中:cfg_mode 被多驅動,但是申明成reg類型,因此VCS不會報ERROR。
module try_top ( input clk , // input rst_n , // input [1:0] cfg_mode_in // ); reg [1:0] cfg_mode ; always@(posedge clk or negedge rst_n) if(~rst_n) cfg_mode <= 1'b0; else cfg_mode <= cfg_mode_in; always@(posedge clk or negedge rst_n) if(~rst_n) cfg_mode <= 1'b0; else cfg_mode <= cfg_mode_in; endmodule
審核編輯:湯梓紅
-
芯片設計
+關注
關注
15文章
1062瀏覽量
55452 -
Verilog
+關注
關注
28文章
1365瀏覽量
111779 -
System
+關注
關注
0文章
166瀏覽量
37559 -
VCS
+關注
關注
0文章
80瀏覽量
9842 -
編譯
+關注
關注
0文章
676瀏覽量
33737
原文標題:systemverilog:logic比reg更有優勢
文章出處:【微信號:IP與SoC設計,微信公眾號:IP與SoC設計】歡迎添加關注!文章轉載請注明出處。
發布評論請先 登錄
SystemVerilog學習一 —— 計數器
[啟芯公開課] SystemVerilog for Verification
是否有更好的方法來存儲比reg [100,000:0] val更有效的大值
使用SystemVerilog來簡化FPGA中接口的連接方式
噪聲頻譜密度(NSD)比信噪比(SNR)更有用?
SystemVerilog Assertion Handbo
SystemVerilog的斷言手冊
SystemVerilog 3.1a Language Re
SystemVerilog的正式驗證和混合驗證
systemverilog:logic比reg更有優勢?

SystemVerilog在硬件設計部分有哪些優勢

SystemVerilog相比于Verilog的優勢

評論