summaryrefslogtreecommitdiff
path: root/core/src/main/scala/chisel3/internal
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/internal
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/internal')
-rw-r--r--core/src/main/scala/chisel3/internal/Binding.scala11
1 files changed, 8 insertions, 3 deletions
diff --git a/core/src/main/scala/chisel3/internal/Binding.scala b/core/src/main/scala/chisel3/internal/Binding.scala
index 6431dd23..bab79bc1 100644
--- a/core/src/main/scala/chisel3/internal/Binding.scala
+++ b/core/src/main/scala/chisel3/internal/Binding.scala
@@ -141,11 +141,16 @@ case class DontCareBinding() extends UnconstrainedBinding
private[chisel3] case class ViewBinding(target: Element) extends UnconstrainedBinding
/** Binding for Aggregate Views
- * @param childMap Mapping from children of this view to each child's target
+ * @param childMap Mapping from children of this view to their respective targets
* @param target Optional Data this Aggregate views if the view is total and the target is a Data
+ * @note For any Elements in the childMap, both key and value must be Elements
+ * @note The types of key and value need not match for the top Data in a total view of type
+ * Aggregate
*/
-private[chisel3] case class AggregateViewBinding(childMap: Map[Data, Element], target: Option[Data])
- extends UnconstrainedBinding
+private[chisel3] case class AggregateViewBinding(childMap: Map[Data, Data]) extends UnconstrainedBinding {
+ // Helper lookup function since types of Elements always match
+ def lookup(key: Element): Option[Element] = childMap.get(key).map(_.asInstanceOf[Element])
+}
/** Binding for Data's returned from accessing an Instance/Definition members, if not readable/writable port */
private[chisel3] case object CrossModuleBinding extends TopBinding {