方法<init>()在凿子测试中未发现V



我用一个Dma模块编写了一个示例案例,该模块是esp凿加速器中的一个子模块,但当我运行sbt test或运行单个测试时,我会得到一个错误:method <init>()V not found代码是:

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$类文件包含对类型为treadle.stage.TreadleTesterPhase的无参数构造函数的调用(这就是<init>()V的意思:这是JVM ese,表示"一个没有参数的构造函数"。<init>是"方法"的名称(构造函数在JVM级别具有该名称(,()包含参数(无参数之间没有任何内容(,V指示函数返回void,所有构造函数都是这样定义的。但是,类型treadle.stage.TreadleTesterPhase存在,但其中没有无参数构造函数。

对此的常见解释是,它在以前的一些版本中曾经使用过,但现在已经不再使用了,并且您使用的knocktest.backends库是针对仍然存在它的旧版本编译的。

修复方法是将您的依赖项更新为最新版本。如果这仍然不起作用,那么scala生态系统往往会破坏很多东西,并倾向于放弃项目,所以要弄清楚两者中哪一个是"旧的"。与网站等核实该项目是否已被放弃,或者他们发布更新的速度是否很慢。

如果放弃,就开始寻找替代方案。Scala并不是一个很好的生态系统,无法将废弃的项目作为代码库的一部分。如果没有放弃,则降级另一个,直到错误消失。

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

特别是,该存储库似乎正在使用与Chisel 3.2兼容的项目。你改变了版本吗?还是这只是一个本地版本?

最新更新