summaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
authorSoyaOhnishi2021-01-25 11:15:52 +0900
committerGitHub2021-01-24 18:15:52 -0800
commit2a96767097264eade18ff26e1d8bce192383a190 (patch)
tree21c0578617974a7a6b831032491e1577bb3bdbaa /core/src/main
parente63b9667d89768e0ec6dc8a9153335cb48a213a7 (diff)
Refactor EnumAnnotations and EnumFactory (#1747)
This is a nit fix. no logic is changed. * Rename `typeName` to `enumTypeName` in ScalaDoc * Add return type at public method * Rename `enum_records` into `enumRecords` to retain name consistency Co-authored-by: Jack Koenig <koenig@sifive.com>
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/scala/chisel3/StrongEnum.scala18
1 files changed, 9 insertions, 9 deletions
diff --git a/core/src/main/scala/chisel3/StrongEnum.scala b/core/src/main/scala/chisel3/StrongEnum.scala
index 2d372a94..7d328eb7 100644
--- a/core/src/main/scala/chisel3/StrongEnum.scala
+++ b/core/src/main/scala/chisel3/StrongEnum.scala
@@ -18,7 +18,7 @@ object EnumAnnotations {
/** An annotation for strong enum instances that are ''not'' inside of Vecs
*
* @param target the enum instance being annotated
- * @param typeName the name of the enum's type (e.g. ''"mypackage.MyEnum"'')
+ * @param enumTypeName the name of the enum's type (e.g. ''"mypackage.MyEnum"'')
*/
case class EnumComponentAnnotation(target: Named, enumTypeName: String) extends SingleTargetAnnotation[Named] {
def duplicate(n: Named): EnumComponentAnnotation = this.copy(target = n)
@@ -50,11 +50,11 @@ object EnumAnnotations {
*
*/
case class EnumVecAnnotation(target: Named, typeName: String, fields: Seq[Seq[String]]) extends SingleTargetAnnotation[Named] {
- def duplicate(n: Named) = this.copy(target = n)
+ def duplicate(n: Named): EnumVecAnnotation = this.copy(target = n)
}
case class EnumVecChiselAnnotation(target: InstanceId, typeName: String, fields: Seq[Seq[String]]) extends ChiselAnnotation {
- override def toFirrtl = EnumVecAnnotation(target.toNamed, typeName, fields)
+ override def toFirrtl: EnumVecAnnotation = EnumVecAnnotation(target.toNamed, typeName, fields)
}
/** An annotation for enum types (rather than enum ''instances'').
@@ -225,11 +225,11 @@ abstract class EnumFactory {
private[chisel3] var width: Width = 0.W
private case class EnumRecord(inst: Type, name: String)
- private val enum_records = mutable.ArrayBuffer.empty[EnumRecord]
+ private val enumRecords = mutable.ArrayBuffer.empty[EnumRecord]
- private def enumNames = enum_records.map(_.name).toSeq
- private def enumValues = enum_records.map(_.inst.litValue()).toSeq
- private def enumInstances = enum_records.map(_.inst).toSeq
+ private def enumNames = enumRecords.map(_.name).toSeq
+ private def enumValues = enumRecords.map(_.inst.litValue()).toSeq
+ private def enumInstances = enumRecords.map(_.inst).toSeq
private[chisel3] val enumTypeName = getClass.getName.init
@@ -241,7 +241,7 @@ abstract class EnumFactory {
def all: Seq[Type] = enumInstances
private[chisel3] def nameOfValue(id: BigInt): Option[String] = {
- enum_records.find(_.inst.litValue() == id).map(_.name)
+ enumRecords.find(_.inst.litValue() == id).map(_.name)
}
protected def Value: Type = macro EnumMacros.ValImpl
@@ -253,7 +253,7 @@ abstract class EnumFactory {
// We have to use UnknownWidth here, because we don't actually know what the final width will be
result.bindToLiteral(id, UnknownWidth())
- enum_records.append(EnumRecord(result, name))
+ enumRecords.append(EnumRecord(result, name))
width = (1 max id.bitLength).W
id += 1