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

Commit

Permalink
Allow patched versions of Verilator (#582)
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Burns authored Dec 7, 2022
1 parent f3571c5 commit 9a9d347
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/main/scala/chiseltest/simulator/VerilatorSimulator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ private object VerilatorSimulator extends Simulator {
}
}

// example version string: Verilator 4.038 2020-07-11 rev v4.038
// example version string1: Verilator 4.038 2020-07-11 rev v4.038
// example version string2: Verilator 5.002.p 2022-11-15 rev v5.002-12-g58821e0eb
private lazy val version: (Int, Int) = { // (major, minor)
val versionSplitted = os
.proc(
Expand All @@ -59,10 +60,18 @@ private object VerilatorSimulator extends Simulator {
versionSplitted.length > 1 && versionSplitted.head == "Verilator",
s"Unknown verilator version string: ${versionSplitted.mkString(" ")}"
)
val Array(majStr, minStr) = versionSplitted(1).split('.').map(_.trim)
assert(majStr.length == 1 && minStr.length == 3, s"$majStr.$minStr is not of the expected format: D.DDD")
val (maj, min) = (majStr.toInt, minStr.toInt)
// println(s"Detected Verilator version $maj.$min")

val (maj, min) = versionSplitted(1).split('.').map(_.trim) match {
case Array(majStr, minStr) =>
assert(majStr.length == 1 && minStr.length == 3, s"${majStr}.${minStr} is not of the expected format: D.DDD")
(majStr.toInt, minStr.toInt)
case Array(majStr, minStr, s) =>
assert(majStr.length == 1 && minStr.length == 3, s"${majStr}.${minStr} is not of the expected format: D.DDD.s+")
(majStr.toInt, minStr.toInt)
case s =>
assert(false, s"${s} is not of the expected format: D.DDD or D.DDD.s+")
(0, 0)
}
(maj, min)
}

Expand Down

0 comments on commit 9a9d347

Please sign in to comment.