|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
rule of thumb/ c1 M8 W# x; \/ ?' F0 ^- w
# ~: R1 S6 {0 G3 x
: i; M# T4 D S- 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
1 o5 t+ l! e% J0 h) Q% U! m* a: @
9 f9 j( I, b. Z9 n0 i5 p y% u3 B) J% B; r0 J& n( p
+ P' F5 `" Z# E( x
basic signed addition8 X) R! F$ {% K% r8 t! l) g* J
( r/ H$ `+ r1 J$ _- r
7 B& c0 w4 U3 I7 {' R+ F. V
* t' H3 q2 B4 n
% T7 _; c v, i5 \1 q
/ r$ ?% h1 P# s ^, I, t |
|