From 94d5b90493b42dd2c85d0d94ea707a69160d0536 Mon Sep 17 00:00:00 2001 From: Paul Rigge Date: Wed, 1 May 2019 19:55:21 -0700 Subject: Make asTypeOf work for bundles with zero-width fields. (#1079) Closes #1075.--- chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'chiselFrontend') diff --git a/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala b/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala index 35f53013..c75974f0 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala @@ -66,8 +66,16 @@ sealed abstract class Aggregate extends Data { var i = 0 val bits = WireDefault(UInt(this.width), that) // handles width padding for (x <- flatten) { - x.connectFromBits(bits(i + x.getWidth - 1, i)) - i += x.getWidth + val fieldWidth = x.getWidth + if (fieldWidth > 0) { + x.connectFromBits(bits(i + fieldWidth - 1, i)) + i += fieldWidth + } else { + // There's a zero-width field in this bundle. + // Zero-width fields can't really be assigned to, but the frontend complains if there are uninitialized fields, + // so we assign it to DontCare. We can't use connectFromBits() on DontCare, so use := instead. + x := DontCare + } } } } -- cgit v1.2.3