[英]Is signed type valid for each element using typedef + packed array (v.s. multidimensional packed array)
I have a question about signed property with multiple packed dimensions which is defined in stages with typedef. 我有一个关于具有多个打包维度的已签名属性的问题,该属性已在typedef阶段定义。
Basically, 基本上,
logic signed [1:0][2:0] foo;
* foo[0] is not signed (signed is meaningless if you expect signed element) because all entire packed array is signed but each element is not signed. * foo [0]没有签名(如果期望签名的元素,则带符号是没有意义的),因为所有打包数组均已签名,但每个元素均未签名。
But, 但,
typedef logic signed [1:0] foo_t;
foo_t [2:0] foo;
* foo[0] is signed. * foo [0]已签名。 What a strange.. 真奇怪
Q1> What happens? Q1>会发生什么? Why is it signed?? 为什么要签名?
Q2> Is it same declaration with logic signed [1:0][2:0] foo; Q2>是否是逻辑声明为[1:0] [2:0] foo的相同声明? // ?? // ??
Q3> LRM says that [1:0] index varies most rapidly, which is not my expectation. Q3> LRM说[1:0]指数变化最快,这不是我的期望。 logic signed [2:0][1:0] foo; 逻辑符号[2:0] [1:0] foo; //?? //?
This is an artifact of the allowed syntax(BNF). 这是允许的语法(BNF)的伪像。 The signed
keyword applies signedness to the identifier as a whole, not to the individual elements ( logic
) you are packing. signed
关键字将符号性整体应用于标识符,而不应用于您要打包的单个元素( logic
)。 There's no syntax that allowes you to control the signedness of each dimension except by the typedef stages you discovered. 除了发现的typedef阶段外,没有语法可以控制每个维度的签名 。
When you create a multidimensional array in stages, each dimension you add varies less rapidly than the previous. 当您分阶段创建多维数组时,添加的每个维的变化速度都不会比前一个快。 So dimensionally, your typedef is equivalent to 因此,从维度上讲,您的typedef等效于
logic signed [2:0][1:0] foo;
foo_t [2:0] foo; // the [2:0] gets added to the left of [1:0]
If use an unpacked array, we can also keep signed property for each element. 如果使用解压缩数组,我们还可以为每个元素保留签名属性。
logic signed [1:0] foo [2:0];
But, it seems that array of typedef with unpacked array is not supported by systemverilog. 但是,似乎systemverilog不支持带解压缩数组的typedef数组。
typedef logic signed data_t [3:0];
data_t [2:0] foo;
When I try this, compiler shows an error 当我尝试此操作时,编译器显示错误
“illegal element type for a vector (vector element type must be an integral type)”. “向量的非法元素类型(向量元素类型必须为整数类型)”。 - you may leave any comment for this. -您可以对此发表任何评论。
Anyway, thanks for your answer. 无论如何,谢谢您的回答。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.