我想實現一個結構化的讀端口MEM沒有默認:鑿:如何避免錯誤指明的資訊
class TagType() extends Bundle()
{
import Consts._
val valid = Bool()
val dirty = Bool()
val tag = UInt(width = ADDR_MSB - ADDR_LSB + 1)
}
object TagType
{
def apply() = new TagType()
}
val tag_read = TagType()
//val tag_read = Reg(TagType())
val tag_read_port = UInt(width = TagType().getWidth)
val tag_ram = Mem(UInt(width = TagType().getWidth), num_lines , seqRead = false)
when (tag_read) {
tag_read_port := tag_ram(line_no)
tag_read.toBits := tag_read_port
}
當我使用的組合
val tag_read = TagType()
,而不是連續
val tag_read = Reg(TagType())
我得到錯誤
Cache.scala:39: error: NO DEFAULT SPECIFIED FOR WIRE: /*? in class cache.Cache*/ Chisel.Bool(width=1, connect to 0 inputs:()) in component class cache.Cache in class cache.TagType
Cache.scala:40: error: NO DEFAULT SPECIFIED FOR WIRE: /*? in class cache.Cache*/ Chisel.Bool(width=1, connect to 0 inputs:()) in component class cache.Cache in class cache.TagType
Cache.scala:41: error: NO DEFAULT SPECIFIED FOR WIRE: /*? in class cache.Cache*/ Chisel.UInt(width=28, connect to 0 inputs:()) in component class cache.Cache in class cache.TagType
此錯誤信息的含義是什麼?
第二個問題:
是否有可能一個結構化的紅埠一拉SystemVerilog的,即直接讀取的
tag_read.toBites := tag_ram(line_no)
代替
tag_read_port := tag_ram(line_no)
tag_read.toBits := tag_read_port
謝謝!
感謝您的意見。當然,這是(...)條件中的一個類型,實際上它是Bool變量的時候(...)。爲了初始化默認值,我發現使用companion對象的apply方法很方便。 –
只需添加一行39/40/41即可對應類TagType中的有效,髒,標記字段,謝謝! –
使用對象的apply方法初始化默認值可能是一個好主意,但您必須小心:在這種特殊情況下,Reg(TagType())創建類型爲TagType的寄存器,而Reg(init = TagType() )將在復位後創建具有適當初始值的類型TagType的寄存器。我承認我不使用這種對象應用技術,所以上面的語法可能不正確,但希望這個想法足夠清晰。 – Chris