summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/compatibility.scala
diff options
context:
space:
mode:
authorRichard Lin2017-08-17 17:24:02 -0700
committerJack Koenig2017-08-17 17:24:02 -0700
commit6e12ed9fd7a771eb30f44b8e1c4ab33f6ad8e0a6 (patch)
tree0ff452193d515adc32ecccacb2b58daa9a1d95cb /src/main/scala/chisel3/compatibility.scala
parent802cfc4405c28ae212a955a92c7a6ad2d2b6f0c2 (diff)
More of the bindings refactor (#635)
Rest of the binding refactor
Diffstat (limited to 'src/main/scala/chisel3/compatibility.scala')
-rw-r--r--src/main/scala/chisel3/compatibility.scala50
1 files changed, 45 insertions, 5 deletions
diff --git a/src/main/scala/chisel3/compatibility.scala b/src/main/scala/chisel3/compatibility.scala
index 4d2d9311..f181caba 100644
--- a/src/main/scala/chisel3/compatibility.scala
+++ b/src/main/scala/chisel3/compatibility.scala
@@ -46,7 +46,15 @@ package object Chisel { // scalastyle:ignore package.object.name
type ChiselException = chisel3.internal.ChiselException
type Data = chisel3.core.Data
- val Wire = chisel3.core.Wire
+ object Wire extends chisel3.core.WireFactory {
+ import chisel3.core.CompileOptions
+
+ def apply[T <: Data](dummy: Int = 0, init: T)(implicit compileOptions: CompileOptions): T =
+ chisel3.core.WireInit(init)
+
+ def apply[T <: Data](t: T, init: T)(implicit compileOptions: CompileOptions): T =
+ chisel3.core.WireInit(t, init)
+ }
object Clock {
def apply(): Clock = new Clock
@@ -82,7 +90,39 @@ package object Chisel { // scalastyle:ignore package.object.name
}
type Aggregate = chisel3.core.Aggregate
- val Vec = chisel3.core.Vec
+ object Vec extends chisel3.core.VecFactory {
+ import chisel3.core.CompileOptions
+ import chisel3.internal.sourceinfo._
+
+ @deprecated("Vec argument order should be size, t; this will be removed by the official release", "chisel3")
+ def apply[T <: Data](gen: T, n: Int)(implicit compileOptions: CompileOptions): Vec[T] =
+ apply(n, gen)
+
+ /** Creates a new [[Vec]] of length `n` composed of the result of the given
+ * function repeatedly applied.
+ *
+ * @param n number of elements (and the number of times the function is
+ * called)
+ * @param gen function that generates the [[Data]] that becomes the output
+ * element
+ */
+ def fill[T <: Data](n: Int)(gen: => T)(implicit compileOptions: CompileOptions): Vec[T] =
+ apply(Seq.fill(n)(gen))
+
+ def apply[T <: Data](elts: Seq[T]): Vec[T] = macro VecTransform.apply_elts
+ def do_apply[T <: Data](elts: Seq[T])(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Vec[T] =
+ chisel3.core.VecInit(elts)
+
+ def apply[T <: Data](elt0: T, elts: T*): Vec[T] = macro VecTransform.apply_elt0
+ def do_apply[T <: Data](elt0: T, elts: T*)
+ (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Vec[T] =
+ chisel3.core.VecInit(elt0 +: elts.toSeq)
+
+ def tabulate[T <: Data](n: Int)(gen: (Int) => T): Vec[T] = macro VecTransform.tabulate
+ def do_tabulate[T <: Data](n: Int)(gen: (Int) => T)
+ (implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Vec[T] =
+ chisel3.core.VecInit.tabulate(n)(gen)
+ }
type Vec[T <: Data] = chisel3.core.Vec[T]
type VecLike[T <: Data] = chisel3.core.VecLike[T]
type Record = chisel3.core.Record
@@ -484,8 +524,8 @@ package object Chisel { // scalastyle:ignore package.object.name
object experimental { // scalastyle:ignore object.name
import scala.annotation.compileTimeOnly
- class dump extends chisel3.internal.naming.dump
- class treedump extends chisel3.internal.naming.treedump
- class chiselName extends chisel3.internal.naming.chiselName
+ class dump extends chisel3.internal.naming.dump // scalastyle:ignore class.name
+ class treedump extends chisel3.internal.naming.treedump // scalastyle:ignore class.name
+ class chiselName extends chisel3.internal.naming.chiselName // scalastyle:ignore class.name
}
}