2013-10-27 32 views
1

我想實現一個結構化的讀端口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 

謝謝!

回答

1

39/40/41對應的行是什麼?

「when(tag_read)」是什麼意思?你不應該在when語句中使用Bool()而不是對象嗎?

什麼是「line_no」? (順序讀取通過註冊地址來執行)。

什麼是你想用tag_read完成=調節器(TagType())...... [編輯]你創建類型TagType的寄存器,不具有關聯值的節點。 因此,我懷疑錯誤是,如果「tag_read_cond」不是真的,那麼該寄存器沒有默認值/初始值。使用Reg(init = something)可能會修復錯誤[end edits]

我可能會失去對象TagType代碼。我不確定你想用它做什麼。此代碼會宣佈tagType,並給它一組默認值:

val tag_read = new TagType() 
tag_read.valid := Bool(false) 
tag_read.dirty := Bool(false) 
tag_read.tag := UInt(0) 

val tag_ram = Mem(new TagType(), num_lines , seqRead = false) 

when (tag_read_cond) { 
    tag_read := tag_ram(line_no) 
} 

鑿生氣,如果你的變量沒有默認值(即存在通過你的邏輯路徑,其中變量不會得到因爲鑿子不支持X的/不關心)。

雖然你可以拋棄大部分的代碼,可能只寫這個,如果你不介意額外的端口:

val tag_ram = Mem(new TagType(), num_lines , seqRead = false) 
val tag_read = tag_ram(line_no) 

而對於連續的回憶:

val tag_ram = Mem(new TagType(), num_lines , seqRead = true) 
val tag_read = tag_ram(RegEnable(line_no, tag_read_cond)) 

注意地址已註冊,具有啓用條件,可以告訴內存只有在評估爲真時纔讀取它。鑿子手冊給出了關於構建順序存儲器的更多示例/解釋。

+0

感謝您的意見。當然,這是(...)條件中的一個類型,實際上它是Bool變量的時候(...)。爲了初始化默認值,我發現使用companion對象的apply方法很方便。 –

+0

只需添加一行39/40/41即可對應類TagType中的有效,髒,標記字段,謝謝! –

+0

使用對象的apply方法初始化默認值可能是一個好主意,但您必須小心:在這種特殊情況下,Reg(TagType())創建類型爲TagType的寄存器,而Reg(init = TagType() )將在復位後創建具有適當初始值的類型TagType的寄存器。我承認我不使用這種對象應用技術,所以上面的語法可能不正確,但希望這個想法足夠清晰。 – Chris