2016-11-08 3 views
2

나는 official web page에 주어진 GCD 예제로 Chisel3을 배우려고합니다. 이 예제에서는 - %라는 연산자를 사용합니다. 그 의미는 무엇입니까? Wiki 에 설명되어 있지 않습니다. 그리고 Cheatsheet은 "빼기"를 정상적인 빼기 기호 '-'로 말합니다.'&'및 '%'는 연산자에서 - Chisel3의 &, - %, + &, + %를 의미합니까?

그럼 간단한 빼기 '-'와 퍼센트 빼기 '- %'의 차이점은 무엇입니까?

[편집]

좋아, 발견 chisel3 code 하에서 이러한 함수의 정의 : 빼기 또는 첨가의 결과가 상기의 bigest 피연산자 플러스 하나의 비트 크기가 될 것이다

// 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) 

& 연산자로 . % operator를 사용하면 연산 결과는 가장 큰 피연산자의 크기가됩니다. normal + 또는 -와 같습니다. 그런 다음 -와 - %와 +와 + % 사이의 차이점은 무엇입니까?

답변

2

Wiki 운영자 페이지에이 정보가 포함되지 않았 음을 알려 주시면 곧 추가하겠습니다.

당신은 당신의 편집으로 머리에 못을 명중했다 : +&-&은 결과의 폭이 가장 넓은 피연산자의 크기에 1을 더한 동일 점에서 연산자를 확대하고있다 +%-%이 아닌 확장 운영자입니다 결과의 너비는 가장 넓은 피연산자와 같습니다.

++%의 별명은 -이고 별명은 -%입니다.