-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[major] Add fd
operand to printf
statement
#213
base: main
Are you sure you want to change the base?
Conversation
90153ea
to
d6c252d
Compare
spec.md
Outdated
@@ -2236,8 +2236,9 @@ circuit Foo: | |||
wire cond: UInt<1> | |||
wire a: UInt | |||
wire b: UInt | |||
node fd = SInt<32>(-2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we basically may need a new type in Firrtl and CIRCT, but anyway it LGTM. in CIRCT we need to check the fd shouldn't be used for circuit construction.
This is getting pretty Verilog-specific which I don't really like. Specifically, in order for this to work, it likely also needs an Is the motivation for this to write to specific files or to select between stdout/stderr? If the motivation is to write to different files, then I'd prefer a Chisel/post-processing solution:
The end result of this is the same as writing to different files. However, it avoids having to introduce a real notion of a file descriptor in FIRRTL. |
The fundamental motivation for this is to enable the SystemVerilog generated by Chisel&CIRCT can be
Sure, I'm working on adding
If I understand correctly, |
The reason of post processing is hard is we also want write a giant log into file while keeping stdout clean for other usages e.g. uart. |
Thinking about this... Would it be acceptable to pipe all of the output (stdout, stderr, or both) into a script which then does the splitting for you, while leaving some things on stdout/stderr? Without writing the script: $ ./run-verilator | slice-outputs
UART
UART
UART
$ ls
info.log warn.log debug.log layer-1.log layer2.log |
This is doable, but for a user experience, this is a bad design that each user need to writing their own logging script... |
If we did do this, then it's reasonable to both build the logging library in Chisel and provide the script for working with this in Chisel as well. 🤓 |
I do agree, after getting Since Chisel doesn't support UVM-based Scoreboard functionality, the logging package can be used as a utility to do the offline checking. e.g. Trace event of each core, doing check after simulation is done(not at simulation runtime or UVM check_phase). |
Err... I'm saying that I'm not convinced of the need for the file descriptor and think the logging can be packaged up with a library in Chisel and a script to post-process it. Alternatively, a file descriptor is something that is circuit-global and is said to be open for the duration of the simulation/evaluation of a circuit. WDYT? @darthscsi: WDYT? |
I think the situation is the |
Going off of what I was suggesting above... Something like the following may make more sense: circuit Foo:
file Bar, "Bar.log", read
public module Foo:
input clock: Clock
input a: UInt<1>
printf(clock, UInt<1>(1), Bar, "hello world") Alternatively, just putting the filename in the printf may be fine and it's up to the lowering to figure out what file descriptors to create: printf(clock, UInt<1>(1), file="Bar.log", "hello world") Basically, what is the right way to get a |
I thought about it, maybe the file handler should for each public module or instance?
I think this could be a good solution, making it a
WDYT? |
There is a limitation for the number of the files that a single process can open ( |
I'm actually quite amenable to this provided:
Reasoning: Concerns: |
This PR proposes to add a new operand
fd
toprintf
statement, which will allow us tofopen
a file and write formatted strings to it in the future. (fopen
andfclose
will be implemented as intrinsics latter)