2
我正在試着用official web page給出的GCD示例來學習Chisel3。這個例子使用運算符 - %,這是什麼意思? 這不是在Wiki 上解釋。並且Cheatsheet將「減法」稱爲正常減法符號' - '。'&'和'%'在操作符中的含義是什麼 - &, - %,+&,+%在Chisel3中?
那麼簡單減法' - '和減法百分比' - %'之間有什麼區別?
[編輯]
好的,我發現這些功能chisel3 code下定義:
// TODO: refactor to share documentation with Num or add independent scaladoc
def unary_- : UInt = UInt(0) - this
def unary_-% : UInt = UInt(0) -% this
def +& (other: UInt): UInt = binop(UInt((this.width max other.width) + 1), AddOp, other)
def + (other: UInt): UInt = this +% other
def +% (other: UInt): UInt = (this +& other) tail 1
def -& (other: UInt): UInt = binop(UInt((this.width max other.width) + 1), SubOp, other)
def - (other: UInt): UInt = this -% other
def -% (other: UInt): UInt = (this -& other) tail 1
def * (other: UInt): UInt = binop(UInt(this.width + other.width), TimesOp, other)
def * (other: SInt): SInt = other * this
def/(other: UInt): UInt = binop(UInt(this.width), DivideOp, other)
def % (other: UInt): UInt = binop(UInt(this.width), RemOp, other)
def & (other: UInt): UInt = binop(UInt(this.width max other.width), BitAndOp, other)
def | (other: UInt): UInt = binop(UInt(this.width max other.width), BitOrOp, other)
def^(other: UInt): UInt = binop(UInt(this.width max other.width), BitXorOp, other)
隨着&操作者減法或加法的結果將是bigest操作數加一的位的大小。 但是對於%運算符,運算結果將是bigest操作數的大小......與正常的+或 - 一樣。那麼 - 和 - %和+ an +%之間有什麼區別?