在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
-
驅動器
+關注
關注
54文章
8472瀏覽量
148475 -
仿真器
+關注
關注
14文章
1027瀏覽量
84597 -
RTL
+關注
關注
1文章
388瀏覽量
60489 -
VCS
+關注
關注
0文章
80瀏覽量
9801 -
Verilog語言
+關注
關注
0文章
113瀏覽量
8442
發布評論請先 登錄
相關推薦
SystemVerilog學習一 —— 計數器
[啟芯公開課] SystemVerilog for Verification
是否有更好的方法來存儲比reg [100,000:0] val更有效的大值
使用SystemVerilog來簡化FPGA中接口的連接方式
噪聲頻譜密度(NSD)比信噪比(SNR)更有用?
SystemVerilog Assertion Handbo
SystemVerilog的斷言手冊
SystemVerilog 3.1a Language Re
SystemVerilog的正式驗證和混合驗證
SystemVerilog在硬件設計部分有哪些優勢

systemverilog:logic比reg更有優勢

SystemVerilog相比于Verilog的優勢

評論