Skip to content

Commit

Permalink
Add circuit test with ChiselEnums
Browse files Browse the repository at this point in the history
  • Loading branch information
rameloni committed Jul 11, 2024
1 parent a8f30e8 commit a713fda
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,52 @@ object TywavesAnnotationCircuits {
}

}

// Test enumeration
class TopCircuitChiselEnum extends RawModule {
object MyEnum extends ChiselEnum {
val A, B, C = Value
}

object MyEnum2 extends ChiselEnum {
val D, E, F = Value
}

object ScopeEnum {
object MyEnum2 extends ChiselEnum {
val D, E = Value
}
}

val inputEnum = IO(Input(MyEnum()))

val io = IO(Input(new Bundle {
val a = MyEnum()
val b = MyEnum2()
val c = Bool()
}))

// So the enumVecAnnotation will have fields
val i = IO(Input(new Bundle {
val e = MyEnum()
val b = new Bundle {
val inner_e = ScopeEnum.MyEnum2()
val NOENUM = Bool()
val inner_ee = MyEnum()
val inner_b = new Bundle {
val inner_inner_e = MyEnum()
val inner_NOENUM = Bool()
val inner_ee = MyEnum2()
}
val v = Vec(3, MyEnum())
}
val v = Vec(3, MyEnum())
}))

val vBundle = VecInit(i)
val v = IO(Input(Vec(3, MyEnum())))
val vv = IO(Input(Vec(2, Vec(2, MyEnum()))))
}
}

object MemCircuits {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,15 @@ class TypeAnnotationDataTypesSpec extends AnyFunSpec with Matchers with chiselTe
// format: on
}
}

describe("Chisel enum Annotations") {
val targetDir = os.pwd / "test_run_dir" / "TywavesAnnotationSpec" / "Enum Values Annotations"
val args: Array[String] = Array("--target", "chirrtl", "--target-dir", targetDir.toString)
// format: off
it("should annotate chiselEnum") {
// ChiselEnums are already annotated, so simply emit a .fir file for firtool tests
new ChiselStage(true).execute(args, Seq(ChiselGeneratorAnnotation(() => new TopCircuitChiselEnum)))
// format: on
}
}
}

0 comments on commit a713fda

Please sign in to comment.