1. 程式人生 > >Chisel3 - 運算符和位寬推斷

Chisel3 - 運算符和位寬推斷

ttr see 相同 C4D 針對 blink sig event -i

https://mp.weixin.qq.com/s/rI-CJM6GyI6EUHPZ3uYiFg

如同Verilog中的眾多運算符,Chisel也針對自身的數據類型,提供了很多運算符。 Chisel語言內嵌於Scala。在Scala中,基本上所有的運算符都被當做一般的字符,可以作為命名符號(identifier)的一部分。並且Scala支持省略函數調用時,括在參數兩邊的括號。所以Scala中定義運算符重載很簡單,可以很大的提高代碼的可讀性。 1. 運算符 參考鏈接: https://github.com/freechipsproject/chisel3/wiki/Builtin-Operators
a. Bitwise operators ?技術分享圖片? ~ & | ^ 這些其實都是方法名,如: ?技術分享圖片? b. Bitwise reductions ?技術分享圖片? c. Equality comparison. ?技術分享圖片? d. Shifts ?技術分享圖片? e. Bitfield manipulation ?技術分享圖片? f. Logical Operations ?技術分享圖片? g. Arithmetic operations ?技術分享圖片? h. Arithmetic comparisons ?技術分享圖片? 2. 位寬推斷 兩個相同類型但位寬不同的變量,也可以進行運算。運算參數以及運算結果的位寬會進行自動推斷拓展。
參考鏈接: https://github.com/freechipsproject/chisel3/wiki/Width-Inference ?技術分享圖片? Chisel provides bit width inference to reduce design effort. Users are encouraged to manually specify widths of ports and registers to prevent any surprises, but otherwise unspecified widths will be inferred by the Firrtl compiler.
For all circuit components declared with unspecified widths, the FIRRTL compiler will infer the minimum possible width that maintains the legality of all its incoming connections. Implicit here is that inference is done in a right to left fashion in the sense of an assignment statement in chisel, i.e. from the left hand side from the right hand side. If a component has no incoming connections, and the width is unspecified, then an error is thrown to indicate that the width could not be inferred. For module input ports with unspecified widths, the inferred width is the minimum possible width that maintains the legality of all incoming connections to all instantiations of the module. The width of a ground-typed multiplexor expression is the maximum of its two corresponding input widths. For multiplexing aggregate-typed expressions, the resulting widths of each leaf subelement is the maximum of its corresponding two input leaf subelement widths. The width of a conditionally valid expression is the width of its input expression. For the full formal description see the Firrtl Spec.

Chisel3 - 運算符和位寬推斷