From 741761cfbac8d8b7e297666c66d91cb773a6f109 Mon Sep 17 00:00:00 2001 From: mergify[bot] Date: Thu, 10 Mar 2022 01:10:30 +0000 Subject: Emit FIRRTL bulkconnects whenever possible (#2381) (#2440) Chisel <> semantics differ somewhat from FIRRTL <= semantics, so we only emit <= when it would be legal. Otherwise we continue the old behavior of emitting a connection for every leaf-level Element. Co-authored-by: Deborah Soung Co-authored-by: Jack Koenig (cherry picked from commit 3553a1583403824718923a6cc530cec3b38f5704) Co-authored-by: Jared Barocsi <82000041+jared-barocsi@users.noreply.github.com> Co-authored-by: Jack Koenig --- src/test/scala/chiselTests/RecordSpec.scala | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/test/scala/chiselTests/RecordSpec.scala') diff --git a/src/test/scala/chiselTests/RecordSpec.scala b/src/test/scala/chiselTests/RecordSpec.scala index da3840dd..30b55812 100644 --- a/src/test/scala/chiselTests/RecordSpec.scala +++ b/src/test/scala/chiselTests/RecordSpec.scala @@ -27,6 +27,17 @@ trait RecordSpecUtils { io.out <> io.in } + class ConnectionTestModule(output: => Record, input: => Record) extends Module { + val io = IO(new Bundle { + val inMono = Input(input) + val outMono = Output(output) + val inBi = Input(input) + val outBi = Output(output) + }) + io.outMono := io.inMono + io.outBi <> io.inBi + } + class RecordSerializationTest extends BasicTester { val recordType = new CustomBundle("fizz" -> UInt(16.W), "buzz" -> UInt(16.W)) val record = Wire(recordType) @@ -110,6 +121,14 @@ class RecordSpec extends ChiselFlatSpec with RecordSpecUtils with Utils { ChiselStage.elaborate { new MyModule(new MyBundle, fooBarType) } } + they should "emit FIRRTL bulk connects when possible" in { + val chirrtl = (new ChiselStage).emitChirrtl( + gen = new ConnectionTestModule(fooBarType, fooBarType) + ) + chirrtl should include("io.outMono <= io.inMono @[RecordSpec.scala") + chirrtl should include("io.outBi <= io.inBi @[RecordSpec.scala") + } + they should "not allow aliased fields" in { class AliasedFieldRecord extends Record { val foo = UInt(8.W) -- cgit v1.2.3