在systemverilog協(xié)議中,logic定義四態(tài)值,即向量(vector)的每個(gè)位(bit)可以是邏輯0, 1, Z或X,與verilog協(xié)議中的reg很接近。但是logic有個(gè)很明顯的優(yōu)勢,不允許多驅(qū)動(dòng)。
多驅(qū)動(dòng)對(duì)關(guān)鍵字logic而言是語法錯(cuò)誤,在VCS編譯階段就能夠發(fā)現(xiàn),能夠更早得發(fā)現(xiàn)錯(cuò)誤。
而在Verilog協(xié)議中,并沒有強(qiáng)調(diào)reg是不允許多驅(qū)的,因此VCS等編譯工具不會(huì)主動(dòng)報(bào)錯(cuò)。
需要在spyglass lint才能檢查出來,或者通過VCS 仿真發(fā)現(xiàn)。
在芯片設(shè)計(jì)中,更早的暴露問題一直是設(shè)計(jì)和驗(yàn)證人員追求的目標(biāo),因此在RTL編碼時(shí),如果正常設(shè)計(jì)是不允許多驅(qū)動(dòng)的場景中,建議使用logic替代reg。
如下案例中:cfg_mode 被多驅(qū)動(dòng),在實(shí)際項(xiàng)目設(shè)計(jì)中,多驅(qū)動(dòng)的問題往往更加隱蔽,更不容易發(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報(bào)錯(cuò):

如下案例中:cfg_mode 被多驅(qū)動(dòng),但是申明成reg類型,因此VCS不會(huì)報(bào)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
審核編輯:湯梓紅
-
芯片設(shè)計(jì)
+關(guān)注
關(guān)注
15文章
1169瀏覽量
56775 -
Verilog
+關(guān)注
關(guān)注
30文章
1374瀏覽量
114704 -
System
+關(guān)注
關(guān)注
0文章
166瀏覽量
38809 -
VCS
+關(guān)注
關(guān)注
0文章
80瀏覽量
10334 -
編譯
+關(guān)注
關(guān)注
0文章
696瀏覽量
35266
原文標(biāo)題:systemverilog:logic比reg更有優(yōu)勢
文章出處:【微信號(hào):IP與SoC設(shè)計(jì),微信公眾號(hào):IP與SoC設(shè)計(jì)】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。
發(fā)布評(píng)論請(qǐng)先 登錄
SystemVerilog學(xué)習(xí)一 —— 計(jì)數(shù)器
[啟芯公開課] SystemVerilog for Verification
是否有更好的方法來存儲(chǔ)比reg [100,000:0] val更有效的大值
使用SystemVerilog來簡化FPGA中接口的連接方式
噪聲頻譜密度(NSD)比信噪比(SNR)更有用?
SystemVerilog Assertion Handbo
SystemVerilog的斷言手冊
SystemVerilog 3.1a Language Re
SystemVerilog的正式驗(yàn)證和混合驗(yàn)證
數(shù)字硬件建模SystemVerilog之Interface和modport介紹
systemverilog:logic比reg更有優(yōu)勢?
SystemVerilog在硬件設(shè)計(jì)部分有哪些優(yōu)勢
SystemVerilog相比于Verilog的優(yōu)勢
systemverilog:logic比reg更有優(yōu)勢
評(píng)論