2016-11-08 170 views
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 +%之間有什麼區別?

回答

2

我很抱歉沒有在Wiki運營商頁面中包含這些信息,我很快就會添加它。

你一針見血的頭部與編輯:+&-&正在擴大,運營商的結果的寬度等於最寬的操作數的大小加上1 +%-%在非運營商不斷擴大結果的寬度等於最寬的操作數。

+只是別名到+%-別名到-%

相關問題