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

Add test demonstrating a ref to an aggregate member #3369

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Changes from all commits
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
53 changes: 53 additions & 0 deletions src/test/scala/chiselTests/interface/InterfaceSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,57 @@ class InterfaceSpec extends AnyFunSpec with Matchers {

}

it("should support ref types that point to subfields of aggregates") {
object RefInterface extends Interface {

final class RefBundle extends Bundle {
val r = Output(Probe(Bool()))
}

override type Ports = RefBundle

override type Properties = Unit

override val ports = new Ports

}

class RefComponent extends RawModule {
val w_ref = IO(Output(Probe(Bool())))
val w = Wire(new Bundle {
val a = UInt(4.W)
val b = Bool()
})
w.a := 2.U(4.W)
w.b := true.B
val w_probe = ProbeValue(w.b)
define(w_ref, w_probe)
}

implicit val refConformance =
new ConformsTo[RefInterface.type, RefComponent] {
override def genModule() = new RefComponent

override def portMap = Seq(
_.w_ref -> _.r
)

override def properties = {}
}

class RefClient extends RawModule {
val x = IO(Output(Bool()))
val refInterface = chisel3.Module(new RefInterface.Wrapper.BlackBox)
x := read(refInterface.io.r)
}

val dir = new java.io.File("test_run_dir/interface/InterfaceSpec/should-support-ref-types-to-aggregates")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we better derive this directory? There are utility functions to generate test directories.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this same feedback applies throughout this file so I won't block this particular PR on it but let's please clean this aspect of the tests up.

Drivers.compile(
dir,
Drivers.CompilationUnit(() => new RefClient),
Drivers.CompilationUnit(() => new RefInterface.Wrapper.Module)
)
Drivers.link(dir, "compile-0/RefClient.sv")
}

}