-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Create RecordMap for better diplomatic I/O naming #2486
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
02901d3
Heterogeneous Bag: optionally take a list of names to better name the…
mwachs5 7a9eec6
Update src/main/scala/util/HeterogeneousBag.scala
mwachs5 0b31473
Revert "Update src/main/scala/util/HeterogeneousBag.scala"
mwachs5 69509ef
Revert "Heterogeneous Bag: optionally take a list of names to better …
mwachs5 df19c63
Create RecordListMap to get signals with better names that Heterogeno…
mwachs5 88d2c9f
Update src/main/scala/util/RecordListMap.scala
mwachs5 cd1e858
Update and rename RecordListMap.scala to RecordMap.scala
mwachs5 c49ded5
Update RecordMap.scala
mwachs5 0153770
RecordMap: just extend Seq instead of Map
mwachs5 36f8809
RecordMap: review feedback
mwachs5 fc8a644
RecordMap: add companion object
mwachs5 af5fa3b
RecordMap: Add some convenient accessor functions, make eltMap publich
mwachs5 77265d9
RecordMap: clean up API for accessing members via data
mwachs5 2636ef6
Update src/main/scala/util/RecordMap.scala
mwachs5 7a517c5
Update src/main/scala/util/RecordMap.scala
mwachs5 d246e4c
Update src/main/scala/util/RecordMap.scala
mwachs5 0aa33e2
Update RecordMap.scala
mwachs5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// See LICENSE.SiFive for license details. | ||
|
||
package freechips.rocketchip.util | ||
|
||
import chisel3._ | ||
import scala.collection.immutable.ListMap | ||
import chisel3.internal.requireIsChiselType | ||
import chisel3.experimental.DataMirror.internal.chiselTypeClone | ||
|
||
final class RecordMap[T <: Data] private (eltMap: ListMap[String, T]) | ||
extends Record { | ||
|
||
eltMap.foreach { case (name, elt) => requireIsChiselType(elt, name) } | ||
|
||
// This is needed for Record | ||
val elements = ListMap[String, T]() ++ eltMap.mapValues(chiselTypeClone(_).asInstanceOf[T]) // mapValues return value is lazy | ||
|
||
def apply(x: Int) = elements.values.toSeq(x) | ||
def apply(x: String) = elements.get(x) | ||
def size = elements.size | ||
def data = elements.values | ||
|
||
override def cloneType: this.type = (new RecordMap(eltMap)).asInstanceOf[this.type] | ||
|
||
} | ||
|
||
object RecordMap { | ||
|
||
def apply[T <: Data](eltMap: ListMap[String, T]) = new RecordMap(eltMap) | ||
|
||
def apply[T <: Data](elements: (String, T)*): RecordMap[T] = { | ||
new RecordMap[T](ListMap[String, T](elements:_*)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are the type parameters needed here? Does the following now just work? new RecordMap(ListMap(elements:_*)) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it probably just works. will try |
||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.