简体   繁体   English

带位选择器和不带位选择器的赋值有什么区别? (e/Specman)

[英]What is difference between assignment with and without bit selector? (e/Specman)

I'm coding in e (Specman) programming language.我正在使用 e(Specman)编程语言进行编码。 If I want to assign integer variable with constant, what is the difference if I use bit selector (selecting all 32 bits) or not?如果我想用常量分配整数变量,如果我使用位选择器(选择所有 32 位)有什么区别?

I wanted to assign integer variable with negative constant in form: 32'b1... but this value was automatically cast to positive number (larger than MAX_INT) and I got the error.我想以以下形式分配具有负常量的整数变量:32'b1...但是这个值被自动转换为正数(大于MAX_INT)并且我得到了错误。 Then I tried using bit selector ([31:0]) on variable and assignment passed with no errors.然后我尝试在变量上使用位选择器 ([31:0]),并且没有错误地通过赋值。 Good number was assigned to variable.好的数字被分配给变量。 I'm not sure why is this case.我不确定为什么会这样。 What is the reason negative number is automatically cast when we don't use bit selector, and why not when we use it.当我们不使用位选择器时自动转换负数的原因是什么,为什么不使用它。

Code with error:有错误的代码:

int_variable = 32'b111111111111111111111111

Code with no error:没有错误的代码:

int_variable[31:0] = 32'b111111111111111111111111

The docs say文档说

In an assignment (lhs = rhs), the right-hand side (rhs) expression inherits the context of the left-hand side (lhs) expression在赋值 (lhs = rhs) 中,右侧 (rhs) 表达式继承左侧 (lhs) 表达式的上下文

So your rhs expression should automatically be cast to -1 (assuming your code contains 32 or more 1's; for 31 1's you would get MAX_INT).因此,您的 rhs 表达式应该自动转换为 -1(假设您的代码包含 32 个或更多 1;对于 31 个 1,您将获得 MAX_INT)。

I don't think Specman gives an error for this.我不认为 Specman 对此有任何错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM