Skip to content

Commit

Permalink
Apply formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkoenig committed Dec 17, 2024
1 parent 3c93271 commit 5f7e78b
Show file tree
Hide file tree
Showing 195 changed files with 1,869 additions and 2,210 deletions.
40 changes: 17 additions & 23 deletions core/src/main/scala-2/chisel3/Aggregate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ object VecInit extends VecInitImpl with SourceInfoDoc {

/** @group SourceInfoTransformMacro */
def do_tabulate[T <: Data](
n: Int
)(gen: (Int) => T
)(
n: Int
)(gen: (Int) => T)(
implicit sourceInfo: SourceInfo
): Vec[T] = _tabulateImpl(n)(gen)

Expand All @@ -136,10 +135,9 @@ object VecInit extends VecInitImpl with SourceInfoDoc {

/** @group SourceInfoTransformMacro */
def do_tabulate[T <: Data](
n: Int,
m: Int
)(gen: (Int, Int) => T
)(
n: Int,
m: Int
)(gen: (Int, Int) => T)(
implicit sourceInfo: SourceInfo
): Vec[Vec[T]] = _tabulateImpl(n, m)(gen)

Expand All @@ -157,11 +155,10 @@ object VecInit extends VecInitImpl with SourceInfoDoc {

/** @group SourceInfoTransformMacro */
def do_tabulate[T <: Data](
n: Int,
m: Int,
p: Int
)(gen: (Int, Int, Int) => T
)(
n: Int,
m: Int,
p: Int
)(gen: (Int, Int, Int) => T)(
implicit sourceInfo: SourceInfo
): Vec[Vec[Vec[T]]] = _tabulateImpl(n, m, p)(gen)

Expand Down Expand Up @@ -189,10 +186,9 @@ object VecInit extends VecInitImpl with SourceInfoDoc {

/** @group SourceInfoTransformMacro */
def do_fill[T <: Data](
n: Int,
m: Int
)(gen: => T
)(
n: Int,
m: Int
)(gen: => T)(
implicit sourceInfo: SourceInfo
): Vec[Vec[T]] = _fillImpl(n, m)(gen)

Expand All @@ -209,11 +205,10 @@ object VecInit extends VecInitImpl with SourceInfoDoc {

/** @group SourceInfoTransformMacro */
def do_fill[T <: Data](
n: Int,
m: Int,
p: Int
)(gen: => T
)(
n: Int,
m: Int,
p: Int
)(gen: => T)(
implicit sourceInfo: SourceInfo
): Vec[Vec[Vec[T]]] = _fillImpl(n, m, p)(gen)

Expand All @@ -231,8 +226,7 @@ object VecInit extends VecInitImpl with SourceInfoDoc {
def do_iterate[T <: Data](
start: T,
len: Int
)(f: (T) => T
)(
)(f: (T) => T)(
implicit sourceInfo: SourceInfo
): Vec[T] = _iterateImpl(start, len)(f)
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala-2/chisel3/ChiselEnum.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abstract class EnumType(factory: ChiselEnum, selfAnnotating: Boolean = true)
}

abstract class ChiselEnum extends ChiselEnumImpl {
protected def Value: Type = macro EnumMacros.ValImpl
protected def Value: Type = macro EnumMacros.ValImpl
protected def Value(id: UInt): Type = macro EnumMacros.ValCustomImpl
}

Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala-2/chisel3/Mem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ object SyncReadMem extends ObjectSyncReadMemImpl {
* @param size number of elements in the memory
* @param t data type of memory element
*/
def apply[T <: Data](size: BigInt, t: T): SyncReadMem[T] = macro MemTransform.apply[T]
def apply[T <: Data](size: BigInt, t: T): SyncReadMem[T] = macro MemTransform.apply[T]
def apply[T <: Data](size: BigInt, t: T, ruw: ReadUnderWrite): SyncReadMem[T] = macro MemTransform.apply_ruw[T]

/** Creates a sequential/synchronous-read, sequential/synchronous-write [[SyncReadMem]].
*
* @param size number of elements in the memory
* @param t data type of memory element
*/
def apply[T <: Data](size: Int, t: T): SyncReadMem[T] = macro MemTransform.apply[T]
def apply[T <: Data](size: Int, t: T): SyncReadMem[T] = macro MemTransform.apply[T]
def apply[T <: Data](size: Int, t: T, ruw: ReadUnderWrite): SyncReadMem[T] = macro MemTransform.apply_ruw[T]

/** @group SourceInfoTransformMacro */
Expand Down Expand Up @@ -239,8 +239,8 @@ sealed class SyncReadMem[T <: Data] private[chisel3] (
t: T,
n: BigInt,
val readUnderWrite: SyncReadMem.ReadUnderWrite,
sourceInfo: SourceInfo)
extends MemBase[T](t, n, sourceInfo)
sourceInfo: SourceInfo
) extends MemBase[T](t, n, sourceInfo)
with SyncReadMemImpl[T] {

override def read(x: UInt): T = macro SourceInfoTransform.xArg
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala-2/chisel3/Num.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import chisel3.experimental.SourceInfo
trait Num[T <: Data] extends NumImpl[T] {
// def << (b: T): T
// def >> (b: T): T
//def unary_-: T
// def unary_-: T

// REVIEW TODO: double check ops conventions against FIRRTL

Expand Down
7 changes: 2 additions & 5 deletions core/src/main/scala-2/chisel3/PrintfMacros.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ import scala.reflect.macros.blackbox

object PrintfMacrosCompat {
def _applyMacroWithInterpolatorCheck(
c: blackbox.Context
)(fmt: c.Tree,
data: c.Tree*
)(sourceInfo: c.Tree
): c.Tree = {
c: blackbox.Context
)(fmt: c.Tree, data: c.Tree*)(sourceInfo: c.Tree): c.Tree = {
import c.universe._
_checkFormatString(c)(fmt)
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("printfWithReset"))
Expand Down
71 changes: 20 additions & 51 deletions core/src/main/scala-2/chisel3/VerificationStatementMacros.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,8 @@ object VerifStmtMacrosCompat {

/** @group VerifPrintMacros */
def _applyMacroWithInterpolatorCheck(
c: blackbox.Context
)(cond: c.Tree,
message: c.Tree,
data: c.Tree*
)(sourceInfo: c.Tree
): c.Tree = {
c: blackbox.Context
)(cond: c.Tree, message: c.Tree, data: c.Tree*)(sourceInfo: c.Tree): c.Tree = {
import c.universe._
_checkFormatString(c)(message)
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLinePrintable"))
Expand All @@ -60,35 +56,26 @@ object VerifStmtMacrosCompat {

/** @group VerifPrintMacros */
def _applyMacroWithStringMessage(
c: blackbox.Context
)(cond: c.Tree,
message: c.Tree,
data: c.Tree
)(sourceInfo: c.Tree
): c.Tree = {
c: blackbox.Context
)(cond: c.Tree, message: c.Tree, data: c.Tree)(sourceInfo: c.Tree): c.Tree = {
import c.universe._
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLinePrintable"))
q"$apply_impl_do($cond, ${getLine(c)},_root_.scala.Some(_root_.chisel3.Printable.pack($message,..$data)))($sourceInfo)"
}

/** @group VerifPrintMacros */
def _applyMacroWithPrintableMessage(
c: blackbox.Context
)(cond: c.Tree,
message: c.Tree
)(sourceInfo: c.Tree
): c.Tree = {
c: blackbox.Context
)(cond: c.Tree, message: c.Tree)(sourceInfo: c.Tree): c.Tree = {
import c.universe._
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLinePrintable"))
q"$apply_impl_do($cond, ${getLine(c)}, _root_.scala.Some($message))($sourceInfo)"
}

/** @group VerifPrintMacros */
def _applyMacroWithNoMessage(
c: blackbox.Context
)(cond: c.Tree
)(sourceInfo: c.Tree
): c.Tree = {
c: blackbox.Context
)(cond: c.Tree)(sourceInfo: c.Tree): c.Tree = {
import c.universe._
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLinePrintable"))
q"$apply_impl_do($cond, ${getLine(c)}, _root_.scala.None)($sourceInfo)"
Expand Down Expand Up @@ -127,12 +114,8 @@ object VerifStmtMacrosCompat {

/** @group VerifPrintMacros */
def _applyMacroWithInterpolatorCheck(
c: blackbox.Context
)(cond: c.Tree,
message: c.Tree,
data: c.Tree*
)(sourceInfo: c.Tree
): c.Tree = {
c: blackbox.Context
)(cond: c.Tree, message: c.Tree, data: c.Tree*)(sourceInfo: c.Tree): c.Tree = {
import c.universe._
_checkFormatString(c)(message)
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLinePrintable"))
Expand All @@ -141,35 +124,26 @@ object VerifStmtMacrosCompat {

/** @group VerifPrintMacros */
def _applyMacroWithStringMessage(
c: blackbox.Context
)(cond: c.Tree,
message: c.Tree,
data: c.Tree
)(sourceInfo: c.Tree
): c.Tree = {
c: blackbox.Context
)(cond: c.Tree, message: c.Tree, data: c.Tree)(sourceInfo: c.Tree): c.Tree = {
import c.universe._
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLinePrintable"))
q"$apply_impl_do($cond, ${getLine(c)}, _root_.scala.Some(_root_.chisel3.Printable.pack($message, ..$data)))($sourceInfo)"
}

/** @group VerifPrintMacros */
def _applyMacroWithPrintableMessage(
c: blackbox.Context
)(cond: c.Tree,
message: c.Tree
)(sourceInfo: c.Tree
): c.Tree = {
c: blackbox.Context
)(cond: c.Tree, message: c.Tree)(sourceInfo: c.Tree): c.Tree = {
import c.universe._
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLinePrintable"))
q"$apply_impl_do($cond, ${getLine(c)}, _root_.scala.Some($message))($sourceInfo)"
}

/** @group VerifPrintMacros */
def _applyMacroWithNoMessage(
c: blackbox.Context
)(cond: c.Tree
)(sourceInfo: c.Tree
): c.Tree = {
c: blackbox.Context
)(cond: c.Tree)(sourceInfo: c.Tree): c.Tree = {
import c.universe._
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLinePrintable"))
q"$apply_impl_do($cond, ${getLine(c)}, _root_.scala.None)($sourceInfo)"
Expand Down Expand Up @@ -199,22 +173,17 @@ object VerifStmtMacrosCompat {

/** @group VerifPrintMacros */
def _applyMacroWithNoMessage(
c: blackbox.Context
)(cond: c.Tree
)(sourceInfo: c.Tree
): c.Tree = {
c: blackbox.Context
)(cond: c.Tree)(sourceInfo: c.Tree): c.Tree = {
import c.universe._
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLine"))
q"$apply_impl_do($cond, ${getLine(c)}, _root_.scala.None)($sourceInfo)"
}

/** @group VerifPrintMacros */
def _applyMacroWithMessage(
c: blackbox.Context
)(cond: c.Tree,
message: c.Tree
)(sourceInfo: c.Tree
): c.Tree = {
c: blackbox.Context
)(cond: c.Tree, message: c.Tree)(sourceInfo: c.Tree): c.Tree = {
import c.universe._
val apply_impl_do = symbolOf[this.type].asClass.module.info.member(TermName("_applyWithSourceLine"))
q"$apply_impl_do($cond, ${getLine(c)}, _root_.scala.Some($message))($sourceInfo)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ sealed trait SourceInfo {

sealed trait NoSourceInfo extends SourceInfo {
def makeMessage(f: String => String = x => x): String = ""
def filenameOption: Option[String] = None
def filenameOption: Option[String] = None
}

/** For when source info can't be generated because of a technical limitation, like for Reg because
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import chisel3._
import scala.reflect.runtime.universe.WeakTypeTag

private[chisel3] trait InvertibleDataView {
def swapArgs[A, B, C, D](f: (A, B) => Iterable[(C, D)]): (B, A) => Iterable[(D, C)] = {
case (b, a) => f(a, b).map(_.swap)
def swapArgs[A, B, C, D](f: (A, B) => Iterable[(C, D)]): (B, A) => Iterable[(D, C)] = { case (b, a) =>
f(a, b).map(_.swap)
}

/** Provides `invert` for invertible [[DataView]]s
Expand Down
Loading

0 comments on commit 5f7e78b

Please sign in to comment.