signed and unsigned of verilog

本文详细介绍了Verilog中表达式类型的确定规则,包括十进制数是有符号的,基于基数的数字(除非使用`s`符号)是无符号的,位选择结果和部分选择结果都是无符号的,比较结果也是无符号的。同时,涉及实数的运算结果为实数,无符号运算结果保持无符号,而有符号运算在扩展宽度时若符号位为`X`或`Z`,则会填充`X`或`Z`。赋值操作时,如果右操作数宽度大于左操作数,高位会被截断,且不强制警告或报告大小不匹配错误。举例说明了不同类型变量赋值后的结果变化。
摘要由CSDN通过智能技术生成

the following are the rules for determining the resulting type of an expression

-----expression type depends only on the oprands .It does not depend on the left-hand(if any)

-----decimal numbers are signed 

-----based_numbers are unsigned,except where the s notation is used in the based specifier

-----bit-select results are unsigned , regardless of the oprands

-----part-select results are unsigned ,regradless of oprands

-----part-select results are unsigned regardless of the oprands even if the part-select specifes the entire vector

reg [15:0] a;
reg signed [7:0] b;
initial
a = b[7:0]; // b[7:0] is unsigned and therefore zero-extended

-----concatenate result are unsigned regtadless of the oprands

-----comparison results (1,0) are unsigned regradless of the oprands

-----reals converted to integers by type coercion are signed

-----the sign and size of any self-determine

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值