summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests/DriverSpec.scala
blob: 4f9619e3fe74104f156649e762109c402d5f34f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// See LICENSE for license details.

package chiselTests

import chisel3._

import org.scalatest.{Matchers, FreeSpec}

class DummyModule extends Module {
  val io = IO(new Bundle {
    val in = UInt(INPUT, 1)
    val out = UInt(OUTPUT, 1)
  })
  io.out := io.in
}

class DriverSpec extends FreeSpec with Matchers {
  "Driver's execute methods are used to run chisel and firrtl" - {
    "options can be picked up from comand line with no args" in {
      Driver.execute(Array.empty[String], () => new DummyModule)
    }
    "options can be picked up from comand line setting top name" in {
      Driver.execute(Array("-tn", "dm", "-td", "local-build"), () => new DummyModule)
    }
    "execute returns a chisel execution result" in {
      val args = Array("--compiler", "low")
      val result = Driver.execute(Array.empty[String], () => new DummyModule)
      result shouldBe a[ChiselExecutionSucccess]
      val successResult = result.asInstanceOf[ChiselExecutionSucccess]
      successResult.emitted should include ("circuit DummyModule")
    }
  }
}