@@ -46,6 +46,18 @@ object SpecifiedDirection {
46
46
case Input => Output
47
47
}
48
48
49
+ /** Returns true if specified direction manifests as a flipped field
50
+ *
51
+ * @param dir provided specified direction
52
+ * @return
53
+ */
54
+ private [chisel3] def isFlipped (dir : SpecifiedDirection ): Boolean = dir match {
55
+ case Unspecified => false
56
+ case Flip => true
57
+ case Output => false
58
+ case Input => true
59
+ }
60
+
49
61
/** Returns the effective SpecifiedDirection of this node given the parent's effective SpecifiedDirection
50
62
* and the user-specified SpecifiedDirection of this node.
51
63
*/
@@ -251,8 +263,17 @@ object chiselTypeOf {
251
263
}
252
264
}
253
265
254
- /**
255
- * Input, Output, and Flipped are used to define the directions of Module IOs.
266
+ /** Creates a field of a parent [[Aggregate ]] which is
267
+ * - flipped relative to that parent
268
+ * - coerced all members of the field to be aligned
269
+ *
270
+ * E.g. The following will create a field `i` of `b` where all recursive sub-elements of `i` are aligned, and where `i` flipped relative to `b`
271
+ *
272
+ * ```scala
273
+ * val b = new Bundle {
274
+ * val i = Input(new Decoupled(UInt(32.W))
275
+ * }
276
+ * ```
256
277
*
257
278
* Note that they currently clone their source argument, including its bindings.
258
279
*
@@ -263,12 +284,44 @@ object Input {
263
284
SpecifiedDirection .specifiedDirection(source)(_ => SpecifiedDirection .Input )
264
285
}
265
286
}
287
+
288
+ /** Creates a field of a parent [[Aggregate ]] which is
289
+ * - aligned relative to that parent
290
+ * - coerced all members of the field to be aligned
291
+ *
292
+ * E.g. The following will create a field `i` of `b` where all recursive sub-elements of `i` are aligned, and where `i` is also aligned relative to `b`
293
+ *
294
+ * ```scala
295
+ * val b = new Bundle {
296
+ * val i = Output(new Decoupled(UInt(32.W))
297
+ * }
298
+ * ```
299
+ *
300
+ * Note that they currently clone their source argument, including its bindings.
301
+ *
302
+ * Thus, an error will be thrown if these are used on bound Data
303
+ */
266
304
object Output {
267
305
def apply [T <: Data ](source : => T ): T = {
268
306
SpecifiedDirection .specifiedDirection(source)(_ => SpecifiedDirection .Output )
269
307
}
270
308
}
271
309
310
+ /** Creates a field of a parent [[Aggregate ]] which is
311
+ * - flipped relative to that parent
312
+ *
313
+ * E.g. The following will create a field `i` of `b` where `i` is flipped relative to `b`
314
+ *
315
+ * ```scala
316
+ * val b = new Bundle {
317
+ * val i = Flipped(new Decoupled(UInt(32.W))
318
+ * }
319
+ * ```
320
+ *
321
+ * Note that they currently clone their source argument, including its bindings.
322
+ *
323
+ * Thus, an error will be thrown if these are used on bound Data
324
+ */
272
325
object Flipped {
273
326
def apply [T <: Data ](source : => T ): T = {
274
327
SpecifiedDirection .specifiedDirection(source)(x => SpecifiedDirection .flip(x.specifiedDirection))
0 commit comments