diff options
| author | Chick Markley | 2020-01-22 13:06:55 -0800 |
|---|---|---|
| committer | GitHub | 2020-01-22 13:06:55 -0800 |
| commit | 771b63c128a862de3c942c2a5c1bd1802a39c3f1 (patch) | |
| tree | d0bb56ab43585e1891fe7a7c7f1fbb5692070a08 | |
| parent | 08ae1050dd62f7c5dba6d4acb62cd2848b460d5d (diff) | |
| parent | 993ee4ed8b95e2c78f6fc54ecbd828ac06a32b8b (diff) | |
Merge branch 'master' into add-asbool-to-clock
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/When.scala | 8 | ||||
| -rw-r--r-- | src/main/scala/chisel3/util/Conditional.scala | 16 |
2 files changed, 12 insertions, 12 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/When.scala b/chiselFrontend/src/main/scala/chisel3/When.scala index 50e13a1f..ea243bbe 100644 --- a/chiselFrontend/src/main/scala/chisel3/When.scala +++ b/chiselFrontend/src/main/scala/chisel3/When.scala @@ -28,7 +28,7 @@ object when { // scalastyle:ignore object.name * }}} */ - def apply(cond: => Bool)(block: => Unit)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): WhenContext = { // scalastyle:ignore line.size.limit + def apply(cond: => Bool)(block: => Any)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): WhenContext = { // scalastyle:ignore line.size.limit new WhenContext(sourceInfo, Some(() => cond), block) } } @@ -43,7 +43,7 @@ object when { // scalastyle:ignore object.name * succeeding elsewhen or otherwise; therefore, this information is * added by preprocessing the command queue. */ -final class WhenContext(sourceInfo: SourceInfo, cond: Option[() => Bool], block: => Unit, firrtlDepth: Int = 0) { +final class WhenContext(sourceInfo: SourceInfo, cond: Option[() => Bool], block: => Any, firrtlDepth: Int = 0) { /** This block of logic gets executed if above conditions have been * false and this condition is true. The lazy argument pattern @@ -51,7 +51,7 @@ final class WhenContext(sourceInfo: SourceInfo, cond: Option[() => Bool], block: * declaration and assignment of the Bool node of the predicate in * the correct place. */ - def elsewhen (elseCond: => Bool)(block: => Unit)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): WhenContext = { // scalastyle:ignore line.size.limit + def elsewhen (elseCond: => Bool)(block: => Any)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): WhenContext = { // scalastyle:ignore line.size.limit new WhenContext(sourceInfo, Some(() => elseCond), block, firrtlDepth + 1) } @@ -62,7 +62,7 @@ final class WhenContext(sourceInfo: SourceInfo, cond: Option[() => Bool], block: * assignment of the Bool node of the predicate in the correct * place. */ - def otherwise(block: => Unit)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Unit = + def otherwise(block: => Any)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Unit = new WhenContext(sourceInfo, None, block, firrtlDepth + 1) /* diff --git a/src/main/scala/chisel3/util/Conditional.scala b/src/main/scala/chisel3/util/Conditional.scala index 2459acb8..7aebc815 100644 --- a/src/main/scala/chisel3/util/Conditional.scala +++ b/src/main/scala/chisel3/util/Conditional.scala @@ -15,7 +15,7 @@ import chisel3._ object unless { // scalastyle:ignore object.name /** Does the same thing as [[when$ when]], but with the condition inverted. */ - def apply(c: Bool)(block: => Unit) { + def apply(c: Bool)(block: => Any) { when (!c) { block } } } @@ -25,7 +25,7 @@ object unless { // scalastyle:ignore object.name * @note DO NOT USE. This API is subject to change without warning. */ class SwitchContext[T <: Element](cond: T, whenContext: Option[WhenContext], lits: Set[BigInt]) { - def is(v: Iterable[T])(block: => Unit): SwitchContext[T] = { + def is(v: Iterable[T])(block: => Any): SwitchContext[T] = { if (!v.isEmpty) { val newLits = v.map { w => require(w.litOption.isDefined, "is condition must be literal") @@ -43,8 +43,8 @@ class SwitchContext[T <: Element](cond: T, whenContext: Option[WhenContext], lit this } } - def is(v: T)(block: => Unit): SwitchContext[T] = is(Seq(v))(block) - def is(v: T, vr: T*)(block: => Unit): SwitchContext[T] = is(v :: vr.toList)(block) + def is(v: T)(block: => Any): SwitchContext[T] = is(Seq(v))(block) + def is(v: T, vr: T*)(block: => Any): SwitchContext[T] = is(v :: vr.toList)(block) } /** Use to specify cases in a [[switch]] block, equivalent to a [[when$ when]] block comparing to @@ -60,19 +60,19 @@ object is { // scalastyle:ignore object.name // TODO: Begin deprecation of non-type-parameterized is statements. /** Executes `block` if the switch condition is equal to any of the values in `v`. */ - def apply(v: Iterable[Element])(block: => Unit) { + def apply(v: Iterable[Element])(block: => Any) { require(false, "The 'is' keyword may not be used outside of a switch.") } /** Executes `block` if the switch condition is equal to `v`. */ - def apply(v: Element)(block: => Unit) { + def apply(v: Element)(block: => Any) { require(false, "The 'is' keyword may not be used outside of a switch.") } /** Executes `block` if the switch condition is equal to any of the values in the argument list. */ - def apply(v: Element, vr: Element*)(block: => Unit) { + def apply(v: Element, vr: Element*)(block: => Any) { require(false, "The 'is' keyword may not be used outside of a switch.") } } @@ -91,7 +91,7 @@ object is { // scalastyle:ignore object.name * }}} */ object switch { // scalastyle:ignore object.name - def apply[T <: Element](cond: T)(x: => Unit): Unit = macro impl + def apply[T <: Element](cond: T)(x: => Any): Unit = macro impl def impl(c: Context)(cond: c.Tree)(x: c.Tree): c.Tree = { import c.universe._ val q"..$body" = x val res = body.foldLeft(q"""new SwitchContext($cond, None, Set.empty)""") { |
