Skip to content

Commit b3a8f8a

Browse files
committed
Switch Scala3 sourceInfo implicits to contextual parameters
1 parent 2ef65b6 commit b3a8f8a

File tree

20 files changed

+153
-151
lines changed

20 files changed

+153
-151
lines changed

core/src/main/scala-3/chisel3/Aggregate.scala

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ sealed class Vec[T <: Data] private[chisel3] (gen: => T, length: Int)
5252

5353
override def toString: String = super[VecImpl].toString
5454

55-
def apply(p: UInt)(implicit sourceInfo: SourceInfo): T = do_apply(p)
56-
def do_apply(p: UInt)(implicit sourceInfo: SourceInfo): T = _applyImpl(p)
55+
def apply(p: UInt)(using sourceInfo: SourceInfo): T = do_apply(p)
56+
def do_apply(p: UInt)(using sourceInfo: SourceInfo): T = _applyImpl(p)
5757

5858
/** A reduce operation in a tree like structure instead of sequentially
5959
* @example An adder tree
@@ -76,7 +76,7 @@ sealed class Vec[T <: Data] private[chisel3] (gen: => T, length: Int)
7676
redOp: (T, T) => T,
7777
layerOp: (T) => T = (x: T) => x
7878
)(
79-
implicit sourceInfo: SourceInfo
79+
using sourceInfo: SourceInfo
8080
): T = _reduceTreeImpl(redOp, layerOp)
8181
}
8282

@@ -93,7 +93,7 @@ object VecInit extends VecInitImpl with SourceInfoDoc {
9393
* element
9494
* @note output elements are connected from the input elements
9595
*/
96-
def apply[T <: Data](elts: Seq[T])(implicit sourceInfo: SourceInfo): Vec[T] = _applyImpl(elts)
96+
def apply[T <: Data](elts: Seq[T])(using sourceInfo: SourceInfo): Vec[T] = _applyImpl(elts)
9797

9898
/** Creates a new [[Vec]] composed of the input [[Data]] nodes.
9999
*
@@ -103,7 +103,7 @@ object VecInit extends VecInitImpl with SourceInfoDoc {
103103
* element
104104
* @note output elements are connected from the input elements
105105
*/
106-
def apply[T <: Data](elt0: T, elts: T*)(implicit sourceInfo: SourceInfo): Vec[T] = _applyImpl(elt0, elts: _*)
106+
def apply[T <: Data](elt0: T, elts: T*)(using sourceInfo: SourceInfo): Vec[T] = _applyImpl(elt0, elts: _*)
107107

108108
/** Creates a new [[Vec]] of length `n` composed of the results of the given
109109
* function applied over a range of integer values starting from 0.
@@ -117,7 +117,7 @@ object VecInit extends VecInitImpl with SourceInfoDoc {
117117
n: Int
118118
)(gen: (Int) => T
119119
)(
120-
implicit sourceInfo: SourceInfo
120+
using sourceInfo: SourceInfo
121121
): Vec[T] = _tabulateImpl(n)(gen)
122122

123123
/** Creates a new 2D [[Vec]] of length `n by m` composed of the results of the given
@@ -134,7 +134,7 @@ object VecInit extends VecInitImpl with SourceInfoDoc {
134134
m: Int
135135
)(gen: (Int, Int) => T
136136
)(
137-
implicit sourceInfo: SourceInfo
137+
using sourceInfo: SourceInfo
138138
): Vec[Vec[T]] = _tabulateImpl(n, m)(gen)
139139

140140
/** Creates a new 3D [[Vec]] of length `n by m by p` composed of the results of the given
@@ -152,7 +152,7 @@ object VecInit extends VecInitImpl with SourceInfoDoc {
152152
p: Int
153153
)(gen: (Int, Int, Int) => T
154154
)(
155-
implicit sourceInfo: SourceInfo
155+
using sourceInfo: SourceInfo
156156
): Vec[Vec[Vec[T]]] = _tabulateImpl(n, m, p)(gen)
157157

158158
/** Creates a new [[Vec]] of length `n` composed of the result of the given
@@ -162,7 +162,7 @@ object VecInit extends VecInitImpl with SourceInfoDoc {
162162
* @param gen function that takes in an element T and returns an output
163163
* element of the same type
164164
*/
165-
def fill[T <: Data](n: Int)(gen: => T)(implicit sourceInfo: SourceInfo): Vec[T] = _fillImpl(n)(gen)
165+
def fill[T <: Data](n: Int)(gen: => T)(using sourceInfo: SourceInfo): Vec[T] = _fillImpl(n)(gen)
166166

167167
/** Creates a new 2D [[Vec]] of length `n by m` composed of the result of the given
168168
* function applied to an element of data type T.
@@ -177,7 +177,7 @@ object VecInit extends VecInitImpl with SourceInfoDoc {
177177
m: Int
178178
)(gen: => T
179179
)(
180-
implicit sourceInfo: SourceInfo
180+
using sourceInfo: SourceInfo
181181
): Vec[Vec[T]] = _fillImpl(n, m)(gen)
182182

183183
/** Creates a new 3D [[Vec]] of length `n by m by p` composed of the result of the given
@@ -195,7 +195,7 @@ object VecInit extends VecInitImpl with SourceInfoDoc {
195195
p: Int
196196
)(gen: => T
197197
)(
198-
implicit sourceInfo: SourceInfo
198+
using sourceInfo: SourceInfo
199199
): Vec[Vec[Vec[T]]] = _fillImpl(n, m, p)(gen)
200200

201201
/** Creates a new [[Vec]] of length `n` composed of the result of the given
@@ -211,7 +211,7 @@ object VecInit extends VecInitImpl with SourceInfoDoc {
211211
len: Int
212212
)(f: (T) => T
213213
)(
214-
implicit sourceInfo: SourceInfo
214+
using sourceInfo: SourceInfo
215215
): Vec[T] = _iterateImpl(start, len)(f)
216216
}
217217

@@ -222,32 +222,32 @@ trait VecLike[T <: Data] extends VecLikeImpl[T] with SourceInfoDoc {
222222

223223
/** Creates a dynamically indexed read or write accessor into the array.
224224
*/
225-
def apply(p: UInt)(implicit sourceInfo: SourceInfo): T
225+
def apply(p: UInt)(using sourceInfo: SourceInfo): T
226226

227227
/** Outputs true if p outputs true for every element.
228228
*/
229-
def forall(p: T => Bool)(implicit sourceInfo: SourceInfo): Bool = _forallImpl(p)
229+
def forall(p: T => Bool)(using sourceInfo: SourceInfo): Bool = _forallImpl(p)
230230

231231
/** Outputs true if p outputs true for at least one element.
232232
*/
233-
def exists(p: T => Bool)(implicit sourceInfo: SourceInfo): Bool = _existsImpl(p)
233+
def exists(p: T => Bool)(using sourceInfo: SourceInfo): Bool = _existsImpl(p)
234234

235235
/** Outputs true if the vector contains at least one element equal to x (using
236236
* the === operator).
237237
*/
238-
def contains(x: T)(implicit sourceInfo: SourceInfo, ev: T <:< UInt): Bool = _containsImpl(x)
238+
def contains(x: T)(using sourceInfo: SourceInfo, ev: T <:< UInt): Bool = _containsImpl(x)
239239

240240
/** Outputs the number of elements for which p is true.
241241
*/
242-
def count(p: T => Bool)(implicit sourceInfo: SourceInfo): UInt = _countImpl(p)
242+
def count(p: T => Bool)(using sourceInfo: SourceInfo): UInt = _countImpl(p)
243243

244244
/** Outputs the index of the first element for which p outputs true.
245245
*/
246-
def indexWhere(p: T => Bool)(implicit sourceInfo: SourceInfo): UInt = _indexWhereImpl(p)
246+
def indexWhere(p: T => Bool)(using sourceInfo: SourceInfo): UInt = _indexWhereImpl(p)
247247

248248
/** Outputs the index of the last element for which p outputs true.
249249
*/
250-
def lastIndexWhere(p: T => Bool)(implicit sourceInfo: SourceInfo): UInt = _lastIndexWhereImpl(p)
250+
def lastIndexWhere(p: T => Bool)(using sourceInfo: SourceInfo): UInt = _lastIndexWhereImpl(p)
251251

252252
/** Outputs the index of the element for which p outputs true, assuming that
253253
* the there is exactly one such element.
@@ -259,7 +259,7 @@ trait VecLike[T <: Data] extends VecLikeImpl[T] with SourceInfoDoc {
259259
* true is NOT checked (useful in cases where the condition doesn't always
260260
* hold, but the results are not used in those cases)
261261
*/
262-
def onlyIndexWhere(p: T => Bool)(implicit sourceInfo: SourceInfo): UInt = _onlyIndexWhereImpl(p)
262+
def onlyIndexWhere(p: T => Bool)(using sourceInfo: SourceInfo): UInt = _onlyIndexWhereImpl(p)
263263
}
264264

265265
/** Base class for Aggregates based on key values pairs of String and Data

0 commit comments

Comments
 (0)