From c038d5eb9ffe3e97d2b7e449843db4afb2b662f9 Mon Sep 17 00:00:00 2001 From: LinJiawei Date: Sun, 28 Jun 2020 14:47:16 +0800 Subject: [PATCH] Log: use implict module name instead implict module --- src/main/scala/xiangshan/XSCore.scala | 2 +- src/main/scala/xiangshan/utils/LogUtils.scala | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/scala/xiangshan/XSCore.scala b/src/main/scala/xiangshan/XSCore.scala index a538fa4f9..4389d7734 100644 --- a/src/main/scala/xiangshan/XSCore.scala +++ b/src/main/scala/xiangshan/XSCore.scala @@ -62,7 +62,7 @@ trait HasXSParameter { } trait HasXSLog { this: Module => - implicit val _implict_module = this + implicit val moduleName: String = this.name } abstract class XSModule extends Module diff --git a/src/main/scala/xiangshan/utils/LogUtils.scala b/src/main/scala/xiangshan/utils/LogUtils.scala index ad155abc3..92e062261 100644 --- a/src/main/scala/xiangshan/utils/LogUtils.scala +++ b/src/main/scala/xiangshan/utils/LogUtils.scala @@ -35,8 +35,8 @@ object XSLog { def apply(debugLevel: XSLogLevel) (cond: Bool, pable: Printable) - (implicit m: Module): Any = { - val commonInfo = p"[$debugLevel][time=${GTimer()}] ${m.name}: " + (implicit name: String): Any = { + val commonInfo = p"[$debugLevel][time=${GTimer()}] $name: " when (debugLevel.id.U >= xsLogLevel && cond && displayLog) { printf(commonInfo + pable) } @@ -45,12 +45,12 @@ object XSLog { sealed abstract class LogHelper(val logLevel: XSLogLevel) extends HasXSParameter { - def apply(cond: Bool, fmt: String, data: Bits*)(implicit m: Module): Any = + def apply(cond: Bool, fmt: String, data: Bits*)(implicit name: String): Any = apply(cond, Printable.pack(fmt, data:_*)) - def apply(cond: Bool, pable: Printable)(implicit m: Module): Any = XSLog(logLevel)(cond, pable) - def apply(fmt: String, data: Bits*)(implicit m: Module): Any = + def apply(cond: Bool, pable: Printable)(implicit name: String): Any = XSLog(logLevel)(cond, pable) + def apply(fmt: String, data: Bits*)(implicit name: String): Any = apply(true.B, Printable.pack(fmt, data:_*)) - def apply(pable: Printable)(implicit m: Module): Any = XSLog(logLevel)(true.B, pable) + def apply(pable: Printable)(implicit name: String): Any = XSLog(logLevel)(true.B, pable) // Do not use that unless you have valid reasons def apply(cond: Bool = true.B)(body: => Unit): Any = -- GitLab