File tree 1 file changed +24
-0
lines changed
src/test/scala/chiselTests
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -402,6 +402,30 @@ class ChiselEnumSpec extends ChiselFlatSpec with Utils {
402
402
assertTesterPasses(new CastToUIntTester )
403
403
}
404
404
405
+ // This is a bug, but fixing it may break user code.
406
+ // See: https://github.com/chipsalliance/chisel/issues/4159
407
+ it should " preserve legacy width behavior" in {
408
+ val verilog = ChiselStage .emitSystemVerilog(new RawModule {
409
+ val out1, out2, out3 = IO (Output (UInt (8 .W )))
410
+ val e = EnumExample .e1
411
+ val x = e.asUInt
412
+ val y = e.asTypeOf(UInt ())
413
+ val z = e.asTypeOf(UInt (e.getWidth.W ))
414
+ out1 := Cat (1 .U , x)
415
+ out2 := Cat (1 .U , y)
416
+ out3 := Cat (1 .U , z)
417
+ // The bug is that the width of x is 7 but the value of out1 is 3
418
+ x.getWidth should be(7 )
419
+ x.getWidth should be(EnumExample .getWidth)
420
+ y.widthOption should be(None )
421
+ z.getWidth should be(7 )
422
+ })
423
+ // The bug is that all of these should be the same as out3, or the widths above are wrong
424
+ verilog should include(" assign out1 = 8'h3;" )
425
+ verilog should include(" assign out2 = 8'h3;" )
426
+ verilog should include(" assign out3 = 8'h81;" )
427
+ }
428
+
405
429
it should " cast literal UInts to enums correctly" in {
406
430
assertTesterPasses(new CastFromLitTester )
407
431
}
You can’t perform that action at this time.
0 commit comments