Skip to content

Commit a713fda

Browse files
committed
Add circuit test with ChiselEnums
1 parent a8f30e8 commit a713fda

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

src/test/scala/circtTests/tywavesTests/TywavesAnnotationCircuits.scala

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,52 @@ object TywavesAnnotationCircuits {
313313
}
314314

315315
}
316+
317+
// Test enumeration
318+
class TopCircuitChiselEnum extends RawModule {
319+
object MyEnum extends ChiselEnum {
320+
val A, B, C = Value
321+
}
322+
323+
object MyEnum2 extends ChiselEnum {
324+
val D, E, F = Value
325+
}
326+
327+
object ScopeEnum {
328+
object MyEnum2 extends ChiselEnum {
329+
val D, E = Value
330+
}
331+
}
332+
333+
val inputEnum = IO(Input(MyEnum()))
334+
335+
val io = IO(Input(new Bundle {
336+
val a = MyEnum()
337+
val b = MyEnum2()
338+
val c = Bool()
339+
}))
340+
341+
// So the enumVecAnnotation will have fields
342+
val i = IO(Input(new Bundle {
343+
val e = MyEnum()
344+
val b = new Bundle {
345+
val inner_e = ScopeEnum.MyEnum2()
346+
val NOENUM = Bool()
347+
val inner_ee = MyEnum()
348+
val inner_b = new Bundle {
349+
val inner_inner_e = MyEnum()
350+
val inner_NOENUM = Bool()
351+
val inner_ee = MyEnum2()
352+
}
353+
val v = Vec(3, MyEnum())
354+
}
355+
val v = Vec(3, MyEnum())
356+
}))
357+
358+
val vBundle = VecInit(i)
359+
val v = IO(Input(Vec(3, MyEnum())))
360+
val vv = IO(Input(Vec(2, Vec(2, MyEnum()))))
361+
}
316362
}
317363

318364
object MemCircuits {

src/test/scala/circtTests/tywavesTests/dataTypesTests/TypeAnnotationDataTypesSpec.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,15 @@ class TypeAnnotationDataTypesSpec extends AnyFunSpec with Matchers with chiselTe
222222
// format: on
223223
}
224224
}
225+
226+
describe("Chisel enum Annotations") {
227+
val targetDir = os.pwd / "test_run_dir" / "TywavesAnnotationSpec" / "Enum Values Annotations"
228+
val args: Array[String] = Array("--target", "chirrtl", "--target-dir", targetDir.toString)
229+
// format: off
230+
it("should annotate chiselEnum") {
231+
// ChiselEnums are already annotated, so simply emit a .fir file for firtool tests
232+
new ChiselStage(true).execute(args, Seq(ChiselGeneratorAnnotation(() => new TopCircuitChiselEnum)))
233+
// format: on
234+
}
235+
}
225236
}

0 commit comments

Comments
 (0)