summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests/stage/ChiselOptionsViewSpec.scala
blob: b164ff201c8a8e67d3a76f505f6ee02c7c4224e1 (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
34
35
36
37
38
39
40
41
// SPDX-License-Identifier: Apache-2.0

package chiselTests.stage

import firrtl.options.Viewer.view
import firrtl.RenameMap

import chisel3.stage._
import chisel3.internal.firrtl.Circuit
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

class ChiselOptionsViewSpec extends AnyFlatSpec with Matchers {

  behavior.of(ChiselOptionsView.getClass.getName)

  it should "construct a view from an AnnotationSeq" in {
    val bar = Circuit("bar", Seq.empty, Seq.empty, RenameMap())
    val annotations = Seq(
      NoRunFirrtlCompilerAnnotation,
      PrintFullStackTraceAnnotation,
      ChiselOutputFileAnnotation("foo"),
      ChiselCircuitAnnotation(bar)
    )
    val out = view[ChiselOptions](annotations)

    info("runFirrtlCompiler was set to false")
    out.runFirrtlCompiler should be(false)

    info("printFullStackTrace was set to true")
    out.printFullStackTrace should be(true)

    info("outputFile was set to 'foo'")
    out.outputFile should be(Some("foo"))

    info("chiselCircuit was set to circuit 'bar'")
    out.chiselCircuit should be(Some(bar))

  }

}