繁体   English   中英

方法<init> ()V 未在凿子测试中找到</init>

[英]method <init>()V not found in chisel test

我用 Dma 模块编写了一个示例案例,它是esp-chisel-accelerators中的一个子模块,但是当我运行sbt test或运行单个测试时,我收到一个错误: method <init>()V not found the code is :

class QuickDMA_test extends FlatSpec with ChiselScalatestTester with Matchers{
    behavior of "QuickDMAModule"
    // test class body here
    it should "read some number to tlb" in {
        //test case body here
        implicit val parames: Config = (new QuickDMAConfig).toInstance
        test(new Wrapper()(parames)).withAnnotations(Seq(WriteVcdAnnotation )) { c =>
          c.io.control.wen.poke(false.B)
......

Dma 模块是


object DmaSize {
  private val enums = Enum(8)
  val Seq(bytes, wordHalf, word, wordDouble, wordQuad, word8, word16, word32) = enums
  def gen: UInt = chiselTypeOf(enums.head)
}

class DmaControl extends Bundle {
  val index = UInt(32.W)
  val length = UInt(32.W)
  val size = DmaSize.gen
}

class DmaIO(val dmaWidth: Int) extends Bundle {
  val Seq(readControl, writeControl) = Seq.fill(2)(Decoupled(new DmaControl))
  val readChannel = Flipped(Decoupled(UInt(dmaWidth.W)))
  val writeChannel = Decoupled(UInt(dmaWidth.W))
}

class DmaRequest(val memorySize: Int) extends Bundle {
  val index = UInt(log2Up(memorySize).W)
  val length = UInt(log2Up(memorySize).W)
  val tpe = Bool()
}

object DmaRequest {
  val read: Bool = false.B
  val write: Bool = true.B

  def init_(memorySize: Int) = {
    val a = Wire(new Valid(new DmaRequest(memorySize)))
    a.valid := false.B
    a.bits.index := DontCare
    a.bits.length := DontCare
    a.bits.tpe := DontCare
    a
  }
}

class Dma[A <: Data](size: Int, gen: A, initFile: Option[String] = None) extends Module {

  private val dmaWidth = gen.getWidth

  val io = IO(Flipped(new DmaIO(dmaWidth)))

  val req = RegInit(DmaRequest.init_(size))

  /* Only one outstanding read or write request at a time */
  Seq(io.readControl, io.writeControl).map(_.ready := !req.valid)

  val arb = Module(new RRArbiter(new DmaControl, 2))
  arb.io.in
    .zip(Seq(io.readControl, io.writeControl))
    .map{ case (a, b) => a <> b }


我通过实例化一个 Dma 模块

val dma = Module(new Dma(1024, UInt(bitwidth.W), Some("src/test/resource/linear-mem.txt")))

错误是

An exception or error caused a run to abort: treadle.stage.TreadleTesterPhase: method <init>()V not found 
java.lang.NoSuchMethodError: treadle.stage.TreadleTesterPhase: method <init>()V not found
    at chiseltest.backends.treadle.TreadleExecutive$.start(TreadleExecutive.scala:51)
    at chiseltest.defaults.package$.createDefaultTester(defaults.scala:24)
    at chiseltest.ChiselScalatestTester$TestBuilder.apply(ChiselScalatestTester.scala:33)
    at QuickDMA_test.$anonfun$new$1(ANDtest.scala:105)
    at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
    at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
    at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
    at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
    at org.scalatest.Transformer.apply(Transformer.scala:22)
    at org.scalatest.Transformer.apply(Transformer.scala:20)
    at org.scalatest.FlatSpecLike$$anon$5.apply(FlatSpecLike.scala:1682)
    at org.scalatest.TestSuite.withFixture(TestSuite.scala:196)
    at org.scalatest.TestSuite.withFixture$(TestSuite.scala:195)
    at QuickDMA_test.chiseltest$ChiselScalatestTester$$super$withFixture(ANDtest.scala:99)
    at chiseltest.ChiselScalatestTester.$anonfun$withFixture$1(ChiselScalatestTester.scala:50)
    at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
    at chiseltest.ChiselScalatestTester.withFixture(ChiselScalatestTester.scala:50)
    at chiseltest.ChiselScalatestTester.withFixture$(ChiselScalatestTester.scala:47)
    at QuickDMA_test.withFixture(ANDtest.scala:99)
    at org.scalatest.FlatSpecLike.invokeWithFixture$1(FlatSpecLike.scala:1680)
    at org.scalatest.FlatSpecLike.$anonfun$runTest$1(FlatSpecLike.scala:1692)
    at org.scalatest.SuperEngine.runTestImpl(Engine.scala:286)
    at org.scalatest.FlatSpecLike.runTest(FlatSpecLike.scala:1692)
    at org.scalatest.FlatSpecLike.runTest$(FlatSpecLike.scala:1674)
    at org.scalatest.FlatSpec.runTest(FlatSpec.scala:1685)
    at org.scalatest.FlatSpecLike.$anonfun$runTests$1(FlatSpecLike.scala:1750)
    at org.scalatest.SuperEngine.$anonfun$runTestsInBranch$1(Engine.scala:393)
    at scala.collection.immutable.List.foreach(List.scala:431)
    at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:381)
    at org.scalatest.SuperEngine.runTestsInBranch(Engine.scala:370)
    at org.scalatest.SuperEngine.$anonfun$runTestsInBranch$1(Engine.scala:407)
    at scala.collection.immutable.List.foreach(List.scala:431)
    at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:381)
    at org.scalatest.SuperEngine.runTestsInBranch(Engine.scala:376)
    at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:458)
    at org.scalatest.FlatSpecLike.runTests(FlatSpecLike.scala:1750)
    at org.scalatest.FlatSpecLike.runTests$(FlatSpecLike.scala:1749)
    at org.scalatest.FlatSpec.runTests(FlatSpec.scala:1685)
    at org.scalatest.Suite.run(Suite.scala:1124)
    at org.scalatest.Suite.run$(Suite.scala:1106)
    at org.scalatest.FlatSpec.org$scalatest$FlatSpecLike$$super$run(FlatSpec.scala:1685)
    at org.scalatest.FlatSpecLike.$anonfun$run$1(FlatSpecLike.scala:1795)
    at org.scalatest.SuperEngine.runImpl(Engine.scala:518)
    at org.scalatest.FlatSpecLike.run(FlatSpecLike.scala:1795)
    at org.scalatest.FlatSpecLike.run$(FlatSpecLike.scala:1793)
    at org.scalatest.FlatSpec.run(FlatSpec.scala:1685)
    at org.scalatest.tools.SuiteRunner.run(SuiteRunner.scala:45)
    at org.scalatest.tools.Runner$.$anonfun$doRunRunRunDaDoRunRun$13(Runner.scala:1349)
    at org.scalatest.tools.Runner$.$anonfun$doRunRunRunDaDoRunRun$13$adapted(Runner.scala:1343)
    at scala.collection.immutable.List.foreach(List.scala:431)
    at org.scalatest.tools.Runner$.doRunRunRunDaDoRunRun(Runner.scala:1343)
    at org.scalatest.tools.Runner$.$anonfun$runOptionallyWithPassFailReporter$24(Runner.scala:1033)
    at org.scalatest.tools.Runner$.$anonfun$runOptionallyWithPassFailReporter$24$adapted(Runner.scala:1011)
    at org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:1509)
    at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:1011)
    at org.scalatest.tools.Runner$.run(Runner.scala:850)
    at org.scalatest.tools.Runner.run(Runner.scala)
    at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2or3(ScalaTestRunner.java:38)
    at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:25)

Scala 生态系统,有点意料之中:你有相互冲突的依赖关系。 您的chiseltest.backends.treadle.TreadleExecutive$ class 文件包含对类型为treadle.stage.TreadleTesterPhase的无参数构造函数的调用(这就是<init>()V的意思:这是 JVM-ese,表示“构造函数为零arguments”。 <init>是“方法”的名称(构造函数在 JVM 级别具有该名称), ()包含 arguments(中间没有任何内容 - 没有参数), V表示void根据定义,所有构造函数都会这样做。但是,类型treadle.stage.TreadleTesterPhase存在但内部没有无参数构造函数。

通常对此的解释是它在以前的某个版本中曾经使用过,但现在不再使用了,并且您使用的 chiseltest.backends 库是针对仍然拥有它的旧版本编译的。

解决方法是将您的依赖项更新到最新版本。 如果这仍然不起作用,那么 scala 生态系统往往会破坏很多东西并倾向于放弃项目,那么请找出两者中的哪一个“较旧”。 如果该项目已被放弃,或者他们只是发布更新缓慢,请与网站等联系。

如果放弃,开始寻找替代品。 Scala 不是一个很好的生态系统,不能尝试将废弃的项目作为代码库的一部分。 如果没有放弃,请降级另一个,直到错误消失。

这是一个链接错误,您的版本不同步。 请参阅 Chisel 网站以获取有关各个项目的哪些版本协同工作的文档: https://www.chisel-lang.org/chisel3/docs/appendix/versioning.html

特别是,该存储库似乎正在使用与 Chisel 3.2 兼容的项目。 您是否完全更改了构建,或者这只是本地构建?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM