Skip to content

Commit

Permalink
Aggregate literals now materialize const wires (#3515)
Browse files Browse the repository at this point in the history
  • Loading branch information
trilorez committed Aug 30, 2023
1 parent 2cf97e2 commit 9a64ac3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 2 additions & 4 deletions core/src/main/scala/chisel3/Data.scala
Original file line number Diff line number Diff line change
Expand Up @@ -634,14 +634,12 @@ abstract class Data extends BaseType with SourceInfoDoc {
case Some(BundleLitBinding(litMap)) =>
litMap.get(this) match {
case Some(litArg) => litArg
// TODO make a Const once const is supported in firtool
case _ => materializeWire() // FIXME FIRRTL doesn't have Bundle literal expressions
case _ => materializeWire(true) // FIXME FIRRTL doesn't have Bundle literal expressions
}
case Some(VecLitBinding(litMap)) =>
litMap.get(this) match {
case Some(litArg) => litArg
// TODO make a Const once const is supported in firtool
case _ => materializeWire() // FIXME FIRRTL doesn't have Vec literal expressions
case _ => materializeWire(true) // FIXME FIRRTL doesn't have Vec literal expressions
}
case Some(DontCareBinding()) =>
materializeWire() // FIXME FIRRTL doesn't have a DontCare expression so materialize a Wire
Expand Down
8 changes: 8 additions & 0 deletions src/test/scala/chiselTests/BundleLiteralSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,12 @@ class BundleLiteralSpec extends ChiselFlatSpec with Utils {
}
}
}

"bundle literals" should "materialize const wires" in {
val chirrtl = ChiselStage.emitCHIRRTL(new Module {
val r = RegInit((new MyBundle).Lit(_.a -> 42.U, _.b -> true.B, _.c -> MyEnum.sB))
})
val wire = """wire.*: const \{ a : UInt<8>, b : UInt<1>, c : UInt<1>\}""".r
(chirrtl should include).regex(wire)
}
}
8 changes: 8 additions & 0 deletions src/test/scala/chiselTests/VecLiteralSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -507,4 +507,12 @@ class VecLiteralSpec extends ChiselFreeSpec with Utils {
vec.getWidth should be(16 * 2)
vec.litValue should be(BigInt("bbbb000a", 16))
}

"vec literals should materialize const wires" in {
val chirrtl = ChiselStage.emitCHIRRTL(new Module {
val r = RegInit(Vec(2, UInt(4.W)).Lit(0 -> 1.U, 1 -> 2.U))
})
val wire = """wire.*: const UInt<4>\[2\]""".r
(chirrtl should include).regex(wire)
}
}

0 comments on commit 9a64ac3

Please sign in to comment.