-
Notifications
You must be signed in to change notification settings - Fork 603
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor out fromBits => asTypeOf, deprecate flatten and other bad APIs
- Loading branch information
Showing
7 changed files
with
260 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// See LICENSE for license details. | ||
|
||
package chisel3.core | ||
|
||
import scala.language.experimental.macros | ||
|
||
import chisel3.internal.Builder.{pushOp} | ||
import chisel3.internal.sourceinfo.{SourceInfo, MuxTransform} | ||
import chisel3.internal.firrtl._ | ||
import chisel3.internal.firrtl.PrimOp._ | ||
|
||
object Mux { | ||
/** Creates a mux, whose output is one of the inputs depending on the | ||
* value of the condition. | ||
* | ||
* @param cond condition determining the input to choose | ||
* @param con the value chosen when `cond` is true | ||
* @param alt the value chosen when `cond` is false | ||
* @example | ||
* {{{ | ||
* val muxOut = Mux(data_in === 3.U, 3.U(4.W), 0.U(4.W)) | ||
* }}} | ||
*/ | ||
def apply[T <: Data](cond: Bool, con: T, alt: T): T = macro MuxTransform.apply[T] | ||
|
||
def do_apply[T <: Data](cond: Bool, con: T, alt: T)(implicit sourceInfo: SourceInfo): T = { | ||
Binding.checkSynthesizable(cond, s"'cond' ($cond)") | ||
Binding.checkSynthesizable(con, s"'con' ($con)") | ||
Binding.checkSynthesizable(alt, s"'alt' ($alt)") | ||
val d = cloneSupertype(Seq(con, alt), "Mux") | ||
pushOp(DefPrim(sourceInfo, d, MultiplexOp, cond.ref, con.ref, alt.ref)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.