summaryrefslogtreecommitdiff
path: root/core/src/main/scala/chisel3/experimental
diff options
context:
space:
mode:
authorAditya Naik2024-05-29 17:28:22 -0700
committerAditya Naik2024-05-29 17:28:22 -0700
commitbc92bb62f9f6a090e74392993e4fcfdd1f6b0676 (patch)
tree160eb4cc2770eaf0c189fab9442d04b2b00b7919 /core/src/main/scala/chisel3/experimental
parent878d488a7c8e0d6973de58b3164022c6a102e449 (diff)
i got 99 errors but "firrtl not found" aint one
Diffstat (limited to 'core/src/main/scala/chisel3/experimental')
-rw-r--r--core/src/main/scala/chisel3/experimental/ChiselEnum.scala60
-rw-r--r--core/src/main/scala/chisel3/experimental/package.scala126
2 files changed, 72 insertions, 114 deletions
diff --git a/core/src/main/scala/chisel3/experimental/ChiselEnum.scala b/core/src/main/scala/chisel3/experimental/ChiselEnum.scala
index 37c6fb58..27b07199 100644
--- a/core/src/main/scala/chisel3/experimental/ChiselEnum.scala
+++ b/core/src/main/scala/chisel3/experimental/ChiselEnum.scala
@@ -2,8 +2,6 @@
package chisel3.experimental
-import scala.language.experimental.macros
-import scala.reflect.macros.blackbox.Context
import scala.collection.mutable
import chisel3._
import chisel3.internal.Builder.pushOp
@@ -116,27 +114,20 @@ abstract class EnumType(private[chisel3] val factory: ChiselEnum, selfAnnotating
this := factory.apply(that.asUInt)
}
- final def ===(that: EnumType): Bool = macro SourceInfoTransform.thatArg
- final def =/=(that: EnumType): Bool = macro SourceInfoTransform.thatArg
- final def <(that: EnumType): Bool = macro SourceInfoTransform.thatArg
- final def <=(that: EnumType): Bool = macro SourceInfoTransform.thatArg
- final def >(that: EnumType): Bool = macro SourceInfoTransform.thatArg
- final def >=(that: EnumType): Bool = macro SourceInfoTransform.thatArg
-
- def do_===(that: EnumType)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
+ def ===(that: EnumType)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
compop(sourceInfo, EqualOp, that)
- def do_=/=(that: EnumType)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
+ def =/=(that: EnumType)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
compop(sourceInfo, NotEqualOp, that)
- def do_<(that: EnumType)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
+ def <(that: EnumType)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
compop(sourceInfo, LessOp, that)
- def do_>(that: EnumType)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
+ def >(that: EnumType)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
compop(sourceInfo, GreaterOp, that)
- def do_<=(that: EnumType)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
+ def <=(that: EnumType)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
compop(sourceInfo, LessEqOp, that)
- def do_>=(that: EnumType)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
+ def >=(that: EnumType)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool =
compop(sourceInfo, GreaterEqOp, that)
- override def do_asUInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt =
+ override def asUInt(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt =
pushOp(DefPrim(sourceInfo, UInt(width), AsUIntOp, ref))
protected[chisel3] override def width: Width = factory.width
@@ -317,10 +308,7 @@ abstract class EnumFactory {
enumRecords.find(_.inst.litValue == id).map(_.name)
}
- protected def Value: Type = macro EnumMacros.ValImpl
- protected def Value(id: UInt): Type = macro EnumMacros.ValCustomImpl
-
- protected def do_Value(name: String): Type = {
+ protected def Value(name: String): Type = {
val result = new Type
// We have to use UnknownWidth here, because we don't actually know what the final width will be
@@ -334,7 +322,7 @@ abstract class EnumFactory {
result
}
- protected def do_Value(name: String, id: UInt): Type = {
+ protected def Value(name: String, id: UInt): Type = {
// TODO: These throw ExceptionInInitializerError which can be confusing to the user. Get rid of the error, and just
// throw an exception
if (id.litOption.isEmpty) {
@@ -401,36 +389,6 @@ abstract class EnumFactory {
}
}
-private[chisel3] object EnumMacros {
- def ValImpl(c: Context): c.Tree = {
- import c.universe._
-
- // Much thanks to michael_s for this solution:
- // stackoverflow.com/questions/18450203/retrieve-the-name-of-the-value-a-scala-macro-invocation-will-be-assigned-to
- val term = c.internal.enclosingOwner
- val name = term.name.decodedName.toString.trim
-
- if (name.contains(" ")) {
- c.abort(c.enclosingPosition, "Value cannot be called without assigning to an enum")
- }
-
- q"""this.do_Value($name)"""
- }
-
- def ValCustomImpl(c: Context)(id: c.Expr[UInt]): c.universe.Tree = {
- import c.universe._
-
- val term = c.internal.enclosingOwner
- val name = term.name.decodedName.toString.trim
-
- if (name.contains(" ")) {
- c.abort(c.enclosingPosition, "Value cannot be called without assigning to an enum")
- }
-
- q"""this.do_Value($name, $id)"""
- }
-}
-
// This is an enum type that can be connected directly to UInts. It is used as a "glue" to cast non-literal UInts
// to enums.
private[chisel3] class UnsafeEnum(override val width: Width) extends EnumType(UnsafeEnum, selfAnnotating = false) {
diff --git a/core/src/main/scala/chisel3/experimental/package.scala b/core/src/main/scala/chisel3/experimental/package.scala
index a69c5b6e..e803c775 100644
--- a/core/src/main/scala/chisel3/experimental/package.scala
+++ b/core/src/main/scala/chisel3/experimental/package.scala
@@ -26,71 +26,71 @@ package object experimental {
val Direction = ActualDirection
- class dump extends chisel3.internal.naming.dump
- class treedump extends chisel3.internal.naming.treedump
+ // class dump extends chisel3.internal.naming.dump
+ // class treedump extends chisel3.internal.naming.treedump
- /** Experimental macro for naming Chisel hardware values
- *
- * By default, Chisel uses reflection for naming which only works for public fields of `Bundle`
- * and `Module` classes. Applying this macro annotation to a `class` or `object` enables Chisel
- * to name any hardware values within the annotated `class` or `object.
- *
- * @example {{{
- * import chisel3._
- * import chisel3.experimental.chiselName
- *
- * @chiselName
- * class MyModule extends Module {
- * val io = IO(new Bundle {
- * val in = Input(UInt(8.W))
- * val out = Output(UInt(8.W))
- * })
- * def createReg(): Unit = {
- * // @chiselName allows Chisel to name this Reg
- * val myReg = RegInit(io.in)
- * io.out := myReg
- * }
- * createReg()
- * }
- * }}}
- */
- class chiselName extends chisel3.internal.naming.chiselName
+ // /** Experimental macro for naming Chisel hardware values
+ // *
+ // * By default, Chisel uses reflection for naming which only works for public fields of `Bundle`
+ // * and `Module` classes. Applying this macro annotation to a `class` or `object` enables Chisel
+ // * to name any hardware values within the annotated `class` or `object.
+ // *
+ // * @example {{{
+ // * import chisel3._
+ // * import chisel3.experimental.chiselName
+ // *
+ // * @chiselName
+ // * class MyModule extends Module {
+ // * val io = IO(new Bundle {
+ // * val in = Input(UInt(8.W))
+ // * val out = Output(UInt(8.W))
+ // * })
+ // * def createReg(): Unit = {
+ // * // @chiselName allows Chisel to name this Reg
+ // * val myReg = RegInit(io.in)
+ // * io.out := myReg
+ // * }
+ // * createReg()
+ // * }
+ // * }}}
+ // */
+ // class chiselName extends chisel3.internal.naming.chiselName
- /** Do not name instances of this type in [[chiselName]]
- *
- * By default, `chiselName` will include `val` names of instances of annotated classes as a
- * prefix in final naming. Mixing in this trait to a `class`, `object`, or anonymous `class`
- * instances will exclude the `val` name from `chiselName` naming.
- *
- * @example {{{
- * import chisel3._
- * import chisel3.experimental.{chiselName, NoChiselNamePrefix}
- *
- * // Note that this is not a Module
- * @chiselName
- * class Counter(w: Int) {
- * val myReg = RegInit(0.U(w.W))
- * myReg := myReg + 1.U
- * }
- *
- * @chiselName
- * class MyModule extends Module {
- * val io = IO(new Bundle {
- * val out = Output(UInt(8.W))
- * })
- * // Name of myReg will be "counter0_myReg"
- * val counter0 = new Counter(8)
- * // Name of myReg will be "myReg"
- * val counter1 = new Counter(8) with NoChiselNamePrefix
- * io.out := counter0.myReg + counter1.myReg
- * }
- * }}}
- */
- @deprecated(
- "@chiselName and NoChiselNamePrefix have been replaced by the compiler plugin and AffectsChiselPrefix. Use these instead",
- "Chisel 3.5"
- )
- trait NoChiselNamePrefix
+ // /** Do not name instances of this type in [[chiselName]]
+ // *
+ // * By default, `chiselName` will include `val` names of instances of annotated classes as a
+ // * prefix in final naming. Mixing in this trait to a `class`, `object`, or anonymous `class`
+ // * instances will exclude the `val` name from `chiselName` naming.
+ // *
+ // * @example {{{
+ // * import chisel3._
+ // * import chisel3.experimental.{chiselName, NoChiselNamePrefix}
+ // *
+ // * // Note that this is not a Module
+ // * @chiselName
+ // * class Counter(w: Int) {
+ // * val myReg = RegInit(0.U(w.W))
+ // * myReg := myReg + 1.U
+ // * }
+ // *
+ // * @chiselName
+ // * class MyModule extends Module {
+ // * val io = IO(new Bundle {
+ // * val out = Output(UInt(8.W))
+ // * })
+ // * // Name of myReg will be "counter0_myReg"
+ // * val counter0 = new Counter(8)
+ // * // Name of myReg will be "myReg"
+ // * val counter1 = new Counter(8) with NoChiselNamePrefix
+ // * io.out := counter0.myReg + counter1.myReg
+ // * }
+ // * }}}
+ // */
+ // @deprecated(
+ // "@chiselName and NoChiselNamePrefix have been replaced by the compiler plugin and AffectsChiselPrefix. Use these instead",
+ // "Chisel 3.5"
+ // )
+ // trait NoChiselNamePrefix
/** Generate prefixes from values of this type in the Chisel compiler plugin
*