0

I'm new to chisel. Currently I'm following chisel-tutorial wiki using chisel3. After cloning the chisel project template linked there, I tried to test and generate verilog output from GCD.scala source file. I got the following error.

> run --v
java.lang.RuntimeException: No main class detected.
    at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) No main class detected.
[error] Total time: 0 s, completed Dec 1, 2016 12:28:46 AM

So following a solution I found on a mailing list (to this same problem) I inserted the following code block at the end of GCD.scala file

object GCDMain {
def main(args: Array[String]): Unit = {
    chiselMainTest(Array[String]("--backend", "c", "--genHarness"),
        () => Module(new GCD())){c => new GCDTests(c)}
}
}

But I still get the same error. (I added the GCDTests class too)

Nikhil
  • 3,711
  • 8
  • 32
  • 43
isururathnayaka
  • 141
  • 1
  • 11

1 Answers1

1

In moving from Chisel 2 to Chisel 3, the developers of Chisel made the decision to promote ScalaTest-style testing of Chisel designs. The chisel-template repo provides a test that can be run with the command sbt test (for more information on testing with sbt, see http://www.scala-sbt.org/0.13/docs/Testing.html). Running this command will generate Verilog and run some execution-driven tests to show that the example code works.

The GCDMain you found in the mailing list would have worked in Chisel 2 but will not work for Chisel 3. If you just want to Verilog and not run any tests, please see Is there a simple example of how to generate verilog from Chisel3 module?.

Community
  • 1
  • 1
Jack Koenig
  • 5,840
  • 15
  • 21
  • Thanks jkoenig. I'll try this – isururathnayaka Dec 01 '16 at 08:38
  • Sorry if this is a noob question. I ran sbt test from base directory and got an error. I searched both this site and mailing list. But couldn't find a solution. BTW sbt test runs fine in the chisel-tutorial directory. It gives the error only in the template repo. I'll post part of the error output since it is too long. [error] /home/isuru/fyp/ChiselProjects/TrialProject/src/test/scala/examples/GCD.scala:6: not found: type GCD [error] class GCDTests(c: GCD) extends PeekPokeTester(c) { – isururathnayaka Dec 01 '16 at 09:17
  • Just as a sanity check, are you using the chisel-tutorial or the chisel-template repo? As far as I can tell `class GCDTests` is not present in the chisel-template, but is present in the chisel-tutorial. – Jack Koenig Dec 01 '16 at 17:53
  • I used chisel-tutorial when I was following the wiki. Now I'm using the chisel-template repo. I copied GCDTests file to the repo hoping to use it as the testbench for GCD, since I used that when I tested GCD in the chisel-tutorial. – isururathnayaka Dec 02 '16 at 09:16
  • 1
    Okay I see now, so the problem is that in the chisel-tutorial, both GCD and GCDTester are in package `examples` so the tester can easily find it. In chisel-template, GCD is located in package `example` (note the lack of s), so at the top of the file containing GCD.scala, try adding `import example.GCD` – Jack Koenig Dec 02 '16 at 18:36