当前位置:文档之家› SystemVerilog介绍

SystemVerilog介绍


3
Copyright@Chang Gung University 2009
SystemVerilog的特性
• Interface簡化 • 資料型態的增加 • 驗證層級提升
4
Copyright@Chang Gung University 2009
SystemVerilog的特性
• Interface簡化
17
Copyright@Chang Gung University 2009
SystemVerilog與Verilog的語法比較
• $fflush
– 用來清空緩衝區的資料。 module top; integer fid,n,r; reg [639:0] str; initial begin fid = $fopen("./test.txt","r"); for(n=0;n<2;n=n+1) begin $fgets(str,fid); $display("Line=%s",str); //$fflush(fid);
Copyright@Chang Gung University 2009
cloes file
test if end of file
16
SystemVerilog與Verilog的語法比較
• $ferror
– 當讀取檔案發生錯誤時,會回傳error code讓我們知道原 因。
module top; integer errno,fid; reg [639:0] str; initial begin fid = $fopen("./test1.txt","r"); #5; errno = $ferror (fid,str); $display("errno:=%d",errno); end
15
Copyright@Chang Gung University 2009
SystemVerilog與Verilog的語法比較
• file I/O 相關函數用法介紹
open file integer file; file=$fopenr("filename"); file=$fopenw("filename"); file=$fopena("filename"); integer file,r; r=$fcloser("filename"); r=$fclosew("filename"); integer file; reg eof; eof=$feof(file);
18
end end endmodule
Copyright@Chang Gung University 2009
SystemVerilog與Verilog的語法比較
• 沒打$fflush的結果
– # Line= –# – # Line= test1 test2
• 打$fflush的結果
– # Line= –# – # Line= test1
13
Copyright@Chang Gung Uerilog的語法比較
• SystemVerilog
– 支援有號數為底的運算
• 例:20 / -2 = -10。
– – – –
增加了次方的運算子,"**"。 做shift的時候會依照是否為有號數來補1或0 允許兩個地方同時呼叫一個function 強化parameter,宣告時可指定其資料型態
2
Copyright@Chang Gung University 2009
What is SystemVerilog?
• SystemVerilog 是一種結合了硬體描述語言(HDL)與 硬體驗證語言(HVL)的語言。 • SystemVerilog 是 IEEE 1364 Verilog-2001擴充後 的標準。 • SystemVerilog 的特色是繼承了 Verilog HDL,VHDL,C,C++。
12
Copyright@Chang Gung University 2009
SystemVerilog與Verilog的語法比較
//Traditional verilog //做a+b+c reg clk,clk1,clk2; initial clk=0,clk1=0,clk2=0; always #10 clk=clk+1; always @(posedge clk) clk1=~clk1; always @(posedge clk1) clk2=~clk2; reg [7:0] d0,d1; reg [7:0] a=0,b=10,c=30; always @(b,c) d0<=a+b+c; always @(a,b,c) d1<=a+b+c; //System verilog //做a+b+c reg clk=0,clk1=0,clk2=0; always #10 clk=clk+1; always @(posedge clk) clk1=~clk1; always @(posedge clk1) clk2=~clk2; reg [7:0] d; reg [7:0] a=0,b=10,c=30; always @(a,b,c) d<=a+b+c;
SystemVerilog 介紹
報告人:鄭智鴻, B9729028 日期:2011/05/25
Copyright © Chang Gung University. Permission required for reproduction or display.
Outline
• • • • • • • • • • • • System Verilog簡介 System Verilog與傳統Verilog比較 資料型態介紹 運算子(operator)介紹 Procedural & Control(程序控制) Tasks and function Interface Class Random constranint Coverage Assertions ModelSim操作介紹
• SystemVerilog它提供了assertion來幫助驗證, assertion 是一種驗證的單元,他能夠對設計的電路 行為進行監看。 • Assertion是一連串的電路行為描述,當一個點的電 路行為發生錯誤就能立刻告知。 • 特色
– 能在發生錯誤時立即提醒 – 是否完成期望中的事項或執行出預期外的結果 – 能以較自動化的方式來驗證設計
• 提高可觀測性
– 傳統的方式無法直接察覺錯誤在哪裡 – 採用assertion來驗證能提高可觀測性
• 提高可控制性
– 傳統的驗證方式很難由人工來產生足夠的測試向量 – 使用Assertion based驗證方式則能提高可控制性
• 提高覆蓋率
– 傳統的人工驗證無法測試到所有可能的情況,所以藉由寫 出足夠數量的assertion來監控各個部分,以達到覆蓋率的 提升。
– SystemVerilog在BUS的表示上,用一條粗線來表示各 Module之間的連結,取代原來要用很多條線來表示的方 式。 SystemVerilog Verilog
5
Copyright@Chang Gung University 2009
SystemVerilog的特性
• 資料型態的增加
– SystemVerilog相較於Verilog擴增了語多資料型別,例 如:class、dynamic、array 、enum等。 – 有助於SystemVerilog在系統層級的建模。
9
Copyright@Chang Gung University 2009
使用Assertion驗證的好處
• 可重複使用
– 當你有一段已知其電路行為的assertion – 你可以把它拿到其它的地方使用 – 此種特性對於驗證來說更加方便
• 提升驗證效率
– Assertion based驗證方式在一發生錯誤就立刻告知,不需 要等到模擬結束。
SystemVerilog與Verilog的語法比較
Interger x,y,z Reg [63:0] m; Initial begin X=-100; Y=-40; Z=30; M=5; $display("x/m=%3d",x/m); $display("y/m=%3d",y/m); $display("x/y=%3d",x/y); $display("y*m=%3d",y*m); $display("k/m=%3d",k/m); //結果 // verilog(REG不支援有號數) x/m=858993439 y/m=858993451 x/y=2 y*m=21474836280 k/m=6 //System verilog x/m=-20 y/m=-8 x/y=2 y*m=-200 k/m=6
• 驗證層級提升
– 以現今的驗證技術,模組層級的驗證已經相當成熟,但提 昇到系統層級時,設計語言的語彙已然不足,所以藉由 SystemVerilog 所提供的功能及豐富的語彙,能使驗證層 級向上提升到系統層級。
6
Copyright@Chang Gung University 2009
SystemVerilog assertion
• 註: parameter的用途是宣告一個固定的常數。
14
Copyright@Chang Gung University 2009
SystemVerilog與Verilog的語法比較
• SystemVerilog強化了存取檔案的功能
相关主题