如何在凿子中打印 printf 或 println UInt?
How to printf or println UInt in chisel?
我正在尝试执行以下代码:
val num1 = 10.U
printf(p"num1 = $num1")
当 运行 示例代码 class 时出现以下错误。
[error] (run-main-8) chisel3.internal.ChiselException: Error: No implicit clock and reset.
[error] chisel3.internal.ChiselException: Error: No implicit clock and reset.
我运行代码使用test:runMain <package.class>
我尝试了 https://github.com/freechipsproject/chisel3/wiki/Printing-in-Chisel 中的其他选项
使用 printf 和 none 它们的工作。
还尝试了 C 风格的打印 printf("num1 = %d",num1)
,这导致了同样的错误。
以下应该有效。 withClockAndReset
提供了
触发 printf 所需的时钟。这里有点挑剔,因为withClock或者withClock和一个嵌套的withReset都不行。
class Hello extends RawModule {
val io = IO(new Bundle {
val out = Output(UInt(8.W))
val myClock = Input(Clock())
val myReset = Input(Bool())
})
withClockAndReset(io.myClock, io.myReset) {
printf("out is %d\n", io.out)
}
io.out := 42.U
}
有一个解决方法。从 Chisel PeekPokeTester 打印 UInt 类型信号可以借助包裹在 println()
.
中的 peek()
函数来完成
println(peek(module_name.io.signal_name).toString(16))
还没有找到直接打印实际信号的方法module_name.io.signal_name
UInt 类型甚至没有 toString 函数所以我不确定这是否可以完成。
我正在尝试执行以下代码:
val num1 = 10.U
printf(p"num1 = $num1")
当 运行 示例代码 class 时出现以下错误。
[error] (run-main-8) chisel3.internal.ChiselException: Error: No implicit clock and reset.
[error] chisel3.internal.ChiselException: Error: No implicit clock and reset.
我运行代码使用test:runMain <package.class>
我尝试了 https://github.com/freechipsproject/chisel3/wiki/Printing-in-Chisel 中的其他选项 使用 printf 和 none 它们的工作。
还尝试了 C 风格的打印 printf("num1 = %d",num1)
,这导致了同样的错误。
以下应该有效。 withClockAndReset
提供了
触发 printf 所需的时钟。这里有点挑剔,因为withClock或者withClock和一个嵌套的withReset都不行。
class Hello extends RawModule {
val io = IO(new Bundle {
val out = Output(UInt(8.W))
val myClock = Input(Clock())
val myReset = Input(Bool())
})
withClockAndReset(io.myClock, io.myReset) {
printf("out is %d\n", io.out)
}
io.out := 42.U
}
有一个解决方法。从 Chisel PeekPokeTester 打印 UInt 类型信号可以借助包裹在 println()
.
peek()
函数来完成
println(peek(module_name.io.signal_name).toString(16))
还没有找到直接打印实际信号的方法module_name.io.signal_name
UInt 类型甚至没有 toString 函数所以我不确定这是否可以完成。