From 5f97bd464dcbad6f797a7687dd8ebf53c61ca172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksandar=20Kondi=C4=87?= Date: Tue, 22 Aug 2023 16:53:57 +0200 Subject: [PATCH] Remove chiseltest hack for peeking and poking FixedPoint * Update sbt version to 1.8.2 * Update build.sbt --- .gitignore | 3 + .gitmodules | 2 +- build.sbt | 100 +++++++++--------- project/build.properties | 2 +- .../dsptools/misc/PeekPokeDspExtensions.scala | 7 +- src/test/scala/dsptools/numbers/LnSpec.scala | 3 +- 6 files changed, 59 insertions(+), 58 deletions(-) diff --git a/.gitignore b/.gitignore index 59408220..1b87efd9 100644 --- a/.gitignore +++ b/.gitignore @@ -344,3 +344,6 @@ hs_err_pid* # ignore lib from rocket build lib + +# bsp +.bsp/ diff --git a/.gitmodules b/.gitmodules index e60bee65..1c9f428d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "fixedpoint"] path = fixedpoint - url = https://github.com/ucb-bar/fixedpoint + url = https://github.com/ucb-bar/fixedpoint.git diff --git a/build.sbt b/build.sbt index 200e6c56..b536c008 100644 --- a/build.sbt +++ b/build.sbt @@ -5,17 +5,13 @@ enablePlugins(SiteScaladocPlugin) enablePlugins(GhpagesPlugin) val defaultVersions = Map( - "chisel3" -> "3.6-SNAPSHOT", - "chiseltest" -> "0.6-SNAPSHOT" + "chisel3" -> "3.6.0", + "chiseltest" -> "0.6.2" ) name := "dsptools" val commonSettings = Seq( - organization := "edu.berkeley.cs", - version := "1.6-SNAPSHOT", - git.remoteRepo := "git@github.com:ucb-bar/dsptools.git", - autoAPIMappings := true, scalaVersion := "2.13.10", scalacOptions ++= Seq("-encoding", "UTF-8", @@ -25,52 +21,15 @@ val commonSettings = Seq( "-language:reflectiveCalls", "-Xfatal-warnings", "-Ymacro-annotations"), - javacOptions ++= Seq("-source", "1.8", "-target", "1.8"), - pomExtra := (http://chisel.eecs.berkeley.edu/ - - - apache_v2 - https://opensource.org/licenses/Apache-2.0 - repo - - - - - grebe - Paul Rigge - http://www.eecs.berkeley.edu/~rigge/ - - - shunshou - Angie Wang - https://www.linkedin.com/in/angie-wang-ee/ - - - chick - Charles Markley - https://aspire.eecs.berkeley.edu/author/chick/ - - ), - publishTo := { - val v = version.value - val nexus = "https://oss.sonatype.org/" - if (v.trim.endsWith("SNAPSHOT")) { - Some("snapshots".at(nexus + "content/repositories/snapshots")) - } else { - Some("releases".at(nexus + "service/local/staging/deploy/maven2")) - } - }, - resolvers ++= Seq( - Resolver.sonatypeRepo("snapshots"), - Resolver.sonatypeRepo("releases") - ), + resolvers ++= Resolver.sonatypeOssRepos("snapshots"), + resolvers ++= Resolver.sonatypeOssRepos("releases"), libraryDependencies ++= { CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, major)) if major <= 12 => Seq() - case _ => Seq("org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.3") + case _ => Seq("org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4") } }, - libraryDependencies ++= Seq("chisel3", "chiseltest").map { dep: String => + libraryDependencies ++= Seq("chisel3").map { dep: String => "edu.berkeley.cs" %% dep % sys.props.getOrElse(dep + "Version", defaultVersions(dep)) }, addCompilerPlugin(("edu.berkeley.cs" %% "chisel3-plugin" % defaultVersions("chisel3")).cross(CrossVersion.full)), @@ -78,11 +37,52 @@ val commonSettings = Seq( val dsptoolsSettings = Seq( name := "dsptools", + organization := "edu.berkeley.cs", + version := "1.6-SNAPSHOT", + git.remoteRepo := "git@github.com:ucb-bar/dsptools.git", + autoAPIMappings := true, libraryDependencies ++= Seq( "org.typelevel" %% "spire" % "0.18.0", "org.scalanlp" %% "breeze" % "2.1.0", "org.scalatest" %% "scalatest" % "3.2.15" % "test" ), + libraryDependencies ++= Seq("chiseltest").map { dep: String => + "edu.berkeley.cs" %% dep % sys.props.getOrElse(dep + "Version", defaultVersions(dep)) + }, + pomExtra := http://chisel.eecs.berkeley.edu/ + + + apache_v2 + https://opensource.org/licenses/Apache-2.0 + repo + + + + + grebe + Paul Rigge + http://www.eecs.berkeley.edu/~rigge/ + + + shunshou + Angie Wang + https://www.linkedin.com/in/angie-wang-ee/ + + + chick + Charles Markley + https://aspire.eecs.berkeley.edu/author/chick/ + + , + publishTo := { + val v = version.value + val nexus = "https://oss.sonatype.org/" + if (v.trim.endsWith("SNAPSHOT")) { + Some("snapshots".at(nexus + "content/repositories/snapshots")) + } else { + Some("releases".at(nexus + "service/local/staging/deploy/maven2")) + } + }, ) val fixedpointSettings = Seq( @@ -94,7 +94,7 @@ val fixedpointSettings = Seq( publishMavenStyle := true -publishArtifact in Test := false +Test / publishArtifact := false pomIncludeRepository := { x => false } @@ -117,5 +117,5 @@ val dsptools = (project in file(".")) .dependsOn(fixedpoint) //.enablePlugins(BuildInfoPlugin) .enablePlugins(ScalaUnidocPlugin) - .settings(commonSettings: _*) - .settings(dsptoolsSettings: _*) + .settings(commonSettings) + .settings(dsptoolsSettings) diff --git a/project/build.properties b/project/build.properties index 0837f7a1..46e43a97 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.3.13 +sbt.version=1.8.2 diff --git a/src/main/scala/dsptools/misc/PeekPokeDspExtensions.scala b/src/main/scala/dsptools/misc/PeekPokeDspExtensions.scala index 68970b50..e28eccf6 100644 --- a/src/main/scala/dsptools/misc/PeekPokeDspExtensions.scala +++ b/src/main/scala/dsptools/misc/PeekPokeDspExtensions.scala @@ -13,15 +13,12 @@ import dsptools.numbers._ trait PeekPokeDspExtensions { this: PeekPokeTester[_] => - private def fixedName(node: FixedPoint): String = - node.instanceName.replace('.', '_') - private def dspPeek(node: Data): (Double, BigInt) = { val bi: BigInt = node match { // Unsigned bigint case r: DspReal => peek(r.node.asInstanceOf[Bits]) case b: Bits => peek(b.asInstanceOf[Bits]) - case f: FixedPoint => peek(fixedName(f)) + case f: FixedPoint => peek(f.asSInt.asInstanceOf[Bits]) } val (dblOut, bigIntOut) = node match { case _: DspReal => (DspTesterUtilities.bigIntBitsToDouble(bi), bi) @@ -62,7 +59,7 @@ trait PeekPokeDspExtensions { case f: FixedPoint => f.binaryPoint match { case KnownBinaryPoint(bp) => - poke(fixedName(f) /*f.asSInt.asInstanceOf[Bits]*/, FixedPoint.toBigInt(value, bp)) + poke(f.asSInt.asInstanceOf[Bits], FixedPoint.toBigInt(value, bp)) case _ => throw DspException("Must poke FixedPoint with known binary point") } case r: DspReal => poke(r.node.asInstanceOf[Bits], DspTesterUtilities.doubleToBigIntBits(value)) diff --git a/src/test/scala/dsptools/numbers/LnSpec.scala b/src/test/scala/dsptools/numbers/LnSpec.scala index ce957ff1..c3506c68 100644 --- a/src/test/scala/dsptools/numbers/LnSpec.scala +++ b/src/test/scala/dsptools/numbers/LnSpec.scala @@ -21,11 +21,12 @@ class LnTester(c: LnModule) extends PeekPokeTester(c) with PeekPokeDspExtensions poke(c.io.num, 11.0) private val x = peek(c.io.ln) println(s"poked 1.0 got $x expected ${math.log(11.0)}") - } + class LnSpec extends AnyFreeSpec with ChiselScalatestTester { "ln should work" in { test(new LnModule) + .withAnnotations(Seq(VerilatorBackendAnnotation)) .runPeekPoke(new LnTester(_)) } }