summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/scala/chisel3/util/experimental/decode/decoder.scala25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/main/scala/chisel3/util/experimental/decode/decoder.scala b/src/main/scala/chisel3/util/experimental/decode/decoder.scala
index 2ef474e1..87e839d3 100644
--- a/src/main/scala/chisel3/util/experimental/decode/decoder.scala
+++ b/src/main/scala/chisel3/util/experimental/decode/decoder.scala
@@ -9,27 +9,34 @@ import chisel3.util.experimental.getAnnotations
import firrtl.annotations.Annotation
import logger.LazyLogging
+import scala.concurrent.ExecutionContext.Implicits.global
+import scala.concurrent.duration.Duration
+import scala.concurrent.{Await, Future}
+
object decoder extends LazyLogging {
- def apply(minimizer: Minimizer, input: UInt, truthTable: TruthTable): UInt = {
+ def apply(minimizer: Minimizer, input: UInt, truthTable: TruthTable, timeout: Int = 5): UInt = {
val minimizedTable = getAnnotations().collect {
case DecodeTableAnnotation(_, in, out) => TruthTable(in) -> TruthTable(out)
}.toMap.getOrElse(
{
- logger.trace(s"""Decoder Cache Hit!
+ logger.warn(s"""Decoder Cache Hit!
|${truthTable.table}
|""".stripMargin)
truthTable
}, {
val startTime = System.nanoTime()
- val minimizedTable = minimizer.minimize(truthTable)
+ val future = Future(minimizer.minimize(truthTable))
+ var now = System.nanoTime()
+ while (!future.isCompleted) {
+ val elapsed = (System.nanoTime() - now) / 1e9
+ now = System.nanoTime()
+ if(elapsed > timeout) logger.error(s"Minimizer has been executed for ${(System.nanoTime() - startTime) / 1e9} seconds.")
+ }
+ val minimizedTable = Await.result(future, Duration.Inf)
val totalTime = System.nanoTime() - startTime
val totalTimeInSeconds = totalTime / 1e9
- val info = f"Logic Minimize with $minimizer finished in ${totalTimeInSeconds} second"
- if (totalTimeInSeconds > 5)
- logger.error(
- s"$info spends too long, consider using chisel3.util.experimental.DecodeTableAnnotation to cache decode result or switch to EspressoMinimizer."
- )
- else logger.trace(info)
+ val info = f"Logic Minimize with $minimizer finished in $totalTimeInSeconds second"
+ logger.warn(info)
minimizedTable
}
)