aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorchick2016-09-23 16:40:08 -0700
committerDonggyu Kim2016-09-25 14:39:44 -0700
commit1f168585c80d5c96e41353d6275d99b34b967b23 (patch)
tree44eee3d8e94cf41e2bd5094cff99ed58441cc7f4 /src
parent16286528ad957a7d62a9c1b18bd6335a3102ea5b (diff)
remove unnecessary blocks
example 1 s"${x}" example 2 case blah => { ??? }
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/firrtl/Annotations.scala4
-rw-r--r--src/main/scala/firrtl/Driver.scala2
-rw-r--r--src/main/scala/firrtl/Emitter.scala3
-rw-r--r--src/main/scala/firrtl/StringLit.scala5
-rw-r--r--src/main/scala/firrtl/Visitor.scala12
-rw-r--r--src/main/scala/firrtl/passes/CheckChirrtl.scala20
-rw-r--r--src/main/scala/firrtl/passes/Checks.scala94
-rw-r--r--src/main/scala/firrtl/passes/ConstProp.scala6
-rw-r--r--src/main/scala/firrtl/passes/Inline.scala125
-rw-r--r--src/main/scala/firrtl/passes/LowerTypes.scala2
-rw-r--r--src/main/scala/firrtl/passes/Passes.scala2
-rw-r--r--src/main/scala/firrtl/passes/RemoveCHIRRTL.scala3
-rw-r--r--src/main/scala/firrtl/passes/ReplSeqMem.scala2
-rw-r--r--src/main/scala/firrtl/passes/ReplaceMemMacros.scala4
-rw-r--r--src/main/scala/firrtl/passes/SplitExpressions.scala9
-rw-r--r--src/main/scala/firrtl/passes/UpdateDuplicateMemMacros.scala2
16 files changed, 139 insertions, 156 deletions
diff --git a/src/main/scala/firrtl/Annotations.scala b/src/main/scala/firrtl/Annotations.scala
index 987501ec..6ed9854f 100644
--- a/src/main/scala/firrtl/Annotations.scala
+++ b/src/main/scala/firrtl/Annotations.scala
@@ -81,7 +81,7 @@ object Annotations {
trait Rigid extends Permissibility {
def check(from: Named, tos: Seq[Named], which: Annotation): Unit = tos.size match {
case 0 => throw new AnnotationException(s"Cannot remove the rigid annotation ${which.serialize} on ${from.name}")
- case 1 => {}
+ case 1 =>
case _ => throw new AnnotationException(s"Cannot expand a rigid annotation on ${from.name} -> ${tos.map(_.name)}")
}
}
@@ -92,7 +92,7 @@ object Annotations {
trait Firm extends Permissibility {
def check(from: Named, tos: Seq[Named], which: Annotation): Unit = tos.size match {
case 0 => throw new AnnotationException(s"Cannot remove the firm annotation ${which.serialize} on ${from.name}")
- case _ => {}
+ case _ =>
}
}
diff --git a/src/main/scala/firrtl/Driver.scala b/src/main/scala/firrtl/Driver.scala
index 4022a813..ca25ef7a 100644
--- a/src/main/scala/firrtl/Driver.scala
+++ b/src/main/scala/firrtl/Driver.scala
@@ -155,7 +155,7 @@ Optional Arguments:
case flag :: value :: tail if(customOptions.contains(flag)) =>
annotations += customOptions(flag)(value)
nextOption(map, tail)
- case ("-h" | "--help") :: tail => { println(usage); sys.exit(0) }
+ case ("-h" | "--help") :: tail => println(usage); sys.exit(0)
case option :: tail =>
throw new Exception("Unknown option " + option + usage)
}
diff --git a/src/main/scala/firrtl/Emitter.scala b/src/main/scala/firrtl/Emitter.scala
index ead8581d..2eaf5f36 100644
--- a/src/main/scala/firrtl/Emitter.scala
+++ b/src/main/scala/firrtl/Emitter.scala
@@ -311,7 +311,7 @@ class VerilogEmitter extends Emitter {
def addUpdate(e: Expression, tabs: String): Seq[Seq[Any]] = {
netlist.getOrElse(e, e) match {
- case m: Mux if canFlatten(m) => {
+ case m: Mux if canFlatten(m) =>
val ifStatement = Seq(tabs, "if(", m.cond, ") begin")
val trueCase = addUpdate(m.tval, tabs + tab)
val elseStatement = Seq(tabs, "end else begin")
@@ -322,7 +322,6 @@ class VerilogEmitter extends Emitter {
ifStatement +: trueCase :+ endStatement
else
ifStatement +: trueCase ++: elseStatement +: falseCase :+ endStatement
- }
case _ if (weq(e, r)) => Seq()
case _ => Seq(Seq(tabs, r, " <= ", e, ";"))
}
diff --git a/src/main/scala/firrtl/StringLit.scala b/src/main/scala/firrtl/StringLit.scala
index b34fc498..fd282177 100644
--- a/src/main/scala/firrtl/StringLit.scala
+++ b/src/main/scala/firrtl/StringLit.scala
@@ -79,11 +79,10 @@ trait StringLitHandler {
// TODO Finalize supported escapes, implement hex2Bytes
//case 0x78 => (4, hex2Bytes(in.slice(2, 3)))) // hex escape
//case 0x75 => (6, hex2Bytes(in.slice(2, 5))) // unicode excape
- case e => { // error
- val msg = s"Invalid escape character ${e.toChar}! " +
+ case e => // error
+ val msg = s"Invalid escape character ${e.toChar}! " +
"Valid characters [nt'\"\\]"
throw new InvalidEscapeCharException(msg)
- }
}
unescape(in.drop(n), out ++ bytes) // consume n
} else {
diff --git a/src/main/scala/firrtl/Visitor.scala b/src/main/scala/firrtl/Visitor.scala
index 05202555..00ef8f1b 100644
--- a/src/main/scala/firrtl/Visitor.scala
+++ b/src/main/scala/firrtl/Visitor.scala
@@ -61,15 +61,13 @@ class Visitor(infoMode: InfoMode) extends FIRRTLBaseVisitor[FirrtlNode] {
case ZeroPattern(_*) => BigInt(0)
case HexPattern(hexdigits) =>
hexdigits(0) match {
- case NegPattern(_) => {
+ case NegPattern(_) =>
BigInt("-" + hexdigits, 16)
- }
case _ => BigInt(hexdigits, 16)
}
- case DecPattern(sign, num) => {
+ case DecPattern(sign, num) =>
if (sign != null) BigInt(sign + num, 10)
else BigInt(num, 10)
- }
case _ => throw new Exception("Invalid String for conversion to BigInt " + s)
}
}
@@ -297,7 +295,7 @@ class Visitor(infoMode: InfoMode) extends FIRRTLBaseVisitor[FirrtlNode] {
Reference(ctx.getText, UnknownType)
else
ctx.getChild(0).getText match {
- case "UInt" => {
+ case "UInt" =>
// This could be better
val (width, value) =
if (ctx.getChildCount > 4)
@@ -307,8 +305,7 @@ class Visitor(infoMode: InfoMode) extends FIRRTLBaseVisitor[FirrtlNode] {
(IntWidth(BigInt(scala.math.max(bigint.bitLength, 1))), bigint)
}
UIntLiteral(value, width)
- }
- case "SInt" => {
+ case "SInt" =>
val (width, value) =
if (ctx.getChildCount > 4)
(IntWidth(string2BigInt(ctx.IntLit(0).getText)), string2BigInt(ctx.IntLit(1).getText))
@@ -317,7 +314,6 @@ class Visitor(infoMode: InfoMode) extends FIRRTLBaseVisitor[FirrtlNode] {
(IntWidth(BigInt(bigint.bitLength + 1)), bigint)
}
SIntLiteral(value, width)
- }
case "validif(" => ValidIf(visitExp(ctx.exp(0)), visitExp(ctx.exp(1)), UnknownType)
case "mux(" => Mux(visitExp(ctx.exp(0)), visitExp(ctx.exp(1)), visitExp(ctx.exp(2)), UnknownType)
case _ =>
diff --git a/src/main/scala/firrtl/passes/CheckChirrtl.scala b/src/main/scala/firrtl/passes/CheckChirrtl.scala
index 21628633..9858c0d2 100644
--- a/src/main/scala/firrtl/passes/CheckChirrtl.scala
+++ b/src/main/scala/firrtl/passes/CheckChirrtl.scala
@@ -37,25 +37,25 @@ object CheckChirrtl extends Pass {
type NameSet = collection.mutable.HashSet[String]
class NotUniqueException(info: Info, mname: String, name: String) extends PassException(
- s"${info}: [module ${mname}] Reference ${name} does not have a unique name.")
+ s"$info: [module $mname] Reference $name does not have a unique name.")
class InvalidLOCException(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Invalid connect to an expression that is not a reference or a WritePort.")
+ s"$info: [module $mname] Invalid connect to an expression that is not a reference or a WritePort.")
class UndeclaredReferenceException(info: Info, mname: String, name: String) extends PassException(
- s"${info}: [module ${mname}] Reference ${name} is not declared.")
+ s"$info: [module $mname] Reference $name is not declared.")
class MemWithFlipException(info: Info, mname: String, name: String) extends PassException(
- s"${info}: [module ${mname}] Memory ${name} cannot be a bundle type with flips.")
+ s"$info: [module $mname] Memory $name cannot be a bundle type with flips.")
class InvalidAccessException(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Invalid access to non-reference.")
+ s"$info: [module $mname] Invalid access to non-reference.")
class ModuleNotDefinedException(info: Info, mname: String, name: String) extends PassException(
- s"${info}: Module ${name} is not defined.")
+ s"$info: Module $name is not defined.")
class NegWidthException(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Width cannot be negative or zero.")
+ s"$info: [module $mname] Width cannot be negative or zero.")
class NegVecSizeException(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Vector type size cannot be negative.")
+ s"$info: [module $mname] Vector type size cannot be negative.")
class NegMemSizeException(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Memory size cannot be negative or zero.")
+ s"$info: [module $mname] Memory size cannot be negative or zero.")
class NoTopModuleException(info: Info, name: String) extends PassException(
- s"${info}: A single module must be named ${name}.")
+ s"$info: A single module must be named $name.")
// TODO FIXME
// - Do we need to check for uniquness on port names?
diff --git a/src/main/scala/firrtl/passes/Checks.scala b/src/main/scala/firrtl/passes/Checks.scala
index 082544c0..03ea106c 100644
--- a/src/main/scala/firrtl/passes/Checks.scala
+++ b/src/main/scala/firrtl/passes/Checks.scala
@@ -40,41 +40,41 @@ object CheckHighForm extends Pass {
// Custom Exceptions
class NotUniqueException(info: Info, mname: String, name: String) extends PassException(
- s"${info}: [module ${mname}] Reference ${name} does not have a unique name.")
+ s"$info: [module $mname] Reference $name does not have a unique name.")
class InvalidLOCException(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Invalid connect to an expression that is not a reference or a WritePort.")
+ s"$info: [module $mname] Invalid connect to an expression that is not a reference or a WritePort.")
class NegUIntException(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] UIntLiteral cannot be negative.")
+ s"$info: [module $mname] UIntLiteral cannot be negative.")
class UndeclaredReferenceException(info: Info, mname: String, name: String) extends PassException(
- s"${info}: [module ${mname}] Reference ${name} is not declared.")
+ s"$info: [module $mname] Reference $name is not declared.")
class PoisonWithFlipException(info: Info, mname: String, name: String) extends PassException(
- s"${info}: [module ${mname}] Poison ${name} cannot be a bundle type with flips.")
+ s"$info: [module $mname] Poison $name cannot be a bundle type with flips.")
class MemWithFlipException(info: Info, mname: String, name: String) extends PassException(
- s"${info}: [module ${mname}] Memory ${name} cannot be a bundle type with flips.")
+ s"$info: [module $mname] Memory $name cannot be a bundle type with flips.")
class InvalidAccessException(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Invalid access to non-reference.")
+ s"$info: [module $mname] Invalid access to non-reference.")
class ModuleNotDefinedException(info: Info, mname: String, name: String) extends PassException(
- s"${info}: Module ${name} is not defined.")
+ s"$info: Module $name is not defined.")
class IncorrectNumArgsException(info: Info, mname: String, op: String, n: Int) extends PassException(
- s"${info}: [module ${mname}] Primop ${op} requires ${n} expression arguments.")
+ s"$info: [module $mname] Primop $op requires $n expression arguments.")
class IncorrectNumConstsException(info: Info, mname: String, op: String, n: Int) extends PassException(
- s"${info}: [module ${mname}] Primop ${op} requires ${n} integer arguments.")
+ s"$info: [module $mname] Primop $op requires $n integer arguments.")
class NegWidthException(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Width cannot be negative or zero.")
+ s"$info: [module $mname] Width cannot be negative or zero.")
class NegVecSizeException(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Vector type size cannot be negative.")
+ s"$info: [module $mname] Vector type size cannot be negative.")
class NegMemSizeException(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Memory size cannot be negative or zero.")
+ s"$info: [module $mname] Memory size cannot be negative or zero.")
class BadPrintfException(info: Info, mname: String, x: Char) extends PassException(
- s"${info}: [module ${mname}] Bad printf format: " + "\"%" + x + "\"")
+ s"$info: [module $mname] Bad printf format: " + "\"%" + x + "\"")
class BadPrintfTrailingException(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Bad printf format: trailing " + "\"%\"")
+ s"$info: [module $mname] Bad printf format: trailing " + "\"%\"")
class BadPrintfIncorrectNumException(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Bad printf format: incorrect number of arguments")
+ s"$info: [module $mname] Bad printf format: incorrect number of arguments")
class InstanceLoop(info: Info, mname: String, loop: String) extends PassException(
- s"${info}: [module ${mname}] Has instance loop $loop")
+ s"$info: [module $mname] Has instance loop $loop")
class NoTopModuleException(info: Info, name: String) extends PassException(
- s"${info}: A single module must be named ${name}.")
+ s"$info: A single module must be named $name.")
// TODO FIXME
// - Do we need to check for uniquness on port names?
@@ -232,51 +232,51 @@ object CheckTypes extends Pass {
// Custom Exceptions
class SubfieldNotInBundle(info: Info, mname: String, name: String) extends PassException(
- s"${info}: [module ${mname} ] Subfield ${name} is not in bundle.")
+ s"$info: [module $mname ] Subfield $name is not in bundle.")
class SubfieldOnNonBundle(info: Info, mname: String, name: String) extends PassException(
- s"${info}: [module ${mname}] Subfield ${name} is accessed on a non-bundle.")
+ s"$info: [module $mname] Subfield $name is accessed on a non-bundle.")
class IndexTooLarge(info: Info, mname: String, value: Int) extends PassException(
- s"${info}: [module ${mname}] Index with value ${value} is too large.")
+ s"$info: [module $mname] Index with value $value is too large.")
class IndexOnNonVector(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Index illegal on non-vector type.")
+ s"$info: [module $mname] Index illegal on non-vector type.")
class AccessIndexNotUInt(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Access index must be a UInt type.")
+ s"$info: [module $mname] Access index must be a UInt type.")
class IndexNotUInt(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Index is not of UIntType.")
+ s"$info: [module $mname] Index is not of UIntType.")
class EnableNotUInt(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Enable is not of UIntType.")
+ s"$info: [module $mname] Enable is not of UIntType.")
class InvalidConnect(info: Info, mname: String, lhs: String, rhs: String) extends PassException(
- s"${info}: [module ${mname}] Type mismatch. Cannot connect ${lhs} to ${rhs}.")
+ s"$info: [module $mname] Type mismatch. Cannot connect $lhs to $rhs.")
class InvalidRegInit(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Type of init must match type of DefRegister.")
+ s"$info: [module $mname] Type of init must match type of DefRegister.")
class PrintfArgNotGround(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Printf arguments must be either UIntType or SIntType.")
+ s"$info: [module $mname] Printf arguments must be either UIntType or SIntType.")
class ReqClk(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Requires a clock typed signal.")
+ s"$info: [module $mname] Requires a clock typed signal.")
class EnNotUInt(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Enable must be a UIntType typed signal.")
+ s"$info: [module $mname] Enable must be a UIntType typed signal.")
class PredNotUInt(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Predicate not a UIntType.")
+ s"$info: [module $mname] Predicate not a UIntType.")
class OpNotGround(info: Info, mname: String, op: String) extends PassException(
- s"${info}: [module ${mname}] Primop ${op} cannot operate on non-ground types.")
+ s"$info: [module $mname] Primop $op cannot operate on non-ground types.")
class OpNotUInt(info: Info, mname: String, op: String, e: String) extends PassException(
- s"${info}: [module ${mname}] Primop ${op} requires argument ${e} to be a UInt type.")
+ s"$info: [module $mname] Primop $op requires argument $e to be a UInt type.")
class OpNotAllUInt(info: Info, mname: String, op: String) extends PassException(
- s"${info}: [module ${mname}] Primop ${op} requires all arguments to be UInt type.")
+ s"$info: [module $mname] Primop $op requires all arguments to be UInt type.")
class OpNotAllSameType(info: Info, mname: String, op: String) extends PassException(
- s"${info}: [module ${mname}] Primop ${op} requires all operands to have the same type.")
+ s"$info: [module $mname] Primop $op requires all operands to have the same type.")
class NodePassiveType(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Node must be a passive type.")
+ s"$info: [module $mname] Node must be a passive type.")
class MuxSameType(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Must mux between equivalent types.")
+ s"$info: [module $mname] Must mux between equivalent types.")
class MuxPassiveTypes(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Must mux between passive types.")
+ s"$info: [module $mname] Must mux between passive types.")
class MuxCondUInt(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] A mux condition must be of type UInt.")
+ s"$info: [module $mname] A mux condition must be of type UInt.")
class ValidIfPassiveTypes(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Must validif a passive type.")
+ s"$info: [module $mname] Must validif a passive type.")
class ValidIfCondUInt(info: Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] A validif condition must be of type UInt.")
+ s"$info: [module $mname] A validif condition must be of type UInt.")
//;---------------- Helper Functions --------------
def ut: UIntType = UIntType(UnknownWidth)
@@ -436,7 +436,7 @@ object CheckGenders extends Pass {
}
class WrongGender(info:Info, mname: String, expr: String, wrong: Gender, right: Gender) extends PassException(
- s"${info}: [module ${mname}] Expression ${expr} is used as a ${wrong} but can only be used as a ${right}.")
+ s"$info: [module $mname] Expression $expr is used as a $wrong but can only be used as a $right.")
def run (c:Circuit): Circuit = {
val errors = new Errors()
@@ -530,17 +530,17 @@ object CheckGenders extends Pass {
object CheckWidths extends Pass {
def name = "Width Check"
class UninferredWidth (info: Info, mname: String) extends PassException(
- s"${info} : [module ${mname}] Uninferred width.")
+ s"$info : [module $mname] Uninferred width.")
class WidthTooSmall(info: Info, mname: String, b: BigInt) extends PassException(
s"$info : [module $mname] Width too small for constant ${serialize(b)}.")
class NegWidthException(info:Info, mname: String) extends PassException(
- s"${info}: [module ${mname}] Width cannot be negative or zero.")
+ s"$info: [module $mname] Width cannot be negative or zero.")
class BitsWidthException(info: Info, mname: String, hi: BigInt, width: BigInt) extends PassException(
- s"${info}: [module ${mname}] High bit $hi in bits operator is larger than input width $width.")
+ s"$info: [module $mname] High bit $hi in bits operator is larger than input width $width.")
class HeadWidthException(info: Info, mname: String, n: BigInt, width: BigInt) extends PassException(
- s"${info}: [module ${mname}] Parameter $n in head operator is larger than input width $width.")
+ s"$info: [module $mname] Parameter $n in head operator is larger than input width $width.")
class TailWidthException(info: Info, mname: String, n: BigInt, width: BigInt) extends PassException(
- s"${info}: [module ${mname}] Parameter $n in tail operator is larger than input width $width.")
+ s"$info: [module $mname] Parameter $n in tail operator is larger than input width $width.")
def run(c: Circuit): Circuit = {
val errors = new Errors()
diff --git a/src/main/scala/firrtl/passes/ConstProp.scala b/src/main/scala/firrtl/passes/ConstProp.scala
index 77ca161f..a95d3de0 100644
--- a/src/main/scala/firrtl/passes/ConstProp.scala
+++ b/src/main/scala/firrtl/passes/ConstProp.scala
@@ -176,7 +176,7 @@ object ConstProp extends Pass {
}
// Calculates an expression's range of values
x match {
- case e: DoPrim => {
+ case e: DoPrim =>
def r0 = range(e.args.head)
def r1 = range(e.args(1))
e.op match {
@@ -192,7 +192,6 @@ object ConstProp extends Pass {
case Geq if (r0 < r1) => zero
case _ => e
}
- }
case e => e
}
}
@@ -230,12 +229,11 @@ object ConstProp extends Pass {
case _ => e
}
case Bits => e.args.head match {
- case lit: Literal => {
+ case lit: Literal =>
val hi = e.consts.head.toInt
val lo = e.consts(1).toInt
require(hi >= lo)
UIntLiteral((lit.value >> lo) & ((BigInt(1) << (hi - lo + 1)) - 1), getWidth(e.tpe))
- }
case x if bitWidth(e.tpe) == bitWidth(x.tpe) => x.tpe match {
case t: UIntType => x
case _ => asUInt(x, e.tpe)
diff --git a/src/main/scala/firrtl/passes/Inline.scala b/src/main/scala/firrtl/passes/Inline.scala
index 23d8caf1..e2a69751 100644
--- a/src/main/scala/firrtl/passes/Inline.scala
+++ b/src/main/scala/firrtl/passes/Inline.scala
@@ -22,7 +22,7 @@ class InlineInstances (transID: TransID) extends Transform {
def execute(circuit: Circuit, annotationMap: AnnotationMap): TransformResult = {
annotationMap.get(transID) match {
case None => TransformResult(circuit, None, None)
- case Some(map) => {
+ case Some(map) =>
val moduleNames = mutable.HashSet[ModuleName]()
val instanceNames = mutable.HashSet[ComponentName]()
map.values.foreach {x: Annotation => x match {
@@ -32,7 +32,6 @@ class InlineInstances (transID: TransID) extends Transform {
}}
check(circuit, moduleNames.toSet, instanceNames.toSet)
run(circuit, moduleNames.toSet, instanceNames.toSet)
- }
// Default behavior is to error if more than one annotation for inlining
// This could potentially change
@@ -49,11 +48,11 @@ class InlineInstances (transID: TransID) extends Transform {
val moduleMap = (for(m <- c.modules) yield m.name -> m).toMap
def checkExists(name: String): Unit =
if (!moduleMap.contains(name))
- errors += new PassException(s"Annotated module does not exist: ${name}")
+ errors += new PassException(s"Annotated module does not exist: $name")
def checkExternal(name: String): Unit = moduleMap(name) match {
- case m: ExtModule => errors += new PassException(s"Annotated module cannot be an external module: ${name}")
- case _ => {}
- }
+ case m: ExtModule => errors += new PassException(s"Annotated module cannot be an external module: $name")
+ case _ =>
+ }
def checkInstance(cn: ComponentName): Unit = {
var containsCN = false
def onStmt(name: String)(s: Statement): Statement = {
@@ -63,7 +62,7 @@ class InlineInstances (transID: TransID) extends Transform {
containsCN = true
checkExternal(module_name)
}
- case _ => {}
+ case _ =>
}
s map onStmt(name)
}
@@ -101,71 +100,67 @@ class InlineInstances (transID: TransID) extends Transform {
val inlinedInstances = mutable.ArrayBuffer[String]()
// Recursive. Replaces inst.port with inst$port
def onExp(e: Expression): Expression = e match {
- case WSubField(WRef(ref, _, _, _), field, tpe, gen) => {
- // Relies on instance declaration before any instance references
- if (inlinedInstances.contains(ref)) {
- val newName = ref + inlineDelim + field
- set(ComponentName(ref, ModuleName(m.name, cname)), Seq.empty)
- WRef(newName, tpe, WireKind, gen)
- }
- else e
- }
+ case WSubField(WRef(ref, _, _, _), field, tpe, gen) =>
+ // Relies on instance declaration before any instance references
+ if (inlinedInstances.contains(ref)) {
+ val newName = ref + inlineDelim + field
+ set(ComponentName(ref, ModuleName(m.name, cname)), Seq.empty)
+ WRef(newName, tpe, WireKind, gen)
+ }
+ else e
case e => e map onExp
}
// Recursive. Inlines tagged instances
def onStmt(s: Statement): Statement = s match {
- case WDefInstance(info, instName, moduleName, instTpe) => {
- def rename(name:String): String = {
- val newName = instName + inlineDelim + name
- update(ComponentName(name, ModuleName(moduleName, cname)), ComponentName(newName, ModuleName(m.name, cname)))
- newName
- }
- // Rewrites references in inlined statements from ref to inst$ref
- def renameStmt(s: Statement): Statement = {
- def renameExp(e: Expression): Expression = {
- e map renameExp match {
- case WRef(name, tpe, kind, gen) => WRef(rename(name), tpe, kind, gen)
- case e => e
- }
- }
- s map rename map renameStmt map renameExp
- }
- val shouldInline =
- modsToInline.contains(ModuleName(moduleName, cname)) ||
- instsToInline.contains(ComponentName(instName, ModuleName(m.name, cname)))
- // Used memoized instance if available
- val instModule =
- if (inlinedModules.contains(name)) inlinedModules(name)
- else {
- // Warning - can infinitely recurse if there is an instance loop
- onModule(originalModules(moduleName))
- }
- if (shouldInline) {
- inlinedInstances += instName
- val instInModule = instModule match {
- case m: ExtModule => throw new PassException("Cannot inline external module")
- case m: Module => m
- }
- val stmts = mutable.ArrayBuffer[Statement]()
- for (p <- instInModule.ports) {
- stmts += DefWire(p.info, rename(p.name), p.tpe)
- }
- stmts += renameStmt(instInModule.body)
- Block(stmts.toSeq)
- } else s
- }
+ case WDefInstance(info, instName, moduleName, instTpe) =>
+ def rename(name:String): String = {
+ val newName = instName + inlineDelim + name
+ update(ComponentName(name, ModuleName(moduleName, cname)), ComponentName(newName, ModuleName(m.name, cname)))
+ newName
+ }
+ // Rewrites references in inlined statements from ref to inst$ref
+ def renameStmt(s: Statement): Statement = {
+ def renameExp(e: Expression): Expression = {
+ e map renameExp match {
+ case WRef(name, tpe, kind, gen) => WRef(rename(name), tpe, kind, gen)
+ case e => e
+ }
+ }
+ s map rename map renameStmt map renameExp
+ }
+ val shouldInline =
+ modsToInline.contains(ModuleName(moduleName, cname)) ||
+ instsToInline.contains(ComponentName(instName, ModuleName(m.name, cname)))
+ // Used memoized instance if available
+ val instModule =
+ if (inlinedModules.contains(name)) inlinedModules(name)
+ else {
+ // Warning - can infinitely recurse if there is an instance loop
+ onModule(originalModules(moduleName))
+ }
+ if (shouldInline) {
+ inlinedInstances += instName
+ val instInModule = instModule match {
+ case m: ExtModule => throw new PassException("Cannot inline external module")
+ case m: Module => m
+ }
+ val stmts = mutable.ArrayBuffer[Statement]()
+ for (p <- instInModule.ports) {
+ stmts += DefWire(p.info, rename(p.name), p.tpe)
+ }
+ stmts += renameStmt(instInModule.body)
+ Block(stmts.toSeq)
+ } else s
case s => s map onExp map onStmt
}
m match {
- case Module(info, name, ports, body) => {
- val mx = Module(info, name, ports, onStmt(body))
- inlinedModules(name) = mx
- mx
- }
- case m: ExtModule => {
- inlinedModules(m.name) = m
- m
- }
+ case Module(info, name, ports, body) =>
+ val mx = Module(info, name, ports, onStmt(body))
+ inlinedModules(name) = mx
+ mx
+ case m: ExtModule =>
+ inlinedModules(m.name) = m
+ m
}
}
diff --git a/src/main/scala/firrtl/passes/LowerTypes.scala b/src/main/scala/firrtl/passes/LowerTypes.scala
index 967b4a1c..70631cc3 100644
--- a/src/main/scala/firrtl/passes/LowerTypes.scala
+++ b/src/main/scala/firrtl/passes/LowerTypes.scala
@@ -112,7 +112,7 @@ object LowerTypes extends Pass {
case None => mem
}
Seq(mergeRef(loMem, mergeRef(port, field)))
- case name => error(s"Error! Unhandled memory field ${name}")(info, mname)
+ case name => error(s"Error! Unhandled memory field $name")(info, mname)
}
}
diff --git a/src/main/scala/firrtl/passes/Passes.scala b/src/main/scala/firrtl/passes/Passes.scala
index 7b37cf65..a182b2af 100644
--- a/src/main/scala/firrtl/passes/Passes.scala
+++ b/src/main/scala/firrtl/passes/Passes.scala
@@ -204,7 +204,7 @@ object Legalize extends Pass {
case SIntType(_) =>
val bits = DoPrim(Bits, e.args, Seq(msb, msb), BoolType)
DoPrim(AsSInt, Seq(bits), Seq.empty, SIntType(IntWidth(1)))
- case t => error(s"Unsupported type ${t} for Primop Shift Right")
+ case t => error(s"Unsupported type $t for Primop Shift Right")
}
} else {
e
diff --git a/src/main/scala/firrtl/passes/RemoveCHIRRTL.scala b/src/main/scala/firrtl/passes/RemoveCHIRRTL.scala
index 4cc85774..8c158da9 100644
--- a/src/main/scala/firrtl/passes/RemoveCHIRRTL.scala
+++ b/src/main/scala/firrtl/passes/RemoveCHIRRTL.scala
@@ -119,7 +119,7 @@ object RemoveCHIRRTL extends Pass {
val mem = DefMemory(s.info, s.name, s.tpe, s.size, 1, if (s.seq) 1 else 0,
rds map (_.name), wrs map (_.name), rws map (_.name))
Block(mem +: stmts)
- case (s: CDefMPort) => {
+ case (s: CDefMPort) =>
types(s.name) = types(s.mem)
val addrs = ArrayBuffer[String]()
val clks = ArrayBuffer[String]()
@@ -149,7 +149,6 @@ object RemoveCHIRRTL extends Pass {
(addrs map (x => Connect(s.info, SubField(SubField(Reference(s.mem, ut), s.name, ut), x, ut), s.exps.head))) ++
(clks map (x => Connect(s.info, SubField(SubField(Reference(s.mem, ut), s.name, ut), x, ut), s.exps(1)))) ++
(ens map (x => Connect(s.info,SubField(SubField(Reference(s.mem,ut), s.name, ut), x, ut), one))))
- }
case (s) => s map collect_refs(mports, smems, types, refs, raddrs)
}
diff --git a/src/main/scala/firrtl/passes/ReplSeqMem.scala b/src/main/scala/firrtl/passes/ReplSeqMem.scala
index 0933eefe..3b51d73f 100644
--- a/src/main/scala/firrtl/passes/ReplSeqMem.scala
+++ b/src/main/scala/firrtl/passes/ReplSeqMem.scala
@@ -49,7 +49,7 @@ class ConfWriter(filename: String) {
val ports = (writers ++ readers ++ readwriters) mkString ","
val maskGranConf = maskGran match { case None => "" case Some(p) => s"mask_gran $p" }
val width = bitWidth(m.dataType)
- val conf = s"name ${m.name} depth ${m.depth} width ${width} ports ${ports} ${maskGranConf} \n"
+ val conf = s"name ${m.name} depth ${m.depth} width $width ports $ports $maskGranConf \n"
outputBuffer.append(conf)
}
def serialize() = {
diff --git a/src/main/scala/firrtl/passes/ReplaceMemMacros.scala b/src/main/scala/firrtl/passes/ReplaceMemMacros.scala
index 2e6ba3cc..2342b193 100644
--- a/src/main/scala/firrtl/passes/ReplaceMemMacros.scala
+++ b/src/main/scala/firrtl/passes/ReplaceMemMacros.scala
@@ -85,8 +85,8 @@ class ReplaceMemMacros(writer: ConfWriter) extends Pass {
(s: Statement): Statement = s match {
case m: DefMemory if containsInfo(m.info, "useMacro") =>
if (!containsInfo(m.info, "maskGran")) {
- m.writers foreach { w => memPortMap(s"${m.name}.${w}.mask") = EmptyExpression }
- m.readwriters foreach { w => memPortMap(s"${m.name}.${w}.wmask") = EmptyExpression }
+ m.writers foreach { w => memPortMap(s"${m.name}.$w.mask") = EmptyExpression }
+ m.readwriters foreach { w => memPortMap(s"${m.name}.$w.wmask") = EmptyExpression }
}
val info = getInfo(m.info, "info") match {
case None => NoInfo
diff --git a/src/main/scala/firrtl/passes/SplitExpressions.scala b/src/main/scala/firrtl/passes/SplitExpressions.scala
index 31306046..5c41a1f7 100644
--- a/src/main/scala/firrtl/passes/SplitExpressions.scala
+++ b/src/main/scala/firrtl/passes/SplitExpressions.scala
@@ -19,21 +19,18 @@ object SplitExpressions extends Pass {
// Splits current expression if needed
// Adds named temporaries to v
def split(e: Expression): Expression = e match {
- case e: DoPrim => {
+ case e: DoPrim =>
val name = namespace.newTemp
v += DefNode(get_info(s), name, e)
WRef(name, e.tpe, kind(e), gender(e))
- }
- case e: Mux => {
+ case e: Mux =>
val name = namespace.newTemp
v += DefNode(get_info(s), name, e)
WRef(name, e.tpe, kind(e), gender(e))
- }
- case e: ValidIf => {
+ case e: ValidIf =>
val name = namespace.newTemp
v += DefNode(get_info(s), name, e)
WRef(name, e.tpe, kind(e), gender(e))
- }
case e => e
}
diff --git a/src/main/scala/firrtl/passes/UpdateDuplicateMemMacros.scala b/src/main/scala/firrtl/passes/UpdateDuplicateMemMacros.scala
index 5b420591..675494b4 100644
--- a/src/main/scala/firrtl/passes/UpdateDuplicateMemMacros.scala
+++ b/src/main/scala/firrtl/passes/UpdateDuplicateMemMacros.scala
@@ -78,7 +78,7 @@ object MemTransformUtils {
for ((p, i) <- ports.zipWithIndex; f <- fields) {
val newPort = createSubField(createRef(m.name), portType+i)
val field = createSubField(newPort, f)
- memPortMap(s"${m.name}.${p}.${f}") = field
+ memPortMap(s"${m.name}.$p.$f") = field
}
updateMemPortMap(m.readers, rFields, "R")
updateMemPortMap(m.writers, wFields, "W")