我正在尝试实现一个到 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
谢谢!
最佳答案
39/40/41 行对应什么?
“当(tag_read)”是什么意思?难道你不应该在when语句中使用Bool()而不是对象吗?
什么是“line_no”? (通过注册地址来执行顺序读取)。
你想用 tag_read = Reg(TagType()) 来完成什么...[编辑]你正在创建一个 TagType 类型的寄存器,而不是一个具有与其关联的值的节点。 因此我怀疑错误是如果“tag_read_cond”不为真,则该寄存器没有默认/初始值。使用 Reg(init=something) 可能会修复错误[结束编辑]。
我可能会丢失对象 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)
}
如果你的变量没有默认值(即,在你的逻辑中有一条路径,其中变量不会被设置,因为 Chisel 不支持 X/不关心),Chisel 会生气。
尽管你可以放弃大部分代码,如果你不介意额外的端口,可能只写这个:
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))
请注意,地址已注册,并且具有启用条件,可以告诉内存仅在评估为真时才读取它。 Chisel 手册提供了更多有关构建顺序存储器的示例/解释。
关于scala - 凿子:如何避免错误 NO DEFAULT SPECIFIED FOR WIRE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19616144/