summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests
diff options
context:
space:
mode:
authorJack Koenig2020-10-30 09:57:30 -0700
committerGitHub2020-10-30 09:57:30 -0700
commit0979133b2e67c82f916c2739bbda5df1c692a1d3 (patch)
tree1ef0ef42595a1e59fe9f545895589e9e92f29d17 /src/test/scala/chiselTests
parent362a3e3552cfe90d980e81cc6928abe25c06243d (diff)
Fix bug where refs may not get set for Records (#1645)
This requires a combination of things, but it happens to be a combination used by Diplomacy in Rocket Chip. It must be a Record in compatibility code with Vecs as fields and a mix of components with and without set directions.
Diffstat (limited to 'src/test/scala/chiselTests')
-rw-r--r--src/test/scala/chiselTests/CompatibilitySpec.scala18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/CompatibilitySpec.scala b/src/test/scala/chiselTests/CompatibilitySpec.scala
index f3799613..50213d4d 100644
--- a/src/test/scala/chiselTests/CompatibilitySpec.scala
+++ b/src/test/scala/chiselTests/CompatibilitySpec.scala
@@ -8,6 +8,8 @@ import chisel3.testers.BasicTester
import org.scalacheck.Gen
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
+import scala.collection.immutable.ListMap
+
// Need separate import to override compile options from Chisel._
object CompatibilityCustomCompileOptions {
import Chisel.{defaultCompileOptions => _, _}
@@ -578,4 +580,20 @@ class CompatibiltySpec extends ChiselFlatSpec with ScalaCheckDrivenPropertyCheck
result.compileOptions should be theSameInstanceAs (customCompileOptions)
}
+ it should "properly set the refs of Records" in {
+ class MyRecord extends Record {
+ val foo = Vec(1, Bool()).asInput
+ val bar = Vec(1, Bool())
+ val elements = ListMap("in" -> foo, "out" -> bar)
+ def cloneType = (new MyRecord).asInstanceOf[this.type]
+ }
+ class Foo extends Module {
+ val io = IO(new MyRecord)
+ io.bar := io.foo
+ }
+ val verilog = ChiselStage.emitVerilog(new Foo)
+ // Check that the names are correct (and that the FIRRTL is valid)
+ verilog should include ("assign io_out_0 = io_in_0;")
+ }
+
}