隊(duì)列同樣可以保存類(lèi)對(duì)象,這在驗(yàn)證環(huán)境中是非常有用的,下面是一個(gè)例子:
class animals;
string sname;
int i1;
function new (string name="UN");
sname = name;
i1++;
endfunction
endclass
module tb;
// queue of class type 'animals'
animals alist [$];
initial begin
animals f, f2; //declare two variables of type animals
// Create a new class object 'f' and push into the queue
f = new ("lion");
alist.push_front (f);
// Create another class object 'f2'and push into the queue
f2 = new ("tiger");
alist.push_back (f2);
// Iterate through queue and access each class object
foreach (alist[i]) begin
$display ("alist[%0d] = %s", i, alist[i].sname);
$display ("alist[%0d] = %p", i, alist[i]);
end
// Simply display the whole queue
$display ("alist = %p", alist);
end
endmodule
仿真log:
# KERNEL: alist[0] = lion
# KERNEL: alist[0] = '{sname:"lion", i1:1}
# KERNEL: alist[1] = tiger
# KERNEL: alist[1] = '{sname:"tiger", i1:1}
# KERNEL: alist = '{'{sname:"lion", i1:1}, '{sname:"tiger", i1:1}}
該示例聲明了一個(gè)名為“animals”的類(lèi),字符串“name”初始化為“UN”。
聲明了兩個(gè)“animals”類(lèi)型的對(duì)象" f "和“f2”。
創(chuàng)建“animals”類(lèi)型的對(duì)象隊(duì)列“alist”。
分別實(shí)例化兩個(gè)對(duì)象“f”和“f2”,然后push到隊(duì)列中。
審核編輯:湯梓紅
聲明:本文內(nèi)容及配圖由入駐作者撰寫(xiě)或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。
舉報(bào)投訴
-
Verilog
+關(guān)注
關(guān)注
30文章
1374瀏覽量
114545 -
System
+關(guān)注
關(guān)注
0文章
166瀏覽量
38700 -
隊(duì)列
+關(guān)注
關(guān)注
1文章
46瀏覽量
11241
原文標(biāo)題:SystemVerilog中的類(lèi)隊(duì)列
文章出處:【微信號(hào):芯片驗(yàn)證工程師,微信公眾號(hào):芯片驗(yàn)證工程師】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
熱點(diǎn)推薦
例說(shuō)Verilog HDL和VHDL區(qū)別
Verilog和VHDL之間的區(qū)別將在本文中通過(guò)示例進(jìn)行詳細(xì)說(shuō)明。對(duì)優(yōu)點(diǎn)和缺點(diǎn)的Verilog和VHDL進(jìn)行了討論。
SystemVerilog 3.1a語(yǔ)言參考手冊(cè)
本參考手冊(cè)詳細(xì)描述了Accellera為使用Verilog硬件描述語(yǔ)言在更高的抽象層次上進(jìn)行系統(tǒng)的建模和驗(yàn)證所作的擴(kuò)展。這些擴(kuò)展將Verilog語(yǔ)言推向了系統(tǒng)級(jí)空間和驗(yàn)證級(jí)空間。SystemVerilog
發(fā)表于 07-22 12:14
?188次下載
SystemC 和SystemVerilog的比較
就 SystemC 和 SystemVerilog 這兩種語(yǔ)言而言, SystemC 是C++在硬件支持方面的擴(kuò)展,而 SystemVerilog 則繼承了 Verilog,并對(duì) Verilo
發(fā)表于 08-16 10:52
?5727次閱讀
System Verilog與verilog的對(duì)比
SystemVerilog語(yǔ)言簡(jiǎn)介 SystemVerilog是一種硬件描述和驗(yàn)證語(yǔ)言(HDVL),它基于IEEE1364-2001 Verilog硬件描述語(yǔ)言(HDL),并對(duì)其進(jìn)行了擴(kuò)展,包括擴(kuò)充
使用Verilog/SystemVerilog硬件描述語(yǔ)言練習(xí)數(shù)字硬件設(shè)計(jì)
HDLBits 是一組小型電路設(shè)計(jì)習(xí)題集,使用 Verilog/SystemVerilog 硬件描述語(yǔ)言 (HDL) 練習(xí)數(shù)字硬件設(shè)計(jì)~
SystemVerilog中的Shallow Copy
SystemVerilog中的句柄賦值和對(duì)象復(fù)制的概念是有區(qū)別的。
FPGA學(xué)習(xí)-SystemVerilog語(yǔ)言簡(jiǎn)介
SystemVerilog是一種硬件描述和驗(yàn)證語(yǔ)言(HDVL),它基于IEEE1364-2001 Verilog硬件描述語(yǔ)言(HDL),并對(duì)其進(jìn)行了擴(kuò)展,包括擴(kuò)充了 C語(yǔ)言 數(shù)據(jù)類(lèi)型、結(jié)構(gòu)、壓縮和非
從Verilog PLI到SystemVerilog DPI的演變過(guò)程
寫(xiě)過(guò)Verilog和systemverilog的人肯定都用過(guò)系統(tǒng)自定義的函數(shù)$display,這是預(yù)定好的,可以直接調(diào)用的功能。
如何實(shí)現(xiàn)全面的SystemVerilog語(yǔ)法覆蓋
SystemVeirlog的全面支持是開(kāi)發(fā)商用仿真器的第一道門(mén)檻。市面上可以找到不少基于純Verilog的仿真器,但是真正能完整支持SystemVerilog 的仍然屈指可數(shù)。如何全面地支持SystemVerilog語(yǔ)言,是開(kāi)發(fā)
verilog/systemverilog中隱藏的初始化說(shuō)明
在Verilog和SystemVerilog中經(jīng)常需要在使用變量或者線網(wǎng)之前,期望變量和線網(wǎng)有對(duì)應(yīng)的初始值
verilog-2005和systemverilog-2017標(biāo)準(zhǔn)規(guī)范
作為邏輯工程師,在FPGA和數(shù)字IC開(kāi)發(fā)和設(shè)計(jì)中,一般采用verilog,VHDL或SystemVerilog等作為硬件描述語(yǔ)言進(jìn)行工程設(shè)計(jì),將一張白板描繪出萬(wàn)里江山圖景。
SystemVerilog在硬件設(shè)計(jì)部分有哪些優(yōu)勢(shì)
談到SystemVerilog,很多工程師都認(rèn)為SystemVerilog僅僅是一門(mén)驗(yàn)證語(yǔ)言,事實(shí)上不只如此。傳統(tǒng)的Verilog和VHDL被稱(chēng)為HDL(Hardware Description
SystemVerilog相比于Verilog的優(yōu)勢(shì)
我們?cè)購(gòu)膶?duì)可綜合代碼的支持角度看看SystemVerilog相比于Verilog的優(yōu)勢(shì)。針對(duì)硬件設(shè)計(jì),SystemVerilog引入了三種進(jìn)程always_ff,always_comb
verilog同步和異步的區(qū)別 verilog阻塞賦值和非阻塞賦值的區(qū)別
Verilog中同步和異步的區(qū)別,以及阻塞賦值和非阻塞賦值的區(qū)別。 一、Verilog中同步和異步的區(qū)別 同步傳輸和異步傳輸是指數(shù)據(jù)在電路中
systemverilog和verilog的區(qū)別
評(píng)論