diff options
| author | Richard Lin | 2016-05-20 16:34:03 -0700 |
|---|---|---|
| committer | Richard Lin | 2016-05-20 16:34:03 -0700 |
| commit | d742d70a05b5fa997517ea7b5eb2d15b23e7a431 (patch) | |
| tree | 3c2453014c78e889fd1502085661ed604c5f0b34 /chiselFrontend/src/main/scala/Chisel/SeqUtils.scala | |
| parent | d7697eb14a0195cc3726bf45fdf38c631b6f6507 (diff) | |
| parent | e92f2f69477a6ce86fc148a1a95db5797f2e3051 (diff) | |
Merge pull request #186 from ucb-bar/sloc_impl
Source locators
Diffstat (limited to 'chiselFrontend/src/main/scala/Chisel/SeqUtils.scala')
| -rw-r--r-- | chiselFrontend/src/main/scala/Chisel/SeqUtils.scala | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/chiselFrontend/src/main/scala/Chisel/SeqUtils.scala b/chiselFrontend/src/main/scala/Chisel/SeqUtils.scala index c63f5735..e3e58cb4 100644 --- a/chiselFrontend/src/main/scala/Chisel/SeqUtils.scala +++ b/chiselFrontend/src/main/scala/Chisel/SeqUtils.scala @@ -2,9 +2,15 @@ package Chisel +import scala.language.experimental.macros + +import internal.sourceinfo.{SourceInfo, SourceInfoTransform} + private[Chisel] object SeqUtils { /** Equivalent to Cat(r(n-1), ..., r(0)) */ - def asUInt[T <: Bits](in: Seq[T]): UInt = { + def asUInt[T <: Bits](in: Seq[T]): UInt = macro SourceInfoTransform.inArg + + def do_asUInt[T <: Bits](in: Seq[T])(implicit sourceInfo: SourceInfo): UInt = { if (in.tail.isEmpty) { in.head.asUInt } else { @@ -15,7 +21,9 @@ private[Chisel] object SeqUtils { } /** Counts the number of true Bools in a Seq */ - def count(in: Seq[Bool]): UInt = { + def count(in: Seq[Bool]): UInt = macro SourceInfoTransform.inArg + + def do_count(in: Seq[Bool])(implicit sourceInfo: SourceInfo): UInt = { if (in.size == 0) { UInt(0) } else if (in.size == 1) { @@ -26,7 +34,9 @@ private[Chisel] object SeqUtils { } /** Returns data value corresponding to first true predicate */ - def priorityMux[T <: Bits](in: Seq[(Bool, T)]): T = { + def priorityMux[T <: Bits](in: Seq[(Bool, T)]): T = macro SourceInfoTransform.inArg + + def do_priorityMux[T <: Bits](in: Seq[(Bool, T)])(implicit sourceInfo: SourceInfo): T = { if (in.size == 1) { in.head._2 } else { @@ -35,7 +45,9 @@ private[Chisel] object SeqUtils { } /** Returns data value corresponding to lone true predicate */ - def oneHotMux[T <: Data](in: Iterable[(Bool, T)]): T = { + def oneHotMux[T <: Data](in: Iterable[(Bool, T)]): T = macro SourceInfoTransform.inArg + + def do_oneHotMux[T <: Data](in: Iterable[(Bool, T)])(implicit sourceInfo: SourceInfo): T = { if (in.tail.isEmpty) { in.head._2 } else { |
