SystemVerilog“struct”表示相同或不同數(shù)據(jù)類型的集合。
struct可以作為一個(gè)整體使用,也可以單獨(dú)通過(guò)名稱引用組成這個(gè)struct的元素。由于這些元素的數(shù)據(jù)類型可能不相同,所以不能夠使用數(shù)組。
如果需要在多個(gè)module或者類中使用相同的struct,則應(yīng)該將struct定義(`typedef)放到SystemVerilog package中,然后將其導(dǎo)入到每個(gè)module或者class。
默認(rèn)情況下,struct都是unpacked的,我們也可以顯式地加上關(guān)鍵字。下面是一個(gè)簡(jiǎn)單的示例,展示了array和struct的區(qū)別。
// Normal arrays -> a collection of variables of same data type int array [10]; // all elements are of type ‘int’ bit [7:0] mem [256]; // all elements are of type ‘bit’ // Structures -> a collection of variables of same or different data types struct { byte val1; int val2; string val3; } DataValue;
當(dāng)然,我們也可以定義一個(gè)數(shù)組,其中數(shù)組中的每一個(gè)數(shù)據(jù)項(xiàng)都是一個(gè)struct.
DataValue v1[20]; //array of structures struct { byte val1; int val2[10]; //array within a structure string val3; } DataValue;
審核編輯:湯梓紅
-
Verilog
+關(guān)注
關(guān)注
29文章
1366瀏覽量
112146 -
System
+關(guān)注
關(guān)注
0文章
166瀏覽量
37740 -
Struct
+關(guān)注
關(guān)注
0文章
31瀏覽量
11067
原文標(biāo)題:SystemVerilog中的struct
文章出處:【微信號(hào):芯片驗(yàn)證工程師,微信公眾號(hào):芯片驗(yàn)證工程師】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。
發(fā)布評(píng)論請(qǐng)先 登錄
SystemVerilog中的Virtual Methods
SystemVerilog中的“const”類屬性
SystemVerilog的斷言手冊(cè)
typedef struct的用法
SystemVerilog中$cast的應(yīng)用
SystemVerilog中的操作方法
SystemVerilog中可以嵌套的數(shù)據(jù)結(jié)構(gòu)
Systemverilog中的union
SystemVerilog中的Shallow Copy
SystemVerilog中的Semaphores
C++中struct和class的區(qū)別?
帶你了解SystemVerilog中的關(guān)聯(lián)數(shù)組

Systemverilog中的Driving Strength講解

評(píng)論