diff --git a/difftest b/difftest index ab7820f3..08260b42 160000 --- a/difftest +++ b/difftest @@ -1 +1 @@ -Subproject commit ab7820f33c72e45df0781d954931bef7f6da66dd +Subproject commit 08260b420e8447c539056555eba14fda19c5d07f diff --git a/src/main/scala/sim/NutShellSim.scala b/src/main/scala/sim/NutShellSim.scala index 9f10463d..0cae1624 100644 --- a/src/main/scala/sim/NutShellSim.scala +++ b/src/main/scala/sim/NutShellSim.scala @@ -16,18 +16,12 @@ package sim -import system._ -import nutcore.NutCoreConfig - -import chisel3._ -import chisel3.util._ -import chisel3.util.experimental.BoringUtils - import bus.axi4._ +import chisel3._ import device.AXI4RAM -import nutcore._ -import utils.GTimer import difftest._ +import nutcore.NutCoreConfig +import system._ class SimTop extends Module { lazy val config = NutCoreConfig(FPGAPlatform = false) @@ -48,18 +42,5 @@ class SimTop extends Module { soc.io.meip := mmio.io.meip val difftest = DifftestModule.finish("nutshell") - - val log_begin, log_end, log_level = WireInit(0.U(64.W)) - log_begin := difftest.logCtrl.begin - log_end := difftest.logCtrl.end - log_level := difftest.logCtrl.level - - assert(log_begin <= log_end) - BoringUtils.addSource(WireInit((GTimer() >= log_begin) && (GTimer() < log_end)), "DISPLAY_ENABLE") - - // make BoringUtils not report boring exception when EnableDebug is set to false - val dummyWire = WireInit(false.B) - BoringUtils.addSink(dummyWire, "DISPLAY_ENABLE") - difftest.uart <> mmio.io.uart } diff --git a/src/main/scala/utils/Debug.scala b/src/main/scala/utils/Debug.scala index 5384ca70..98fa133a 100644 --- a/src/main/scala/utils/Debug.scala +++ b/src/main/scala/utils/Debug.scala @@ -17,11 +17,9 @@ package utils import chisel3._ -import chisel3.util._ -import chisel3.util.experimental.BoringUtils -import utils.LogLevel.LogLevel - +import difftest.common.LogPerfControl import nutcore.NutCoreConfig +import utils.LogLevel.LogLevel object LogLevel extends Enumeration { type LogLevel = Value @@ -36,23 +34,17 @@ object LogLevel extends Enumeration { object LogUtil { - def displayLog: Bool = { - val enableDisplay = WireInit(false.B) - BoringUtils.addSink(enableDisplay, "DISPLAY_ENABLE") - enableDisplay + def control(): (Bool, UInt) = { + val control = LogPerfControl() + (control.logEnable, control.timer) } - // def LogLevel: UInt = { - // val log_level = WireInit(0.U(64.W)) - // BoringUtils.addSink(log_level, "DISPLAY_LOG_LEVEL") - // log_level - // } - def apply(debugLevel: LogLevel) (prefix: Boolean, cond: Bool, pable: Printable) (implicit name: String): Any = { - val commonInfo = p"[${GTimer()}] $name: " - when (cond && displayLog) { + val c = control() + val commonInfo = p"[${c._2}] $name: " + when (cond && c._1) { if(prefix) printf(commonInfo) printf(pable) } @@ -77,7 +69,7 @@ sealed abstract class LogHelper(val logLevel: LogLevel) { // NOOP/NutShell style debug def apply(flag: Boolean = NutCoreConfig().EnableDebug, cond: Bool = true.B)(body: => Unit): Any = { if(NutCoreConfig().EnhancedLog){ - if(flag) { when (cond && LogUtil.displayLog) { body } } + if(flag) { when (cond && LogUtil.control()._1) { body } } } else { if(flag) { when (cond) { body } } }