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 +%之间有什么区别?