[英]How to extend chisel3's bundle to a specific width the value this.getWidth?
我正在將一些 chisel3 bundle 結構重新解釋為另一個 bundle。 說,
val a = Wire(new BundleA)
val b = Wire(new BundleB)
b := a.asTypeOf(b)
兩個bundle的寬度不同,我需要將BundleB擴展到BundleB
的寬度,使BundleA
從MSB開始與BundleB
BundleA
。
我試過了
class BundleB extends Bundle{
val sub = UInt(subfield.W)
val dummy = UInt((fullwidth - this.getWidth).W)
}
但是 B 的寬度仍然只是subfield
,而不是fullwidth
那么如何用虛擬數據和當前寬度構造一束特定寬度呢?
實際上,Chisel 在這里沒有出錯是一個錯誤,但是this.getWidth
導致 Chisel 過早地解析BundleB
,將sub
作為字段抓取但忽略dummy
。
沒有內置方法可以獲取您正在構建的Bundle
的“當前運行寬度”,您需要自己完成,例如:
class BundleB(val subfieldWidth: Int, val fullWidth: Int) extends Bundle {
val sub = UInt(subfieldWidth.W)
private val currentWidth = subfieldWidth // + ... if you have other fields
val dummy = UInt((fullWidth - subfieldWidth).W)
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.