一个变量如何确定它的值而不在systemverilog中初始化它? [英] how does a variable to be decided it's value without it's initialize in systemverilog?
问题描述
现在我正在尝试挖掘 systemverilog 如下
Now I'm trying to digging the systemverilog as the below
denaliCdn_ahbTransaction burst1;
task sendTransfers;
burst1= new;
burst1.Direction = DENALI_CDN_AHB_DIRECTION_WRITE;
burst1.FirstAddress = 32'h4020;//16416 M3 and M0 to S1
burst1.Kind = DENALI_CDN_AHB_BURSTKIND_INCR4;
burst1.Size = DENALI_CDN_AHB_TRANSFERSIZE_HALFWORD;
burst1.Data = new [8];
foreach (burst1.Data[ii])
burst1.Data[ii] = ii;
void'(activeMaster1.transAdd(burst1,0));
....
endtask
特别是,从这里开始,如何在未初始化的情况下确定 ii 的值?
Especially, from here , how does ii be decided it's value without initialized ?
foreach (burst1.Data[ii])
burst1.Data[ii] = ii;
一个变量如何在 systemverilog 中没有初始化的情况下确定它的值?
how does a variable to be decided it's value without it's initialize in systemverilog?
推荐答案
您的问题有一个通用的答案和一个特定的答案.
There is a general answer and a specific answer to your question.
一般的答案是 System-Verilog 中的所有类型都初始化为特定值:
The general answer is that all types in System-Verilog initialise to specific values:
int 0
real 0.0
string ""
logic 1'bx
但是,您问题的具体答案是您具体标识的代码
However, the specific answer to your question is that the code you specifically identify
foreach (burst1.Data[ii])
burst1.Data[ii] = ii;
实际上是在执行初始化而不是依赖它.动态数组burst1.data
由8个元素组成
is actually performing initialisation rather than relying on it. The dynamic array burst1.data
is constructed with 8 elements in the line
burst1.Data = new [8];
线
foreach (burst1.Data[ii])
遍历该数组,循环 8 次,每个元素一次.变量 ii
取数组中每个元素的索引值,即 0 到 7.行
iterates over that array, looping 8 times, once for each element. The variable ii
takes the value of the index of each element in the array, ie 0 to 7. The line
burst1.Data[ii] = ii;
将数组的元素 ii
设置为值 ii
,从而初始化数组.
Sets element ii
of the array to the value ii
and so is initialising the array.
这篇关于一个变量如何确定它的值而不在systemverilog中初始化它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!