diff options
| author | Henry Cook | 2015-08-05 00:54:32 -0700 |
|---|---|---|
| committer | Andrew Waterman | 2015-08-05 16:36:08 -0700 |
| commit | f98e9e4143a113ac1020ed20c5e01b41aa29efe5 (patch) | |
| tree | 89fa57975e1f137ee184aafdc7a0a81ec09aa994 /src/main/scala/Chisel/Error.scala | |
| parent | a02d788d9e9c4b42fd866e5c34e42aa771aab68c (diff) | |
Massive Driver simplification, some tweaks to Parameter api
Diffstat (limited to 'src/main/scala/Chisel/Error.scala')
| -rw-r--r-- | src/main/scala/Chisel/Error.scala | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main/scala/Chisel/Error.scala b/src/main/scala/Chisel/Error.scala index 1ad5414d..287b65eb 100644 --- a/src/main/scala/Chisel/Error.scala +++ b/src/main/scala/Chisel/Error.scala @@ -31,6 +31,16 @@ package Chisel import scala.collection.mutable.ArrayBuffer +class ChiselException(message: String, cause: Throwable) extends Exception(message, cause) + +object throwException { + def apply(s: String, t: Throwable = null) = { + val xcpt = new ChiselException(s, t) + ChiselError.findFirstUserLine(xcpt.getStackTrace) foreach { u => xcpt.setStackTrace(Array(u)) } + throw xcpt + } +} + /** This Singleton implements a log4j compatible interface. It is used through out the Chisel package to report errors and warnings detected at runtime. @@ -39,6 +49,9 @@ object ChiselError { var hasErrors: Boolean = false; val ChiselErrors = new ArrayBuffer[ChiselError]; + var startTime = System.currentTimeMillis + def elapsedTime: Long = System.currentTimeMillis - startTime + def clear() { ChiselErrors.clear() hasErrors = false @@ -58,7 +71,7 @@ object ChiselError { /** Emit an informational message (useful to track long running passes) */ def info(m: String): Unit = - println(tag("info", Console.MAGENTA) + " [%2.3f] ".format(Driver.elapsedTime/1e3) + m) + println(tag("info", Console.MAGENTA) + " [%2.3f] ".format(elapsedTime/1e3) + m) /** emit a warning message */ def warning(m: => String) { |
