首页 > 解决方案 > Chisel 3.4.2 syncmem 和一个黑盒子。不使用 --repl-seq-mem 选项替换内存

问题描述

我使用 --repl-seq-mem 选项运行 MemtestInst 代码。它有一个黑盒子和一个 SyncReadMem。没有内存替换发生,配置文件为空。如果我评论 MyBBox 线或使用较旧的凿子,更换工作。有效的凿子:

val defaultVersions = Map(
  "chisel3" -> "3.2.5",
  "chisel-iotesters" -> "1.3.5"
  )

这个失败了(到目前为止最新的一个):

val defaultVersions = Map(
  "chisel3" -> "3.4.2",
  "chisel-iotesters" -> "1.5.2"
  )

斯卡拉代码:

package explore

import chisel3._
import chisel3.util._

class MemoryInst extends Module {
  val bitsDatNb = 64
  val bitsAddrNb = 9

  val io = IO(new Bundle {
    val wAddr = Input(UInt(bitsAddrNb.W))
    val wData = Input(UInt(bitsDatNb.W))
    val wEn   = Input(Bool())
    val rAddr = Input(UInt(bitsAddrNb.W))
    val rEn   = Input(Bool())
    val rData = Output(UInt(bitsDatNb.W))
  })

  val myBbox = Module( new MyBBox())
  val memFile = SyncReadMem(1<<bitsAddrNb, UInt(bitsDatNb.W))

  when(io.wEn) {
    memFile.write(io.wAddr, io.wData)
  }
  io.rData := memFile.read(io.rAddr, io.rEn)
}
class MyBBox() extends BlackBox(
  Map(
    "LEN_BITS" -> 8,
    "ADDR_BITS" -> 10,
    "DATA_BITS" -> 64)) with HasBlackBoxResource {

  val io = IO(new Bundle {
    val clock = Input(Clock())
    val reset = Input(Bool())
  })
  setResource("/verilog/someverilog.v")
}

object MemtestInst extends App {
  chisel3.Driver.execute(args, () => new MemoryInst)
}

我错过了什么吗?

提前致谢!

标签: chiselfirrtl

解决方案


我对 Chisel 3.4.0 版有同样的问题

我可以确认您拥有的类似代码适用于没有黑盒的内存映射,而不适用于它。我建议添加以下内容

import chisel3.stage.{ChiselStage, ChiselGeneratorAnnotation}

和改变

object MemtestInst extends App {
  chisel3.Driver.execute(args, () => new MemoryInst)
}

object MemtestInst extends App {
    val annos = Seq(ChiselGeneratorAnnotation(() => 
        new MemoryInst()
    ))
    (new ChiselStage).execute(args, annos)
}

我认为chisel3.Driver.execute是 3.4 及更高版本。


推荐阅读