Giter VIP home page Giter VIP logo

chisel-template's Introduction

Chisel Project Template

You've done the Chisel Bootcamp, and now you are ready to start your own Chisel project. The following procedure should get you started with a clean running Chisel3 project.

Make your own Chisel3 project

Dependencies

JDK 8 or newer

We recommend LTS releases Java 8 and Java 11. You can install the JDK as your operating system recommends, or use the prebuilt binaries from AdoptOpenJDK.

SBT or mill

SBT is the most common build tool in the Scala community. You can download it here.
mill is another Scala/Java build tool without obscure DSL like SBT. You can download it here

Verilator

The test with svsim needs Verilator installed. See Verilator installation instructions here.

How to get started

Create a repository from the template

This repository is a Github template. You can create your own repository from it by clicking the green Use this template in the top right. Please leave Include all branches unchecked; checking it will pollute the history of your new repository. For more information, see "Creating a repository from a template".

Wait for the template cleanup workflow to complete

After using the template to create your own blank project, please wait a minute or two for the Template cleanup workflow to run which will removes some template-specific stuff from the repository (like the LICENSE). Refresh the repository page in your browser until you see a 2nd commit by actions-user titled Template cleanup.

Clone your repository

Once you have created a repository from this template and the Template cleanup workflow has completed, you can click the green button to get a link for cloning your repository. Note that it is easiest to push to a repository if you set up SSH with Github, please see the related documentation. SSH is required for pushing to a Github repository when using two-factor authentication.

git clone [email protected]:%REPOSITORY%.git
cd %NAME%

(The variables wrapped in % will be filled in by the template cleanup)

Set project organization and name in build.sbt

The cleanup workflow will have attempted to provide sensible defaults for ThisBuild / organization and name in the build.sbt. Feel free to use your text editor of choice to change them as you see fit.

Clean up the README.md file

Again, use you editor of choice to make the README specific to your project.

Add a LICENSE file

It is important to have a LICENSE for open source (or closed source) code. This template repository has the Unlicense in order to allow users to add any license they want to derivative code. The Unlicense is stripped when creating a repository from this template so that users do not accidentally unlicense their own work.

For more information about a license, check out the Github Docs.

Commit your changes

git commit -m 'Starting %NAME%'
git push origin main

Did it work?

You should now have a working Chisel3 project.

You can run the included test with:

sbt test

Alternatively, if you use Mill:

mill %NAME%.test

You should see a whole bunch of output that ends with something like the following lines

[info] Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[success] Total time: 5 s, completed Dec 16, 2020 12:18:44 PM

If you see the above then...

It worked!

You are ready to go. We have a few recommended practices and things to do.

  • Use packages and following conventions for structure and naming
  • Package names should be clearly reflected in the testing hierarchy
  • Build tests for all your work
  • Read more about testing in SBT in the SBT docs
  • This template includes a test dependency on ScalaTest. This, coupled with svsim (included with Chisel) and verilator, are a starting point for testing Chisel generators.
    • You can remove this dependency in the build.sbt file if you want to
  • Change the name of your project in the build.sbt file
  • Change your README.md

Problems? Questions?

Check out the Chisel Users Community page for links to get in contact!

chisel-template's People

Contributors

azureskyresearch avatar chick avatar dt27182 avatar edwardcwang avatar jackkoenig avatar jiegec avatar martoni avatar ravencus avatar scala-steward avatar schoeberl avatar seldridge avatar sequencer avatar ucbjrl avatar zhutmost avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chisel-template's Issues

Move to Giter8

I propose that we move this into a Giter8 project. This simplifies what the user has to do down to one line:

sbt new seldridge/chisel-template.g8

You also have some ability to customize the project with some super idiotic (m4-level) string replacement.

I have an example version (using the release branch as opposed to master) here:

failed to build the GCD module

Hi developers,

I'm trying to build the GCD module as follows,

package gcd

import chisel3._

/**
  * Compute GCD using subtraction method.
  * Subtracts the smaller from the larger until register y is zero.
  * value in register x is then the GCD
  */
class GCD extends Module {
  val io = IO(new Bundle {
    val value1        = Input(UInt(16.W))
    val value2        = Input(UInt(16.W))
    val loadingValues = Input(Bool())
    val outputGCD     = Output(UInt(16.W))
    val outputValid   = Output(Bool())
  })

  val x  = Reg(UInt())
  val y  = Reg(UInt())

  when(x > y) { x := x - y }
    .otherwise { y := y - x }

  when(io.loadingValues) {
    x := io.value1
    y := io.value2
  }

  io.outputGCD := x
  io.outputValid := y === 0.U
}

But it failed for some bugs I cannot solve. Here is the log of builder.
image

Thank you.

local verilator installation directory config

Hi! Since I'm using a shared server machine, I have verilator installed in .local, so I receive this error at 'sbt test': VGCD.mk:60: /usr/local/share/verilator/include/verilated.mk: No such file or directory
I tried changing 'VERILATOR_ROOT = /usr/local/share/verilator' to the correct directory, but the file is regenerated and the change is overwritten, right? I guess I could assign one path to another, but is there a way to point the project to the local verilator installation?

Thank you!

problem in build.sbt

Hi, when I issue " sbt run", it generated this kind of error. But when I changed the type, it's fixed. Is there anyone who's interested to fix this?

My sbt version is 1.1.0.
And my setting in build.sbt is like this:
name := "chisel-tutorial"
scalaVersion := "2.12.4"
crossScalaVersions := Seq("2.11.11", "2.12.3")

/Users/Powei/Dropbox/riscv/chisel/chisel-tutorial/build.sbt:7: error: scrutinee is incompatible with pattern type;
found : Int
required: Long
case Some((2, scalaMajor: Int)) if scalaMajor < 12 => Seq()
^
/Users/Powei/Dropbox/riscv/chisel/chisel-tutorial/build.sbt:19: error: scrutinee is incompatible with pattern type;
found : Int
required: Long
case Some((2, scalaMajor: Int)) if scalaMajor < 12 =>

Thanks in advance.

chisel github packaging system

I'm using chisel-template for each of my Chisel-project. Until now I published my packages locally to use them in other projects. It works but it's not easy to share Chisel project with this publish method.

So I started looking for the right way to publish «globally» my packages.

And I found a way with github packaging services. I don't know if this is the right solution to publish globally Chisel packages but it seems to works.

So it could be interesting to add this option in chisel-template no ?

Continuous Integration

Add continuous integration on some provider (Travis, Circle CI, GitHub actions) so that this is tested and guaranteed to work out of the box.

Dependencies broken?

I got a bunch of broken dependencies errors (chisel3, io testers) when I tried to use this template. I assume this'll be fixed for the actual Chisel 3 release?

  • As an aside, there should be some kind of documentation on getting a basic Chisel 3 project up and running if you don't want to run tests -- i.e. the equivalent of the old chiselMain but now with Driver rather than having to dig through rocket to see how it's done.
  • For people starting out / when dependencies are broken, what to do with your build.sbt to point to local Chisel/Firrtl stuff.
  • Also, an explanation on how to use Driver.elaborate followed by Firrtl stuff directly (rather than dumping Chirrtl to a file and then separately running Firrtl) would be nice for people just starting out, I'm sure.

/Chisel3/Chisel/

Since Chisel version 5 is the latest one, update the README accordingly.

skeleton and sbt-chisel-dep

I'm currently trying to use subprojects as described in the skeleton branch and with sbt-chisel-dep.
Here is the hierarchy of my projetc and an example of build.sbt:

  • myproj/
    • build.sbt
    • src/
    • subproj1/
      • build.sbt
      • src/
    • subproj2/
      • build.sbt
      • src/

def scalacOptionsVersion(scalaVersion: String): Seq[String] = {
  Seq() ++ {
    // If we're building with Scala > 2.11, enable the compile option
    //  switch to support our anonymous Bundle definitions:
    //  https://github.com/scala/bug/issues/10047
    CrossVersion.partialVersion(scalaVersion) match {
      case Some((2, scalaMajor: Long)) if scalaMajor < 12 => Seq()
      case _ => Seq("-Xsource:2.11")
    }
  }
}

def javacOptionsVersion(scalaVersion: String): Seq[String] = {
  Seq() ++ {
    // Scala 2.12 requires Java 8. We continue to generate
    //  Java 7 compatible code for Scala 2.11
    //  for compatibility with old clients.
    CrossVersion.partialVersion(scalaVersion) match {
      case Some((2, scalaMajor: Long)) if scalaMajor < 12 =>
        Seq("-source", "1.7", "-target", "1.7")
      case _ =>
        Seq("-source", "1.8", "-target", "1.8")
    }
  }
}

scalacOptions ++= scalacOptionsVersion(scalaVersion.value)

javacOptions ++= javacOptionsVersion(scalaVersion.value)

resolvers ++= Seq(
  Resolver.sonatypeRepo("snapshots"),
  Resolver.sonatypeRepo("releases")
)

addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)

// Provide a managed dependency on X if -DXVersion="" is supplied on the command line.
val defaultVersions = Seq(
  "chisel-iotesters" -> "1.4.1+",
  "chiseltest"  -> "0.2.1+"
  )

val projDeps = chisel.dependencies(Seq(
  ("org.myproj" %% "subproj1" % "0.0.1-SNAPSHOT", "gen/subproj1"),
  ("org.myproj" %% "subproj2" % "0.0.1-SNAPSHOT", "gen/subproj2")
))

libraryDependencies ++= defaultVersions.map { case (dep, ver) =>
  "edu.berkeley.cs" %% dep % sys.props.getOrElse(dep + "Version", ver) }
libraryDependencies ++= projDeps.libraries

val dependentProjects = projDeps.projects

lazy val myproj = (project in file("."))
    .settings(
      version := "0.0.1-SNAPSHOT",
      organization := "org.myproj",
      scalaVersion := "2.12.10",
      publishLocal := {},
      publish := {},
      packagedArtifacts := Map.empty,
      libraryDependencies ++= projDeps.libraries
    )
    .dependsOn(dependentProjects.map(classpathDependency(_)): _*)
    .aggregate(dependentProjects: _*)

In subproj2/src/test/scala, I have a ChiselFlatSpec tester hat I run with the sbt command 'testOnly subproj2.Tester'.
But, when I launch it from the myproj directory, it seems to check all the different subproject before launch it:

[info] Run completed in 25 milliseconds.
[info] Total number of tests run: 0
[info] Suites: completed 0, aborted 0
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
[info] No tests were executed.
[info] Passed: Total 0, Failed 0, Errors 0, Passed 0
[info] No tests to run for Test / testOnly
[info] ScalaTest
[info] Run completed in 10 milliseconds.
[info] Total number of tests run: 0
[info] Suites: completed 0, aborted 0
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
[info] No tests were executed.
[info] Passed: Total 0, Failed 0, Errors 0, Passed 0
[info] [0.015] RAN 8 CYCLES PASSED
[info] Tester:
[info] InitRam
[info] - should test read sequences
[info] - should test write sequences
[info] ScalaTest
[info] Run completed in 6 seconds, 173 milliseconds.
[info] Total number of tests run: 2
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[info] Passed: Total 2, Failed 0, Errors 0, Passed 2

It it is not a major problem at the moment (I only have two sub-projects), it could be penalizing if this number increases.
Do you know what this could be due to? Maybe the management of ChiselFlatSpec is not compatible the subprojects or have I badly configured my build.sbt?

Template Cleanup failing

Template cleanup keeps failing after every re-run on Push changes.

image

Its also giving a warning
Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16: actions/checkout@v2, ad-m/[email protected]. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.

SBT test failed

Can't simulate the template with sbt test :

 sbt test
[info] welcome to sbt 1.9.7 (Private Build Java 16.0.1)
[info] loading settings for project chisel-template-build from plugins.sbt ...
[info] loading project definition from /tmp/chisel-template/project
[info] loading settings for project root from build.sbt ...
[info] set current project to %NAME% (in build file:/tmp/chisel-template/)
[info] compiling 2 Scala sources to /tmp/chisel-template/target/scala-2.13/classes ...
[info] compiling 1 Scala source to /tmp/chisel-template/target/scala-2.13/test-classes ...
[info] GCDSpec:
[info] - Gcd should calculate proper greatest common denominator *** FAILED ***
[info]   java.lang.Exception: make: Entering directory '/tmp/chisel3.simulator.EphemeralSimulator/114498@martoni/workdir-default'
[info] ls . | grep -v Makefile | grep -v execution-script.txt | xargs rm -rf
[info] \
[info] /usr/local/bin/verilator \
[info] 	'--cc' \
[info] 	'--exe' \
[info] 	'--build' \
[info] 	'-o' \
[info] 	'../simulation' \
[info] 	'--top-module' \
[info] 	'svsimTestbench' \
[info] 	'--Mdir' \
[info] 	'verilated-sources' \
[info] 	'-CFLAGS' \
[info] 	'-std=c++11 -I/tmp/chisel3.simulator.EphemeralSimulator/114498@martoni/workdir-default -DSVSIM_ENABLE_VERILATOR_SUPPORT' \
[info] 	'../primary-sources/DecoupledGcd.sv' 'c-dpi-bridge.cpp' '../generated-sources/testbench.sv' '../generated-sources/simulation-driver.cpp'
[info] make[1]: Entering directory '/tmp/chisel3.simulator.EphemeralSimulator/114498@martoni/workdir-default/verilated-sources'
[info] ccache g++  -I.  -MMD -I/usr/local/share/verilator/include -I/usr/local/share/verilator/include/vltstd -DVM_COVERAGE=0 -DVM_SC=0 -DVM_TRACE=0 -DVM_TRACE_FST=0 -DVM_TRACE_VCD=0 -faligned-new -fcf-protection=none -Wno-bool-operation -Wno-shadow -Wno-sign-compare -Wno-tautological-compare -Wno-uninitialized -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-unused-variable    -std=c++11 -I/tmp/chisel3.simulator.EphemeralSimulator/114498@martoni/workdir-default -DSVSIM_ENABLE_VERILATOR_SUPPORT   -Os -c -o c-dpi-bridge.o c-dpi-bridge.cpp
[info] ccache g++  -I.  -MMD -I/usr/local/share/verilator/include -I/usr/local/share/verilator/include/vltstd -DVM_COVERAGE=0 -DVM_SC=0 -DVM_TRACE=0 -DVM_TRACE_FST=0 -DVM_TRACE_VCD=0 -faligned-new -fcf-protection=none -Wno-bool-operation -Wno-shadow -Wno-sign-compare -Wno-tautological-compare -Wno-uninitialized -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-unused-variable    -std=c++11 -I/tmp/chisel3.simulator.EphemeralSimulator/114498@martoni/workdir-default -DSVSIM_ENABLE_VERILATOR_SUPPORT   -Os -c -o simulation-driver.o simulation-driver.cpp
[info] In file included from ./VsvsimTestbench.h:11,
[info]                  from simulation-driver.cpp:883:
[info] /usr/local/share/verilator/include/verilated.h:76:22: error: ‘literals’ is not a namespace-name
[info]    76 | using namespace std::literals;  // "<std::string literal>"s; see SF.7 core guideline
[info]       |                      ^~~~~~~~
[info] In file included from /usr/local/share/verilator/include/verilated.h:950,
[info]                  from ./VsvsimTestbench.h:11,
[info]                  from simulation-driver.cpp:883:
[info] /usr/local/share/verilator/include/verilated_types.h: In function ‘std::string VL_TO_STRING(const VlEvent&)’:
[info] /usr/local/share/verilator/include/verilated_types.h:266:12: error: unable to find string literal operator ‘operator""s’ with ‘const char [11]’, ‘long unsigned int’ arguments
[info]   266 |     return "triggered="s + (e.isTriggered() ? "true" : "false");
[info]       |            ^~~~~~~~~~~~~
[info] /usr/local/share/verilator/include/verilated_types.h: In function ‘std::string VL_TO_STRING(const VlEventBase&)’:
[info] /usr/local/share/verilator/include/verilated_types.h:277:12: error: unable to find string literal operator ‘operator""s’ with ‘const char [11]’, ‘long unsigned int’ arguments
[info]   277 |     return "triggered="s + (e.isTriggered() ? "true" : "false");
[info]       |            ^~~~~~~~~~~~~
[info] /usr/local/share/verilator/include/verilated_types.h: In constructor ‘VlClassRef<T_Class>::VlClassRef(VlClassRef<T_Class>&&)’:
[info] /usr/local/share/verilator/include/verilated_types.h:1651:23: error: ‘exchange’ is not a member of ‘std’; did you mean ‘vlstd::exchange’?
[info]  1651 |         : m_objp{std::exchange(moved.m_objp, nullptr)} {}
[info]       |                       ^~~~~~~~
[info] In file included from /usr/local/share/verilator/include/verilated.h:42,
[info]                  from ./VsvsimTestbench.h:11,
[info]                  from simulation-driver.cpp:883:
[info] /usr/local/share/verilator/include/verilatedos.h:637:3: note: ‘vlstd::exchange’ declared here
[info]   637 | T exchange(T& obj, U&& new_value) {
[info]       |   ^~~~~~~~
[info] In file included from /usr/local/share/verilator/include/verilated.h:950,
[info]                  from ./VsvsimTestbench.h:11,
[info]                  from simulation-driver.cpp:883:
[info] /usr/local/share/verilator/include/verilated_types.h: In constructor ‘VlClassRef<T_Class>::VlClassRef(VlClassRef<T_OtherClass>&&)’:
[info] /usr/local/share/verilator/include/verilated_types.h:1661:23: error: ‘exchange’ is not a member of ‘std’; did you mean ‘vlstd::exchange’?
[info]  1661 |         : m_objp{std::exchange(moved.m_objp, nullptr)} {}
[info]       |                       ^~~~~~~~
[info] In file included from /usr/local/share/verilator/include/verilated.h:42,
[info]                  from ./VsvsimTestbench.h:11,
[info]                  from simulation-driver.cpp:883:
[info] /usr/local/share/verilator/include/verilatedos.h:637:3: note: ‘vlstd::exchange’ declared here
[info]   637 | T exchange(T& obj, U&& new_value) {
[info]       |   ^~~~~~~~
[info] In file included from /usr/local/share/verilator/include/verilated.h:950,
[info]                  from ./VsvsimTestbench.h:11,
[info]                  from simulation-driver.cpp:883:
[info] /usr/local/share/verilator/include/verilated_types.h: In member function ‘VlClassRef<T_Class>& VlClassRef<T_Class>::operator=(VlClassRef<T_Class>&&)’:
[info] /usr/local/share/verilator/include/verilated_types.h:1676:23: error: ‘exchange’ is not a member of ‘std’; did you mean ‘vlstd::exchange’?
[info]  1676 |         m_objp = std::exchange(moved.m_objp, nullptr);
[info]       |                       ^~~~~~~~
[info] In file included from /usr/local/share/verilator/include/verilated.h:42,
[info]                  from ./VsvsimTestbench.h:11,
[info]                  from simulation-driver.cpp:883:
[info] /usr/local/share/verilator/include/verilatedos.h:637:3: note: ‘vlstd::exchange’ declared here
[info]   637 | T exchange(T& obj, U&& new_value) {
[info]       |   ^~~~~~~~
[info] In file included from /usr/local/share/verilator/include/verilated.h:950,
[info]                  from ./VsvsimTestbench.h:11,
[info]                  from simulation-driver.cpp:883:
[info] /usr/local/share/verilator/include/verilated_types.h: In member function ‘VlClassRef<T_Class>& VlClassRef<T_Class>::operator=(VlClassRef<T_OtherClass>&&)’:
[info] /usr/local/share/verilator/include/verilated_types.h:1691:23: error: ‘exchange’ is not a member of ‘std’; did you mean ‘vlstd::exchange’?
[info]  1691 |         m_objp = std::exchange(moved.m_objp, nullptr);
[info]       |                       ^~~~~~~~
[info] In file included from /usr/local/share/verilator/include/verilated.h:42,
[info]                  from ./VsvsimTestbench.h:11,
[info]                  from simulation-driver.cpp:883:
[info] /usr/local/share/verilator/include/verilatedos.h:637:3: note: ‘vlstd::exchange’ declared here
[info]   637 | T exchange(T& obj, U&& new_value) {
[info]       |   ^~~~~~~~
[info] make[1]: *** [VsvsimTestbench.mk:65: simulation-driver.o] Error 1
[info] make[1]: Leaving directory '/tmp/chisel3.simulator.EphemeralSimulator/114498@martoni/workdir-default/verilated-sources'
[info] %Error: make -C verilated-sources -f VsvsimTestbench.mk -j 1 exited with 2
[info] %Error: Command Failed ulimit -s unlimited 2>/dev/null; exec /usr/local/bin/verilator_bin --cc --exe --build -o ../simulation --top-module svsimTestbench --Mdir verilated-sources -CFLAGS -std=c++11\ -I/tmp/chisel3.simulator.EphemeralSimulator/114498\@martoni/workdir-default\ -DSVSIM_ENABLE_VERILATOR_SUPPORT ../primary-sources/DecoupledGcd.sv c-dpi-bridge.cpp ../generated-sources/testbench.sv ../generated-sources/simulation-driver.cpp
[info] make: *** [Makefile:12: simulation] Error 2
[info] make: Leaving directory '/tmp/chisel3.simulator.EphemeralSimulator/114498@martoni/workdir-default'
[info]   at svsim.Workspace.compile(Workspace.scala:390)
[info]   at chisel3.simulator.Simulator$WorkspaceCompiler.liftedTree1$1(Simulator.scala:60)
[info]   at chisel3.simulator.Simulator$WorkspaceCompiler.process(Simulator.scala:53)
[info]   at chisel3.simulator.SingleBackendSimulator.processBackends(Simulator.scala:139)
[info]   at chisel3.simulator.SingleBackendSimulator.processBackends$(Simulator.scala:138)
[info]   at chisel3.simulator.EphemeralSimulator$DefaultSimulator.processBackends(EphemeralSimulator.scala:27)
[info]   at chisel3.simulator.Simulator._simulate(Simulator.scala:116)
[info]   at chisel3.simulator.Simulator._simulate$(Simulator.scala:97)
[info]   at chisel3.simulator.EphemeralSimulator$DefaultSimulator._simulate(EphemeralSimulator.scala:27)
[info]   at chisel3.simulator.SingleBackendSimulator.simulate(Simulator.scala:146)
[info]   ...
[info] Run completed in 2 seconds, 948 milliseconds.
[info] Total number of tests run: 1
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 0, failed 1, canceled 0, ignored 0, pending 0
[info] *** 1 TEST FAILED ***
[error] Failed tests:
[error] 	gcd.GCDSpec
[error] (Test / test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 9 s, completed 7 mars 2024, 15:23:36

Same error occur with chisel version 6.1.0 and 7.0.0-M1 in build.sbt.

Tested with following verilator versions :

# on one computer
$ verilator --version
Verilator 4.038 2020-07-11 rev v4.036-114-g0cd4a57ad

# on another computer
$ verilator --version
Verilator 5.022 2024-02-24 rev v5.020-157-g2b4852048

Making the repo as a github template project

It's been a while that Github is offering an option to make an existing repository as a template project:

https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template

I think that's not a bad idea to enable this option for this repository, I've briefly listed the benefits that it offers:

  • Start with no history and no reference to this repository.
  • It's possible to run a Template cleanup workflow to override template-specific configurations, such as the sbt details. You can look at this example Tempate-cleanup
  • You can choose to include the directory structure and files from only the default/master branch

There are more details here:
https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template

Github workflows:
https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions

How to infer a parametrized top module

Hello
I'm trying to run a test for a parametrized top with the following:

testOnly my_pkg.DspTester -- -z verilator

This works fine for a non-parametrized top, like

class DspTop(dwin:Int, dwout:Int) extends Module {...}

Buf fails for

class DspTop[A <: Data, B <: Data](inType:A, outType:B) extends Module {...}

giving: No tests to run for Test / testOnly

My tester is

object MaccMain extends App with Params {

  val inType  = UInt(dwin.W)
  val outType = UInt(dwout.W)
  //val inType  = FixedPoint(16.W, 10.BP)
  //val outType = FixedPoint(32.W, 20.BP)
  
  //iotesters.Driver.execute (args, () => new Macc(dwin, dwout)){
  //  c => new MaccUnitTest(c)
  //}
  iotesters.Driver.executeFirrtlRepl(args, () => new DspTop(inType, outType)) 
}

Using Chisel3 and FIRRTL from master and Chisel-Template with changes to the latest Scala and Chisel

PS: Using Chisel-Template only, NOT DspTools

How to run verilator

This works for Basic:

testOnly tpu_pkg.MaccTester -- -z Basic

For verilator trying different options, but neither works. How to fix ?

testOnly tpu_pkg.MaccTester -- -z --backend-name verilator

mill compile fail

is mill version issue ?

Compiling /home/lenged/project/test/chisel/chisel01/build.sc
build.sc:8: object bsp is not a member of package mill
import mill.bsp._
^
build.sc:5: value ScalaTest is not a member of object mill.scalalib.TestModule
import mill.scalalib.TestModule.ScalaTest
^
build.sc:29: not found: type ScalaTest
object test extends Tests with ScalaTest {
^
Compilation Failed
lenged@lenged-pc:/project/test/chisel/chisel01]$jmill version
jmill: command not found
lenged@lenged-pc:
/project/test/chisel/chisel01]$which mill
/usr/local/bin/mill
lenged@lenged-pc:~/project/test/chisel/chisel01]$mill -v
Mill Build Tool version 0.6.3
Java version: 11.0.15, vendor: Private Build, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "Linux", version: 5.4.0-117-generic, arch: amd64

Mill compile error

using command "mill -i mill.scalalib.GenIdea/idea", it outputs the following error:

[info] compiling 1 Scala source to /Users/Test/test-mill/out/mill-build/compile.dest/classes ...
[error]  /Users/Test/test-mill/build.sc:25:23: not found: type Tests
[error]   object test extends Tests with ScalaTest {
[error]                       ^
[error] one error found
1 targets failed
compile Compilation failed

How to resolved it?

when i run ./run-examples.sh GCD --backend-name verilator i get that error

verilated.o: In function VL_FINISH_MT(char const*, int, char const*)': verilated.cpp:(.text+0x7): undefined reference tovl_finish(char const, int, char const)'
collect2: error: ld returned 1 exit status
VGCD.mk:64: recipe for target 'VGCD' failed
make: Leaving directory '/home/salman/chisel-tutorial/test_run_dir/examples/GCD'
make: *** [VGCD] Error 1

Errors: 1: in the following tutorials
Tutorial GCD: throwable assertion failed:

No license?

The three-clause BSD license is nowhere in this repository despite constant See LICENSE for license details. action going on in the source files. I am assuming this is an omission, could the maintainer please clarify?

Request for a little tutorial on how to use the template.

Hello, can you do a quick tutorial on this template using software that captures the computer screen? Can be set up the template from the Github clone and using it to create a very simple Chisel project, like a register or something.

Thanks

Add Main Method to Generate Verilog

Proposal to add a main that will generate Verilog into a target directory.

I'm finding that I always add this whenever I clone chisel-template and it's likely reasonable to just include this upstream.

Doesn't work with 3.1-SNAPSHOT

I tested template «as it» and it working well, then I tested with last snapshot changing line in build.sbt :

// Provide a managed dependency on X if -DXVersion="" is supplied on the command line.
val defaultVersions = Map(
  "chisel3" -> "3.1-SNAPSHOT",
  "chisel-iotesters" -> "1.1-SNAPSHOT"
  )

But got this error :

[info] [0,007] Elaborating design...
[info] [0,135] Done elaborating.
[info] GCDTester:
[info] GCD
[info] Exception encountered when attempting to run a suite with class name: example.test.GCDTester *** ABORTED ***
[info]   java.lang.NoSuchMethodError: chisel3.internal.firrtl.Component.id()Lchisel3/core/Module;
[info]   at chisel3.iotesters.getTopModule$.apply(PeekPokeTesterUtils.scala:45)
[info]   at chisel3.iotesters.setupFirrtlTerpBackend$.apply(FirrtlTerpBackend.scala:112)
[info]   at chisel3.iotesters.Driver$$anonfun$execute$1.apply$mcZ$sp(Driver.scala:48)
[info]   at chisel3.iotesters.Driver$$anonfun$execute$1.apply(Driver.scala:35)
[info]   at chisel3.iotesters.Driver$$anonfun$execute$1.apply(Driver.scala:35)
[info]   at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
[info]   at chisel3.iotesters.Driver$.execute(Driver.scala:35)
[info]   at chisel3.iotesters.Driver$.apply(Driver.scala:212)
[info]   at example.test.GCDTester$$anonfun$2$$anonfun$apply$1.apply$mcV$sp(GCDUnitTest.scala:56)
[info]   at example.test.GCDTester$$anonfun$2$$anonfun$apply$1.apply(GCDUnitTest.scala:58)
[info]   ...
[info] ScalaCheck
[info] Passed: Total 0, Failed 0, Errors 0, Passed 0
[info] ScalaTest
[info] Run completed in 1 second, 664 milliseconds.
[info] Total number of tests run: 0
[info] Suites: completed 0, aborted 1
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
[info] *** 1 SUITE ABORTED ***
[error] Error: Total 1, Failed 0, Errors 1, Passed 0
[error] Error during tests:
[error] 	example.test.GCDTester
[error] (test:test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 3 s, completed 26 avr. 2017 14:06:02

Too much magic ;-)

Dear all,

the template worked as described, but for my feeling there is too much magic going on to understand a proposed Chisel project structure. What is 'sbt test' doing? Executing some Scala code in a path that has two times 'test' in the path? There is no main in the Scala/Chisel code. Is this Scala/sbt convention?

In the GCD tester I see two nested loops that should result in 100 tests, - what is the notion of SETP n -> m?

Then some magic invokes verilator and a a C++ compiler and tests run again. Are these now Verilog tests? The same thing as before? What was that before?

Sorry for those many questions, just want to get an idea on the design and test flow of Chisel 3 ;-)

Cheers,
Martin

question about the /src/test/scala/gcd/GCDUnitTest.scala

Hello,

In the GCDUnitTest.scala, there is a comment '' sbt 'testOnly examples.test.GCDTester'. However, in chisel-template repo, we don't have example folder.

And I can run "sbt 'test:runMain gcd.GCDMain --generate-vcd-output on' " successfully . But how to run the GCDTester?

sbt complains about feature warnings which are irrelevant to new users

Type of issue: bug report | feature request

Impact: no functional change

Development Phase: request

Please tell us about your environment: Chisel 3.1

What is the use case for changing the behavior?

Is there a way for us to suppress feature warnings (or at the very least "reflective access of structural type member" warnings) which are irrelevant to users?

Currently running sbt raises feature warnings to users by default:

[warn] there were 1 feature warnings; re-run with -feature for details
[warn] one warning found 

Enabling them leads sbt/scalac to complain excessively about accessing io fields, which is confusing to users since they have to wonder if this is a bug in their code (which it is not):

[warn] /.../src/main/scala/GCD.scala:32:6: reflective access of structural type member value outputGCD should be enabled
[warn] by making the implicit value scala.language.reflectiveCalls visible.
[warn]   io.outputGCD := x
[warn]      ^
[warn] /.../src/main/scala/GCD.scala:33:6: reflective access of structural type member value outputValid should be enabled
[warn] by making the implicit value scala.language.reflectiveCalls visible.
[warn]   io.outputValid := y === 0.U
[warn]      ^
[warn] 5 warnings found
[info] Done compiling.
[info] Compiling 1 Scala source to /.../target/scala-2.12/test-classes ...
[warn] /.../src/test/scala/GCDTester.scala:36:19: reflective access of structural type member value value1 should be enabled
[warn] by making the implicit value scala.language.reflectiveCalls visible.
[warn] This can be achieved by adding the import clause 'import scala.language.reflectiveCalls'
[warn] or by setting the compiler option -language:reflectiveCalls.
[warn] See the Scaladoc for value scala.language.reflectiveCalls for a discussion
[warn] why the feature should be explicitly enabled.
[warn]       poke(gcd.io.value1, i)
[warn]                   ^
[warn] /.../src/test/scala/GCDTester.scala:37:19: reflective access of structural type member value value2 should be enabled
[warn] by making the implicit value scala.language.reflectiveCalls visible.
[warn]       poke(gcd.io.value2, j)

mill testOnly fail

gcd.GCDSpec *** ABORTED ***
java.lang.NoClassDefFoundError: chisel3/MultiIOModule
at chiseltest.internal.VerilatorBackendAnnotation$.(Testers2.scala:127)
at chiseltest.internal.VerilatorBackendAnnotation$.(Testers2.scala)
at chiseltest.experimental.ChiselTestCli.$init$(ChiselTestShell.scala:16)
at chiseltest.experimental.ChiselTestShell.(ChiselTestShell.scala:22)
at chiseltest.ChiselScalatestTester$TestBuilder.apply(ChiselScalatestTester.scala:26)
at gcd.GCDSpec.$anonfun$new$1(GCDSpec.scala:24)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
...
Cause: java.lang.ClassNotFoundException: chisel3.MultiIOModule
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
at mill.api.ClassLoader$$anon$1.findClass(ClassLoader.scala:47)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at chiseltest.internal.VerilatorBackendAnnotation$.(Testers2.scala:127)
at chiseltest.internal.VerilatorBackendAnnotation$.(Testers2.scala)
at chiseltest.experimental.ChiselTestCli.$init$(ChiselTestShell.scala:16)
at chiseltest.experimental.ChiselTestShell.(ChiselTestShell.scala:22)
at chiseltest.ChiselScalatestTester$TestBuilder.apply(ChiselScalatestTester.scala:26)

Update to use chisel3

The title explains it all. Like import chisel3._ and the new port specification style.

The GCDSpec test class comment document and the class name are inconsistent

The GCDSpec test class comment document:

/**
  * This is a trivial example of how to run this Specification
  * From within sbt use:
  * {{{
  * testOnly gcd.GcdDecoupledTester
  * }}}
  * From a terminal shell use:
  * {{{
  * sbt 'testOnly gcd.GcdDecoupledTester'
  * }}}
  */

the class GCDSpec should be named GcdDecoupledTester
or change the comment
testOnly gcd.GcdDecoupledTester to testOnly gcd.GCDSpec

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.