summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/internal
diff options
context:
space:
mode:
authorJim Lawson2019-03-18 12:17:33 -0700
committerGitHub2019-03-18 12:17:33 -0700
commit2c449c5d6e23dcbb60e8c64cab6b6f4ba6ae313f (patch)
tree3daffa8eb0f57faf31d3977700be38f5be31e59a /src/main/scala/chisel3/internal
parentcfb2f08db9d9df121a82f138dd71297dbcea66cc (diff)
Split #974 into two PRs - scalastyle updates (#1037)
* Update style warnings now that subprojects are aggregated. Use "scalastyle-test-config.xml" for scalastyle config in tests. Enable "_" in method names and accept method names ending in "_=". Re-sync scalastyle-test-config.xml with scalastyle-config.xml * Remove bogus tests that crept in with git add * Add missing import.
Diffstat (limited to 'src/main/scala/chisel3/internal')
-rw-r--r--src/main/scala/chisel3/internal/firrtl/Converter.scala12
-rw-r--r--src/main/scala/chisel3/internal/firrtl/Emitter.scala9
2 files changed, 13 insertions, 8 deletions
diff --git a/src/main/scala/chisel3/internal/firrtl/Converter.scala b/src/main/scala/chisel3/internal/firrtl/Converter.scala
index 181bdfe8..ee9d3a99 100644
--- a/src/main/scala/chisel3/internal/firrtl/Converter.scala
+++ b/src/main/scala/chisel3/internal/firrtl/Converter.scala
@@ -42,7 +42,7 @@ private[chisel3] object Converter {
// TODO
// * Memoize?
// * Move into the Chisel IR?
- def convert(arg: Arg, ctx: Component): fir.Expression = arg match {
+ def convert(arg: Arg, ctx: Component): fir.Expression = arg match { // scalastyle:ignore cyclomatic.complexity
case Node(id) =>
convert(id.getRef, ctx)
case Ref(name) =>
@@ -54,8 +54,10 @@ private[chisel3] object Converter {
case Index(imm, value) =>
fir.SubAccess(convert(imm, ctx), convert(value, ctx), fir.UnknownType)
case ModuleIO(mod, name) =>
+ // scalastyle:off if.brace
if (mod eq ctx.id) fir.Reference(name, fir.UnknownType)
else fir.SubField(fir.Reference(mod.getRef.name, fir.UnknownType), name, fir.UnknownType)
+ // scalastyle:on if.brace
case u @ ULit(n, UnknownWidth()) =>
fir.UIntLiteral(n, fir.IntWidth(u.minWidth))
case ULit(n, w) =>
@@ -75,7 +77,7 @@ private[chisel3] object Converter {
}
/** Convert Commands that map 1:1 to Statements */
- def convertSimpleCommand(cmd: Command, ctx: Component): Option[fir.Statement] = cmd match {
+ def convertSimpleCommand(cmd: Command, ctx: Component): Option[fir.Statement] = cmd match { // scalastyle:ignore cyclomatic.complexity line.size.limit
case e: DefPrim[_] =>
val consts = e.args.collect { case ILit(i) => i }
val args = e.args.flatMap {
@@ -145,8 +147,9 @@ private[chisel3] object Converter {
* @param ctx Component (Module) context within which we are translating
* @return FIRRTL Statement that is equivalent to the input cmds
*/
- def convert(cmds: Seq[Command], ctx: Component): fir.Statement = {
+ def convert(cmds: Seq[Command], ctx: Component): fir.Statement = { // scalastyle:ignore cyclomatic.complexity
@tailrec
+ // scalastyle:off if.brace
def rec(acc: Queue[fir.Statement],
scope: List[WhenFrame])
(cmds: Seq[Command]): Seq[fir.Statement] = {
@@ -190,6 +193,7 @@ private[chisel3] object Converter {
}
}
}
+ // scalastyle:on if.brace
fir.Block(rec(Queue.empty, List.empty)(cmds))
}
@@ -209,7 +213,7 @@ private[chisel3] object Converter {
case d => d.specifiedDirection
}
- def extractType(data: Data, clearDir: Boolean = false): fir.Type = data match {
+ def extractType(data: Data, clearDir: Boolean = false): fir.Type = data match { // scalastyle:ignore cyclomatic.complexity line.size.limit
case _: Clock => fir.ClockType
case d: EnumType => fir.UIntType(convert(d.width))
case d: UInt => fir.UIntType(convert(d.width))
diff --git a/src/main/scala/chisel3/internal/firrtl/Emitter.scala b/src/main/scala/chisel3/internal/firrtl/Emitter.scala
index 68513423..050c8b72 100644
--- a/src/main/scala/chisel3/internal/firrtl/Emitter.scala
+++ b/src/main/scala/chisel3/internal/firrtl/Emitter.scala
@@ -26,7 +26,7 @@ private class Emitter(circuit: Circuit) {
s"$dirString ${e.id.getRef.name} : ${emitType(e.id, clearDir)}"
}
- private def emitType(d: Data, clearDir: Boolean = false): String = d match {
+ private def emitType(d: Data, clearDir: Boolean = false): String = d match { // scalastyle:ignore cyclomatic.complexity line.size.limit
case d: Clock => "Clock"
case d: chisel3.core.EnumType => s"UInt${d.width}"
case d: UInt => s"UInt${d.width}"
@@ -55,15 +55,15 @@ private class Emitter(circuit: Circuit) {
case d => d.specifiedDirection
}
- private def emit(e: Command, ctx: Component): String = {
+ private def emit(e: Command, ctx: Component): String = { // scalastyle:ignore cyclomatic.complexity
val firrtlLine = e match {
case e: DefPrim[_] => s"node ${e.name} = ${e.op.name}(${e.args.map(_.fullName(ctx)).mkString(", ")})"
case e: DefWire => s"wire ${e.name} : ${emitType(e.id)}"
case e: DefReg => s"reg ${e.name} : ${emitType(e.id)}, ${e.clock.fullName(ctx)}"
- case e: DefRegInit => s"reg ${e.name} : ${emitType(e.id)}, ${e.clock.fullName(ctx)} with : (reset => (${e.reset.fullName(ctx)}, ${e.init.fullName(ctx)}))"
+ case e: DefRegInit => s"reg ${e.name} : ${emitType(e.id)}, ${e.clock.fullName(ctx)} with : (reset => (${e.reset.fullName(ctx)}, ${e.init.fullName(ctx)}))" // scalastyle:ignore line.size.limit
case e: DefMemory => s"cmem ${e.name} : ${emitType(e.t)}[${e.size}]"
case e: DefSeqMemory => s"smem ${e.name} : ${emitType(e.t)}[${e.size}]"
- case e: DefMemPort[_] => s"${e.dir} mport ${e.name} = ${e.source.fullName(ctx)}[${e.index.fullName(ctx)}], ${e.clock.fullName(ctx)}"
+ case e: DefMemPort[_] => s"${e.dir} mport ${e.name} = ${e.source.fullName(ctx)}[${e.index.fullName(ctx)}], ${e.clock.fullName(ctx)}" // scalastyle:ignore line.size.limit
case e: Connect => s"${e.loc.fullName(ctx)} <= ${e.exp.fullName(ctx)}"
case e: BulkConnect => s"${e.loc1.fullName(ctx)} <- ${e.loc2.fullName(ctx)}"
case e: Attach => e.locs.map(_.fullName(ctx)).mkString("attach (", ", ", ")")
@@ -94,6 +94,7 @@ private class Emitter(circuit: Circuit) {
s"skip"
}
firrtlLine + e.sourceInfo.makeMessage(" " + _)
+ // scalastyle:on line.size.limit
}
private def emitParam(name: String, p: Param): String = {