summaryrefslogtreecommitdiff
path: root/core/src/main/scala/chisel3/experimental/hierarchy
diff options
context:
space:
mode:
authormergify[bot]2022-04-12 00:09:55 +0000
committerGitHub2022-04-12 00:09:55 +0000
commit898142ba05b04fb1602b249fd1ae81baa3f47f89 (patch)
tree75304868c8e8a43abc79a5e125c51167fccce6b4 /core/src/main/scala/chisel3/experimental/hierarchy
parentd766e8f7270579406d54abc9015d494cd199c6ce (diff)
Enhance views to [sometimes] support dynamic indexing and implement FlatIO (backport #2476) (#2479)
* Capture 1:1 mappings of Aggregates inside of views This is implemented by including any corresponding Aggregates from the DataView.mapping in the AggregateViewBinding.childMap (which is now of type Map[Data, Data]). This enables dynamically indexing Vecs that are themselves elements of larger Aggregates in views when the corresponding element of the view is a Vec of the same type. It also increases the number of cases where a single Target can represent part of a view. (cherry picked from commit 1f6b1ca14ccf86918065073c3f6f3626dd83a68e) * Add FlatIO API for creating ports from Bundles without a prefix (cherry picked from commit 772a3a1fe3b9372b7c2d7cd2d424b2adcd633cdb) * [docs] Add FlatIO to the general cookbook (cherry picked from commit b4159641350f238f0f899b69954142ce8ee11544) Co-authored-by: Jack Koenig <koenig@sifive.com>
Diffstat (limited to 'core/src/main/scala/chisel3/experimental/hierarchy')
-rw-r--r--core/src/main/scala/chisel3/experimental/hierarchy/Lookupable.scala16
1 files changed, 8 insertions, 8 deletions
diff --git a/core/src/main/scala/chisel3/experimental/hierarchy/Lookupable.scala b/core/src/main/scala/chisel3/experimental/hierarchy/Lookupable.scala
index 60290f83..46a38e7c 100644
--- a/core/src/main/scala/chisel3/experimental/hierarchy/Lookupable.scala
+++ b/core/src/main/scala/chisel3/experimental/hierarchy/Lookupable.scala
@@ -173,12 +173,12 @@ object Lookupable {
// We have to lookup the target(s) of the view since they may need to be underlying into the current context
val newBinding = data.topBinding match {
case ViewBinding(target) => ViewBinding(lookupData(reify(target)))
- case avb @ AggregateViewBinding(map, targetOpt) =>
+ case avb @ AggregateViewBinding(map) =>
data match {
- case _: Element => ViewBinding(lookupData(reify(map(data))))
+ case e: Element => ViewBinding(lookupData(reify(avb.lookup(e).get)))
case _: Aggregate =>
// Provide a 1:1 mapping if possible
- val singleTargetOpt = targetOpt.filter(_ => avb == data.binding.get).flatMap(reifySingleData)
+ val singleTargetOpt = map.get(data).filter(_ => avb == data.binding.get).flatMap(reifySingleData)
singleTargetOpt match {
case Some(singleTarget) => // It is 1:1!
// This is a little tricky because the values in newMap need to point to Elements of newTarget
@@ -187,15 +187,15 @@ object Lookupable {
case (res, from) =>
(res: Data) -> mapRootAndExtractSubField(map(from), _ => newTarget)
}.toMap
- AggregateViewBinding(newMap, Some(newTarget))
+ AggregateViewBinding(newMap + (result -> newTarget))
case None => // No 1:1 mapping so we have to do a flat binding
// Just remap each Element of this aggregate
val newMap = coiterate(result, data).map {
// Upcast res to Data since Maps are invariant in the Key type parameter
- case (res, from) => (res: Data) -> lookupData(reify(map(from)))
+ case (res, from) => (res: Data) -> lookupData(reify(avb.lookup(from).get))
}.toMap
- AggregateViewBinding(newMap, None)
+ AggregateViewBinding(newMap)
}
}
}
@@ -204,8 +204,8 @@ object Lookupable {
// We must also mark non-1:1 and child Aggregates in the view for renaming
newBinding match {
case _: ViewBinding => // Do nothing
- case AggregateViewBinding(_, target) =>
- if (target.isEmpty) {
+ case AggregateViewBinding(childMap) =>
+ if (!childMap.contains(result)) {
Builder.unnamedViews += result
}
// Binding does not capture 1:1 for child aggregates views