How to printf or println UInt in chisel?
I am trying to execute the following code:
val num1 = 10.U
printf(p"num1 = $num1")
I am getting the following error when running this code in an example class.
[error] (run-main-8) chisel3.internal.ChiselException: Error: No implicit clock and reset.
[error] chisel3.internal.ChiselException: Error: No implicit clock and reset.
I am running the code using test:runMain <package.class>
I tried the other options in https://github.com/freechipsproject/chisel3/wiki/Printing-in-Chisel
using the printf and none of them worked.
Also tried the C style printing printf("num1 = %d",num1)
and this results in the same error.
chisel
add a comment |
I am trying to execute the following code:
val num1 = 10.U
printf(p"num1 = $num1")
I am getting the following error when running this code in an example class.
[error] (run-main-8) chisel3.internal.ChiselException: Error: No implicit clock and reset.
[error] chisel3.internal.ChiselException: Error: No implicit clock and reset.
I am running the code using test:runMain <package.class>
I tried the other options in https://github.com/freechipsproject/chisel3/wiki/Printing-in-Chisel
using the printf and none of them worked.
Also tried the C style printing printf("num1 = %d",num1)
and this results in the same error.
chisel
Please give more code context. Where did you wrote these two lines ? In a chisel module ?
– FabienM
Nov 26 '18 at 14:38
No this is not written in a module. Its written in the test directoryobject TestPrinting extends App { ... }
Maybe this is the problem.
– caylus
Nov 26 '18 at 22:07
So seems liken the printf(p"num1 - $num1") will generate and fwrite() verilog statement, all I am trying to do here is print thing in the test bench side.
– caylus
Nov 28 '18 at 22:49
add a comment |
I am trying to execute the following code:
val num1 = 10.U
printf(p"num1 = $num1")
I am getting the following error when running this code in an example class.
[error] (run-main-8) chisel3.internal.ChiselException: Error: No implicit clock and reset.
[error] chisel3.internal.ChiselException: Error: No implicit clock and reset.
I am running the code using test:runMain <package.class>
I tried the other options in https://github.com/freechipsproject/chisel3/wiki/Printing-in-Chisel
using the printf and none of them worked.
Also tried the C style printing printf("num1 = %d",num1)
and this results in the same error.
chisel
I am trying to execute the following code:
val num1 = 10.U
printf(p"num1 = $num1")
I am getting the following error when running this code in an example class.
[error] (run-main-8) chisel3.internal.ChiselException: Error: No implicit clock and reset.
[error] chisel3.internal.ChiselException: Error: No implicit clock and reset.
I am running the code using test:runMain <package.class>
I tried the other options in https://github.com/freechipsproject/chisel3/wiki/Printing-in-Chisel
using the printf and none of them worked.
Also tried the C style printing printf("num1 = %d",num1)
and this results in the same error.
chisel
chisel
edited Nov 26 '18 at 13:35
caylus
asked Nov 26 '18 at 13:26
cayluscaylus
12816
12816
Please give more code context. Where did you wrote these two lines ? In a chisel module ?
– FabienM
Nov 26 '18 at 14:38
No this is not written in a module. Its written in the test directoryobject TestPrinting extends App { ... }
Maybe this is the problem.
– caylus
Nov 26 '18 at 22:07
So seems liken the printf(p"num1 - $num1") will generate and fwrite() verilog statement, all I am trying to do here is print thing in the test bench side.
– caylus
Nov 28 '18 at 22:49
add a comment |
Please give more code context. Where did you wrote these two lines ? In a chisel module ?
– FabienM
Nov 26 '18 at 14:38
No this is not written in a module. Its written in the test directoryobject TestPrinting extends App { ... }
Maybe this is the problem.
– caylus
Nov 26 '18 at 22:07
So seems liken the printf(p"num1 - $num1") will generate and fwrite() verilog statement, all I am trying to do here is print thing in the test bench side.
– caylus
Nov 28 '18 at 22:49
Please give more code context. Where did you wrote these two lines ? In a chisel module ?
– FabienM
Nov 26 '18 at 14:38
Please give more code context. Where did you wrote these two lines ? In a chisel module ?
– FabienM
Nov 26 '18 at 14:38
No this is not written in a module. Its written in the test directory
object TestPrinting extends App { ... }
Maybe this is the problem.– caylus
Nov 26 '18 at 22:07
No this is not written in a module. Its written in the test directory
object TestPrinting extends App { ... }
Maybe this is the problem.– caylus
Nov 26 '18 at 22:07
So seems liken the printf(p"num1 - $num1") will generate and fwrite() verilog statement, all I am trying to do here is print thing in the test bench side.
– caylus
Nov 28 '18 at 22:49
So seems liken the printf(p"num1 - $num1") will generate and fwrite() verilog statement, all I am trying to do here is print thing in the test bench side.
– caylus
Nov 28 '18 at 22:49
add a comment |
2 Answers
2
active
oldest
votes
The following ought to work. The withClockAndReset
provides the
clock needed to trigger the printf. Its a little picky here, because withClock or withClock and a nested withReset will not work.
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 %dn", io.out)
}
io.out := 42.U
}
add a comment |
There is a workaround. Printing of UInt type signals from the Chisel PeekPokeTester can be done with the help of the peek()
function wrapped in a println()
.
println(peek(module_name.io.signal_name).toString(16))
Still have not found a way to directly print the actual signal module_name.io.signal_name
the UInt type does not even have toString function so I am not sure if this can even be done.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53482147%2fhow-to-printf-or-println-uint-in-chisel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The following ought to work. The withClockAndReset
provides the
clock needed to trigger the printf. Its a little picky here, because withClock or withClock and a nested withReset will not work.
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 %dn", io.out)
}
io.out := 42.U
}
add a comment |
The following ought to work. The withClockAndReset
provides the
clock needed to trigger the printf. Its a little picky here, because withClock or withClock and a nested withReset will not work.
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 %dn", io.out)
}
io.out := 42.U
}
add a comment |
The following ought to work. The withClockAndReset
provides the
clock needed to trigger the printf. Its a little picky here, because withClock or withClock and a nested withReset will not work.
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 %dn", io.out)
}
io.out := 42.U
}
The following ought to work. The withClockAndReset
provides the
clock needed to trigger the printf. Its a little picky here, because withClock or withClock and a nested withReset will not work.
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 %dn", io.out)
}
io.out := 42.U
}
edited Nov 26 '18 at 18:33
answered Nov 26 '18 at 16:04
Chick MarkleyChick Markley
1,560810
1,560810
add a comment |
add a comment |
There is a workaround. Printing of UInt type signals from the Chisel PeekPokeTester can be done with the help of the peek()
function wrapped in a println()
.
println(peek(module_name.io.signal_name).toString(16))
Still have not found a way to directly print the actual signal module_name.io.signal_name
the UInt type does not even have toString function so I am not sure if this can even be done.
add a comment |
There is a workaround. Printing of UInt type signals from the Chisel PeekPokeTester can be done with the help of the peek()
function wrapped in a println()
.
println(peek(module_name.io.signal_name).toString(16))
Still have not found a way to directly print the actual signal module_name.io.signal_name
the UInt type does not even have toString function so I am not sure if this can even be done.
add a comment |
There is a workaround. Printing of UInt type signals from the Chisel PeekPokeTester can be done with the help of the peek()
function wrapped in a println()
.
println(peek(module_name.io.signal_name).toString(16))
Still have not found a way to directly print the actual signal module_name.io.signal_name
the UInt type does not even have toString function so I am not sure if this can even be done.
There is a workaround. Printing of UInt type signals from the Chisel PeekPokeTester can be done with the help of the peek()
function wrapped in a println()
.
println(peek(module_name.io.signal_name).toString(16))
Still have not found a way to directly print the actual signal module_name.io.signal_name
the UInt type does not even have toString function so I am not sure if this can even be done.
answered Jan 8 at 19:46
cayluscaylus
12816
12816
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53482147%2fhow-to-printf-or-println-uint-in-chisel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please give more code context. Where did you wrote these two lines ? In a chisel module ?
– FabienM
Nov 26 '18 at 14:38
No this is not written in a module. Its written in the test directory
object TestPrinting extends App { ... }
Maybe this is the problem.– caylus
Nov 26 '18 at 22:07
So seems liken the printf(p"num1 - $num1") will generate and fwrite() verilog statement, all I am trying to do here is print thing in the test bench side.
– caylus
Nov 28 '18 at 22:49