Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OpaqueSlot handling of contextual names #2708

Merged
merged 2 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/scala/chisel3/internal/firrtl/IR.scala
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ case class Slot(imm: Node, name: String) extends Arg {
}

case class OpaqueSlot(imm: Node) extends Arg {
override def contextualName(ctx: Component): String = imm.name
override def contextualName(ctx: Component): String = imm.contextualName(ctx)
override def name: String = imm.name
}

Expand Down
35 changes: 18 additions & 17 deletions src/test/scala/chiselTests/RecordSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,18 @@ trait RecordSpecUtils {
val in = IO(Input(new InnerRecord))
val out = IO(Output(new InnerRecord))
val inst = Module(new InnerModule)
inst.foo := in
out := inst.bar
inst.io.foo := in
out := inst.io.bar
}

class InnerModule extends Module {
val foo = IO(Input(new InnerRecord))
val bar = IO(Output(new InnerRecord))
val io = IO(new Bundle {
val foo = Input(new InnerRecord)
val bar = Output(new InnerRecord)
})

// DO NOT do this; just for testing element connections
bar.elements.head._2 := foo.elements.head._2
io.bar.elements.head._2 := io.foo.elements.head._2
}

class NamedSingleElementRecord extends Record {
Expand Down Expand Up @@ -239,25 +241,24 @@ class RecordSpec extends ChiselFlatSpec with RecordSpecUtils with Utils {
var mod: NestedRecordModule = null
ChiselStage.elaborate { mod = new NestedRecordModule; mod }
val testStrings = Seq(
mod.in.toTarget.toString(),
mod.in.k.toTarget.toString(),
mod.in.k.k.toTarget.toString(),
mod.in.elements.head._2.toTarget.toString(),
mod.in.k.elements.head._2.toTarget.toString(),
mod.in.k.k.elements.head._2.toTarget.toString()
mod.inst.io.foo.toTarget.serialize,
mod.inst.io.foo.k.toTarget.serialize,
mod.inst.io.foo.k.k.toTarget.serialize,
mod.inst.io.foo.elements.head._2.toTarget.serialize,
mod.inst.io.foo.k.elements.head._2.toTarget.serialize,
mod.inst.io.foo.k.k.elements.head._2.toTarget.serialize
)
testStrings.foreach(x => assert(x == "~NestedRecordModule|NestedRecordModule>in"))
testStrings.foreach(x => assert(x == "~NestedRecordModule|InnerModule>io.foo"))
}

they should "work correctly when connecting nested opaque type elements" in {
val nestedRecordChirrtl = ChiselStage.emitChirrtl { new NestedRecordModule }
nestedRecordChirrtl should include("input in : UInt<8>")
nestedRecordChirrtl should include("output out : UInt<8>")
nestedRecordChirrtl should include("inst.foo <= in")
nestedRecordChirrtl should include("out <= inst.bar")
nestedRecordChirrtl should include("input foo : UInt<8>")
nestedRecordChirrtl should include("output bar : UInt<8>")
nestedRecordChirrtl should include("bar <= foo")
nestedRecordChirrtl should include("inst.io.foo <= in")
nestedRecordChirrtl should include("out <= inst.io.bar")
nestedRecordChirrtl should include("output io : { flip foo : UInt<8>, bar : UInt<8>}")
nestedRecordChirrtl should include("io.bar <= io.foo")
}

they should "throw an error when map contains a named element and opaqueType is overriden to true" in {
Expand Down