You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调用Dsptools产生Chisel运行时错误的问题求助

Chisel项目使用dsptools的DspComplex类型时报插件缺失错误

问题现象

近期开始学习使用Chisel进行硬件开发,项目需要依赖dsptools库,运行极简测试用例时出现异常。

  • 初始实现的Radix2Butterfly模块仅使用FixedPoint类型定义IO端口,实现基2蝶形运算的实数操作逻辑,对应代码如下:
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"))
}
  • 执行sbt test运行配套简单测试用例时可正常通过,无报错。
  • 仅在模块的IO Bundle中新增一行DspComplex类型的输入端口a1定义,修改后的代码如下:
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"))
}
  • 再次运行测试抛出如下运行时错误:
[info] - should pass *** FAILED ***
[info]   java.lang.AssertionError: assertion failed: The Chisel compiler plugin is now required for compiling Chisel code. Please see official Chisel documentation for build configuration instructions.
[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]   ...

当前项目配置

当前项目的build.sbt配置如下:

// 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"

配置中已经添加了报错信息提及的Chisel编译器插件相关依赖。

问题原因与修复方法

核心问题是依赖版本不兼容:引入的rocket-dsptools 1.2.6是适配Chisel 3.4.x系列的版本,和项目使用的Chisel 3.5.3存在API、编译器插件逻辑的二进制兼容问题,导致DspComplex类初始化时的插件存在性检查误判,抛出断言错误。
按以下步骤修复即可:

  • 替换dsptools依赖:移除原有rocket-dsptools依赖,添加适配Chisel 3.5系列的dsptools依赖:
libraryDependencies += "edu.berkeley.cs" %% "dsptools" % "1.5.6"
  • 移除冗余编译参数:配置中-P:chiselplugin:genBundleElements是Chisel 3.4时期的插件参数,3.5版本默认开启对应特性,不需要额外配置,删掉这行避免编译警告。
  • 清理编译缓存:执行sbt clean清空历史编译产物,再重新运行sbt test即可正常运行。

内容的提问来源于stack exchange,提问作者Hakime

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.26 22:15:48