在systemverilog協(xié)議中,logic定義四態(tài)值,即向量(vector)的每個位(bit)可以是邏輯0, 1, Z或X,與verilog協(xié)議中的reg很接近。但是logic有個很明顯的優(yōu)勢,不允許多驅(qū)動。
多驅(qū)動對關(guān)鍵字logic而言是語法錯誤,在VCS編譯階段就能夠發(fā)現(xiàn),能夠更早得發(fā)現(xiàn)錯誤。
而在Verilog協(xié)議中,并沒有強調(diào)reg是不允許多驅(qū)的,因此VCS等編譯工具不會主動報錯。
需要在spyglass lint才能檢查出來,或者通過VCS 仿真發(fā)現(xiàn)。
在芯片設(shè)計中,更早的暴露問題一直是設(shè)計和驗證人員追求的目標(biāo),因此在RTL編碼時,如果正常設(shè)計是不允許多驅(qū)動的場景中,建議使用logic替代reg。
如下案例中:cfg_mode 被多驅(qū)動,在實際項目設(shè)計中,多驅(qū)動的問題往往更加隱蔽,更不容易發(fā)現(xiàn)。
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 被多驅(qū)動,但是申明成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
-
驅(qū)動器
+關(guān)注
關(guān)注
54文章
8693瀏覽量
149922 -
仿真器
+關(guān)注
關(guān)注
14文章
1037瀏覽量
85386 -
RTL
+關(guān)注
關(guān)注
1文章
389瀏覽量
61087 -
VCS
+關(guān)注
關(guān)注
0文章
80瀏覽量
9912 -
Verilog語言
+關(guān)注
關(guān)注
0文章
113瀏覽量
8553
發(fā)布評論請先 登錄
SystemVerilog學(xué)習(xí)一 —— 計數(shù)器
[啟芯公開課] SystemVerilog for Verification
是否有更好的方法來存儲比reg [100,000:0] val更有效的大值
使用SystemVerilog來簡化FPGA中接口的連接方式
噪聲頻譜密度(NSD)比信噪比(SNR)更有用?
SystemVerilog Assertion Handbo
SystemVerilog的斷言手冊
SystemVerilog 3.1a Language Re
SystemVerilog的正式驗證和混合驗證
SystemVerilog在硬件設(shè)計部分有哪些優(yōu)勢

systemverilog:logic比reg更有優(yōu)勢

SystemVerilog相比于Verilog的優(yōu)勢

評論