summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala
diff options
context:
space:
mode:
authorJim Lawson2017-04-26 12:55:41 -0700
committerAdam Izraelevitz2017-04-26 12:55:41 -0700
commit7449fdc9043708e426aeb8b12b30226db9e47a80 (patch)
treee7c52aeb0e37bbd4d8f7887db8e5f0defe54d90e /chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala
parent4a6396ca5ff9dfba9019552012bce459ef3c3b1e (diff)
Dropimportnotstrict492 - More updates to get things through rocket-chip. (#592)
* Remove explicit import of NotStrict - fixes #492 * Provide macro for MemBase.apply(). * Provide macro for MemBase.apply(). Since a macro cannot override an abstract method, provide a concrete apply method n VecLike() that we can override with a macro. * Remove concrete apply() in VecLike. Since MemBase no longer extends the trait VecLike, we do not require a concrete method to which we can apply a macro to extract the appropriate CompileOptions. * Add missing implicit compileOptions to do_pad() and do_zext(). The latter caused: ``` [error] /vm/home/jenkins/workspace/rocket-chip_with_chisel3/hardfloat/src/main/scala/MulAddRecFN.scala:205: too many arguments for method do_zext: (implicit sourceInfo: chisel3.internal.sourceinfo.SourceInfo)chisel3.core.SInt [error] val CDom_sExp = io.fromPreMul.sExpSum - io.fromPreMul.doSubMags.zext ``` * Add SourceInfoTransform macros to Vec methods in order to avoid apply() chain issues. Since utils methods are no longer NotStrict, Pipe objects need access to the client's compile options. There may be more. * Respond to review comments. Don't propagate SourceInfo through helper functions. Replace old usages of CompileOptionsTransform with the now equivalent SourceInfoTransform and redefine CompileOptionsTransform to only deal with CompileOptions. Just thread CompileOptions (not SourceInfo) through deprecated functions.
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala22
1 files changed, 13 insertions, 9 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala b/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala
index 97028995..6a4d8cff 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala
@@ -223,10 +223,12 @@ sealed class Vec[T <: Data] private (gen: => T, val length: Int)
/** Creates a dynamically indexed read or write accessor into the array.
*/
- def apply(idx: UInt)(implicit compileOptions: CompileOptions): T = {
- Binding.checkSynthesizable(idx ,s"'idx' ($idx)")
+ override def apply(p: UInt): T = macro CompileOptionsTransform.pArg
+
+ def do_apply(p: UInt)(implicit compileOptions: CompileOptions): T = {
+ Binding.checkSynthesizable(p ,s"'p' ($p)")
val port = gen
- val i = Vec.truncateIndex(idx, length)(UnlocatableSourceInfo, compileOptions)
+ val i = Vec.truncateIndex(p, length)(UnlocatableSourceInfo, compileOptions)
port.setRef(this, i)
// Bind each element of port to being whatever the base type is
@@ -243,11 +245,11 @@ sealed class Vec[T <: Data] private (gen: => T, val length: Int)
def apply(idx: Int): T = self(idx)
@deprecated("Use Vec.apply instead", "chisel3")
- def read(idx: UInt)(implicit compileOptions: CompileOptions): T = apply(idx)
+ def read(idx: UInt)(implicit compileOptions: CompileOptions): T = do_apply(idx)(compileOptions)
@deprecated("Use Vec.apply instead", "chisel3")
def write(idx: UInt, data: T)(implicit compileOptions: CompileOptions): Unit = {
- apply(idx)(compileOptions).:=(data)(DeprecatedSourceInfo, compileOptions)
+ do_apply(idx)(compileOptions).:=(data)(DeprecatedSourceInfo, compileOptions)
}
override def cloneType: this.type = {
@@ -277,7 +279,9 @@ sealed class Vec[T <: Data] private (gen: => T, val length: Int)
* operations.
*/
trait VecLike[T <: Data] extends collection.IndexedSeq[T] with HasId {
- def apply(idx: UInt)(implicit compileOptions: CompileOptions): T
+ def apply(p: UInt): T = macro CompileOptionsTransform.pArg
+
+ def do_apply(p: UInt)(implicit compileOptions: CompileOptions): T
// IndexedSeq has its own hashCode/equals that we must not use
override def hashCode: Int = super[HasId].hashCode
@@ -325,14 +329,14 @@ trait VecLike[T <: Data] extends collection.IndexedSeq[T] with HasId {
/** Outputs the index of the first element for which p outputs true.
*/
- def indexWhere(p: T => Bool): UInt = macro CompileOptionsTransform.pArg
+ def indexWhere(p: T => Bool): UInt = macro SourceInfoTransform.pArg
def do_indexWhere(p: T => Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt =
SeqUtils.priorityMux(indexWhereHelper(p))
/** Outputs the index of the last element for which p outputs true.
*/
- def lastIndexWhere(p: T => Bool): UInt = macro CompileOptionsTransform.pArg
+ def lastIndexWhere(p: T => Bool): UInt = macro SourceInfoTransform.pArg
def do_lastIndexWhere(p: T => Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt =
SeqUtils.priorityMux(indexWhereHelper(p).reverse)
@@ -347,7 +351,7 @@ trait VecLike[T <: Data] extends collection.IndexedSeq[T] with HasId {
* true is NOT checked (useful in cases where the condition doesn't always
* hold, but the results are not used in those cases)
*/
- def onlyIndexWhere(p: T => Bool): UInt = macro CompileOptionsTransform.pArg
+ def onlyIndexWhere(p: T => Bool): UInt = macro SourceInfoTransform.pArg
def do_onlyIndexWhere(p: T => Bool)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt =
SeqUtils.oneHotMux(indexWhereHelper(p))