summaryrefslogtreecommitdiff
path: root/core/src/main/scala/chisel3
diff options
context:
space:
mode:
authormergify[bot]2022-06-07 23:11:54 +0000
committerGitHub2022-06-07 23:11:54 +0000
commit205d8bb34b2ac2acaef6d318a4f9e3aee181110e (patch)
tree042b01ec82a9f723cdf0215ef5ba78b1631459a3 /core/src/main/scala/chisel3
parent42f5d89045e7db323670964a982c59319cf9001f (diff)
Add single argument Bits.extract (#2566) (#2568)
(cherry picked from commit 255c56c3955a8c16191a6751e7d547cfcfd96705) Co-authored-by: Jared Barocsi <82000041+jared-barocsi@users.noreply.github.com>
Diffstat (limited to 'core/src/main/scala/chisel3')
-rw-r--r--core/src/main/scala/chisel3/Bits.scala32
1 files changed, 27 insertions, 5 deletions
diff --git a/core/src/main/scala/chisel3/Bits.scala b/core/src/main/scala/chisel3/Bits.scala
index c914e88c..72094a65 100644
--- a/core/src/main/scala/chisel3/Bits.scala
+++ b/core/src/main/scala/chisel3/Bits.scala
@@ -100,10 +100,10 @@ sealed abstract class Bits(private[chisel3] val width: Width) extends Element wi
* @param x an index
* @return the specified bit
*/
- final def apply(x: BigInt): Bool = macro IntLiteralApplyTransform.safeApply
+ final def extract(x: BigInt): Bool = macro SourceInfoTransform.xArg
/** @group SourceInfoTransformMacro */
- final def do_apply(x: BigInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = {
+ final def do_extract(x: BigInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = {
if (x < 0) {
Builder.error(s"Negative bit indices are illegal (got $x)")
}
@@ -128,25 +128,47 @@ sealed abstract class Bits(private[chisel3] val width: Width) extends Element wi
* @param x an index
* @return the specified bit
*/
+ final def apply(x: BigInt): Bool = macro IntLiteralApplyTransform.safeApply
+
+ /** @group SourceInfoTransformMacro */
+ final def do_apply(x: BigInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
+ do_extract(x)
+
+ /** Returns the specified bit on this $coll as a [[Bool]], statically addressed.
+ *
+ * @param x an index
+ * @return the specified bit
+ */
final def apply(x: Int): Bool = macro IntLiteralApplyTransform.safeApply
/** @group SourceInfoTransformMacro */
final def do_apply(x: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
- do_apply(BigInt(x))
+ do_extract(BigInt(x))
/** Returns the specified bit on this wire as a [[Bool]], dynamically addressed.
*
* @param x a hardware component whose value will be used for dynamic addressing
* @return the specified bit
*/
- final def apply(x: UInt): Bool = macro SourceInfoTransform.xArg
+ final def extract(x: UInt): Bool = macro SourceInfoTransform.xArg
/** @group SourceInfoTransformMacro */
- final def do_apply(x: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = {
+ final def do_extract(x: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = {
val theBits = this >> x
theBits(0)
}
+ /** Returns the specified bit on this wire as a [[Bool]], dynamically addressed.
+ *
+ * @param x a hardware component whose value will be used for dynamic addressing
+ * @return the specified bit
+ */
+ final def apply(x: UInt): Bool = macro SourceInfoTransform.xArg
+
+ /** @group SourceInfoTransformMacro */
+ final def do_apply(x: UInt)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
+ do_extract(x)
+
/** Returns a subset of bits on this $coll from `hi` to `lo` (inclusive), statically addressed.
*
* @example