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

Cant import chiseltest._ #712

Closed
HakamAtassi opened this issue Feb 17, 2024 · 1 comment
Closed

Cant import chiseltest._ #712

HakamAtassi opened this issue Feb 17, 2024 · 1 comment

Comments

@HakamAtassi
Copy link

Hello,

I've been experiencing some difficulty importing chiseltest into my project and have been unable to find why. Testing a simple chisel passthrough module:

package passThrough

import chisel3._
import chisel3.util._


class passThrough extends Module{
  val io = IO(new Bundle{
    val in = Input(UInt(32.W))
    val out = Output(UInt(32.W))
  })

  io.out := io.in
}

Against the test file

package passThrough

import chisel3._
import chisel3.experimental.BundleLiterals._
import chisel3.simulator.EphemeralSimulator._
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.flatspec._
import org.scalatest.matchers.must.Matchers



class passthroghSpec extends AnyFreeSpec with Matchers {
  "passThough should passthough" in {
    simulate(new passThrough) { dut =>
      for(input <- 0 to 1024) {
        dut.io.in.poke(input.U)
        dut.io.out.expect(input.U)
      }

    }
  }
}

works fine. However, including import chiseltest._ into my test file results in "chiseltest not found" (build.sbt included at the end).

package passThrough

import chisel3._
import chisel3.experimental.BundleLiterals._
import chisel3.simulator.EphemeralSimulator._
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.flatspec._
import org.scalatest.matchers.must.Matchers

import chiseltest._    // <<<<<<<<<<<<<< Error here 

class passthroghSpec extends AnyFreeSpec with Matchers {
  "passThough should passthough" in {
    simulate(new passThrough) { dut =>
      for(input <- 0 to 1024) {
        dut.io.in.poke(input.U)
        dut.io.out.expect(input.U)
      }

    }
  }
}

[error] passThroughSpec.scala:10:8: not found: object chiseltest
[error] import chiseltest._

My build file is

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

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",
  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",
    // do not warn about firrtl deprecations
    "-Wconf:cat=deprecation&msg=will not be supported as part of the migration to the MLIR-based FIRRTL Compiler:s"
  ),
  // Always target Java8 for maximum compatibility
  javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
  libraryDependencies ++= Seq(
    "org.chipsalliance" %% "chisel" % chiselVersion,
    "edu.berkeley.cs" %% "chiseltest" % "6.0-SNAPSHOT",            // <<<<<<<<<<<<<<<<, chiseltest added here 

    "edu.berkeley.cs" %% "firrtl2" % firrtlVersion,
    "org.scalatest" %% "scalatest" % "3.2.17",
    "net.java.dev.jna" % "jna" % "5.14.0",
    compilerPlugin(("org.chipsalliance" % "chisel-plugin" % chiselVersion).cross(CrossVersion.full))
  ),
  resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
  resolvers ++= Resolver.sonatypeOssRepos("releases")
)

lazy val publishSettings = Seq(
  publishMavenStyle := true,
  Test / publishArtifact := false,
  pomIncludeRepository := { x => false },
  // scm is set by sbt-ci-release
  pomExtra :=
    <url>https://github.com/ucb-bar/chiseltest/</url>
      <licenses>
        <license>
          <name>Apache-2.0</name>
          <url>https://opensource.org/licenses/Apache-2.0</url>
          <distribution>repo</distribution>
        </license>
        <license>
          <name>BSD-3-Clause</name>
          <url>https://opensource.org/licenses/BSD-3-Clause</url>
          <distribution>repo</distribution>
        </license>
      </licenses>
      <developers>
        <developer>
          <id>ekiwi</id>
          <name>Kevin Laeufer</name>
          <email>laeufer@berkeley.edu</email>
        </developer>
        <developer>
          <id>ducky64</id>
          <name>Richard Lin</name>
        </developer>
      </developers>,
  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"))
    }
  }
)

lazy val chiseltest = (project in file("."))
  .settings(commonSettings)
  .settings(chiseltestSettings)
  .settings(publishSettings)

I have already tried snapshots 5 and 6. No idea what is causing this issue. Any suggestions? This build.sbt has been ripped straight from the chiseltest repo, so am unsure as to what the issue could be. It works for verilog generation fine, but not chiseltest for some reason. Please let me know if there is anything I am missing. Thanks.

@ekiwi
Copy link
Collaborator

ekiwi commented Feb 18, 2024

You shouldn't really use the build.sbt from the chiseltest repository unless you are trying to develop chiseltest itself, in which case you want to just fork and clone the chiseltest repo.

If you want to use chiseltest in your own project I would recommend starting with the following build.sbt: https://github.com/freechipsproject/chisel-template/blob/024989a81da65278c9c92aaf40d44ecc9ce0343f/build.sbt

@ekiwi ekiwi closed this as completed Feb 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants