diff options
| author | Jack Koenig | 2021-12-10 15:56:56 -0800 |
|---|---|---|
| committer | GitHub | 2021-12-10 15:56:56 -0800 |
| commit | 630d05bdca90ec1c80eaaa7834e755f51095463d (patch) | |
| tree | b310b410326082947fa3db39f7645c02e80e6913 /core | |
| parent | 3f21bbb52363c3105f6a0ff961fa7a411dd0c7ab (diff) | |
Add support for dynamic indexing on Vec identity views (#2298)
Diffstat (limited to 'core')
| -rw-r--r-- | core/src/main/scala/chisel3/Aggregate.scala | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/core/src/main/scala/chisel3/Aggregate.scala b/core/src/main/scala/chisel3/Aggregate.scala index 6c6d89c3..dbde7068 100644 --- a/core/src/main/scala/chisel3/Aggregate.scala +++ b/core/src/main/scala/chisel3/Aggregate.scala @@ -3,7 +3,7 @@ package chisel3 import chisel3.experimental.VecLiterals.AddVecLiteralConstructor -import chisel3.experimental.dataview.{InvalidViewException, isView} +import chisel3.experimental.dataview.{InvalidViewException, isView, reifySingleData} import scala.collection.immutable.{SeqMap, VectorMap} import scala.collection.mutable.{HashSet, LinkedHashMap} @@ -258,9 +258,20 @@ sealed class Vec[T <: Data] private[chisel3] (gen: => T, val length: Int) def do_apply(p: UInt)(implicit compileOptions: CompileOptions): T = { requireIsHardware(this, "vec") requireIsHardware(p, "vec index") + + // Special handling for views if (isView(this)) { - throw InvalidViewException("Dynamic indexing of Views is not yet supported") + reifySingleData(this) match { + // Views complicate things a bit, but views that correspond exactly to an identical Vec can just forward the + // dynamic indexing to the target Vec + // In theory, we could still do this forwarding if the sample element were different by deriving a DataView + case Some(target: Vec[T @unchecked]) if this.length == target.length && + this.sample_element.typeEquivalent(target.sample_element) => + return target.do_apply(p) + case _ => throw InvalidViewException("Dynamic indexing of Views is not yet supported") + } } + val port = gen // Reconstruct the resolvedDirection (in Aggregate.bind), since it's not stored. |
