Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Commit

Permalink
Bump to chisel 6 release (#705)
Browse files Browse the repository at this point in the history
* Bump to chisel 6 release

- Bumped chisel -> 6.0.0
 - Fixed missing (moved) 'Width' class
- Bumped scala -> 2.13.12
 - Fixed compilation issues due to 'scala.io' namespace clash
- bump sbt -> 1.9.8
- fix Verilator 5.x coverage
- fix Verilator 5.x tests

* downgrade sbt to 1.9.7 to work around sbt/sbt#7463

* make sure all dependencies are up to date

- bump sbt-ci-release sbt plugin
- bump jna dependency

* print a warning on unsupported annotations

and encourage users to report it for further investigation and possible conversions/workarounds.

* add help2man install for verilator dependencies

- add jvm 21 to tests
- bump ubuntu (only verilator test for now) to 22.04 (LTS)

* rollback verilator reg. to ubuntu 20.04

due to verilator/verilator#3993
(hopefully we can build newer versions of verilator on 20.04)

* ignore firrtl ConstType and only consider the  underlying type

* remote verilator tests for 5.018 and 5.020
  • Loading branch information
kammoh authored Feb 5, 2024
1 parent b2d8908 commit c9917be
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 34 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
scala: [ 2.13.10 ]
jvm: [ 8, 11, 20 ]
scala: [ 2.13.12 ]
jvm: [ 8, 11, 20, 21 ]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -86,20 +86,20 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
# 4.028: Ubuntu 20.04, Fedora 32
# 4.028: Ubuntu 22.04, Fedora 32
# 4.032: Fedora 33
# 4.034: Chipyard
# 4.038: Ubuntu 20.10
# 4.108: Fedora 34
# 4.200: currently the latest version on brew (MacOS)
# 4.202: added "forcePerInstance" to support our coverage flow
# 5.018: current version on Homebrew (5/2/2024)
# 5.020: latest release (5/2/2024)
version: ["4.028", "4.032", "4.034", "4.038", "4.108", "4.200", "4.202"]

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Verilator Build Dependencies
run: sudo apt-get install -y git make autoconf g++ flex bison libfl2 libfl-dev
run: sudo apt-get install -y git make autoconf g++ flex bison libfl2 libfl-dev help2man
- name: Cache Verilator ${{ matrix.version }}
uses: actions/cache@v3
id: cache-verilator
Expand Down
11 changes: 6 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@

lazy val commonSettings = Seq(
organization := "edu.berkeley.cs",
scalaVersion := "2.13.10",
crossScalaVersions := Seq("2.13.10")
scalaVersion := "2.13.12",
crossScalaVersions := Seq("2.13.12")
)

val chiselVersion = "6.0.0-M3"
val chiselVersion = "6.0.0"
val firrtlVersion = "6.0-SNAPSHOT"

lazy val chiseltestSettings = Seq(
name := "chiseltest",
// we keep in sync with chisel version names
version := "6.0-SNAPSHOT",
version := "6.0.0",
scalacOptions := Seq(
"-deprecation",
"-feature",
"-Xcheckinit",
"-language:reflectiveCalls",
// do not warn about firrtl imports, once the firrtl repo is removed, we will need to import the code
"-Wconf:cat=deprecation&msg=Importing from firrtl is deprecated:s",
Expand All @@ -28,7 +29,7 @@ lazy val chiseltestSettings = Seq(
"org.chipsalliance" %% "chisel" % chiselVersion,
"edu.berkeley.cs" %% "firrtl2" % firrtlVersion,
"org.scalatest" %% "scalatest" % "3.2.17",
"net.java.dev.jna" % "jna" % "5.13.0",
"net.java.dev.jna" % "jna" % "5.14.0",
compilerPlugin(("org.chipsalliance" % "chisel-plugin" % chiselVersion).cross(CrossVersion.full))
),
resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.8.2
sbt.version=1.9.7
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
logLevel := Level.Warn
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.11")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
6 changes: 3 additions & 3 deletions src/main/scala/chiseltest/iotesters/PeekPokeTester.scala
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ abstract class PeekPokeTester[T <: Module](val dut: T) extends LazyLogging {
private def maskedBigInt(bigInt: BigInt, width: Int): BigInt = bigInt & ((BigInt(1) << width) - 1)

// helps us work around the fact that signal.width is private!
private def getFirrtlWidth(signal: Bits): chisel3.internal.firrtl.Width = signal.widthOption match {
case Some(value) => chisel3.internal.firrtl.KnownWidth(value)
case None => chisel3.internal.firrtl.UnknownWidth()
private def getFirrtlWidth(signal: Bits): chisel3.Width = signal.widthOption match {
case Some(value) => chisel3.KnownWidth(value)
case None => chisel3.UnknownWidth()
}

/** Locate a specific bundle element, given a name path. TODO: Handle Vecs
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/chiseltest/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ package object chiseltest {
}

// helps us work around the fact that signal.width is private!
def getFirrtlWidth(signal: Bits): chisel3.internal.firrtl.Width = signal.widthOption match {
case Some(value) => chisel3.internal.firrtl.KnownWidth(value)
case None => chisel3.internal.firrtl.UnknownWidth()
def getFirrtlWidth(signal: Bits): chisel3.Width = signal.widthOption match {
case Some(value) => chisel3.KnownWidth(value)
case None => chisel3.UnknownWidth()
}

def boolBitsToString(bits: BigInt): String = (bits != 0).toString
Expand Down
8 changes: 7 additions & 1 deletion src/main/scala/chiseltest/simulator/ChiselBridge.scala
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ private object ChiselBridge {
// ignoreDecodeTableAnnotation since it is not needed by the firrtl compiler
case _: DecodeTableAnnotation => None
//
case _ => throw new NotImplementedError(s"TODO: convert ${anno}")
case _ =>
println(
s"[WARNING] Unsupported annotation: ${anno.getClass.getSimpleName}\n" +
s" Please report this issue at https://github.com/ucb-bar/chiseltest/issues"
)
Some(UnsupportedAnnotation(anno.getClass.getSimpleName, anno.toString))
}

private def convert(c: Circuit): firrtl2.ir.Circuit =
Expand Down Expand Up @@ -200,6 +205,7 @@ private object ChiselBridge {
case AsyncResetType => firrtl2.ir.AsyncResetType
case AnalogType(w) => firrtl2.ir.AnalogType(convert(w))
case UnknownType => firrtl2.ir.UnknownType
case ConstType(tpe) => convert(tpe)
case BundleType(fields) =>
firrtl2.ir.BundleType(fields.map { case Field(name, flip, tpe) =>
firrtl2.ir.Field(name, convert(flip), convert(tpe))
Expand Down
22 changes: 17 additions & 5 deletions src/main/scala/chiseltest/simulator/VerilatorCoverage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ private object VerilatorCoverage {
Coverage.collectCoverageAnnotations(annos) ++ annos.collect { case a: OrderedCoverPointsAnnotation => a }
}

def loadCoverage(annos: AnnotationSeq, coverageData: os.Path): List[(String, Long)] = {
def loadCoverage(annos: AnnotationSeq, coverageData: os.Path, version: (Int, Int)): List[(String, Long)] = {
val entries = parseCoverageData(coverageData)
verilatorCoverageToCoverageMap(entries, annos)
verilatorCoverageToCoverageMap(entries, annos, version)
}

private def verilatorCoverageToCoverageMap(es: List[CoverageEntry], annos: AnnotationSeq): List[(String, Long)] = {
private def verilatorCoverageToCoverageMap(es: List[CoverageEntry], annos: AnnotationSeq, version: (Int, Int))
: List[(String, Long)] = {
// map from module name to an ordered list of cover points in said module
val coverPoints = annos.collect { case a: OrderedCoverPointsAnnotation => a.target.module -> a.covers }.toMap
// map from instance path name to the name of the module
Expand All @@ -49,8 +50,19 @@ private object VerilatorCoverage {
// process the coverage entries on a per instance basis
es.groupBy(_.path).toList.flatMap { case (name, entries) =>
// we look up the cover points by first converting to the module name
val covers = coverPoints(instToModule(name))
processInstanceCoverage(name, covers, entries)
instToModule.get(name) match {
case Some(module) =>
val covers = coverPoints(module)
processInstanceCoverage(name, covers, entries)
case None if name.contains("*") =>
instToModule.flatMap {
case (inst, module) if inst.matches(name.replace("*", ".*")) =>
val covers = coverPoints(module)
processInstanceCoverage(inst, covers, entries)
case _ => Nil
}
case _ => throw new RuntimeException(s"Could not find module for instance: $name")
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/chiseltest/simulator/VerilatorSimulator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private object VerilatorSimulator extends Simulator {
val coverageFile = targetDir / "coverage.dat"
def readCoverage(): List[(String, Long)] = {
assert(os.exists(coverageFile), s"Could not find `$coverageFile` file!")
VerilatorCoverage.loadCoverage(coverageAnnos, coverageFile)
VerilatorCoverage.loadCoverage(coverageAnnos, coverageFile, (majorVersion, minorVersion))
}

val args = getSimulatorArgs(state)
Expand Down Expand Up @@ -152,7 +152,7 @@ private object VerilatorSimulator extends Simulator {
val coverageFile = targetDir / "coverage.dat"
def readCoverage(): List[(String, Long)] = {
assert(os.exists(coverageFile), s"Could not find `$coverageFile` file!")
VerilatorCoverage.loadCoverage(coverageAnnos, coverageFile)
VerilatorCoverage.loadCoverage(coverageAnnos, coverageFile, (majorVersion, minorVersion))
}

val args = getSimulatorArgs(state)
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/treadle2/stage/phases/GetFirrtlAst.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object GetFirrtlAst extends Phase {
def handleFirrtlFile(): Option[AnnotationSeq] = {
annotationSeq.collectFirst { case FirrtlFileAnnotation(fileName) => fileName } match {
case Some(fileName) =>
val file = io.Source.fromFile(fileName)
val file = scala.io.Source.fromFile(fileName)
val text = file.mkString
file.close()

Expand Down
4 changes: 1 addition & 3 deletions src/test/scala/chiseltest/simulator/Verilator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class VerilatorSpecificTests extends FlatSpecWithTargetDir {
val (_, out) = CaptureStdout {
sim.findVersions()
}
assert(out.contains("Found Verilator 4"))
assert(out.contains("Found Verilator "))
}

it should "print out commands and verilator results in debug mode" taggedAs RequiresVerilator in {
Expand All @@ -45,8 +45,6 @@ class VerilatorSpecificTests extends FlatSpecWithTargetDir {
val verilatorBinName = if (JNAUtils.isWindows) { "verilator_bin" }
else { "verilator" }
assert(out.contains(s"${verilatorBinName} --cc --exe "))
assert(out.contains("g++"))
assert(out.contains("perl"))
assert(out.contains("make -C"))
}
}
2 changes: 1 addition & 1 deletion src/test/scala/chiseltest/tests/VecPokeExpectTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.scalatest.freespec.AnyFreeSpec

class UsesVec extends Module {
val in = IO(Input(Vec(4, UInt(5.W))))
val addr = IO(Input(UInt(8.W)))
val addr = IO(Input(UInt(2.W)))
val out = IO(Output(UInt(5.W)))

out := in(addr)
Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/treadle2/ModuleInLineSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ModuleInLineSpec extends AnyFlatSpec with Matchers with LazyLogging {

it should "expand instances as found" in {
val stream = getClass.getResourceAsStream("/treadle/three_deep.fir")
val input = io.Source.fromInputStream(stream).mkString
val input = scala.io.Source.fromInputStream(stream).mkString

TreadleTestHarness(Seq(FirrtlSourceAnnotation(input))) { tester =>
tester.engine.symbolTable.outputPortsNames.size should be > 0
Expand All @@ -21,7 +21,7 @@ class ModuleInLineSpec extends AnyFlatSpec with Matchers with LazyLogging {

it should "nester registers should all be using the same clock" in {
val stream = getClass.getResourceAsStream("/treadle/NestedModsWithReg.fir")
val input = io.Source.fromInputStream(stream).mkString
val input = scala.io.Source.fromInputStream(stream).mkString

TreadleTestHarness(Seq(FirrtlSourceAnnotation(input))) { tester =>
def testIt(): Unit = {
Expand Down

0 comments on commit c9917be

Please sign in to comment.