aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorJack Koenig2020-04-13 21:23:54 -0700
committerGitHub2020-04-14 04:23:54 +0000
commitf8546a7c165e0bde4b3e5682dd6edd0a3e199b31 (patch)
treebbf3968663ee2be767266a4ff4e5fb1fc9939b34 /src/main
parent6cc66a9df1848b81a7954ee5e09925bae605fb88 (diff)
Allow casts in AsyncReset literal value check (#1523)
Chisel emits all literals as UInts cast to the correct type, make CheckResets support casts when checking that async reset registers are reset to literal values. Co-authored-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/scala/firrtl/checks/CheckResets.scala17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/main/scala/firrtl/checks/CheckResets.scala b/src/main/scala/firrtl/checks/CheckResets.scala
index 406b7f62..facd5c01 100644
--- a/src/main/scala/firrtl/checks/CheckResets.scala
+++ b/src/main/scala/firrtl/checks/CheckResets.scala
@@ -6,10 +6,12 @@ import firrtl._
import firrtl.options.{Dependency, PreservesAll}
import firrtl.passes.{Errors, PassException}
import firrtl.ir._
+import firrtl.Utils.isCast
import firrtl.traversals.Foreachers._
import firrtl.WrappedExpression._
import scala.collection.mutable
+import scala.annotation.tailrec
object CheckResets {
class NonLiteralAsyncResetValueException(info: Info, mname: String, reg: String, init: String) extends PassException(
@@ -52,12 +54,15 @@ class CheckResets extends Transform with PreservesAll[Transform] {
stmt.foreach(onStmt(regCheck, drivers))
}
- private def findDriver(drivers: DirectDriverMap)(expr: Expression): Expression =
- drivers.get(we(expr)) match {
- case Some(lit: Literal) => lit
- case Some(other) => findDriver(drivers)(other)
- case None => expr
- }
+ @tailrec
+ private def findDriver(drivers: DirectDriverMap)(expr: Expression): Expression = expr match {
+ case lit: Literal => lit
+ case DoPrim(op, args, _,_) if isCast(op) => findDriver(drivers)(args.head)
+ case other => drivers.get(we(other)) match {
+ case Some(e) => findDriver(drivers)(e)
+ case None => other
+ }
+ }
private def onMod(errors: Errors)(mod: DefModule): Unit = {
val regCheck = new RegCheckList()