I wrote a sample case with a Dma Module which is a sub module in esp-chisel-accelerators, but When I run sbt test
or run a single test, I get an error :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)
......
and the Dma module is
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 }
I instance a Dma module by
val dma = Module(new Dma(1024, UInt(bitwidth.W), Some("src/test/resource/linear-mem.txt")))
and the error is
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)
CodePudding user response:
Scala ecosystem, so kinda expectable: You have conflicting dependencies. Your chiseltest.backends.treadle.TreadleExecutive$
class file contains a call to the no-args constructor of the type treadle.stage.TreadleTesterPhase
(that's what <init>()V
means: That's JVM-ese for "A constructor that has zero arguments". The <init>
is the name of the 'method' (constructors have that name at the JVM level), the ()
contains the arguments (nothing is in between - no arguments) and the V
indicates the function returns void
, which all constructors do by definition. However, the type treadle.stage.TreadleTesterPhase
exists but does not have a no-args constructor inside it.
The usual explanation for this is that it used to in some previous version but it no longer does now, and the chiseltest.backends library you use was compiled against that older version that still had it.
The fix is to update your dependencies to the latest. If that still doesn't work, well, the scala ecosystem tends to break stuff a lot and tends to abandon projects, so then figure out which one of the two is 'older'. Check with the website etc if that project has been abandoned or if they are merely slow to release an update.
If abandoned, start looking for alternatives. Scala is not a great ecosystem to try to keep abandoned projects a part of your codebase. If not abandoned, downgrade the other one until the error goes away.
CodePudding user response:
This is a linkage error, you have versions that are out-of-sync. Please see the Chisel website for documentation on which versions of the various projects work together: https://www.chisel-lang.org/chisel3/docs/appendix/versioning.html
In particular, that repository appears to be using projects that are compatible with Chisel 3.2. Have you changed the build at all or is this just a local build?