aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/passes
diff options
context:
space:
mode:
authorJack2016-05-09 23:33:36 -0700
committerJack Koenig2016-06-10 16:32:50 -0700
commit26e33c343332c2f65bb45bc17b40a9cb7d22e2fd (patch)
treea02cead24db710db2f1832d0e3389ad256085600 /src/main/scala/firrtl/passes
parent1eb8be78938721dd0d609f684c159bc1d1ddcfd6 (diff)
API Cleanup - Statement
trait Stmt -> abstract class Statement (to match Expression) abbrev. exp -> expr BulkConnect -> PartialConnect camelCase things that were snake_case case class Empty() -> case object EmptyStmt Change >120 character Statements to multiline
Diffstat (limited to 'src/main/scala/firrtl/passes')
-rw-r--r--src/main/scala/firrtl/passes/CheckInitialization.scala12
-rw-r--r--src/main/scala/firrtl/passes/Checks.scala31
-rw-r--r--src/main/scala/firrtl/passes/CommonSubexpressionElimination.scala8
-rw-r--r--src/main/scala/firrtl/passes/ConstProp.scala10
-rw-r--r--src/main/scala/firrtl/passes/DeadCodeElimination.scala12
-rw-r--r--src/main/scala/firrtl/passes/ExpandWhens.scala26
-rw-r--r--src/main/scala/firrtl/passes/Inline.scala8
-rw-r--r--src/main/scala/firrtl/passes/LowerTypes.scala16
-rw-r--r--src/main/scala/firrtl/passes/PadWidths.scala4
-rw-r--r--src/main/scala/firrtl/passes/Passes.scala138
-rw-r--r--src/main/scala/firrtl/passes/RemoveValidIf.scala2
-rw-r--r--src/main/scala/firrtl/passes/SplitExpressions.scala6
-rw-r--r--src/main/scala/firrtl/passes/Uniquify.scala20
13 files changed, 137 insertions, 156 deletions
diff --git a/src/main/scala/firrtl/passes/CheckInitialization.scala b/src/main/scala/firrtl/passes/CheckInitialization.scala
index 493b7a3a..d364f0dc 100644
--- a/src/main/scala/firrtl/passes/CheckInitialization.scala
+++ b/src/main/scala/firrtl/passes/CheckInitialization.scala
@@ -41,16 +41,16 @@ import annotation.tailrec
object CheckInitialization extends Pass {
def name = "Check Initialization"
- private case class VoidExpr(stmt: Stmt, voidDeps: Seq[Expression])
+ private case class VoidExpr(stmt: Statement, voidDeps: Seq[Expression])
- class RefNotInitializedException(info: Info, mname: String, name: String, trace: Seq[Stmt]) extends PassException(
+ class RefNotInitializedException(info: Info, mname: String, name: String, trace: Seq[Statement]) extends PassException(
s"$info : [module $mname] Reference $name is not fully initialized.\n" +
trace.map(s => s" ${get_info(s)} : ${s.serialize}").mkString("\n")
)
- private def getTrace(expr: WrappedExpression, voidExprs: Map[WrappedExpression, VoidExpr]): Seq[Stmt] = {
+ private def getTrace(expr: WrappedExpression, voidExprs: Map[WrappedExpression, VoidExpr]): Seq[Statement] = {
@tailrec
- def rec(e: WrappedExpression, map: Map[WrappedExpression, VoidExpr], trace: Seq[Stmt]): Seq[Stmt] = {
+ def rec(e: WrappedExpression, map: Map[WrappedExpression, VoidExpr], trace: Seq[Statement]): Seq[Statement] = {
val voidExpr = map(e)
val newTrace = voidExpr.stmt +: trace
if (voidExpr.voidDeps.nonEmpty) rec(voidExpr.voidDeps.head, map, newTrace) else newTrace
@@ -85,10 +85,10 @@ object CheckInitialization extends Pass {
hasVoid(e)
(void, voidDeps)
}
- def checkInitS(s: Stmt): Stmt = {
+ def checkInitS(s: Statement): Statement = {
s match {
case con: Connect =>
- val (hasVoid, voidDeps) = hasVoidExpr(con.exp)
+ val (hasVoid, voidDeps) = hasVoidExpr(con.expr)
if (hasVoid) voidExprs(con.loc) = VoidExpr(con, voidDeps)
con
case node: DefNode =>
diff --git a/src/main/scala/firrtl/passes/Checks.scala b/src/main/scala/firrtl/passes/Checks.scala
index a88ad051..272c96ea 100644
--- a/src/main/scala/firrtl/passes/Checks.scala
+++ b/src/main/scala/firrtl/passes/Checks.scala
@@ -46,7 +46,7 @@ object CheckHighForm extends Pass with LazyLogging {
// Custom Exceptions
class NotUniqueException(name: String) extends PassException(s"${sinfo}: [module ${mname}] Reference ${name} does not have a unique name.")
class InvalidLOCException extends PassException(s"${sinfo}: [module ${mname}] Invalid connect to an expression that is not a reference or a WritePort.")
- class NegUIntException extends PassException(s"${sinfo}: [module ${mname}] UIntValue cannot be negative.")
+ class NegUIntException extends PassException(s"${sinfo}: [module ${mname}] UIntLiteral cannot be negative.")
class UndeclaredReferenceException(name: String) extends PassException(s"${sinfo}: [module ${mname}] Reference ${name} is not declared.")
class PoisonWithFlipException(name: String) extends PassException(s"${sinfo}: [module ${mname}] Poison ${name} cannot be a bundle type with flips.")
class MemWithFlipException(name: String) extends PassException(s"${sinfo}: [module ${mname}] Memory ${name} cannot be a bundle type with flips.")
@@ -197,7 +197,7 @@ object CheckHighForm extends Pass with LazyLogging {
e map (checkHighFormT)
e
}
- def checkHighFormS(s: Stmt): Stmt = {
+ def checkHighFormS(s: Statement): Statement = {
def checkName(name: String): String = {
if (names.contains(name)) errors.append(new NotUniqueException(name))
else names(name) = true
@@ -209,12 +209,8 @@ object CheckHighForm extends Pass with LazyLogging {
s map (checkHighFormT)
s map (checkHighFormE)
s match {
- case s: DefPoison => {
- if (hasFlip(s.tpe)) errors.append(new PoisonWithFlipException(s.name))
- checkHighFormT(s.tpe)
- }
case s: DefMemory => {
- if (hasFlip(s.data_type)) errors.append(new MemWithFlipException(s.name))
+ if (hasFlip(s.dataType)) errors.append(new MemWithFlipException(s.name))
if (s.depth <= 0) errors.append(new NegMemSizeException)
}
case s: WDefInstance => {
@@ -222,7 +218,7 @@ object CheckHighForm extends Pass with LazyLogging {
errors.append(new ModuleNotDefinedException(s.module))
}
case s: Connect => checkValidLoc(s.loc)
- case s: BulkConnect => checkValidLoc(s.loc)
+ case s: PartialConnect => checkValidLoc(s.loc)
case s: Print => checkFstring(s.string, s.args.length)
case _ => // Do Nothing
}
@@ -444,11 +440,11 @@ object CheckTypes extends Pass with LazyLogging {
}
}
- def check_types_s (s:Stmt) : Stmt = {
+ def check_types_s (s:Statement) : Statement = {
s map (check_types_e(get_info(s))) match {
- case (s:Connect) => if (wt(tpe(s.loc)) != wt(tpe(s.exp))) errors.append(new InvalidConnect(s.info, s.loc.serialize, s.exp.serialize))
+ case (s:Connect) => if (wt(tpe(s.loc)) != wt(tpe(s.expr))) errors.append(new InvalidConnect(s.info, s.loc.serialize, s.expr.serialize))
case (s:DefRegister) => if (wt(s.tpe) != wt(tpe(s.init))) errors.append(new InvalidRegInit(s.info))
- case (s:BulkConnect) => if (!bulk_equals(tpe(s.loc),tpe(s.exp),Default,Default) ) errors.append(new InvalidConnect(s.info, s.loc.serialize, s.exp.serialize))
+ case (s:PartialConnect) => if (!bulk_equals(tpe(s.loc),tpe(s.expr),Default,Default) ) errors.append(new InvalidConnect(s.info, s.loc.serialize, s.expr.serialize))
case (s:Stop) => {
if (wt(tpe(s.clk)) != wt(ClockType) ) errors.append(new ReqClk(s.info))
if (wt(tpe(s.en)) != wt(ut()) ) errors.append(new EnNotUInt(s.info))
@@ -587,12 +583,11 @@ object CheckGenders extends Pass {
e
}
- def check_genders_s (genders:HashMap[String,Gender])(s:Stmt) : Stmt = {
+ def check_genders_s (genders:HashMap[String,Gender])(s:Statement) : Statement = {
s map (check_genders_e(get_info(s),genders))
s map (check_genders_s(genders))
(s) match {
case (s:DefWire) => genders(s.name) = BIGENDER
- case (s:DefPoison) => genders(s.name) = MALE
case (s:DefRegister) => genders(s.name) = BIGENDER
case (s:DefNode) => {
check_gender(s.info,genders,MALE)(s.value)
@@ -602,7 +597,7 @@ object CheckGenders extends Pass {
case (s:WDefInstance) => genders(s.name) = MALE
case (s:Connect) => {
check_gender(s.info,genders,FEMALE)(s.loc)
- check_gender(s.info,genders,MALE)(s.exp)
+ check_gender(s.info,genders,MALE)(s.expr)
}
case (s:Print) => {
for (x <- s.args ) {
@@ -611,14 +606,14 @@ object CheckGenders extends Pass {
check_gender(s.info,genders,MALE)(s.en)
check_gender(s.info,genders,MALE)(s.clk)
}
- case (s:BulkConnect) => {
+ case (s:PartialConnect) => {
check_gender(s.info,genders,FEMALE)(s.loc)
- check_gender(s.info,genders,MALE)(s.exp)
+ check_gender(s.info,genders,MALE)(s.expr)
}
case (s:Conditionally) => {
check_gender(s.info,genders,MALE)(s.pred)
}
- case (s:Empty) => false
+ case EmptyStmt => false
case (s:Stop) => {
check_gender(s.info,genders,MALE)(s.en)
check_gender(s.info,genders,MALE)(s.clk)
@@ -687,7 +682,7 @@ object CheckWidths extends Pass {
}
e
}
- def check_width_s (s:Stmt) : Stmt = {
+ def check_width_s (s:Statement) : Statement = {
s map (check_width_s) map (check_width_e(get_info(s)))
def tm (t:Type) : Type = mapr(check_width_w(info(s)) _,t)
s map (tm)
diff --git a/src/main/scala/firrtl/passes/CommonSubexpressionElimination.scala b/src/main/scala/firrtl/passes/CommonSubexpressionElimination.scala
index 35bd86ce..f58572b1 100644
--- a/src/main/scala/firrtl/passes/CommonSubexpressionElimination.scala
+++ b/src/main/scala/firrtl/passes/CommonSubexpressionElimination.scala
@@ -36,12 +36,12 @@ import annotation.tailrec
object CommonSubexpressionElimination extends Pass {
def name = "Common Subexpression Elimination"
- private def cseOnce(s: Stmt): (Stmt, Long) = {
+ private def cseOnce(s: Statement): (Statement, Long) = {
var nEliminated = 0L
val expressions = collection.mutable.HashMap[MemoizedHash[Expression], String]()
val nodes = collection.mutable.HashMap[String, Expression]()
- def recordNodes(s: Stmt): Stmt = s match {
+ def recordNodes(s: Statement): Statement = s match {
case x: DefNode =>
nodes(x.name) = x.value
expressions.getOrElseUpdate(x.value, x.name)
@@ -62,14 +62,14 @@ object CommonSubexpressionElimination extends Pass {
case _ => e map eliminateNodeRef
}
- def eliminateNodeRefs(s: Stmt): Stmt = s map eliminateNodeRefs map eliminateNodeRef
+ def eliminateNodeRefs(s: Statement): Statement = s map eliminateNodeRefs map eliminateNodeRef
recordNodes(s)
(eliminateNodeRefs(s), nEliminated)
}
@tailrec
- private def cse(s: Stmt): Stmt = {
+ private def cse(s: Statement): Statement = {
val (res, n) = cseOnce(s)
if (n > 0) cse(res) else res
}
diff --git a/src/main/scala/firrtl/passes/ConstProp.scala b/src/main/scala/firrtl/passes/ConstProp.scala
index 7c78e283..11c14e56 100644
--- a/src/main/scala/firrtl/passes/ConstProp.scala
+++ b/src/main/scala/firrtl/passes/ConstProp.scala
@@ -132,8 +132,8 @@ object ConstProp extends Pass {
case _ => false
}
def isZero(e: Expression) = e match {
- case UIntValue(value,_) => value == BigInt(0)
- case SIntValue(value,_) => value == BigInt(0)
+ case UIntLiteral(value, _) => value == BigInt(0)
+ case SIntLiteral(value, _) => value == BigInt(0)
case _ => false
}
x match {
@@ -159,8 +159,8 @@ object ConstProp extends Pass {
def <= (that: Range) = this.max <= that.min
}
def range(e: Expression): Range = e match {
- case UIntValue(value, _) => Range(value, value)
- case SIntValue(value, _) => Range(value, value)
+ case UIntLiteral(value, _) => Range(value, value)
+ case SIntLiteral(value, _) => Range(value, value)
case _ => tpe(e) match {
case SIntType(IntWidth(width)) => Range(
min = BigInt(0) - BigInt(2).pow(width.toInt - 1),
@@ -273,7 +273,7 @@ object ConstProp extends Pass {
propagated
}
- def constPropStmt(s: Stmt): Stmt = {
+ def constPropStmt(s: Statement): Statement = {
s match {
case x: DefNode => nodeMap(x.name) = x.value
case _ =>
diff --git a/src/main/scala/firrtl/passes/DeadCodeElimination.scala b/src/main/scala/firrtl/passes/DeadCodeElimination.scala
index cdff1639..8482fe1d 100644
--- a/src/main/scala/firrtl/passes/DeadCodeElimination.scala
+++ b/src/main/scala/firrtl/passes/DeadCodeElimination.scala
@@ -36,7 +36,7 @@ import annotation.tailrec
object DeadCodeElimination extends Pass {
def name = "Dead Code Elimination"
- private def dceOnce(s: Stmt): (Stmt, Long) = {
+ private def dceOnce(s: Statement): (Statement, Long) = {
val referenced = collection.mutable.HashSet[String]()
var nEliminated = 0L
@@ -48,16 +48,16 @@ object DeadCodeElimination extends Pass {
e
}
- def checkUse(s: Stmt): Stmt = s map checkUse map checkExpressionUse
+ def checkUse(s: Statement): Statement = s map checkUse map checkExpressionUse
- def maybeEliminate(x: Stmt, name: String) =
+ def maybeEliminate(x: Statement, name: String) =
if (referenced(name)) x
else {
nEliminated += 1
- Empty()
+ EmptyStmt
}
- def removeUnused(s: Stmt): Stmt = s match {
+ def removeUnused(s: Statement): Statement = s match {
case x: DefRegister => maybeEliminate(x, x.name)
case x: DefWire => maybeEliminate(x, x.name)
case x: DefNode => maybeEliminate(x, x.name)
@@ -69,7 +69,7 @@ object DeadCodeElimination extends Pass {
}
@tailrec
- private def dce(s: Stmt): Stmt = {
+ private def dce(s: Statement): Statement = {
val (res, n) = dceOnce(s)
if (n > 0) dce(res) else res
}
diff --git a/src/main/scala/firrtl/passes/ExpandWhens.scala b/src/main/scala/firrtl/passes/ExpandWhens.scala
index 1dac5e17..e20ed793 100644
--- a/src/main/scala/firrtl/passes/ExpandWhens.scala
+++ b/src/main/scala/firrtl/passes/ExpandWhens.scala
@@ -70,12 +70,12 @@ object ExpandWhens extends Pass {
}
expsx
}
- private def squashEmpty(s: Stmt): Stmt = {
+ private def squashEmpty(s: Statement): Statement = {
s map squashEmpty match {
case Begin(stmts) =>
- val newStmts = stmts filter (_ != Empty())
+ val newStmts = stmts filter (_ != EmptyStmt)
newStmts.size match {
- case 0 => Empty()
+ case 0 => EmptyStmt
case 1 => newStmts.head
case _ => Begin(newStmts)
}
@@ -102,16 +102,16 @@ object ExpandWhens extends Pass {
// ------------ Pass -------------------
def run(c: Circuit): Circuit = {
- def expandWhens(m: Module): (LinkedHashMap[WrappedExpression, Expression], ArrayBuffer[Stmt], Stmt) = {
+ def expandWhens(m: Module): (LinkedHashMap[WrappedExpression, Expression], ArrayBuffer[Statement], Statement) = {
val namespace = Namespace(m)
- val simlist = ArrayBuffer[Stmt]()
+ val simlist = ArrayBuffer[Statement]()
// defaults ideally would be immutable.Map but conversion from mutable.LinkedHashMap to mutable.Map is VERY slow
def expandWhens(
netlist: LinkedHashMap[WrappedExpression, Expression],
defaults: Seq[collection.mutable.Map[WrappedExpression, Expression]],
p: Expression)
- (s: Stmt): Stmt = {
+ (s: Statement): Statement = {
s match {
case w: DefWire =>
getFemaleRefs(w.name, w.tpe, BIGENDER) foreach (ref => netlist(ref) = WVoid())
@@ -120,13 +120,13 @@ object ExpandWhens extends Pass {
getFemaleRefs(r.name, r.tpe, BIGENDER) foreach (ref => netlist(ref) = ref)
r
case c: Connect =>
- netlist(c.loc) = c.exp
- Empty()
+ netlist(c.loc) = c.expr
+ EmptyStmt
case c: IsInvalid =>
- netlist(c.exp) = WInvalid()
- Empty()
+ netlist(c.expr) = WInvalid()
+ EmptyStmt
case s: Conditionally =>
- val memos = ArrayBuffer[Stmt]()
+ val memos = ArrayBuffer[Statement]()
val conseqNetlist = LinkedHashMap[WrappedExpression, Expression]()
val altNetlist = LinkedHashMap[WrappedExpression, Expression]()
@@ -164,14 +164,14 @@ object ExpandWhens extends Pass {
} else {
simlist += Print(s.info, s.string, s.args, s.clk, AND(p, s.en))
}
- Empty()
+ EmptyStmt
case s: Stop =>
if (weq(p, one)) {
simlist += s
} else {
simlist += Stop(s.info, s.ret, s.clk, AND(p, s.en))
}
- Empty()
+ EmptyStmt
case s => s map expandWhens(netlist, defaults, p)
}
}
diff --git a/src/main/scala/firrtl/passes/Inline.scala b/src/main/scala/firrtl/passes/Inline.scala
index f1b71149..d120426b 100644
--- a/src/main/scala/firrtl/passes/Inline.scala
+++ b/src/main/scala/firrtl/passes/Inline.scala
@@ -52,7 +52,7 @@ object InlineInstances extends Transform {
}
def checkInstance(cn: ComponentName): Unit = {
var containsCN = false
- def onStmt(name: String)(s: Stmt): Stmt = {
+ def onStmt(name: String)(s: Statement): Statement = {
s match {
case WDefInstance(_, inst_name, module_name, tpe) =>
if (name == inst_name) {
@@ -106,7 +106,7 @@ object InlineInstances extends Transform {
case e => e map onExp
}
// Recursive. Inlines tagged instances
- def onStmt(s: Stmt): Stmt = s match {
+ def onStmt(s: Statement): Statement = s match {
case WDefInstance(info, instName, moduleName, instTpe) => {
def rename(name:String): String = {
val newName = instName + inlineDelim + name
@@ -114,7 +114,7 @@ object InlineInstances extends Transform {
newName
}
// Rewrites references in inlined statements from ref to inst$ref
- def renameStmt(s: Stmt): Stmt = {
+ 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)
@@ -139,7 +139,7 @@ object InlineInstances extends Transform {
case m: ExtModule => throw new PassException("Cannot inline external module")
case m: Module => m
}
- val stmts = mutable.ArrayBuffer[Stmt]()
+ val stmts = mutable.ArrayBuffer[Statement]()
for (p <- instInModule.ports) {
stmts += DefWire(p.info, rename(p.name), p.tpe)
}
diff --git a/src/main/scala/firrtl/passes/LowerTypes.scala b/src/main/scala/firrtl/passes/LowerTypes.scala
index 05d46e42..36919756 100644
--- a/src/main/scala/firrtl/passes/LowerTypes.scala
+++ b/src/main/scala/firrtl/passes/LowerTypes.scala
@@ -153,7 +153,7 @@ object LowerTypes extends Pass {
case e: DoPrim => e map (lowerTypesExp)
}
- def lowerTypesStmt(s: Stmt): Stmt = {
+ def lowerTypesStmt(s: Statement): Statement = {
s map lowerTypesStmt match {
case s: DefWire =>
sinfo = s.info
@@ -195,14 +195,14 @@ object LowerTypes extends Pass {
}
case s: DefMemory =>
sinfo = s.info
- memDataTypeMap += (s.name -> s.data_type)
- if (s.data_type.isGround) {
+ memDataTypeMap += (s.name -> s.dataType)
+ if (s.dataType.isGround) {
s
} else {
- val exps = create_exps(s.name, s.data_type)
+ val exps = create_exps(s.name, s.dataType)
val stmts = exps map { e =>
DefMemory(s.info, loweredName(e), tpe(e), s.depth,
- s.write_latency, s.read_latency, s.readers, s.writers,
+ s.writeLatency, s.readLatency, s.readers, s.writers,
s.readwriters)
}
Begin(stmts)
@@ -224,9 +224,9 @@ object LowerTypes extends Pass {
Begin(stmts)
case s: IsInvalid =>
sinfo = s.info
- kind(s.exp) match {
+ kind(s.expr) match {
case k: MemKind =>
- val exps = lowerTypesMemExp(s.exp)
+ val exps = lowerTypesMemExp(s.expr)
Begin(exps map (exp => IsInvalid(s.info, exp)))
case _ => s map (lowerTypesExp)
}
@@ -234,7 +234,7 @@ object LowerTypes extends Pass {
sinfo = s.info
kind(s.loc) match {
case k: MemKind =>
- val exp = lowerTypesExp(s.exp)
+ val exp = lowerTypesExp(s.expr)
val locs = lowerTypesMemExp(s.loc)
Begin(locs map (loc => Connect(s.info, loc, exp)))
case _ => s map (lowerTypesExp)
diff --git a/src/main/scala/firrtl/passes/PadWidths.scala b/src/main/scala/firrtl/passes/PadWidths.scala
index 58725928..3054aab0 100644
--- a/src/main/scala/firrtl/passes/PadWidths.scala
+++ b/src/main/scala/firrtl/passes/PadWidths.scala
@@ -57,10 +57,10 @@ object PadWidths extends Pass {
}
}
// Recursive. Fixes assignments and register initialization widths
- private def onStmt(s: Stmt): Stmt = {
+ private def onStmt(s: Statement): Statement = {
s map onExp match {
case s: Connect => {
- val ex = fixup(width(s.loc))(s.exp)
+ val ex = fixup(width(s.loc))(s.expr)
Connect(s.info, s.loc, ex)
}
case s: DefRegister => {
diff --git a/src/main/scala/firrtl/passes/Passes.scala b/src/main/scala/firrtl/passes/Passes.scala
index 42b51268..094166fb 100644
--- a/src/main/scala/firrtl/passes/Passes.scala
+++ b/src/main/scala/firrtl/passes/Passes.scala
@@ -76,7 +76,7 @@ object ToWorkingIR extends Pass {
case e => e
}
}
- def toStmt (s:Stmt) : Stmt = {
+ def toStmt (s:Statement) : Statement = {
s map (toExp) match {
case s:DefInstance => WDefInstance(s.info,s.name,s.module,UnknownType)
case s => s map (toStmt)
@@ -99,22 +99,21 @@ object ResolveKinds extends Pass {
def run (c:Circuit): Circuit = {
def resolve_kinds (m:DefModule, c:Circuit):DefModule = {
val kinds = LinkedHashMap[String,Kind]()
- def resolve (body:Stmt) = {
+ def resolve (body:Statement) = {
def resolve_expr (e:Expression):Expression = {
e match {
case e:WRef => WRef(e.name,tpe(e),kinds(e.name),e.gender)
case e => e map (resolve_expr)
}
}
- def resolve_stmt (s:Stmt):Stmt = s map (resolve_stmt) map (resolve_expr)
+ def resolve_stmt (s:Statement):Statement = s map (resolve_stmt) map (resolve_expr)
resolve_stmt(body)
}
def find (m:DefModule) = {
- def find_stmt (s:Stmt):Stmt = {
+ def find_stmt (s:Statement):Statement = {
s match {
case s:DefWire => kinds(s.name) = WireKind()
- case s:DefPoison => kinds(s.name) = PoisonKind()
case s:DefNode => kinds(s.name) = NodeKind()
case s:DefRegister => kinds(s.name) = RegKind()
case s:WDefInstance => kinds(s.name) = InstanceKind()
@@ -148,13 +147,12 @@ object ResolveKinds extends Pass {
object InferTypes extends Pass {
private var mname = ""
def name = "Infer Types"
- def set_type (s:Stmt,t:Type) : Stmt = {
+ def set_type (s:Statement, t:Type) : Statement = {
s match {
case s:DefWire => DefWire(s.info,s.name,t)
case s:DefRegister => DefRegister(s.info,s.name,t,s.clock,s.reset,s.init)
- case s:DefMemory => DefMemory(s.info,s.name,t,s.depth,s.write_latency,s.read_latency,s.readers,s.writers,s.readwriters)
+ case s:DefMemory => DefMemory(s.info,s.name,t,s.depth,s.writeLatency,s.readLatency,s.readers,s.writers,s.readwriters)
case s:DefNode => s
- case s:DefPoison => DefPoison(s.info,s.name,t)
}
}
def remove_unknowns_w (w:Width)(implicit namespace: Namespace):Width = {
@@ -182,7 +180,7 @@ object InferTypes extends Pass {
case e:SIntValue => e
}
}
- def infer_types_s (s:Stmt) : Stmt = {
+ def infer_types_s (s:Statement) : Statement = {
s match {
case s:DefRegister => {
val t = remove_unknowns(get_type(s))
@@ -195,12 +193,6 @@ object InferTypes extends Pass {
types(s.name) = t
set_type(sx,t)
}
- case s:DefPoison => {
- val sx = s map (infer_types_e)
- val t = remove_unknowns(get_type(sx))
- types(s.name) = t
- set_type(sx,t)
- }
case s:DefNode => {
val sx = s map (infer_types_e)
val t = remove_unknowns(get_type(sx))
@@ -210,7 +202,7 @@ object InferTypes extends Pass {
case s:DefMemory => {
val t = remove_unknowns(get_type(s))
types(s.name) = t
- val dt = remove_unknowns(s.data_type)
+ val dt = remove_unknowns(s.dataType)
set_type(s,dt)
}
case s:WDefInstance => {
@@ -272,21 +264,21 @@ object ResolveGenders extends Pass {
}
}
- def resolve_s (s:Stmt) : Stmt = {
+ def resolve_s (s:Statement) : Statement = {
s match {
case s:IsInvalid => {
- val expx = resolve_e(FEMALE)(s.exp)
+ val expx = resolve_e(FEMALE)(s.expr)
IsInvalid(s.info,expx)
}
case s:Connect => {
val locx = resolve_e(FEMALE)(s.loc)
- val expx = resolve_e(MALE)(s.exp)
+ val expx = resolve_e(MALE)(s.expr)
Connect(s.info,locx,expx)
}
- case s:BulkConnect => {
+ case s:PartialConnect => {
val locx = resolve_e(FEMALE)(s.loc)
- val expx = resolve_e(MALE)(s.exp)
- BulkConnect(s.info,locx,expx)
+ val expx = resolve_e(MALE)(s.expr)
+ PartialConnect(s.info,locx,expx)
}
case s => s map (resolve_e(MALE)) map (resolve_s)
}
@@ -557,12 +549,12 @@ object InferWidths extends Pass {
constrain(ONE,width_BANG(e.cond))
e }
case (e) => e }}
- def get_constraints (s:Stmt) : Stmt = {
+ def get_constraints (s:Statement) : Statement = {
(s map (get_constraints_e)) match {
case (s:Connect) => {
val n = get_size(tpe(s.loc))
val ce_loc = create_exps(s.loc)
- val ce_exp = create_exps(s.exp)
+ val ce_exp = create_exps(s.expr)
for (i <- 0 until n) {
val locx = ce_loc(i)
val expx = ce_exp(i)
@@ -570,11 +562,11 @@ object InferWidths extends Pass {
case Default => constrain(width_BANG(locx),width_BANG(expx))
case Flip => constrain(width_BANG(expx),width_BANG(locx)) }}
s }
- case (s:BulkConnect) => {
- val ls = get_valid_points(tpe(s.loc),tpe(s.exp),Default,Default)
+ case (s:PartialConnect) => {
+ val ls = get_valid_points(tpe(s.loc),tpe(s.expr),Default,Default)
for (x <- ls) {
val locx = create_exps(s.loc)(x._1)
- val expx = create_exps(s.exp)(x._2)
+ val expx = create_exps(s.expr)(x._2)
get_flip(tpe(s.loc),x._1,Default) match {
case Default => constrain(width_BANG(locx),width_BANG(expx))
case Flip => constrain(width_BANG(expx),width_BANG(locx)) }}
@@ -639,7 +631,7 @@ object PullMuxes extends Pass {
}
ex map (pull_muxes_e)
}
- def pull_muxes (s:Stmt) : Stmt = s map (pull_muxes) map (pull_muxes_e)
+ def pull_muxes (s:Statement) : Statement = s map (pull_muxes) map (pull_muxes_e)
val modulesx = c.modules.map {
m => {
mname = m.name
@@ -660,7 +652,7 @@ object ExpandConnects extends Pass {
def expand_connects (m:Module) : Module = {
mname = m.name
val genders = LinkedHashMap[String,Gender]()
- def expand_s (s:Stmt) : Stmt = {
+ def expand_s (s:Statement) : Statement = {
def set_gender (e:Expression) : Expression = {
e map (set_gender) match {
case (e:WRef) => WRef(e.name,e.tpe,e.kind,genders(e.name))
@@ -679,12 +671,11 @@ object ExpandConnects extends Pass {
case (s:DefRegister) => { genders(s.name) = BIGENDER; s }
case (s:WDefInstance) => { genders(s.name) = MALE; s }
case (s:DefMemory) => { genders(s.name) = MALE; s }
- case (s:DefPoison) => { genders(s.name) = MALE; s }
case (s:DefNode) => { genders(s.name) = MALE; s }
case (s:IsInvalid) => {
- val n = get_size(tpe(s.exp))
- val invalids = ArrayBuffer[Stmt]()
- val exps = create_exps(s.exp)
+ val n = get_size(tpe(s.expr))
+ val invalids = ArrayBuffer[Statement]()
+ val exps = create_exps(s.expr)
for (i <- 0 until n) {
val expx = exps(i)
val gexpx = set_gender(expx)
@@ -695,16 +686,16 @@ object ExpandConnects extends Pass {
}
}
if (invalids.length == 0) {
- Empty()
+ EmptyStmt
} else if (invalids.length == 1) {
invalids(0)
} else Begin(invalids)
}
case (s:Connect) => {
val n = get_size(tpe(s.loc))
- val connects = ArrayBuffer[Stmt]()
+ val connects = ArrayBuffer[Statement]()
val locs = create_exps(s.loc)
- val exps = create_exps(s.exp)
+ val exps = create_exps(s.expr)
for (i <- 0 until n) {
val locx = locs(i)
val expx = exps(i)
@@ -716,11 +707,11 @@ object ExpandConnects extends Pass {
}
Begin(connects)
}
- case (s:BulkConnect) => {
- val ls = get_valid_points(tpe(s.loc),tpe(s.exp),Default,Default)
- val connects = ArrayBuffer[Stmt]()
+ case (s:PartialConnect) => {
+ val ls = get_valid_points(tpe(s.loc),tpe(s.expr),Default,Default)
+ val connects = ArrayBuffer[Statement]()
val locs = create_exps(s.loc)
- val exps = create_exps(s.exp)
+ val exps = create_exps(s.expr)
ls.foreach { x => {
val locx = locs(x._1)
val expx = exps(x._2)
@@ -819,8 +810,8 @@ object RemoveAccesses extends Pass {
def remove_m (m:Module) : Module = {
val namespace = Namespace(m)
mname = m.name
- def remove_s (s:Stmt) : Stmt = {
- val stmts = ArrayBuffer[Stmt]()
+ def remove_s (s:Statement) : Statement = {
+ val stmts = ArrayBuffer[Statement]()
def create_temp (e:Expression) : Expression = {
val n = namespace.newTemp
stmts += DefWire(info(s),n,tpe(e))
@@ -852,7 +843,7 @@ object RemoveAccesses extends Pass {
if (i < temps.size) {
stmts += Connect(info(s),get_temp(i),x.base)
} else {
- stmts += Conditionally(info(s),x.guard,Connect(info(s),get_temp(i),x.base),Empty())
+ stmts += Conditionally(info(s),x.guard,Connect(info(s),get_temp(i),x.base),EmptyStmt)
}
}
}
@@ -872,11 +863,11 @@ object RemoveAccesses extends Pass {
if (ls.size == 1 & weq(ls(0).guard,one)) s.loc
else {
val temp = create_temp(s.loc)
- for (x <- ls) { stmts += Conditionally(s.info,x.guard,Connect(s.info,x.base,temp),Empty()) }
+ for (x <- ls) { stmts += Conditionally(s.info,x.guard,Connect(s.info,x.base,temp),EmptyStmt) }
temp
}
- Connect(s.info,locx,remove_e(s.exp))
- } else { Connect(s.info,s.loc,remove_e(s.exp)) }
+ Connect(s.info,locx,remove_e(s.expr))
+ } else { Connect(s.info,s.loc,remove_e(s.expr)) }
}
case (s) => s map (remove_e) map (remove_s)
}
@@ -920,16 +911,16 @@ object Legalize extends Pass {
}
case _ => e
}
- def legalizeConnect(c: Connect): Stmt = {
+ def legalizeConnect(c: Connect): Statement = {
val t = tpe(c.loc)
val w = long_BANG(t)
- if (w >= long_BANG(tpe(c.exp))) c
+ if (w >= long_BANG(tpe(c.expr))) c
else {
val newType = t match {
case _: UIntType => UIntType(IntWidth(w))
case _: SIntType => SIntType(IntWidth(w))
}
- Connect(c.info, c.loc, DoPrim(BITS_SELECT_OP, Seq(c.exp), Seq(w-1, 0), newType))
+ Connect(c.info, c.loc, DoPrim(BITS_SELECT_OP, Seq(c.expr), Seq(w-1, 0), newType))
}
}
def run (c: Circuit): Circuit = {
@@ -939,7 +930,7 @@ object Legalize extends Pass {
case e => e
}
}
- def legalizeS (s: Stmt): Stmt = {
+ def legalizeS (s: Statement): Statement = {
val legalizedStmt = s match {
case c: Connect => legalizeConnect(c)
case _ => s
@@ -973,7 +964,7 @@ object VerilogWrap extends Pass {
case (e) => e
}
}
- def v_wrap_s (s:Stmt) : Stmt = {
+ def v_wrap_s (s:Statement) : Statement = {
s map (v_wrap_s) map (v_wrap_e) match {
case s: Print =>
Print(s.info, VerilogStringLitHandler.format(s.string), s.args, s.clk, s.en)
@@ -1006,7 +997,7 @@ object VerilogRename extends Pass {
case (e) => e map (verilog_rename_e)
}
}
- def verilog_rename_s (s:Stmt) : Stmt = {
+ def verilog_rename_s (s:Statement) : Statement = {
s map (verilog_rename_s) map (verilog_rename_e) map (verilog_rename_n)
}
val modulesx = c.modules.map{ m => {
@@ -1025,14 +1016,13 @@ object VerilogRename extends Pass {
object CInferTypes extends Pass {
def name = "CInfer Types"
var mname = ""
- def set_type (s:Stmt,t:Type) : Stmt = {
+ def set_type (s:Statement, t:Type) : Statement = {
(s) match {
case (s:DefWire) => DefWire(s.info,s.name,t)
case (s:DefRegister) => DefRegister(s.info,s.name,t,s.clock,s.reset,s.init)
case (s:CDefMemory) => CDefMemory(s.info,s.name,t,s.size,s.seq)
case (s:CDefMPort) => CDefMPort(s.info,s.name,t,s.mem,s.exps,s.direction)
case (s:DefNode) => s
- case (s:DefPoison) => DefPoison(s.info,s.name,t)
}
}
@@ -1073,7 +1063,7 @@ object CInferTypes extends Pass {
case (_:UIntValue|_:SIntValue) => e
}
}
- def infer_types_s (s:Stmt) : Stmt = {
+ def infer_types_s (s:Statement) : Statement = {
(s) match {
case (s:DefRegister) => {
types(s.name) = s.tpe
@@ -1084,10 +1074,6 @@ object CInferTypes extends Pass {
types(s.name) = s.tpe
s
}
- case (s:DefPoison) => {
- types(s.name) = s.tpe
- s
- }
case (s:DefNode) => {
val sx = s map (infer_types_e)
val t = get_type(sx)
@@ -1169,26 +1155,26 @@ object CInferMDir extends Pass {
case (e) => e
}
}
- def infer_mdir_s (s:Stmt) : Stmt = {
+ def infer_mdir_s (s:Statement) : Statement = {
(s) match {
case (s:CDefMPort) => {
mports(s.name) = s.direction
s map (infer_mdir_e(MRead))
}
case (s:Connect) => {
- infer_mdir_e(MRead)(s.exp)
+ infer_mdir_e(MRead)(s.expr)
infer_mdir_e(MWrite)(s.loc)
s
}
- case (s:BulkConnect) => {
- infer_mdir_e(MRead)(s.exp)
+ case (s:PartialConnect) => {
+ infer_mdir_e(MRead)(s.expr)
infer_mdir_e(MWrite)(s.loc)
s
}
case (s) => s map (infer_mdir_s) map (infer_mdir_e(MRead))
}
}
- def set_mdir_s (s:Stmt) : Stmt = {
+ def set_mdir_s (s:Statement) : Statement = {
(s) match {
case (s:CDefMPort) =>
CDefMPort(s.info,s.name,s.tpe,s.mem,s.exps,mports(s.name))
@@ -1243,7 +1229,7 @@ object RemoveCHIRRTL extends Pass {
val ut = UnknownType
val mport_types = LinkedHashMap[String,Type]()
def EMPs () : MPorts = MPorts(ArrayBuffer[MPort](),ArrayBuffer[MPort](),ArrayBuffer[MPort]())
- def collect_mports (s:Stmt) : Stmt = {
+ def collect_mports (s:Statement) : Statement = {
(s) match {
case (s:CDefMPort) => {
val mports = hash.getOrElse(s.mem,EMPs())
@@ -1258,11 +1244,11 @@ object RemoveCHIRRTL extends Pass {
case (s) => s map (collect_mports)
}
}
- def collect_refs (s:Stmt) : Stmt = {
+ def collect_refs (s:Statement) : Statement = {
(s) match {
case (s:CDefMemory) => {
mport_types(s.name) = s.tpe
- val stmts = ArrayBuffer[Stmt]()
+ val stmts = ArrayBuffer[Statement]()
val taddr = UIntType(IntWidth(scala.math.max(1,ceil_log2(s.size))))
val tdata = s.tpe
def set_poison (vec:Seq[MPort],addr:String) : Unit = {
@@ -1330,7 +1316,7 @@ object RemoveCHIRRTL extends Pass {
ens += "en"
}
}
- val stmts = ArrayBuffer[Stmt]()
+ val stmts = ArrayBuffer[Statement]()
for (x <- addrs ) {
stmts += Connect(s.info,SubField(SubField(Ref(s.mem,ut),s.name,ut),x,ut),s.exps(0))
}
@@ -1345,7 +1331,7 @@ object RemoveCHIRRTL extends Pass {
case (s) => s map (collect_refs)
}
}
- def remove_chirrtl_s (s:Stmt) : Stmt = {
+ def remove_chirrtl_s (s:Statement) : Statement = {
var has_write_mport = false
var has_readwrite_mport:Option[Expression] = None
def remove_chirrtl_e (g:Gender)(e:Expression) : Expression = {
@@ -1382,8 +1368,8 @@ object RemoveCHIRRTL extends Pass {
}
(s) match {
case (s:Connect) => {
- val stmts = ArrayBuffer[Stmt]()
- val rocx = remove_chirrtl_e(MALE)(s.exp)
+ val stmts = ArrayBuffer[Statement]()
+ val rocx = remove_chirrtl_e(MALE)(s.expr)
val locx = remove_chirrtl_e(FEMALE)(s.loc)
stmts += Connect(s.info,locx,rocx)
if (has_write_mport) {
@@ -1399,13 +1385,13 @@ object RemoveCHIRRTL extends Pass {
if (stmts.size > 1) Begin(stmts)
else stmts(0)
}
- case (s:BulkConnect) => {
- val stmts = ArrayBuffer[Stmt]()
+ case (s:PartialConnect) => {
+ val stmts = ArrayBuffer[Statement]()
val locx = remove_chirrtl_e(FEMALE)(s.loc)
- val rocx = remove_chirrtl_e(MALE)(s.exp)
- stmts += BulkConnect(s.info,locx,rocx)
+ val rocx = remove_chirrtl_e(MALE)(s.expr)
+ stmts += PartialConnect(s.info,locx,rocx)
if (has_write_mport != false) {
- val ls = get_valid_points(tpe(s.loc),tpe(s.exp),Default,Default)
+ val ls = get_valid_points(tpe(s.loc),tpe(s.expr),Default,Default)
val locs = create_exps(get_mask(s.loc))
for (x <- ls ) {
val locx = locs(x._1)
diff --git a/src/main/scala/firrtl/passes/RemoveValidIf.scala b/src/main/scala/firrtl/passes/RemoveValidIf.scala
index 5117caaf..486e9ff8 100644
--- a/src/main/scala/firrtl/passes/RemoveValidIf.scala
+++ b/src/main/scala/firrtl/passes/RemoveValidIf.scala
@@ -13,7 +13,7 @@ object RemoveValidIf extends Pass {
}
}
// Recursive.
- private def onStmt(s: Stmt): Stmt = s map onStmt map onExp
+ private def onStmt(s: Statement): Statement = s map onStmt map onExp
private def onModule(m: DefModule): DefModule = {
m match {
diff --git a/src/main/scala/firrtl/passes/SplitExpressions.scala b/src/main/scala/firrtl/passes/SplitExpressions.scala
index 4f7fa208..61f01e01 100644
--- a/src/main/scala/firrtl/passes/SplitExpressions.scala
+++ b/src/main/scala/firrtl/passes/SplitExpressions.scala
@@ -12,8 +12,8 @@ object SplitExpressions extends Pass {
def name = "Split Expressions"
private def onModule(m: Module): Module = {
val namespace = Namespace(m)
- def onStmt(s: Stmt): Stmt = {
- val v = mutable.ArrayBuffer[Stmt]()
+ def onStmt(s: Statement): Statement = {
+ val v = mutable.ArrayBuffer[Statement]()
// Splits current expression if needed
// Adds named temporaries to v
def split(e: Expression): Expression = e match {
@@ -45,7 +45,7 @@ object SplitExpressions extends Pass {
val x = s map onExp
x match {
case x: Begin => x map onStmt
- case x: Empty => x
+ case EmptyStmt => x
case x => {
v += x
if (v.size > 1) Begin(v.toVector)
diff --git a/src/main/scala/firrtl/passes/Uniquify.scala b/src/main/scala/firrtl/passes/Uniquify.scala
index d0442f37..2fdc3454 100644
--- a/src/main/scala/firrtl/passes/Uniquify.scala
+++ b/src/main/scala/firrtl/passes/Uniquify.scala
@@ -220,24 +220,24 @@ object Uniquify extends Pass {
}
// Creates a Bundle Type from a Stmt
- def stmtToType(s: Stmt)(implicit sinfo: Info, mname: String): BundleType = {
+ def stmtToType(s: Statement)(implicit sinfo: Info, mname: String): BundleType = {
// Recursive helper
- def recStmtToType(s: Stmt): Seq[Field] = s match {
+ def recStmtToType(s: Statement): Seq[Field] = s match {
case s: DefWire => Seq(Field(s.name, Default, s.tpe))
case s: DefRegister => Seq(Field(s.name, Default, s.tpe))
case s: WDefInstance => Seq(Field(s.name, Default, s.tpe))
- case s: DefMemory => s.data_type match {
+ case s: DefMemory => s.dataType match {
case (_: UIntType | _: SIntType) =>
Seq(Field(s.name, Default, get_type(s)))
case tpe: BundleType =>
val newFields = tpe.fields map ( f =>
- DefMemory(s.info, f.name, f.tpe, s.depth, s.write_latency,
- s.read_latency, s.readers, s.writers, s.readwriters)
+ DefMemory(s.info, f.name, f.tpe, s.depth, s.writeLatency,
+ s.readLatency, s.readers, s.writers, s.readwriters)
) flatMap (recStmtToType)
Seq(Field(s.name, Default, BundleType(newFields)))
case tpe: VectorType =>
val newFields = (0 until tpe.size) map ( i =>
- s.copy(name = i.toString, data_type = tpe.tpe)
+ s.copy(name = i.toString, dataType = tpe.tpe)
) flatMap (recStmtToType)
Seq(Field(s.name, Default, BundleType(newFields)))
}
@@ -271,7 +271,7 @@ object Uniquify extends Pass {
case e: DoPrim => e map (uniquifyExp)
}
- def uniquifyStmt(s: Stmt): Stmt = {
+ def uniquifyStmt(s: Statement): Statement = {
s map uniquifyStmt map uniquifyExp match {
case s: DefWire =>
sinfo = s.info
@@ -302,8 +302,8 @@ object Uniquify extends Pass {
sinfo = s.info
if (nameMap.contains(s.name)) {
val node = nameMap(s.name)
- val dataType = uniquifyNamesType(s.data_type, node.elts)
- val mem = s.copy(name = node.name, data_type = dataType)
+ val dataType = uniquifyNamesType(s.dataType, node.elts)
+ val mem = s.copy(name = node.name, dataType = dataType)
// Create new mapping to handle references to memory data fields
val uniqueMemMap = createNameMapping(get_type(s), get_type(mem))
nameMap(s.name) = NameMapNode(node.name, node.elts ++ uniqueMemMap)
@@ -323,7 +323,7 @@ object Uniquify extends Pass {
}
}
- def uniquifyBody(s: Stmt): Stmt = {
+ def uniquifyBody(s: Statement): Statement = {
val bodyType = stmtToType(s)
val uniqueBodyType = uniquifyNames(bodyType, namespace)
val localMap = createNameMapping(bodyType, uniqueBodyType)