-
Notifications
You must be signed in to change notification settings - Fork 3
Description
I am currently working on enabling xfuzz support for NutShell(as DUT) and have made the following modifications:
I added ccover support in build.sc:
import mill., scalalib.
import coursier.maven.MavenRepository
import mill._
import mill.scalalib._
import mill.scalalib.publish._
import $file.difftest.build
object ivys {
val scala = "2.13.10"
val chisel_v = "3.6.0"
val chisel = ivy"edu.berkeley.cs::chisel3:3.6.0"
val chiselPlugin = ivy"edu.berkeley.cs:::chisel3-plugin:3.6.0"
}
trait CommonModule extends ScalaModule {
override def scalaVersion = ivys.scala
override def scalacOptions = Seq("-Ymacro-annotations")
}
trait HasChisel extends ScalaModule {
override def ivyDeps = Agg(ivys.chisel)
override def scalacPluginIvyDeps = Agg(ivys.chiselPlugin)
}
trait CcoverModule extends SbtModule
with HasChisel{
def scalaVersion: T[String] = T(ivys.scala)
def sourceRoot = T.sources { T.workspace / "ccover" / "instrumentation" / "src" }
private def getSources(p: PathRef) = if (os.exists(p.path)) os.walk(p.path) else Seq()
def allSources = T { sourceRoot().flatMap(getSources).map(PathRef(_)) }
def chiselModule: Option[ScalaModule] = None
def chiselPluginJar: T[Option[PathRef]] = None
def chiselIvy = Some(ivys.chisel3)
def chiselPluginIvy = Some(ivys.chisel3Plugin)
def ivyDeps = super.ivyDeps() ++ Agg(ivy"edu.berkeley.cs::chiseltest:0.6.2")
}
object ccover extends CcoverModule
trait CommonNS extends SbtModule with CommonModule with HasChisel
object difftest extends CommonNS {
override def millSourcePath = os.pwd / "difftest"
override def ivyDeps = Agg(ivys.chisel)
override def scalacPluginIvyDeps = Agg(ivys.chiselPlugin)
override def scalacOptions = T(SeqString)
}
object generator extends CommonNS {
override def millSourcePath = os.pwd
val isChisel3 = true
override def moduleDeps = super.moduleDeps ++ Seq(
difftest
) ++
Option.when(isChisel3)(ccover)
object test extends SbtModuleTests with TestModule.ScalaTest
}
Then, integrated ccover into the build process by modifying the generator object.
I modify TopMain.scala located in src/test/scala/TopMain.scala.
/**************************************************************************************
- Copyright (c) 2020 Institute of Computing Technology, CAS
- Copyright (c) 2020 University of Chinese Academy of Sciences
- NutShell is licensed under Mulan PSL v2.
- You can use this software according to the terms and conditions of the Mulan PSL v2.
- You may obtain a copy of Mulan PSL v2 at:
-
http://license.coscl.org.cn/MulanPSL2 - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR
- FIT FOR A PARTICULAR PURPOSE.
- See the Mulan PSL v2 for more details.
***************************************************************************************/
package top
import chisel3._
import chisel3.stage.ChiselGeneratorAnnotation
import circt.stage._
import device.AXI4VGA
import difftest.DifftestModule
import nutcore.NutCoreConfig
import sim.SimTop
import system.NutShell
import xfuzz.CoverPoint
class Top extends Module {
val io = IO(new Bundle{})
val nutshell = Module(new NutShell()(NutCoreConfig()))
val vga = Module(new AXI4VGA)
nutshell.io := DontCare
vga.io := DontCare
dontTouch(nutshell.io)
dontTouch(vga.io)
}
object TopMain extends App {
def parseArgs(info: String, args: Array[String]): String = {
var target = ""
for (arg <- args) { if (arg.startsWith(info + "=") == true) { target = arg } }
require(target != "")
target.substring(info.length()+1)
}
val board = parseArgs("BOARD", args)
val core = parseArgs("CORE", args)
val s = (board match {
case "sim" => Nil
case "pynq" => PynqSettings()
case "axu3cg" => Axu3cgSettings()
case "PXIe" => PXIeSettings()
} ) ++ ( core match {
case "inorder" => InOrderSettings()
case "ooo" => OOOSettings()
case "embedded"=> EmbededSettings()
} )
s.foreach{Settings.settings += } // add and overwrite DefaultSettings
println("====== Settings = (" + board + ", " + core + ") ======")
Settings.settings.toList.sortBy(._1)(Ordering.String).foreach {
case (f, v: Long) =>
println(f + " = 0x" + v.toHexString)
case (f, v) =>
println(f + " = " + v)
}
val generator = if (board == "sim") {
ChiselGeneratorAnnotation(() => new SimTop)
}
else {
ChiselGeneratorAnnotation(() => new Top)
}
var exe_args = args.filter{
value => value.forall(char => char!='=')
}
(new ChiselStage).execute(args, Seq(generator) ++ CoverPoint.getTransforms(args)._2
:+ CIRCTTargetAnnotation(CIRCTTarget.SystemVerilog)
:+ FirtoolOption("--disable-annotation-unknown")
)
}
Finally, I executed the following command in the NutShell(https://github.com/OpenXiangShan/xs-env) directory:
make emu XFUZZ=1 FIRRTL_COVER=mux
However, I encountered the following error:
fatal error: 'firrtl-cover.h' file not found
I checked the build directory and found that the corresponding file was indeed not generated. Could you advise if there are any additional modifications I need to make to resolve this issue?