Search code examples
signal-processingchisel

Calling Dsptools produces a Chisel runtime error


I started to program in Chisel recently and I need to use dsptools for my project. However I am having issues to even have a very simple case working.

For example the code below:

package radix2

import chisel3._
import chisel3.experimental._
import chisel3.util._

import dsptools._
import dsptools.numbers._

class Radix2Butterfly extends Module {
  val io = IO(new Bundle {
    val x1 = Input(FixedPoint(6.W, binaryPoint = 2.BP))
    val x2 = Input(FixedPoint(6.W, binaryPoint = 2.BP))

    val y1 = Output(FixedPoint(12.W, binaryPoint = 4.BP))
    val y2 = Output(FixedPoint(12.W, binaryPoint = 4.BP))
  })

  // Real op
  val twiddle = 1.0.F(2.BP)
  io.y1 := io.x1 + twiddle * io.x2
  io.y2 := io.x1 - twiddle * io.x2
}

object Radix2ButterflyMain extends App {
  println("Generating the Butterfly hardware.")
  emitVerilog(new Radix2Butterfly(), Array("--target-dir", "generated"))
}

Works without issue after doing sbt test (I have a simple test).

However just adding a single line with a call to dsptools like this:

package radix2

import chisel3._
import chisel3.experimental._
import chisel3.util._

import dsptools._
import dsptools.numbers._

class Radix2Butterfly extends Module {
  val io = IO(new Bundle {
    val x1 = Input(FixedPoint(6.W, binaryPoint = 2.BP))
    val x2 = Input(FixedPoint(6.W, binaryPoint = 2.BP))

    val a1 = Input(DspComplex(FixedPoint(6.W, 4.BP), FixedPoint(6.W, 4.BP)))

    val y1 = Output(FixedPoint(12.W, binaryPoint = 4.BP))
    val y2 = Output(FixedPoint(12.W, binaryPoint = 4.BP))
  })

  // Real op
  val twiddle = 1.0.F(2.BP)
  io.y1 := io.x1 + twiddle * io.x2
  io.y2 := io.x1 - twiddle * io.x2
}

object Radix2ButterflyMain extends App {
  println("Generating the Butterfly hardware.")
  emitVerilog(new Radix2Butterfly(), Array("--target-dir", "generated"))
}

Produces the following error:

[info] - should pass *** FAILED ***
[info]   java.lang.AssertionError: assertion failed: The Chisel compiler plugin is now required for compiling Chisel code. Please see https://github.com/chipsalliance/chisel3#build-your-own-chisel-projects.
[info]   at ... ()
[info]   at dsptools.numbers.DspComplex.<init>(DspComplex.scala:59)
[info]   at dsptools.numbers.DspComplex$.apply(DspComplex.scala:24)
[info]   at radix2.Radix2Butterfly$$anon$1.$anonfun$a1$1(Radix2Butterfly.scala:21)
[info]   at chisel3.internal.plugin.package$.autoNameRecursively(package.scala:33)
[info]   at radix2.Radix2Butterfly$$anon$1.<init>(Radix2Butterfly.scala:21)
[info]   at radix2.Radix2Butterfly.$anonfun$io$2(Radix2Butterfly.scala:13)
[info]   at chisel3.internal.prefix$.apply(prefix.scala:48)
[info]   at radix2.Radix2Butterfly.$anonfun$io$1(Radix2Butterfly.scala:13)
[info]   at chisel3.internal.plugin.package$.autoNameRecursively(package.scala:33)
[info]   ...

My file build.sbt looks like this:

// scalaVersion := "2.13.7"
 scalaVersion := "2.12.13"

scalacOptions ++= Seq(
  "-deprecation",
  "-feature",
  "-unchecked",
  // "-Xfatal-warnings",
  // "-Xsource:2.11", // not for 3.5, but for 3.4
  "-language:reflectiveCalls",
  "-Xcheckinit",
  // Enables autoclonetype2
  "-P:chiselplugin:genBundleElements" // not for 3.5, but for 3.4
)

resolvers ++= Seq(
  Resolver.sonatypeRepo("snapshots"),
  Resolver.sonatypeRepo("releases")
)

val chiselVersion = "3.5.3"
addCompilerPlugin("edu.berkeley.cs" %% "chisel3-plugin" % chiselVersion cross CrossVersion.full)
libraryDependencies += "edu.berkeley.cs" %% "chisel3" % chiselVersion
libraryDependencies += "edu.berkeley.cs" %% "chisel-iotesters" % "2.5.0"
libraryDependencies += "edu.berkeley.cs" %% "chiseltest" % "0.5.3"
libraryDependencies += "edu.berkeley.cs" %% "rocket-dsptools" % "1.2.6"

Which I believe has everything I need including the Chisel compiler plugin that the error output refers to. Would greatly appreciate help to fix that issue.

Thanks a lot.


Solution

  • rocket-dsptools is compiled against Chisel 3.2.6 [1]. Chisel only maintains binary compatibility for major versions (where the versioning scheme is <epoch>.<major>.<minor>, see [2]). rocket-dsptools is not maintained by anyone so you cannot use it with the newest versions of Chisel. If you would like to, you will need to build it from source (and likely update a lot of things since 3.2.6 is over 2 years old).