1. 程式人生 > >Chisel3 - bind - Binding

Chisel3 - bind - Binding

https://mp.weixin.qq.com/s/2318e6VJ4wFGpWwBOmTikA   Chisel資料型別(Data)與Module的繫結關係,根據Data的使用方式不同,而有多種繫結型別。   參考連結: https://github.com/freechipsproject/chisel3/blob/master/chiselFrontend/src/main/scala/chisel3/core/Binding.scala   1. Binding   型別繼承圖如下: 其中:
a. interface指代traint; b. 箭頭意思為繼承(extends);   可以看到這些繫結中,有: a. 受控(constrained)和不受控的繫結; b. 只讀繫結; c. 頂層繫結、子繫結; d. 直連(Wire)繫結和暫存器(Reg)繫結; e. 字面量(Literal)繫結,操作繫結; f. 還有不關心(DontCare)的繫結;   2. 繫結相關的異常   分別為: a. ExpectedChiselTypeException: A function expected a Chisel type but got a hardware object
b. ExpectedHardwareException: A function expected a hardware object but got a Chisel type c. MixedDirectionAggregateException: An aggregate had a mix of specified and unspecified directionality children d. RebindingException: Attempted to re-bind an already bound (directionality or hardware) object
    3. requireIsHardware vs. requireIsChiselType   Hardware跟Chisel type並不是互斥的。事實上,兩者都是針對類Data而言的。差別只在於是否繫結。   Data是Chisel中的基本資料型別,Bits/SInt/UInt/Bool/Aggregate都是其子類。這些資料變數(variable)的容器只有兩種:線和暫存器。如果把資料變數放到容器中,連線到hardware graph中,這個資料變數就是hardware的一部分,requireIsHardware(dataVariable)就是真。反之,如果Data型別的資料變數只是一個變數,而沒有連線到hardware graph中,則就只是一個孤立的chisel type的資料變數,而非hardware的一部分。   所以,這兩個命名實際上並不貼切,反而註釋裡面就很好,requireIsBound/requireIsUnBound,或者更詳細一點,requireIsBoundIntoHardwareGraph/requireIsNotBoundIntoHardwareGraph。