rule of thumb
- The format of the signed type is two’s complement. 有符号数均为补码表示
- If any operand in an expression is unsigned the operation is considered to be unsigned. 只有计算表达式右边有无符号数,整个计算式都按照无符号数规则运算
- 只有算式右边全为有符号数,运算才会自动补齐所需的bit数,n+n=n+1.n*n=2n
- The value -4 represented as a 3bit signed hex value would be specified as -3’sh4. A decimal number is always signed. verilog2001中用’s来特别声明有符号数,十进制的数都是有符号数
- Type casting using $unsigned will make the operation unsigned. The operand will be sign extended with 0’s if necessary. $usigned()函数在高位补0
- A=$signed(B) will extend using sign bit. $unsigned()函数会在高位补与符号位相同的bit
basic signed addition
两个n bit数相加,得到n+1 bit结果,比如-2(3’sb110)+3(3’sb011)=1(4’sb0011)

//Code Example 1: Addition - Verilog 1995

本文详细介绍了Verilog中有符号数的表示方法及其在加法、乘法运算中的应用,包括不同版本Verilog语法的区别及注意事项。同时,还探讨了有符号数与无符号数混合运算时的处理方式。
&spm=1001.2101.3001.5002&articleId=80620991&d=1&t=3&u=d616c880ffbd4992810d2ac287efc6ac)
2万+

被折叠的 条评论
为什么被折叠?



