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

Require target is hardware for Vec.apply(a: UInt) #1148

Merged
merged 1 commit into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions chiselFrontend/src/main/scala/chisel3/Aggregate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ sealed class Vec[T <: Data] private[chisel3] (gen: => T, val length: Int)

/** @group SourceInfoTransformMacro */
def do_apply(p: UInt)(implicit compileOptions: CompileOptions): T = {
requireIsHardware(this, "vec")
requireIsHardware(p, "vec index")
val port = gen

Expand Down
11 changes: 11 additions & 0 deletions src/test/scala/chiselTests/Vec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,15 @@ class VecSpec extends ChiselPropSpec {
io.out := VecInit(Seq(4.U, 5.U, DontCare, 2.U))
})
}

property("Indexing a Chisel type Vec by a hardware type should give a sane error message") {
assertThrows[ExpectedHardwareException] {
elaborate{
new Module {
val io = IO(new Bundle{})
val foo = Vec(2, Bool())
foo(0.U) := false.B
}}
}
}
}